/* PrestoComic public reader — server-rendered.
 *
 * Loaded ALONGSIDE landing.css (not instead of). landing.css owns the
 * brand tokens (paper / ink / accent), the navbar, the footer, the
 * button system and the auth modal. This file owns the per-page
 * reader layout: header strip, page stage, prev/next arrows, the
 * <details>-based chapter dropdown.
 *
 * The visual approach mirrors the React `ComicReaderPage` styles in
 * frontend/src/styles.css — the SPA reader is being retired, but
 * the visual identity of the reader page stays the same so we don't
 * break expectations for visitors who already shared a URL.
 */

/* ─── Shell ──────────────────────────────────────────────────────── */
.reader-shell {
  /* The navbar above is sticky and ~58px tall. Let the reader fill
   * the rest of the viewport so the page image gets all available
   * vertical space without the user having to scroll. */
  min-height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  padding: 14px 32px 24px;
  gap: 16px;
}

/* ─── Header strip ──────────────────────────────────────────────── */
.reader-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 10px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
}
.reader-head-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}
.reader-title {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.reader-title-link {
  color: inherit;
  text-decoration: none;
  transition: color 80ms;
}
.reader-title-link:hover { color: var(--accent); }
.reader-byline {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.reader-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.reader-indicator {
  font-size: 12px;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
}

/* ─── TOC dropdown (pure <details>) ─────────────────────────────── */
/* The <summary> wears the .btn.sm.ghost classes from landing.css so
 * we don't need to re-style it here. We just hide the default
 * triangle and reveal the menu when [open]. */
.reader-toc-wrap { position: relative; }
.reader-toc-summary {
  list-style: none;
  cursor: pointer;
}
.reader-toc-summary::-webkit-details-marker { display: none; }
.reader-toc-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  background: var(--paper-bright);
  border: 1px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  min-width: 260px;
  max-height: 60vh;
  overflow: auto;
}
.reader-toc-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-decoration: none;
}
.reader-toc-item:hover { background: var(--paper-deep); }
.reader-toc-item.active { background: var(--ink); color: var(--paper-bright); }
.reader-toc-num {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.reader-toc-item.active .reader-toc-num { color: var(--paper-bright); opacity: 0.7; }
.reader-toc-title { font-size: 14px; }

/* ─── Stage ─────────────────────────────────────────────────────── */
.reader-stage {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 0;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
}
.reader-nav {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--paper-bright);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  transition: transform 80ms, box-shadow 80ms;
  user-select: none;
}
a.reader-nav:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 var(--ink);
}
.reader-nav[data-disabled="true"] {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

.reader-page-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
}
.reader-page-img {
  max-width: 100%;
  /* Viewport height minus navbar (~58px) minus header (~70px) minus
   * footer (~50px) minus shell padding (~38px). The exact number is
   * approximate; what matters is the image always FITS without the
   * page scrolling. */
  max-height: calc(100vh - 220px);
  object-fit: contain;
  display: block;
  border: 1px solid var(--ink-faint);
  background: var(--paper-bright);
}

/* ─── Footer credit ─────────────────────────────────────────────── */
.reader-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--ink-faint);
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
.reader-foot-link,
.reader-foot-cta {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 80ms;
}
.reader-foot-link:hover,
.reader-foot-cta:hover { color: var(--ink); }
.reader-foot-brand {
  font-size: 12px;
  letter-spacing: -0.01em;
  margin-left: 4px;
}
.reader-foot-sep { color: var(--ink-faint); }
.reader-foot-cta { font-weight: 500; }

/* ─── Mobile ────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .reader-shell { padding: 10px 12px 16px; }
  .reader-title { font-size: 18px; }
  .reader-byline { font-size: 11px; }
  .reader-nav {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
  .reader-page-img { max-height: calc(100vh - 240px); }
  .reader-foot { font-size: 11px; gap: 8px; }
}
