/*
  comic-reader.css — Inkpulse flipbook reader chrome.
  Dark stage, centered book, minimal prev/next chrome. No external assets.
*/

.cr-root {
  /* Dark is the default reader skin; the light overrides live below and are
     driven by the site's own [data-theme="light"] root attribute, so the reader
     follows whatever theme the visitor picked instead of forcing dark. */
  --cr-bg: #0b0a0d;
  --cr-panel: #141217;
  --cr-gold: #b98bd6;
  --cr-gold-dim: #7d5b9e;
  --cr-text: #e9e4d8;
  --cr-muted: #8f887b;
  --cr-edge: rgba(155, 89, 182, 0.22);
  /* Page "paper" behind each comic page (also read by the flip canvas in JS). */
  --cr-paper: #0e0c12;
  --cr-stage-top: #17141b;
  --cr-stage-bottom: #050406;
  --cr-topbar-a: rgba(20, 18, 23, 0.9);
  --cr-topbar-b: rgba(11, 10, 13, 0.4);

  /* Full-screen overlay: covers the site nav/footer so the reader is one
     immersive view, not a 100vh block sandwiched between the site chrome
     (which read as a duplicated header/footer top and bottom). */
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: radial-gradient(120% 120% at 50% 0%, var(--cr-stage-top) 0%, var(--cr-bg) 60%, var(--cr-stage-bottom) 100%);
  color: var(--cr-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* Light theme: the site stamps data-theme="light" on the root element. Keep the
   purple accent, lift the stage to paper-white, and darken the text. */
[data-theme="light"] .cr-root {
  --cr-bg: #f3f1f6;
  --cr-panel: #ffffff;
  --cr-gold: #7d5b9e;
  --cr-gold-dim: #9b59b6;
  --cr-text: #1c1a20;
  --cr-muted: #6b6675;
  --cr-edge: rgba(125, 91, 158, 0.28);
  --cr-paper: #ffffff;
  --cr-stage-top: #ffffff;
  --cr-stage-bottom: #e7e3ee;
  --cr-topbar-a: rgba(255, 255, 255, 0.94);
  --cr-topbar-b: rgba(243, 241, 246, 0.6);
}

/* Top bar --------------------------------------------------------------- */
.cr-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: linear-gradient(180deg, var(--cr-topbar-a), var(--cr-topbar-b));
  border-bottom: 1px solid var(--cr-edge);
  z-index: 20;
  flex: 0 0 auto;
}

.cr-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--cr-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55vw;
}

/* Title as a back-link (set when window.COMIC.backUrl is present) */
.cr-back {
  text-decoration: none;
  transition: color 0.15s ease;
}
.cr-back:hover { color: var(--cr-text); }

/* Creator-preview pill in the topbar. */
.cr-note {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 20px;
  color: #b98bd6;
  border: 1px solid rgba(155, 89, 182, 0.5);
  background: rgba(155, 89, 182, 0.12);
  white-space: nowrap;
}

/* Empty-state shell (no pages yet) — reader JS never boots, so style the
   fallback markup rendered by comics/read.blade.php directly. */
.cr-empty-shell {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  background: radial-gradient(120% 120% at 50% 0%, #17141b 0%, #0b0a0d 60%, #050406 100%);
  color: #e9e4d8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.cr-empty-shell .cr-title {
  --cr-gold: #c9a24b;
  color: var(--cr-gold);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.cr-empty-shell .cr-error {
  --cr-muted: #8f887b;
  --cr-edge: rgba(201, 162, 75, 0.16);
}

.cr-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cr-btn {
  appearance: none;
  border: 1px solid var(--cr-edge);
  background: rgba(255, 255, 255, 0.02);
  color: var(--cr-text);
  font: inherit;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.45rem 0.7rem;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}
.cr-btn:hover:not(:disabled) {
  border-color: var(--cr-gold);
  color: var(--cr-gold);
  background: rgba(201, 162, 75, 0.08);
}
.cr-btn:active:not(:disabled) { transform: translateY(1px); }
.cr-btn:disabled { opacity: 0.35; cursor: default; }

.cr-fs { font-size: 1rem; padding: 0.4rem 0.6rem; }

.cr-indicator {
  min-width: 6.5rem;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--cr-muted);
  font-variant-numeric: tabular-nums;
}

/* Stage + book ---------------------------------------------------------- */
.cr-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem clamp(0.5rem, 5vw, 4rem);
}

.cr-book {
  width: 100%;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* StPageFlip injects its own canvas/blocks inside .cr-book. Give the
   generated wrapper room and drop a soft shadow under the book. */
.cr-book .stf__parent {
  margin: 0 auto;
  filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.6));
}
.cr-book img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* StPageFlip page backgrounds: keep the page "paper" dark instead of the default
   white, so a page image that is narrower than its slot (letterboxed) shows a
   dark margin rather than glaring white on the outer edges. */
.cr-book,
.cr-book .stf__parent,
.cr-book .stf__wrapper,
.cr-book .stf__block,
.cr-book .stf__item {
  background-color: var(--cr-paper) !important;
}

/* Edge nav (minimal chrome, ghosted until hover) ------------------------ */
.cr-edge {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: clamp(2.2rem, 4vw, 3rem);
  height: clamp(3.4rem, 12vh, 6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: rgba(10, 9, 12, 0.35);
  color: var(--cr-gold);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.25;
  transition: opacity 0.18s ease, background 0.18s ease;
}
.cr-edge:hover { opacity: 1; background: rgba(201, 162, 75, 0.12); }
.cr-edge-prev { left: clamp(0.25rem, 2vw, 1.2rem); }
.cr-edge-next { right: clamp(0.25rem, 2vw, 1.2rem); }

/* Embedded preview -------------------------------------------------------
   The same reader mounted inline in the comic detail page instead of as a
   full-screen overlay. Bounded height so it sits in the page flow; the
   fullscreen button still lifts it to the viewport via the Fullscreen API. */
.cr-root.cr-embed {
  position: relative;
  inset: auto;
  z-index: 1;
  width: 100%;
  /* A comic page is portrait (~2:3), so the inline preview is a single-page
     book, never a two-page spread. Kept narrow enough that the book area stays
     under the reader's spread threshold (2 x minWidth = 440px), so one preview
     page fills it instead of sitting beside an empty half. */
  max-width: 440px;
  height: clamp(440px, 78vh, 720px);
  margin: 0 auto 2rem;
  border: 1px solid var(--cr-edge);
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

/* States ---------------------------------------------------------------- */
.cr-root.cr-fullscreen {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.cr-error {
  color: var(--cr-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem;
  border: 1px dashed var(--cr-edge);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

@media (max-width: 640px) {
  .cr-title { max-width: 40vw; }
  .cr-btn { padding: 0.4rem 0.55rem; font-size: 0.8rem; }
  .cr-indicator { min-width: 5rem; }
  .cr-stage { padding: 0.6rem 0.5rem; }
}
