:root {
  color-scheme: dark;
  --ink: #070806;
  --panel: #11110f;
  --paper: #e7dec8;
  --muted: #bdb49f;
  --line: rgba(231, 222, 200, 0.22);
  --focus: #d98224;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--paper);
  background: radial-gradient(circle at 50% 42%, rgba(221,162,71,.07), transparent 38%), var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body[data-theme="cortes"] { --focus: #dd743b; }
a { color: inherit; }
button, input { font: inherit; }
button, .reader-link {
  min-height: 2.75rem;
  padding: .6rem .9rem;
  border: 1px solid var(--line);
  border-radius: .2rem;
  color: var(--paper);
  background: rgba(7,9,11,.9);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}
button:hover:not(:disabled), .reader-link:hover { border-color: var(--focus); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
button:disabled { opacity: .28; cursor: default; }

.reader-header {
  min-height: 4.5rem;
  padding: .6rem clamp(.75rem,3vw,2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5,7,9,.96);
}
.reader-header__trail { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: .65rem; }
.reader-brand { flex: 0 0 auto; display: block; color: inherit; line-height: 1; text-decoration: none; }
.reader-brand__logo { width: auto; height: 3rem; display: block; }
.reader-brand__name { font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-size: 1.15rem; letter-spacing: .055em; text-transform: uppercase; }
.reader-brand__tagline { color: var(--muted); font-size: .58rem; font-weight: 700; letter-spacing: .08em; }
.reader-header__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.reader-header__actions { flex: 0 0 auto; display: flex; gap: .45rem; }
.reader-buy-link { display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }

.reader-stage {
  min-height: 0;
  overflow: auto;
  padding: clamp(.65rem,2vh,1.25rem) clamp(.35rem,2vw,1.5rem);
  display: grid;
  grid-template-columns: 3rem minmax(0,1fr) 3rem;
  align-items: center;
  justify-items: center;
  gap: clamp(.25rem,1.5vw,1rem);
  overscroll-behavior: contain;
}
.page-nav {
  position: relative;
  z-index: 8;
  width: 3rem;
  min-height: 3rem;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.8rem;
}
.book {
  position: relative;
  width: min(80vw, calc((100svh - 11rem) * 1.5));
  max-width: 76rem;
  max-height: calc(100svh - 11rem);
  aspect-ratio: 1.5 / 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  user-select: none;
  touch-action: pan-y pinch-zoom;
  filter: drop-shadow(0 2rem 2.8rem rgba(0,0,0,.58));
}
/* The complete Lost World pages are 1800 x 2590; keep a full spread inside
   the visible reader stage instead of using the generic 3:2 comic frame. */
body[data-manifest="/data/the-lost-world-complete-graphic-novel.json"][data-view-mode="page"] .book,
body[data-manifest="/data/eddie-rickenbacker-complete-graphic-novel.json"][data-view-mode="page"] .book {
  width: auto;
  height: calc(100svh - 12rem);
  max-width: min(80vw, 76rem);
  max-height: none;
  aspect-ratio: 3600 / 2590;
}
/* Eddie's cover and story pages are 1400 x 2000. Match the frame to the
   artwork so the image cannot grow below a shorter generic page slot. */
body[data-manifest="/data/eddie-rickenbacker-issue-01.json"][data-view-mode="page"] .book {
  width: min(80vw, calc((100svh - 12rem) * 1.4), 76rem);
  max-height: calc(100svh - 12rem);
  aspect-ratio: 2800 / 2000;
}
.page-slot { position: relative; min-width: 0; overflow: hidden; display: grid; place-items: center; background: var(--panel); box-shadow: inset 0 0 0 1px rgba(241,234,219,.08); }
.page-slot:first-child { border-radius: .35rem 0 0 .35rem; }
.page-slot:last-child { border-radius: 0 .35rem .35rem 0; }
.page-slot.is-empty::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(221,162,71,.04), transparent 48%); }
.page-image { width: 100%; height: 100%; display: block; object-fit: contain; }
.reader-cover-layer { position: relative; width: 100%; height: 100%; overflow: hidden; }
.reader-cover-layer .page-image { width: 100%; height: 100%; }
.reader-cover-layer__cleanup-frame { position: absolute; left: 0; bottom: 0; width: 42%; height: 27%; overflow: hidden; -webkit-mask-image: radial-gradient(ellipse 130% 130% at 0% 100%, #000 0 75%, transparent 100%); mask-image: radial-gradient(ellipse 130% 130% at 0% 100%, #000 0 75%, transparent 100%); }
.reader-cover-layer__cleanup { position: absolute; left: 0; bottom: 0; display: block; width: 238.1%; max-width: none !important; height: auto !important; }
.reader-cover-layer__publisher { position: absolute; left: 3%; bottom: 4%; width: 18%; height: 21%; display: grid; place-items: center; }
.reader-cover-layer__publisher img { display: block; width: auto; max-width: 100%; height: 82%; }
.book::after { content: ""; position: absolute; z-index: 4; inset: 0 auto 0 50%; width: .8rem; transform: translateX(-50%); pointer-events: none; background: linear-gradient(90deg,rgba(0,0,0,.54),rgba(255,255,255,.04) 50%,rgba(0,0,0,.5)); }
.page-load-error { width: min(90%,24rem); padding: 1.2rem; text-align: center; }

body[data-view-mode="width"] .reader-stage { display: block; overflow-x: hidden; padding: 1rem clamp(3.5rem,8vw,7rem) 2rem; scroll-behavior: smooth; }
body[data-view-mode="width"] .book { width: min(100%,58rem); max-width: 58rem; max-height: none; margin-inline: auto; aspect-ratio: auto; display: block; filter: drop-shadow(0 2rem 3rem rgba(0,0,0,.6)); }
body[data-view-mode="width"] .page-slot:first-child { display: none; }
body[data-view-mode="width"] .page-slot:last-child { min-height: 40vh; overflow: visible; border-radius: .25rem; }
body[data-view-mode="width"] .page-image { width: 100%; max-width: 100%; height: auto; }
body[data-view-mode="width"] .reader-cover-layer { height: auto; }
body[data-view-mode="width"] .reader-cover-layer .page-image { width: 100%; height: auto; }
body[data-view-mode="width"] .reader-cover-layer__cleanup { width: 238.1%; height: auto !important; }
body[data-view-mode="width"] .book::after { display: none; }
body[data-view-mode="width"] .page-nav { position: fixed; top: 50%; transform: translateY(-50%); }
body[data-view-mode="width"] #previousButton { left: .8rem; }
body[data-view-mode="width"] #nextButton { right: .8rem; }

.book.is-finale { overflow: visible; border: 1px solid var(--line); border-radius: .35rem; background: radial-gradient(circle at 50% 10%, rgba(221,162,71,.16), transparent 42%), linear-gradient(145deg,#11171c,#07090b 72%); box-shadow: 0 2rem 5rem rgba(0,0,0,.55); }
.book.is-finale .page-slot, .book.is-finale::after { display: none !important; }
.reader-finale { grid-column: 1 / -1; width: 100%; min-height: min(34rem,72vh); padding: clamp(1.2rem,5vw,4rem); display: grid; place-items: center; text-align: center; }
.reader-finale__inner { width: min(100%,44rem); display: grid; justify-items: center; gap: .9rem; }
.reader-finale__eyebrow { margin: 0; color: var(--focus); font-size: .76rem; font-weight: 850; letter-spacing: .16em; text-transform: uppercase; }
.reader-finale h2 { margin: 0; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-size: clamp(2.5rem,6vw,5rem); line-height: .95; letter-spacing: .02em; text-transform: uppercase; }
.reader-finale__copy { margin: 0; color: var(--muted); font-size: clamp(1rem,2vw,1.15rem); }
.reader-finale__unavailable { margin: 0; color: var(--muted); font-size: .9rem; }
.reader-finale__button { min-height: 3rem; padding: .72rem 1rem; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); font-weight: 800; text-decoration: none; }
.reader-finale__button:hover { border-color: var(--focus); }
.reader-finale__button--primary, .reader-finale__button--next { border-color: var(--focus); color: var(--ink); background: var(--focus); }
.reader-finale__button--quiet { background: rgba(7,9,11,.72); }
.reader-recommendation { width: min(100%,32rem); padding: .7rem; display: grid; grid-template-columns: 4.1rem minmax(0,1fr) auto; align-items: center; gap: .9rem; border: 1px solid var(--focus); text-align: left; text-decoration: none; background: rgba(7,9,11,.72); }
.reader-recommendation:hover { background: rgba(221,162,71,.08); }
.reader-recommendation img { width: 4.1rem; aspect-ratio: 17/22; object-fit: cover; }
.reader-recommendation span { min-width: 0; display: grid; }
.reader-recommendation small { color: var(--focus); font-size: .68rem; font-style: normal; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.reader-recommendation strong { margin-top: .12rem; font-size: 1.15rem; }
.reader-recommendation em { color: var(--muted); font-size: .78rem; font-style: normal; }
.reader-recommendation b { font-size: 1.4rem; }

.ad-page { position: absolute; inset: 0; display: block; overflow: hidden; color: var(--paper); text-decoration: none; background: #e9e8ed; }
.ad-page--full { position: relative; aspect-ratio: 17 / 22; background: transparent; }
.ad-page__full { width: 100%; height: 100%; display: block; object-fit: contain; }
.ad-page__book { width: 100%; height: 100%; display: block; object-fit: cover; }
.ad-page__copy { position: absolute; inset: auto 0 0; padding: 3rem 1rem 1rem; display: grid; justify-items: center; gap: .6rem; text-align: center; background: linear-gradient(transparent,rgba(5,7,8,.94) 42%,#050708); }
.ad-page__label { color: #d5d5d5; font-size: .7rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.ad-page__wordmark { width: min(82%,23rem); height: auto; }
.ad-page__cta { padding-bottom: .15rem; border-bottom: 1px solid var(--focus); font-weight: 820; }

.reader-footer { min-height: 5rem; padding: .55rem clamp(.75rem,3vw,2rem) .75rem; display: grid; grid-template-columns: minmax(8rem,14rem) minmax(10rem,1fr) minmax(8rem,16rem); align-items: center; gap: 1rem; border-top: 1px solid var(--line); background: rgba(5,7,9,.96); }
.reader-status { font-size: .88rem; font-weight: 760; }
.reader-progress { width: 100%; height: 2rem; accent-color: var(--focus); }
.reader-hint { color: var(--muted); font-size: .78rem; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.reader-error { grid-column: 1/-1; max-width: 32rem; padding: 1.5rem; border: 1px solid var(--line); background: var(--panel); }

@media (max-width: 760px) {
  .reader-header { min-height: 3.8rem; padding: .45rem .55rem; }
  .reader-brand__logo { height: 2.75rem; }
  .reader-brand__name { font-size: .92rem; }
  .reader-brand__tagline { display: none; }
  .reader-header__trail .reader-link, .reader-header__title { display: none; }
  .reader-header__actions { gap: .3rem; }
  .reader-header__actions button { min-height: 2.75rem; padding: .48rem .58rem; font-size: .74rem; }
  .reader-buy-link { min-height: 2.75rem; padding: .48rem .58rem; font-size: .74rem; }
  #shareButton { display: none; }
  #fullscreenButton { display: none; }
  .reader-stage { grid-template-columns: 3rem minmax(0,1fr) 3rem; gap: .25rem; padding: .5rem .25rem; }
  .book { width: min(100%,calc(100svh - 9.2rem) * .75); max-height: calc(100svh - 9.2rem); aspect-ratio: .75/1; grid-template-columns: 1fr; }
  body[data-manifest="/data/the-lost-world-complete-graphic-novel.json"][data-view-mode="page"] .book,
  body[data-manifest="/data/eddie-rickenbacker-complete-graphic-novel.json"][data-view-mode="page"] .book {
    width: auto;
    height: calc(100svh - 10rem);
    max-width: 100%;
    max-height: none;
    aspect-ratio: 1800 / 2590;
  }
  body[data-manifest="/data/eddie-rickenbacker-issue-01.json"][data-view-mode="page"] .book {
    width: min(100%, calc((100svh - 10rem) * .7));
    max-height: calc(100svh - 10rem);
    aspect-ratio: 1400 / 2000;
  }
  .page-slot:first-child { display: none; }
  .page-slot:last-child { border-radius: .3rem; }
  .book::after { display: none; }
  body[data-view-mode="width"] .reader-stage { padding: .65rem .5rem 4.25rem; }
  body[data-view-mode="width"] .book { width: min(100%, calc(100vw - 1rem)); max-width: calc(100vw - 1rem); }
  body[data-view-mode="width"] .page-nav { width: 2.75rem; min-height: 2.75rem; }
  body[data-view-mode="width"] #previousButton { top: auto; bottom: 4.85rem; left: .45rem; transform: none; }
  body[data-view-mode="width"] #nextButton { top: auto; right: .45rem; bottom: 4.85rem; transform: none; }
  .reader-finale { min-height: 65vh; padding: 1rem; }
  .reader-finale__inner { gap: .7rem; }
  .reader-finale h2 { font-size: clamp(2.2rem,12vw,3.5rem); }
  .reader-recommendation { grid-template-columns: 3.5rem minmax(0,1fr) auto; }
  .reader-recommendation img { width: 3.5rem; }
  .reader-footer { min-height: 4.5rem; grid-template-columns: 1fr; gap: 0; padding-block: .35rem; }
  .reader-status { text-align: center; font-size: .78rem; }
  .reader-hint { display: none; }
  .reader-progress { height: 1.5rem; }
}
@media (max-height: 620px) and (min-width: 761px) {
  .reader-header { min-height: 3.3rem; padding-block: .3rem; }
  .reader-footer { min-height: 4.1rem; padding-block: .25rem; }
  .book { width: min(80vw,calc((100svh - 7.8rem) * 1.5)); max-height: calc(100svh - 7.8rem); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 1ms !important; }
}

/* Comic-only transient leaf turn. Existing page slots/planners stay unchanged. */
.gutter-turn-overlay { position: absolute; z-index: 7; inset: 0; pointer-events: none; perspective: 1800px; }
.gutter-turn-leaf { position: absolute; inset: 0 auto 0 50%; width: 50%; transform-style: preserve-3d; transform-origin: left center; animation: gutter-leaf-forward 850ms cubic-bezier(.32,.05,.18,1) both; }
.gutter-turn-leaf.is-backward { left: 0; transform-origin: right center; animation-name: gutter-leaf-backward; }
.gutter-turn-leaf.is-single { left: 0; width: 100%; }
.gutter-turn-overlay .gutter-turn-face.page-slot { position: absolute; inset: 0; display: grid !important; width: 100%; height: 100%; min-height: 0; overflow: hidden; border-radius: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--panel); }
.gutter-turn-overlay .gutter-turn-face .page-image { width: 100%; height: 100%; object-fit: contain; }
.gutter-turn-overlay .reader-cover-layer { width: 100%; height: 100%; }
.gutter-turn-overlay .gutter-turn-hold.page-slot { width: 50%; }
.gutter-turn-hold.is-right { left: 50% !important; }
.gutter-turn-front { transform: translateZ(.1px); }
.gutter-turn-back { transform: rotateY(180deg); }
.gutter-turn-leaf::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg,rgba(0,0,0,.28),transparent 35%,rgba(0,0,0,.08)); pointer-events: none; transform: translateZ(.2px); backface-visibility: hidden; }
@keyframes gutter-leaf-forward { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
@keyframes gutter-leaf-backward { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
@media (prefers-reduced-motion: reduce) { .gutter-turn-leaf { animation: none; } }
