/* I'm Not Scared of a Trapdoor
   Dark hallway (violet) vs. the lit page (looseleaf). Mobile first. */

/* Fonts: Ultra, Source Sans 3, Patrick Hand. Google Fonts (OFL), self-hosted latin subset. */
@font-face { font-family: 'Ultra'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/Ultra-normal-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Source Sans 3'; font-style: normal; font-weight: 200 900; font-display: swap; src: url(fonts/SourceSans3-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Source Sans 3'; font-style: italic; font-weight: 400; font-display: swap; src: url(fonts/SourceSans3-italic-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Patrick Hand'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/PatrickHand-normal-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --violet-deep: #241D47;
  --violet-mid: #2E265C;
  --violet-line: #4A3F86;
  --ink: #0E0A1E;
  --acid: #B6E21A;
  --amber: #FFBE1A;
  --text: #EEEBF8;
  --muted: #BDB6DE;

  --paper: #FBFAF6;
  --paper-ink: #1F1A3A;
  --rule: #BCD0EA;
  --margin: #E46F69;
  --pencil-red: #C2362F;

  --lh: 32px;        /* ruled line spacing on paper */
  --m: 44px;         /* red margin offset */
  --nav-h: 58px;
  --gutter: 16px;
  --wrap: 1120px;
  --radius: 14px;

  --display: "Ultra", "Rockwell Extra Bold", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --hand: "Patrick Hand", "Comic Sans MS", cursive;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + env(safe-area-inset-top) + 8px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--violet-deep);
  color: var(--text);
  font: 400 1.0625rem/1.6 var(--sans);
  overflow-x: hidden;
}
img { max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--acid); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--acid); outline-offset: 2px; border-radius: 4px; }
.sheet :focus-visible { outline-color: var(--violet-deep); }

.sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100; padding: 10px 14px;
  background: var(--acid); color: var(--ink); font-weight: 700; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 8px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* ── Display type: Ultra, caps, thin dark outline, hard offset shadow ── */
.display {
  font-family: var(--display);
  font-weight: 400;
  text-transform: uppercase;
  color: var(--amber);
  line-height: .95;
  letter-spacing: -.005em;
  margin: 0 0 .5em;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: .07em .07em 0 var(--ink);
  font-size: clamp(2.2rem, 10vw, 4rem);
}
.display.small { font-size: clamp(1.7rem, 7vw, 2.6rem); }
.sheet .display { color: var(--violet-deep); -webkit-text-stroke: 0; text-shadow: .06em .06em 0 var(--amber); }
.lede { max-width: 40em; color: var(--muted); margin: 0 0 1.5rem; font-size: 1.125rem; }
.h3 { font: 700 1.25rem/1.3 var(--sans); margin: 0 0 .35rem; color: var(--text); }

/* ── Nav: bar, sticky, hides on scroll down ── */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: rgba(36, 29, 71, .94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--violet-line);
  transition: transform .25s ease;
}
.nav.hide { transform: translateY(-100%); }
.nav > nav { height: 100%; }
.nav ul { display: flex; justify-content: space-evenly; align-items: stretch; height: 100%; margin: 0 auto; padding: 0 4px; list-style: none; max-width: 640px; }
.nav li { display: flex; }
.nav a {
  display: flex; align-items: center; padding: 0 clamp(6px, 2.4vw, 16px);
  color: var(--text); text-decoration: none; white-space: nowrap;
  font-weight: 600; font-size: clamp(.875rem, 3.9vw, 1rem); letter-spacing: .01em;
}
.nav a:hover { color: var(--acid); }
.nav a.cur { color: var(--acid); box-shadow: inset 0 -3px 0 var(--acid); }

/* ── Hero ── */
.hero { position: relative; text-align: center; background: var(--violet-deep); }
.hero-title { position: relative; z-index: 2; padding: 28px var(--gutter) 0; }
.hero h1 { margin: 0; font-size: clamp(1.75rem, 8.6vw, 4.4rem); line-height: .98; }
.hero h1 span { display: block; }
#title:focus { outline: none; }  /* focused only programmatically, after the rewind */
.hero h1 .big { font-size: 1.34em; line-height: .95; margin-top: .04em; }
.byline {
  margin: .9rem 0 0; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  font-size: .9375rem; color: var(--text);
}
.tagline {
  display: inline-block; margin: 1.1rem auto 0; padding: .35rem 1rem .4rem;
  background: var(--paper); color: var(--paper-ink);
  font: 400 clamp(1.25rem, 5.4vw, 1.6rem)/1.25 var(--hand);
  border-left: 3px solid var(--margin);
  box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-1.2deg);
}
.tagline span { display: block; }
.hero-art { display: block; margin-top: -6vw; position: relative; z-index: 1; }
.hero-art img {
  display: block; width: 100%; height: auto; max-height: 92vh; object-fit: cover; object-position: 50% 62%;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 88%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 22%, #000 88%, transparent 100%);
}

/* ── Looseleaf ── */
.sheet {
  position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent calc(var(--m) - 1px), var(--margin) calc(var(--m) - 1px), var(--margin) calc(var(--m) + 1px), transparent calc(var(--m) + 1px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px), var(--rule) var(--lh));
  color: var(--paper-ink);
}
.sheet::before, .sheet::after {  /* punched holes, showing the hallway through */
  content: ""; position: absolute; left: calc(var(--m) / 2 - 8px); width: 16px; height: 16px;
  border-radius: 50%; background: var(--violet-deep); box-shadow: inset 1px 1px 3px rgba(0,0,0,.5);
}
.sheet::before { top: 48px; }
.sheet::after { bottom: 48px; }
.sheet-inner {
  max-width: calc(38em + var(--m)); margin: 0 auto;
  padding: var(--lh) var(--gutter) var(--lh) calc(var(--m) + 14px);
}
.sheet p { margin: 0 0 var(--lh); line-height: var(--lh); font-size: 1.125rem; }
.sheet h2, .sheet h3.display { height: calc(var(--lh) * 2); line-height: calc(var(--lh) * 2); margin: 0 0 var(--lh); padding: 0; white-space: nowrap; }
.about .sheet-inner { padding-top: calc(var(--lh) * 2); padding-bottom: calc(var(--lh) * 2); }

/* ── Listen ── */
.listen { padding: 56px 0 64px; }
.player {
  display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: start;
  background: var(--violet-mid); border: 2px solid var(--violet-line); border-radius: var(--radius);
  padding: 14px; box-shadow: 6px 6px 0 var(--ink);
}
.pl-cover { width: 72px; height: 72px; border-radius: 8px; display: block; }
.pl-main { min-width: 0; }
.pl-now { margin: 0 0 6px; line-height: 1.25; }
.pl-label { display: block; font-size: .8125rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--acid); }
.pl-title { display: block; font-weight: 700; font-size: 1.1875rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-controls { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px -4px; }
.ctl {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer; color: var(--text);
}
.ctl svg { width: 28px; height: 28px; fill: currentColor; }
.ctl svg text { font: 700 6.4px var(--sans); fill: currentColor; }
.ctl:hover { background: rgba(255,255,255,.08); }
.ctl.play { width: 56px; height: 56px; background: var(--acid); color: var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.ctl.play:hover { background: #c6ef3a; }
.ctl.play svg { width: 30px; height: 30px; }
.i-pause, .playing .i-play { display: none; }
.ctl.play.loading { position: relative; }
.ctl.play.loading::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 3px solid transparent; border-top-color: var(--acid); border-right-color: var(--acid);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .ctl.play.loading::after { animation: none; border-color: var(--acid); opacity: .5; } }
.playing .i-pause { display: block; }
.ctl.rate { width: auto; min-width: 52px; padding: 0 10px; border-radius: 22px; border: 2px solid var(--violet-line); font-weight: 700; font-size: .9375rem; }
.pl-scrub { display: flex; align-items: center; gap: 10px; }
.pl-time { font-variant-numeric: tabular-nums; font-size: .875rem; color: var(--muted); min-width: 2.6em; }
.pl-time:last-child { text-align: right; }
.pl-total { grid-column: 1 / -1; margin: 0; font-size: .875rem; color: var(--muted); border-top: 1px solid var(--violet-line); padding-top: 8px; }

input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px; background: transparent; cursor: pointer; margin: 0;
  --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--acid) var(--p), var(--violet-line) var(--p));
}
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--violet-line); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--acid); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: var(--text); border: 3px solid var(--ink);
}
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 3px solid var(--ink); }

/* Chapters: equal cards you swipe on phones, a two-column track list on desktop */
.chapters {
  list-style: none; margin: 18px calc(var(--gutter) * -1) 0; padding: 4px var(--gutter) 10px;
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: thin;
  overscroll-behavior-x: contain;
}
.chapters li { position: relative; flex: none; scroll-snap-align: start; }
.chapters button {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: 1fr auto; column-gap: 8px; row-gap: 2px;
  width: 172px; height: 72px; padding: 8px 12px; text-align: left; cursor: pointer;
  background: transparent; border: 2px solid var(--violet-line); border-radius: 10px;
}
.chapters .ch-n { grid-row: 1 / 3; font: 400 1.5rem/1 var(--display); color: var(--amber); align-self: center; min-width: 1.1em; text-align: center; }
.chapters .ch-t {
  align-self: start; font-weight: 600; line-height: 1.2; font-size: .9375rem;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.chapters .ch-d { align-self: end; font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chapters .credit .ch-n { display: none; }
.chapters .credit .ch-t { font-weight: 400; color: var(--muted); }
.chapters .credit .ch-t, .chapters .credit .ch-d { grid-column: 1 / -1; }
.chapters button:hover { border-color: var(--muted); }
.chapters button[aria-current="true"] { border-color: var(--acid); background: rgba(182, 226, 26, .1); box-shadow: 3px 3px 0 var(--ink); }
.chapters button[aria-current="true"] .ch-t { color: var(--acid); }

/* Reader: scan + transcript */
.reader { position: relative; margin-top: 18px; }
@media (max-width: 899.98px) {
  .reader { border-radius: 12px; overflow: hidden; background: var(--paper); box-shadow: 6px 6px 0 var(--ink); }
  .reader .tx, .reader .scan-open { box-shadow: none; border-radius: 0; }
  .reader .scan figcaption { margin: 0; padding: 10px 0 12px; background: var(--paper); color: #4F4878; border-top: 1px solid var(--rule); }
}
.view-toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--violet-mid); }
.view-toggle button {
  min-height: 50px; padding: 0 12px; border: 0; border-bottom: 2px solid var(--violet-line); border-radius: 0;
  background: var(--violet-mid); cursor: pointer; font-weight: 600; color: var(--muted);
}
.view-toggle button + button { border-left: 2px solid var(--violet-line); }
.view-toggle button:hover { color: var(--text); }
.view-toggle button[aria-pressed="true"] { background: var(--paper); color: var(--violet-deep); font-weight: 700; border-bottom-color: transparent; }
.view-toggle button:focus-visible { outline-offset: -4px; }
.reader[data-view="text"] .scan { display: none; }
.reader[data-view="page"] .tx-wrap { display: none; }

.scan { margin: 0; }
.scan-open {
  position: relative; display: block; width: 100%; aspect-ratio: 1100 / 1416; padding: 0; border: 0; cursor: zoom-in;
  background: #fff; border-radius: 4px; overflow: hidden; box-shadow: 6px 6px 0 var(--ink);
  perspective: 1400px;
}
.scan-open img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff;
  opacity: 0; transform-origin: 0 50%;
}
.scan-open img.on { opacity: 1; z-index: 1; }
.scan-open img.turn-in { animation: turn-in .55s cubic-bezier(.2, .7, .2, 1) both; z-index: 2; }
@keyframes turn-in {
  from { opacity: 0; transform: rotateY(-28deg) translateX(-3%); filter: brightness(.85); }
  to   { opacity: 1; transform: none; filter: none; }
}
/* the word being read, on the handwritten page */
.scan-word {
  position: absolute; z-index: 3; pointer-events: none; border-radius: 5px;
  background: rgba(182, 226, 26, .5); mix-blend-mode: multiply;
  box-shadow: 0 0 0 2px rgba(182, 226, 26, .55);
  transition: left .12s ease, top .12s ease, width .12s ease, height .12s ease, opacity .15s ease;
}
.scan-word[hidden] { display: block; opacity: 0; }
.scan figcaption { margin-top: 10px; font-size: .9375rem; color: var(--muted); text-align: center; }
.scan.flash figcaption { color: var(--acid); }

.tx-wrap { position: relative; }
.tx {
  height: min(52svh, 460px); min-height: 300px; overflow-y: auto; overscroll-behavior-y: auto;
  border-radius: 4px; box-shadow: 6px 6px 0 var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent calc(var(--m) - 1px), var(--margin) calc(var(--m) - 1px), var(--margin) calc(var(--m) + 1px), transparent calc(var(--m) + 1px)),
    repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--lh) - 1px), var(--rule) calc(var(--lh) - 1px), var(--rule) var(--lh));
  background-attachment: local;
  color: var(--paper-ink);
  padding: var(--lh) 16px var(--lh) calc(var(--m) + 12px);
  font-size: 1.125rem; line-height: var(--lh);
}
.tx p { margin: 0 0 var(--lh); }
.tx-h {
  margin: 0 0 var(--lh); padding-top: var(--lh); line-height: var(--lh);
  font: 700 1rem/var(--lh) var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--violet-deep);
}
.tx-file:first-child .tx-h, .tx-file:first-child .tx-credit { padding-top: 0; }
.tx-credit { font-style: italic; color: #4F4878; }
.tx span[data-t] { cursor: pointer; border-radius: 3px; }
@media (hover: hover) { .tx span[data-t]:hover { background: rgba(182, 226, 26, .35); } }
.tx span.on { background: var(--acid); box-shadow: 0 0 0 2px var(--acid); color: var(--ink); }
.tx-follow {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 3;
  min-height: 40px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 20px;
  background: var(--acid); color: var(--ink); font-weight: 700; cursor: pointer; box-shadow: 3px 3px 0 var(--ink);
}

/* ── Pages grid ── */
.pages { padding: 56px 0 72px; background: linear-gradient(var(--violet-deep), #1C1639); }
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.grid button {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  background: #fff; border-radius: 3px; box-shadow: 3px 3px 0 var(--ink);
  transition: transform .15s ease;
}
.grid img { display: block; width: 100%; height: auto; aspect-ratio: 200 / 258; object-fit: cover; object-position: top; border-radius: 3px; }
.grid .pg-n {
  position: absolute; left: 4px; bottom: 4px; min-width: 22px; padding: 0 5px; border-radius: 4px;
  background: var(--violet-deep); color: var(--text); font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center;
}
.grid .pg-mark {
  position: absolute; right: -5px; top: -5px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--acid); border: 3px solid var(--ink);
}
.grid .marked button { outline: 2px solid var(--acid); outline-offset: 2px; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) { .grid button:hover { transform: translate(-2px, -2px); } }
.more {
  display: flex; align-items: center; justify-content: center; gap: 8px; margin: 22px auto 0;
  min-height: 48px; padding: 0 22px; border: 2px solid var(--acid); border-radius: 24px;
  background: transparent; color: var(--acid); font-weight: 700; font-size: 1rem; cursor: pointer;
}
.more:hover { background: rgba(182, 226, 26, .12); }

/* ── Lightbox ── */
.lb {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0;
  background: rgba(14, 10, 30, .97); color: var(--text);
}
.lb::backdrop { background: rgba(14, 10, 30, .8); }
.lb[open] { display: grid; place-items: center; }
.lb-fig { margin: 0; padding: 56px 12px 16px; display: flex; flex-direction: column; align-items: center; max-height: 100dvh; touch-action: pan-y pinch-zoom; -webkit-user-select: none; user-select: none; }
.lb-fig img { -webkit-user-drag: none; -webkit-touch-callout: none; }
.lb-fig img {
  display: block; width: auto; height: auto; max-width: min(100%, 760px);
  max-height: calc(100dvh - 56px - var(--lb-below, 0px) - var(--cap-h, 40px) - 24px);
  background: #fff; border-radius: 3px; box-shadow: 6px 6px 0 #000;
}
.lb-fig img.swap { animation: lb-in .3s ease both; }
@keyframes lb-in { from { opacity: .2; } to { opacity: 1; } }
.lb figcaption { text-align: center; max-width: 34em; padding: 0 8px; }
.lb-n { margin: 12px 0 0; color: var(--muted); font-size: .9375rem; }
.lb-cap { margin: 6px 0 0; font: 1.375rem/1.3 var(--hand); color: var(--acid); }
.lb-btn {
  position: fixed; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  border: 2px solid var(--violet-line); background: var(--violet-mid); cursor: pointer;
}
.lb-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.lb-close { top: 8px; right: 8px; }
.lb { --lb-below: 72px; }
.lb-fig { padding-bottom: calc(var(--lb-below) + env(safe-area-inset-bottom)); }
.lb-prev { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
.lb-next { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }

/* ── The trapdoor: the very end of the page, the floor of the hallway ── */
.td {
  --leak: .22;   /* how much green gets through the cracks; rises after the first try */
  position: relative; padding: 64px var(--gutter) 72px; overflow: hidden; text-align: center;
  background:
    radial-gradient(ellipse 60% 55% at 50% 42%, rgba(182, 226, 26, calc(var(--leak) * .35)), transparent 70%),
    radial-gradient(ellipse at 50% 40%, #2E2660, #17122F 75%);
  border-top: 1px solid var(--violet-line);
}
.td.leaking { --leak: .55; }
/* the floor, tipped away from you like the cover */
.td-floor {
  --size: min(64vw, 280px);
  position: relative; width: calc(var(--size) * 2.2); max-width: 100%; height: calc(var(--size) * 1.05);
  margin: 0 auto; perspective: 760px; perspective-origin: 50% 0%;
}
.td-floor::before {   /* floor tiles around the hatch */
  content: ""; position: absolute; inset: -40% -30% -10%;
  background-color: #2A2252;
  background-image:
    linear-gradient(rgba(14,10,30,.85) 3px, transparent 3px),
    linear-gradient(90deg, rgba(14,10,30,.85) 3px, transparent 3px),
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.05), transparent 60%);
  background-size: calc(var(--size) / 2.6) calc(var(--size) / 2.6), calc(var(--size) / 2.6) calc(var(--size) / 2.6), 100% 100%;
  background-position: center;
  transform: rotateX(48deg); transform-origin: 50% 60%;
  -webkit-mask-image: radial-gradient(ellipse 55% 60% at 50% 55%, #000 45%, transparent 80%);
  mask-image: radial-gradient(ellipse 55% 60% at 50% 55%, #000 45%, transparent 80%);
}
.td-stage {
  position: absolute; left: 50%; top: 0; width: var(--size); height: var(--size); margin-left: calc(var(--size) / -2);
  transform: rotateX(48deg); transform-origin: 50% 60%; transform-style: preserve-3d;
}
.td-hole {   /* the frame the door sits in */
  position: absolute; inset: -10px; overflow: hidden; border-radius: 3px;
  background: #0B0818;
  box-shadow: inset 0 0 0 4px #1C1530, inset 0 0 0 10px #3A2C48, 0 0 0 3px var(--ink),
              0 0 calc(30px + var(--leak) * 50px) rgba(182, 226, 26, calc(var(--leak) * .55));
}
.td-under {  /* solid floor, the first time */
  position: absolute; inset: 10px;
  background-color: #2A2252;
  background-image:
    linear-gradient(rgba(14,10,30,.85) 3px, transparent 3px),
    linear-gradient(90deg, rgba(14,10,30,.85) 3px, transparent 3px);
  background-size: 50% 50%;
}
.td-glow {
  position: absolute; inset: 10px; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(circle at 50% 50%, #F4FFC8 0, var(--acid) 35%, #4E6A08 100%);
}
.td.can-open .td-under { opacity: 0; }
.td.can-open .td-glow { opacity: 1; }
.td-door {
  position: absolute; inset: 0; padding: 0; border: 3px solid #120D22; border-radius: 2px; cursor: grab;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  /* what shows through the gaps between planks: the light underneath */
  background: rgba(182, 226, 26, var(--leak));
  box-shadow: 0 0 calc(6px + var(--leak) * 18px) rgba(182, 226, 26, calc(var(--leak) * .8)) inset;
  transform-origin: 50% 0; transform-style: preserve-3d;
  touch-action: none; -webkit-user-select: none; user-select: none;
  transition: background .6s ease, box-shadow .6s ease;
}
.td-door:active { cursor: grabbing; }
.td-door:focus-visible { outline: 3px solid var(--acid); outline-offset: 14px; }
.td-plank {
  position: relative;
  background:
    repeating-linear-gradient(91deg, transparent 0 9px, rgba(0,0,0,.18) 9px 10px, transparent 10px 23px),
    repeating-linear-gradient(178deg, rgba(255,255,255,.035) 0 2px, transparent 2px 7px, rgba(0,0,0,.12) 7px 8px, transparent 8px 15px),
    linear-gradient(90deg, #4A3A5C, #3A2D4C 45%, #2E2340);
  box-shadow: inset 2px 0 0 rgba(255,255,255,.06), inset -2px 0 0 rgba(0,0,0,.25);
}
.td-plank:nth-child(2) { background-position: 7px 3px, 0 5px, 0 0; filter: brightness(.94); }
.td-plank:nth-child(3) { background-position: 13px 9px, 0 2px, 0 0; filter: brightness(1.04); }
.td-plank:nth-child(4) { background-position: 4px 6px, 0 7px, 0 0; filter: brightness(.9); }
.td-plank::before, .td-plank::after {   /* nail heads */
  content: ""; position: absolute; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: #1A1426; box-shadow: inset 1px 1px 0 rgba(255,255,255,.12);
}
.td-plank::before { top: 12%; }
.td-plank::after { bottom: 12%; }
.td-brace {  /* cross plank */
  position: absolute; left: -2px; right: -2px; top: 46%; height: 13%;
  background: linear-gradient(180deg, #3E3050, #2B2140); border-block: 2px solid #120D22;
  box-shadow: 0 3px 6px rgba(0,0,0,.35);
}
.td-ring {
  position: absolute; left: 50%; bottom: 13%; width: 30px; height: 30px; margin-left: -15px;
  border: 5px solid #8E86B8; border-radius: 50%; box-shadow: 2px 3px 0 var(--ink), inset 1px 1px 0 rgba(255,255,255,.3);
}
.td-door.seep { background: rgba(182, 226, 26, .9); box-shadow: 0 0 26px rgba(182, 226, 26, .9) inset; }
.td.shake .td-floor { animation: shake .32s linear; }
@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-3px, 1px); }
  80% { transform: translate(2px, 0); }
}
.td-line {
  min-height: 2.6em; margin: 22px auto 0; max-width: 22em;
  font: 400 clamp(1.5rem, 6.4vw, 2rem)/1.25 var(--hand); color: var(--paper);
  opacity: 0; transition: opacity .5s ease;
}
.td-line.show { opacity: 1; }
.td.falling .td-floor { animation: fall-in .9s cubic-bezier(.5, 0, .9, .4) forwards; }
@keyframes fall-in { to { transform: translateY(18%) scale(6); } }

/* ── The rewind: the whole page turns into a tape going back to page one ── */
.rew {
  position: fixed; inset: 0; z-index: 200; pointer-events: none; overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.28) 0 2px, transparent 2px 4px),
    linear-gradient(rgba(36, 29, 71, .18), rgba(36, 29, 71, .18));
  mix-blend-mode: normal;
}
.rew[hidden] { display: none; }
.rew.flash { animation: rew-flash .5s ease-out both; }
@keyframes rew-flash { from { background-color: rgba(36, 29, 71, .9); } to { background-color: transparent; } }
.rew-band {  /* the tracking band rolling down the screen */
  position: absolute; left: 0; right: 0; height: 18vh; top: -20vh;
  background: linear-gradient(transparent, rgba(255,255,255,.12) 40%, rgba(255,255,255,.22) 50%, rgba(0,0,0,.25) 60%, transparent);
  animation: band .55s linear infinite;
}
@keyframes band { to { transform: translateY(140vh); } }
.rew-osd, .rew-count {
  position: absolute; margin: 0; color: #fff; letter-spacing: .06em;
  font: 700 clamp(1.5rem, 6vw, 2.4rem)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-shadow: 2px 0 0 rgba(255,0,80,.7), -2px 0 0 rgba(0,220,255,.7), 0 0 8px rgba(0,0,0,.6);
}
.rew-osd { left: max(20px, env(safe-area-inset-left)); top: calc(20px + env(safe-area-inset-top)); }
.rew-count {
  left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center;
  font-size: clamp(5rem, 30vw, 11rem); font-variant-numeric: tabular-nums; letter-spacing: 0;
  text-shadow: 5px 0 0 rgba(255,0,80,.7), -5px 0 0 rgba(0,220,255,.7), 0 0 24px rgba(0,0,0,.6);
}
.rew-page { display: block; font-size: clamp(1.1rem, 5vw, 1.8rem); letter-spacing: .3em; margin-bottom: .1em; text-shadow: 2px 0 0 rgba(255,0,80,.7), -2px 0 0 rgba(0,220,255,.7), 0 0 8px rgba(0,0,0,.6); }
.rew-sym { display: inline-block; animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
body.rewinding main, body.rewinding .foot { animation: wobble .12s steps(3) infinite; filter: saturate(1.35) contrast(1.08); }
@keyframes wobble { 0% { transform: translateX(0); } 33% { transform: translateX(-3px); } 66% { transform: translateX(2px); } }

/* ── By the numbers ── */
.numbers { padding: 56px 0 0; }
.stats { list-style: none; margin: 0 0 40px; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  display: flex; flex-direction: column; padding: 14px; border-radius: 12px;
  background: var(--violet-mid); border: 2px solid var(--violet-line);
}
.num {
  font: 400 clamp(2rem, 9vw, 3rem)/1 var(--display); color: var(--amber);
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink);
}
.stat .what { margin-top: 6px; color: var(--muted); line-height: 1.3; }
.compare { margin: 0 0 44px; }
.compare > p { margin: 0 0 16px; color: var(--muted); max-width: 40em; }
.bars { display: grid; gap: 10px; max-width: 640px; }
.bar-row { display: grid; grid-template-columns: 7.5em 1fr; align-items: center; gap: 10px; padding-right: 3.6em; }
.bar-l { font-size: .9375rem; color: var(--muted); }
.bar { --scale: 22; position: relative; display: block; height: 34px; border-radius: 4px; }
.bar b { position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); font-weight: 700; white-space: nowrap; }
.bar.me { width: calc(var(--v) / var(--scale) * 100%); background: var(--acid); }
.bar.range {
  width: calc(var(--b) / var(--scale) * 100%);
  background: linear-gradient(90deg, var(--muted) 0 calc(var(--a) / var(--b) * 100%), transparent 0),
              repeating-linear-gradient(135deg, var(--muted) 0 4px, transparent 4px 8px);
}
.bar.range b { left: auto; right: -8px; transform: translate(100%, -50%); }
.dots { display: grid; grid-template-columns: repeat(auto-fill, 9px); grid-auto-rows: 9px; gap: 3px; max-width: 760px; }
.dots i { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--violet-line); }
.dots i.y { background: var(--acid); }
.tallies { list-style: none; margin: 0 0 44px; padding: 0; display: grid; gap: 10px; }
.tallies li { display: flex; align-items: baseline; gap: 12px; font-size: 1.125rem; }
.tallies .num { font-size: 2.2rem; min-width: 1.6em; text-align: right; }

/* Spelling, on paper */
.spelling { margin-top: 8px; }
.spelling .sheet-inner { max-width: calc(52em + var(--m)); padding-top: calc(var(--lh) * 2); padding-bottom: calc(var(--lh) * 2); }
.sp-featured { list-style: none; margin: 0 0 var(--lh); padding: 0; display: grid; grid-template-columns: 1fr; gap: 0; }
.sp-featured li {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "was page" "is page";
  align-items: center; column-gap: 12px; padding: 10px 0 9px; border-bottom: 2px dashed var(--rule);
  min-height: calc(var(--lh) * 3.5);
}
.sp-was { grid-area: was; font: 400 clamp(2.1rem, 9vw, 2.75rem)/1.05 var(--hand); color: var(--paper-ink); }
.sp-was del { text-decoration-color: var(--pencil-red); text-decoration-thickness: 3px; }
.sp-is { grid-area: is; font-weight: 700; font-size: 1.375rem; color: var(--violet-deep); }
.sp-is::before { content: "→ "; color: var(--pencil-red); }
.sp-page, .sp-p button {
  grid-area: page; min-height: 32px; padding: 0 10px; border: 2px solid var(--violet-deep); border-radius: 16px;
  background: transparent; color: var(--violet-deep); font-size: .875rem; font-weight: 600; cursor: pointer;
}
.sp-page:hover, .sp-p button:hover { background: var(--violet-deep); color: var(--paper); }
.sp-all summary {
  cursor: pointer; font-weight: 700; color: var(--violet-deep); line-height: 1.3; min-height: 44px; display: flex; align-items: center; gap: 10px; list-style: none;
}
.sp-all summary::-webkit-details-marker { display: none; }
.sp-all summary::before {
  content: "+"; flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--violet-deep); color: var(--paper); font-size: 1.25rem; line-height: 1;
}
.sp-all[open] summary::before { content: "\2212"; }
.sp-table-wrap { overflow-x: auto; margin-top: 8px; }
.sp-table { width: 100%; border-collapse: collapse; font-size: 1rem; background: rgba(251, 250, 246, .9); }
.sp-table th { text-align: left; font-size: .8125rem; text-transform: uppercase; letter-spacing: .08em; color: #4F4878; padding: 6px 8px; border-bottom: 2px solid var(--violet-deep); }
.sp-table td { padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.sp-table del { font-family: var(--hand); font-size: 1.25rem; text-decoration-color: var(--pencil-red); text-decoration-thickness: 2px; }
.sp-x { color: #4F4878; font-size: .8125rem; }
.sp-p { white-space: normal; }
.sp-p button { min-height: 28px; min-width: 32px; padding: 0 6px; margin: 2px 0; font-size: .8125rem; }

/* ── Where to find it ── */
.find { padding: 64px 0 56px; }
.platforms { list-style: none; margin: 0 0 32px; padding: 0; display: grid; gap: 12px; max-width: 760px; }
.pf {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  height: 58px; padding: 0 20px; border-radius: 12px; border: 2px solid var(--ink);
  font-weight: 700; font-size: 1.0625rem; text-decoration: none; box-shadow: 4px 4px 0 var(--ink);
  transition: transform .12s ease, box-shadow .12s ease;
}
.pf svg { width: 26px; height: 26px; flex: none; }
.pf.kindle { background: #FFFFFF; color: #111; }
.pf.kindle svg { fill: #FF9900; }
.pf.audible { background: #F8991C; color: #111; }
.pf.audible svg { fill: #111; }
.pf.spotify { background: #1DB954; color: #111; }
.pf.spotify svg { fill: #111; }
a.pf:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.pf.epub { background: var(--acid); color: var(--ink); }
.pf.epub svg { fill: var(--ink); }
.pf-note { font-weight: 600; opacity: .7; font-size: .875em; margin-left: 4px; }
.pf.spotify.soon { background: transparent; color: #1DB954; border: 2px dashed #1DB954; box-shadow: none; }
.pf.spotify.soon svg { fill: #1DB954; }
.related { color: var(--muted); margin: 0; }

.foot { padding: 28px var(--gutter) 40px; text-align: center; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--violet-line); }
.foot p { margin: 0; }
.foot .related { margin: 0 auto 12px; max-width: 34em; font-size: 1rem; line-height: 1.75; }
/* Looks already selected; selecting it does the opposite and "unselects" it. */
.foot .hl {
  background: #2F4F94; color: #EEEBF8; padding: 3px 0;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.foot .hl::selection, .foot .hl *::selection { background: var(--violet-deep); color: var(--muted); }

/* ── Mini player: same controls as the main one ── */
.mini {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 4px 12px calc(6px + env(safe-area-inset-bottom));
  background: rgba(46, 38, 92, .97); border-top: 2px solid var(--acid);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transform: translateY(0); transition: transform .25s ease;
  display: grid; grid-template-columns: 1fr; gap: 0;
}
.mini[hidden] { display: grid; transform: translateY(110%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
.mini-scrub { display: flex; align-items: center; gap: 10px; }
.mini-scrub .pl-time { font-size: .8125rem; }
.mini-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-info { flex: 1; min-width: 0; color: var(--text); text-decoration: none; line-height: 1.2; padding: 4px 0; }
.mini-label { display: block; font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--acid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-ctl { display: flex; align-items: center; gap: 2px; flex: none; }
.mini .ctl.play { width: 48px; height: 48px; }
.mini .ctl.rate { min-width: 48px; padding: 0 8px; margin-left: 4px; }
body.has-mini { padding-bottom: calc(var(--mini-h, 112px) + 8px); }

/* Speed menu */
.rate-menu {
  position: fixed; z-index: 80; min-width: 116px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--violet-mid); border: 2px solid var(--violet-line); border-radius: 12px;
  box-shadow: 5px 5px 0 var(--ink);
}
.rate-menu[hidden] { display: none; }
.rate-menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent;
  font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; color: var(--text);
}
.rate-menu button::after { content: ""; width: 16px; }
.rate-menu button[aria-checked="true"] { color: var(--acid); }
.rate-menu button[aria-checked="true"]::after { content: "\2713"; }
.rate-menu button:hover, .rate-menu button:focus-visible { background: rgba(255, 255, 255, .1); outline-offset: -2px; }

/* ── Larger screens ── */
@media (min-width: 640px) {
  :root { --m: 72px; --gutter: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .sp-featured { grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .platforms { grid-template-columns: repeat(2, 1fr); }
  .player { grid-template-columns: 112px 1fr; padding: 18px; gap: 20px; }
  .pl-cover { width: 112px; height: 112px; }
  .pl-total { grid-column: 2; border-top: 0; padding-top: 0; }
  .tallies { grid-template-columns: repeat(3, 1fr); }
  .tallies li { flex-direction: column; gap: 4px; }
  .tallies .num { text-align: left; }
  .tagline span { display: inline; }
}
@media (min-width: 900px) {
  :root { --m: 88px; }
  .hero-title { padding-top: 40px; }
  .hero-art { margin-top: -90px; }
  /* track list: two columns, opening credits at the top left, closing credits at the bottom right */
  .chapters {
    display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: column; grid-template-rows: repeat(7, auto);
    column-gap: 40px; overflow: visible; margin: 24px 0 0; padding: 0;
  }
  .chapters li { border-bottom: 1px solid var(--violet-line); }
  .chapters li:nth-child(1), .chapters li:nth-child(8) { border-top: 1px solid var(--violet-line); }
  .chapters button {
    width: 100%; height: 52px; grid-template-columns: 2.4em 1fr auto; grid-template-rows: 1fr; align-items: center;
    padding: 0 14px 0 10px; border: 0; border-radius: 0;
  }
  .chapters .ch-n, .chapters .credit .ch-n { display: block; grid-row: auto; font-size: 1.3rem; }
  .chapters .ch-t { align-self: center; -webkit-line-clamp: 1; font-size: 1.0625rem; }
  .chapters .ch-d { align-self: center; font-size: .9375rem; }
  .chapters .credit .ch-t { grid-column: 2; }
  .chapters .credit .ch-d { grid-column: 3; }
  .chapters button:hover { background: rgba(255, 255, 255, .05); }
  .chapters button[aria-current="true"] { background: rgba(182, 226, 26, .1); box-shadow: inset 4px 0 0 var(--acid); }
  .view-toggle { display: none; }
  .platforms { grid-template-columns: repeat(4, 1fr); max-width: none; }
  .reader { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: start; }
  .reader[data-view] .scan, .reader[data-view] .tx-wrap { display: block; }
  .scan { position: relative; }
  .scan-open { aspect-ratio: auto; height: min(76vh, 780px); background: #fff; }
  .tx { height: min(76vh, 780px); padding-right: 28px; font-size: 1.1875rem; overscroll-behavior-y: contain; }
  .lb-prev { left: 24px; top: 50%; bottom: auto; transform: translateY(-50%); }
  .lb-next { right: 24px; top: 50%; bottom: auto; transform: translateY(-50%); }
  .lb-close { top: 16px; right: 16px; }
  .lb { --lb-below: 0px; }
  .lb-fig { padding-left: 88px; padding-right: 88px; }
  .dots { grid-template-columns: repeat(auto-fill, 11px); grid-auto-rows: 11px; }
  .dots i { width: 11px; height: 11px; }
  .mini { grid-template-columns: minmax(180px, 280px) 1fr auto; align-items: center; gap: 20px; padding: 8px 24px calc(8px + env(safe-area-inset-bottom)); }
  .mini-scrub { grid-column: 2; grid-row: 1; }
  .mini-row { display: contents; }
  .mini-info { grid-column: 1; grid-row: 1; }
  .mini-ctl { grid-column: 3; grid-row: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scan-open img.turn-in { animation: none; }
}
