/* =========================================================
   THE CANDLE AND THE NAIL — Webtoon Reader Styles
   ========================================================= */

:root {
  --bg-canvas: #000000;
  --charcoal: #1e1e1e;
  --charcoal-light: #2a2a2a;
  --gold: #C9A24A;
  --gold-soft: rgba(201, 162, 74, 0.35);
  --text-white: #ffffff;
  --text-grey: #cccccc;
  --text-grey-dim: #8f8f8f;
  --parchment: #F7F1E4;
  --green-deep: #2F5D53;
  --content-max: 720px;
  --nav-height: 50px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--text-white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
}

/* ===================== STICKY TOP NAV ===================== */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--charcoal);
  height: var(--nav-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.top-nav__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 100%;
  gap: 8px;
}

.top-nav__title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  max-width: 38%;
}

.top-nav__chapter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-grey);
  white-space: nowrap;
  flex: 1;
  justify-content: center;
}

.chapter-arrow {
  background: transparent;
  border: none;
  color: var(--text-grey);
  width: 28px;
  height: 28px;
  min-width: 44px;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
}

.chapter-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chapter-arrow:not(:disabled):hover {
  background: rgba(255,255,255,0.08);
  color: var(--gold);
}

.top-nav__menu {
  background: transparent;
  border: none;
  color: var(--text-grey);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 8px;
}
.top-nav__menu:hover { color: var(--gold); background: rgba(255,255,255,0.06); }

.scroll-progress-track {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: rgba(255,255,255,0.08);
}

.scroll-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.1s linear;
}

/* ===================== TOC DRAWER ===================== */
.toc-drawer {
  position: fixed;
  top: 0; right: -300px;
  width: 280px;
  height: 100%;
  background: var(--charcoal);
  z-index: 200;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
}
.toc-drawer.is-open { right: 0; }

.toc-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  font-weight: 600;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.toc-drawer__header button {
  background: transparent; border: none; color: #fff; font-size: 18px;
  width: 44px; height: 44px;
}

.toc-list {
  list-style: none;
  margin: 0; padding: 8px;
  overflow-y: auto;
}
.toc-list li {
  padding: 12px 10px;
  border-radius: 8px;
  color: var(--text-grey);
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.toc-list li:hover { background: rgba(201,162,74,0.12); color: var(--gold); }

.toc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.toc-backdrop.is-open { opacity: 1; pointer-events: auto; }

/* ===================== READER CANVAS ===================== */
#reader-canvas {
  padding-top: var(--nav-height);
  background: var(--bg-canvas);
}

/* ===================== TITLE SPLASH ===================== */
.title-splash {
  position: relative;
  width: 100%;
  height: calc(100vh - var(--nav-height));
  min-height: 480px;
  overflow: hidden;
}
.title-splash img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}
.title-splash__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.15) 40%, rgba(0,0,0,0.85) 100%);
}
.title-splash__content {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 24px 40px;
  text-align: center;
}
.title-splash__eyebrow {
  color: var(--gold);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 12px;
}
.title-splash__title {
  font-family: 'Merriweather', serif;
  font-weight: 900;
  font-size: clamp(32px, 8vw, 56px);
  line-height: 1.1;
  margin: 0 0 14px;
  text-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.title-splash__subtitle {
  color: var(--text-grey);
  font-size: 14px;
  max-width: 460px;
  margin: 0 auto 28px;
  line-height: 1.5;
}
.title-splash__scrollcue {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: bob 2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}
@media (prefers-reduced-motion: reduce) {
  .title-splash__scrollcue { animation: none; }
}

/* ===================== MEDIA TRACK ===================== */
.media-track {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  background: #000;
  display: flex;
  flex-direction: column;
}

.comic-page {
  margin: 0;
  padding: 0;
  position: relative;
  line-height: 0;
  cursor: zoom-in;
}

.comic-page img {
  width: 100%;
  height: auto;
  display: block;
}

.page-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 6px 10px;
  border-radius: 20px;
  line-height: 1.2;
  pointer-events: none;
}

.comic-page--splash .page-badge {
  background: rgba(0,0,0,0.7);
}

/* ===================== ENGAGEMENT ===================== */
.engagement {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 36px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.engagement__like {
  background: transparent;
  border: none;
  color: var(--text-grey);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 44px;
}
.engagement__like-circle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-grey);
  transition: all 0.25s ease;
}
.engagement__like.is-active .engagement__like-circle {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201,162,74,0.12);
  transform: scale(1.08);
}
.engagement__like.is-active .engagement__count,
.engagement__like.is-active .engagement__label { color: var(--gold); }
.engagement__like.pulse .engagement__like-circle { animation: heart-pulse 0.4s ease; }
@keyframes heart-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1.08); }
}
.engagement__count { font-size: 14px; font-weight: 600; color: #fff; }
.engagement__label { font-size: 12px; }

.engagement__icon-btn {
  background: transparent;
  border: none;
  color: var(--text-grey);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  min-width: 44px;
  min-height: 44px;
}
.engagement__icon-btn i { font-size: 22px; }
.engagement__icon-btn[aria-pressed="true"] { color: var(--gold); }
.engagement__icon-btn:hover { color: var(--gold); }

/* ===================== CREATOR CARD ===================== */
.creator-card {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.creator-card__avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold-soft);
}
.creator-card__info { flex: 1; min-width: 0; }
.creator-card__handle {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}
.creator-card__sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-grey-dim);
}
.creator-card__subscribe {
  background: #2fae5c;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  min-height: 40px;
  transition: background 0.2s ease, transform 0.2s ease;
}
.creator-card__subscribe:hover { background: #279148; }
.creator-card__subscribe.is-subscribed {
  background: transparent;
  border: 1px solid var(--text-grey-dim);
  color: var(--text-grey);
}

/* ===================== EPISODE NAVIGATOR ===================== */
.episode-nav {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 0 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.episode-nav__heading {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
  padding: 0 20px;
}
.episode-nav__track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 0 20px 20px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.episode-card {
  position: relative;
  flex: 0 0 150px;
  scroll-snap-align: start;
  background: var(--charcoal-light);
  border-radius: 10px;
  overflow: hidden;
  padding-bottom: 10px;
}
.episode-card img, .episode-card__placeholder {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-grey-dim);
  font-size: 24px;
}
.episode-card__badge {
  position: absolute;
  top: 8px; left: 8px;
  background: var(--gold);
  color: #1e1e1e;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  z-index: 2;
}
.episode-card--current { border: 1px solid var(--gold-soft); }
.episode-card--disabled { opacity: 0.55; }
.episode-card__title {
  font-size: 13px;
  font-weight: 600;
  margin: 8px 10px 2px;
  color: #fff;
}
.episode-card__meta {
  font-size: 11px;
  margin: 0 10px;
  color: var(--text-grey-dim);
}

/* ===================== COMMENTS ===================== */
.comments {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 20px 40px;
}
.comments__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.comments__header h2 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
}
.comments__header span { color: var(--text-grey-dim); font-weight: 400; }
.comments__sort {
  display: flex;
  gap: 6px;
  background: var(--charcoal-light);
  border-radius: 20px;
  padding: 3px;
}
.comments__sort-btn {
  background: transparent;
  border: none;
  color: var(--text-grey);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  min-height: 30px;
}
.comments__sort-btn.is-active {
  background: var(--gold);
  color: #1e1e1e;
  font-weight: 600;
}

.comments__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--charcoal-light);
  padding: 14px;
  border-radius: 12px;
}
.comments__form input,
.comments__form textarea {
  background: #111;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #fff;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 44px;
}
.comments__form textarea { min-height: 70px; }
.comments__form input:focus,
.comments__form textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.comments__form button {
  align-self: flex-end;
  background: var(--gold);
  color: #1e1e1e;
  border: none;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.comments__form button:hover { background: #dcb662; }

.comments__list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.comments__loading, .comments__empty {
  color: var(--text-grey-dim);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}
.comment-item {
  display: flex;
  gap: 12px;
}
.comment-item__avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #7a5f28);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #1e1e1e;
}
.comment-item__body { flex: 1; min-width: 0; }
.comment-item__meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.comment-item__author {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.comment-item__time {
  font-size: 11px;
  color: var(--text-grey-dim);
}
.comment-item__message {
  font-size: 14px;
  color: var(--text-grey);
  line-height: 1.5;
  margin: 0 0 6px;
  word-wrap: break-word;
}
.comment-item__like {
  background: transparent;
  border: none;
  color: var(--text-grey-dim);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
}
.comment-item__like.is-liked { color: var(--gold); }
.comment-item__like:hover { color: var(--gold); }

/* ===================== FOOTER ===================== */
.site-footer {
  text-align: center;
  padding: 30px 20px 50px;
  color: var(--text-grey-dim);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.site-footer p:first-child {
  color: var(--gold);
  font-family: 'Merriweather', serif;
  font-style: italic;
  font-size: 15px;
  margin-bottom: 8px;
}
.site-footer__fine { font-size: 11px; }

/* ===================== LIGHTBOX ===================== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox.is-open { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox__close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 18px;
}

/* ===================== RESPONSIVE ===================== */
@media (min-width: 768px) {
  .top-nav__title { font-size: 16px; max-width: none; }
  .top-nav__row { padding: 0 24px; }
}

@media (max-width: 380px) {
  .top-nav__chapter span { display: none; }
  .top-nav__title { max-width: 50%; }
}
