/* Scroll Stories engine styles. Layout variables flip between phone and desktop at 720px. */
:root {
  --paper: rgba(250, 246, 238, 0.965);   /* near-opaque: whatever sits behind the card must not show through it (Yates, 2026-09-06) */
  --ink: #2b2825;
  --cream: #f6efe3;
  --floor: 0px;          /* how far above the screen bottom a bottom-anchored figure stands */
  --fig-h: 74vh;         /* bottom-anchored figure height */
  --fig-x: 6vw;          /* inset from the side for bottom-left / bottom-right figures */
  --obj-h: 34vh;         /* center-anchored object height */
  --text-w: min(34vw, 500px);
}
/* "phone" layout = phones and portrait tablets (a 768px-wide iPad in portrait took the desktop layout and the docked card
   landed on the figures' legs on every study beat; found by qa/cover.py 2026-09-06). Keep the two lists below in step. */
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) {
  :root { --floor: 31vh; --fig-h: 42vh; --fig-x: 1vw; --obj-h: 22vh; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #14151a; }
body { font-family: Literata, Georgia, serif; color: var(--ink); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; touch-action: none; }
#runway { position: relative; width: 1px; pointer-events: none; }

#stage { position: fixed; inset: 0; overflow: hidden; background: #14151a; }
.scene { position: absolute; inset: 0; opacity: 0; will-change: opacity, transform; transform-origin: 50% 50%; }
.scene.off { display: none; }

.bg { position: absolute; inset: 0; will-change: transform; transform-origin: var(--focus, 50% 50%); }
.bg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 50%); }
.bg img.alt { opacity: 0; }

.layer { position: absolute; will-change: transform, opacity; transform-origin: 50% 100%; }
.layer img { display: block; height: 100%; width: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.layer.flip img { transform: scaleX(-1); }
.layer[data-anchor="bottom-left"]  { left: var(--fig-x); bottom: var(--floor); height: var(--fig-h); }
.layer[data-anchor="bottom-right"] { right: var(--fig-x); bottom: var(--floor); height: var(--fig-h); }
.layer[data-anchor="center"] { left: 50%; top: 46%; height: var(--obj-h); translate: -50% -50%; transform-origin: 50% 50%; }
.layer[data-anchor="panel"] { left: 50%; top: 44%; width: min(54vw, 52vh); height: auto; translate: -50% -50%; transform-origin: 50% 50%; z-index: 0;
  border-radius: 14px; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45); }
.layer[data-anchor="panel"] img { width: 100%; height: auto; }
.layer .glow { position: absolute; width: 22vmin; height: 22vmin; translate: -50% -50%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 196, 96, 0.55) 0%, rgba(255, 176, 64, 0.22) 35%, rgba(255, 160, 40, 0) 70%);
  opacity: 0; mix-blend-mode: screen; }
.layer .glow.on { animation: glow-pulse 4.5s ease-in-out infinite; }
@keyframes glow-pulse { 0%, 100% { opacity: 0.45; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.1); } }
.layer .frost { position: absolute; inset: -4%; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 255, 255, 0) 30%, rgba(240, 248, 255, 0.85) 75%, #fff 100%); }
.layer .display { position: absolute; display: grid; place-items: center; font: 600 1em "Courier New", monospace; letter-spacing: 0.04em;
  color: #9bffc0; background: #1f2a24; border-radius: 6% / 20%; font-size: 1em; transition: background 0.4s, color 0.4s, box-shadow 0.4s; }
.layer .display.idle { color: #3a5a48; text-shadow: none; }
.layer .display.on { text-shadow: 0 0 8px rgba(120, 255, 170, 0.9), 0 0 22px rgba(80, 220, 140, 0.6); box-shadow: 0 0 18px rgba(90, 240, 150, 0.35); }
.layer .display.flare { color: #eafff0; text-shadow: 0 0 14px #b8ffd2, 0 0 40px rgba(120, 255, 170, 0.9); box-shadow: 0 0 60px rgba(120, 255, 170, 0.9); background: #35604a; }
.layer .display.dark { background: #101512; color: transparent; text-shadow: none; box-shadow: none; }

/* the bg-level glow for backgrounds (a lit window) */
.bg .glow { position: absolute; width: 18vmin; height: 18vmin; translate: -50% -50%; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(255, 200, 110, 0.7) 0%, rgba(255, 180, 70, 0.25) 40%, rgba(255, 160, 40, 0) 70%); mix-blend-mode: screen; }
.bg .glow { transition: opacity 0.8s ease; }
.bg .glow.on { animation: glow-pulse 5s ease-in-out infinite; }
/* scene-wide overlays driven by background motions: frost (a white bloom from the edges) and tint (a color wash) */
.bg .veil-frost, .bg .veil-tint { position: absolute; inset: -2%; pointer-events: none; opacity: 0; }
.bg .veil-frost { background: radial-gradient(ellipse at 50% 55%, rgba(255, 255, 255, 0) 25%, rgba(236, 246, 255, 0.75) 70%, #f4fbff 100%); }
.bg .veil-tint { mix-blend-mode: multiply; }

/* text */
.text { position: absolute; display: grid; z-index: 5; pointer-events: none; }
.text > .beat { grid-area: 1 / 1; align-self: center; opacity: 0; will-change: opacity, transform; pointer-events: none; }   /* each card is its own height; the grid cell is as tall as the longest beat and must not stretch the short ones */
.text > .beat.active { pointer-events: auto; }
.beat { background: var(--paper); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 16px;
  padding: clamp(16px, 2.4vw, 28px) clamp(18px, 2.6vw, 32px); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22); }
.beat p { margin: 0; font-size: clamp(1.05rem, 0.9vw + 0.75rem, 1.4rem); line-height: 1.5; font-weight: 400; text-wrap: pretty; }
.beat.kind-verse p { font-style: italic; font-size: clamp(1.1rem, 1vw + 0.8rem, 1.5rem); }
.beat .cite { display: block; margin-top: 0.8em; font-size: 0.8em; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7; font-style: normal; }
.beat.effect-page { background: #f4ead6; box-shadow: inset 0 0 60px rgba(120, 90, 40, 0.15), 0 18px 50px rgba(0, 0, 0, 0.3); }
.beat.enter-flip, .beat.exit-flip { transform-origin: 0% 50%; backface-visibility: hidden; }   /* the page turns in from, and back over, its left edge */
@media (min-width: 721px) and (orientation: landscape), (min-width: 1025px) {
  .text { top: 50%; translate: 0 -50%; width: var(--text-w); left: 6vw; }
  .text[data-side="right"] { left: auto; right: 6vw; }
  .text[data-side="center"] { left: 50%; translate: -50% -50%; width: min(52vw, 640px); }
  /* bottom: figures on both sides and a floating panel in the middle; the card docks at the foot of the screen so nothing paints through it */
  .text[data-side="bottom"] { left: 50%; top: auto; bottom: 5vh; translate: -50% 0; width: min(52vw, 640px); align-items: end; }
}
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) {
  .text { left: 4vw; right: 4vw; bottom: max(3.5vh, env(safe-area-inset-bottom)); align-items: end; }
  .text > .beat { align-self: end; }
  /* floating panels sit up and to the right, above every head: the figures stand on a 31vh floor here and a centered panel
     covered the standing man's and the seated man's faces (tablet, 2026-09-06). !important beats the per-layer inline top */
  .layer[data-anchor="panel"] { left: 62%; top: 24% !important; width: min(46vw, 30vh); }
}

/* title */
/* no transform here on purpose: a transformed ancestor would trap the fixed-position scroll hint */
.text.has-title { top: auto; bottom: 12%; left: 5vw; right: 5vw; width: auto; max-width: 900px; margin: 0 auto; translate: none; text-align: center; align-items: start; }   /* desktop: the title sits on the lawn under the house */
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) { .text.has-title { top: 7%; bottom: auto; } }   /* phone: the sky is free above the house */
.beat.effect-title { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
.beat.effect-title h1 { margin: 0; font-family: Fraunces, Georgia, serif; font-style: italic; font-weight: 500; letter-spacing: -0.01em;
  font-size: clamp(2.3rem, 6.2vw, 4.8rem); line-height: 1.05; color: var(--cream); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.5); text-wrap: balance; }
.beat.effect-title .subtitle { display: block; margin-top: 1em; font-size: clamp(1rem, 1vw + 0.55rem, 1.3rem); letter-spacing: 0.06em;   /* shown exactly as written: the author's "A Present-day Parable" (2026-09-23) */ color: var(--cream); opacity: 0.85; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6); }

/* hint: sits at the foot of the screen, outside the card */
.beat.kind-hint { position: fixed; left: 50%; bottom: max(4vh, env(safe-area-inset-bottom)); translate: -50% 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  color: var(--cream); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7); text-align: center; padding: 0; width: 90vw; }
.beat.kind-hint p { font-size: clamp(0.9rem, 0.5vw + 0.7rem, 1.05rem); letter-spacing: 0.02em; }
.beat.kind-hint p::after { content: ""; display: block; width: 12px; height: 12px; margin: 14px auto 0; border-right: 2px solid var(--cream); border-bottom: 2px solid var(--cream); transform: rotate(45deg); animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 0%, 100% { translate: 0 0; opacity: 0.5; } 50% { translate: 0 8px; opacity: 1; } }

/* share card */
.beat.effect-share { text-align: center; }
.beat.effect-share p { font-family: Fraunces, Georgia, serif; font-style: italic; font-size: clamp(1.5rem, 2vw + 0.6rem, 2.3rem); }
.share-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.share-row a, .share-row button { font: inherit; font-size: 0.95rem; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  text-decoration: none; cursor: pointer; transition: background 0.2s, color 0.2s; }
.share-row a:hover, .share-row button:hover { background: var(--ink); color: var(--cream); }
.share-row [data-action="share"] { display: none; }
body.can-share .share-row [data-action="share"] { display: inline-block; }
body.can-share .share-row [data-action="sms"], body.can-share .share-row [data-action="email"] { display: none; }
/* end card, 2026-09-23: Share is the one filled button (Yates, 2026-09-23); where the browser has no share sheet the
   Share button is removed and Copy link takes the fill. "Encourage the author" sits under the row, outlined; under it a
   quiet line of ways onward (Read it again, All stories, and previous / next story once a neighbor exists) */
body.can-share .share-row [data-action="share"], body:not(.can-share) .share-row [data-action="copy"] { background: var(--ink); color: var(--cream); }
body.can-share .share-row [data-action="share"]:hover, body:not(.can-share) .share-row [data-action="copy"]:hover { background: transparent; color: var(--ink); }
.encourage-open { display: inline-block; margin-top: 18px; font: inherit; font-size: 1rem; padding: 11px 22px; border-radius: 999px; border: 1.5px solid var(--ink);
  background: transparent; color: var(--ink); cursor: pointer; transition: background 0.2s, color 0.2s; }
.encourage-open:hover { background: var(--ink); color: var(--cream); }
.onward { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-top: 16px; font-size: 0.85rem; }
.onward a, .share-again { color: var(--ink); opacity: 0.72; text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.onward a:hover, .share-again:hover { opacity: 1; }

/* the encouragement form: a native modal dialog on the story's paper and ink */
body.modal-open { touch-action: auto; }
#encourage { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 18px; background: #faf6ee; color: var(--ink);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5); overflow: auto; overscroll-behavior: contain; touch-action: auto; }
#encourage::backdrop { background: rgba(10, 10, 14, 0.62); backdrop-filter: blur(3px); }
.enc-in { position: relative; padding: clamp(22px, 4vw, 34px); }
.enc-close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--ink); opacity: 0.6; cursor: pointer; }
.enc-close:hover { opacity: 1; }
.enc-close:focus:not(:focus-visible) { outline: none; }   /* the dialog focuses its first control on open; no ring unless the reader is on a keyboard */
#encourage h2 { margin: 0 0 0.35em; font-family: Fraunces, Georgia, serif; font-style: italic; font-weight: 500; font-size: clamp(1.6rem, 2vw + 1rem, 2.1rem); }
.enc-lede { margin: 0 0 18px; opacity: 0.8; line-height: 1.5; }
.enc-chips { border: 0; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.enc-chips legend { width: 100%; margin-bottom: 8px; font-size: 0.9rem; opacity: 0.75; padding: 0; }
.enc-chips label { position: relative; cursor: pointer; }
.enc-chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.enc-chips span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1.5px solid rgba(43, 40, 37, 0.45); font-size: 0.95rem; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.enc-chips input:checked + span { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.enc-chips input:focus-visible + span { outline: 2px solid #8a6d3b; outline-offset: 2px; }
.enc-field { display: block; margin-bottom: 14px; font-size: 0.95rem; }
.enc-field span { opacity: 0.6; font-size: 0.85em; }
.enc-field textarea, .enc-field input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-size: 1rem; color: var(--ink);
  background: #fff; border: 1.5px solid rgba(43, 40, 37, 0.3); border-radius: 10px; resize: vertical; }
.enc-field textarea:focus, .enc-field input:focus { outline: none; border-color: var(--ink); }
.enc-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.enc-send, .enc-thanks button { margin-top: 4px; font: inherit; font-size: 1rem; padding: 12px 26px; border-radius: 999px; border: 0; background: var(--ink); color: var(--cream); cursor: pointer; }
.enc-send:disabled { opacity: 0.6; cursor: wait; }
.enc-status { min-height: 1.4em; margin: 12px 0 0; font-size: 0.9rem; }
.enc-thanks p { line-height: 1.5; margin: 0 0 18px; }

/* html layers (the contest poster) */
.layer.html-poster { left: 50%; top: 44%; translate: -50% -50%; width: min(48vw, 46vh); height: auto; transform-origin: 50% 50%; }
.layer.html-poster.small .poster .b { display: none; }   /* the wall copies carry the word only */
.poster { background: #efe3c8; color: #2b2825; padding: 6% 7%; border-radius: 3px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); text-align: center; font-family: Fraunces, Georgia, serif; }
.poster .k { font-size: clamp(1.4rem, 3.4vw, 3rem); font-weight: 700; letter-spacing: 0.1em; }
.poster .b { font-size: clamp(0.8rem, 1.4vw, 1.2rem); margin-top: 0.8em; line-height: 1.4; }

/* moving graphics (2026-09-06): CSS-animated layers that run on their own clock, shown and hidden by the beat windows */
/* particles: a full-frame field of dots; each <i> carries its own start point, size, delay and speed from build.py */
.layer.html-particles { left: 0; top: 0; width: 100%; height: 100%; translate: none; overflow: hidden; transform-origin: 50% 50%; }
.layer.html-particles i { position: absolute; left: var(--x); top: var(--y); width: calc(var(--s) * 7px); height: calc(var(--s) * 7px); border-radius: 50%; background: #fff; opacity: 0; will-change: transform, opacity; }
.layer.html-particles.snow i { top: -6%; width: calc(var(--s) * 9px); height: calc(var(--s) * 9px); box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); animation: snowfall calc(var(--t) * 11s) linear var(--d) infinite; }
@keyframes snowfall { 0% { transform: translate3d(0, 0, 0); opacity: 0; } 8% { opacity: 0.9; } 92% { opacity: 0.85; } 100% { transform: translate3d(7vw, 112vh, 0); opacity: 0; } }
.layer.html-particles.stars i { width: calc(var(--s) * 3px); height: calc(var(--s) * 3px); box-shadow: 0 0 4px rgba(255, 255, 255, 0.9); animation: starfield calc(var(--t) * 26s) linear var(--d) infinite; }
@keyframes starfield { 0% { transform: translate3d(0, 0, 0); opacity: 0; } 12% { opacity: 0.8; } 50% { opacity: 0.35; } 88% { opacity: 0.8; } 100% { transform: translate3d(-42vw, 4vh, 0); opacity: 0; } }
/* sparkle: glints that twinkle in place (sunlight on water) */
.layer.html-particles.sparkle i { width: calc(var(--s) * 5px); height: calc(var(--s) * 5px); background: #fff8dc; box-shadow: 0 0 8px 2px rgba(255, 248, 200, 0.9); animation: twinkle calc(var(--t) * 2.6s) ease-in-out var(--d) infinite; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(0.4); } 50% { opacity: 1; transform: scale(1.2); } }
/* ash: grey specks that rise slowly and sway (the smoke of the fear scene) */
.layer.html-particles.ash i { top: 104%; width: calc(var(--s) * 6px); height: calc(var(--s) * 6px); background: #9a9aa6; box-shadow: none; animation: ashrise calc(var(--t) * 16s) linear var(--d) infinite; }
@keyframes ashrise { 0% { transform: translate3d(0, 0, 0); opacity: 0; } 10% { opacity: 0.6; } 50% { transform: translate3d(3vw, -55vh, 0); } 90% { opacity: 0.5; } 100% { transform: translate3d(-2vw, -112vh, 0); opacity: 0; } }
/* scraps: torn bits of paper tumbling across the street on the wind */
.layer.html-particles.scraps i { left: 104%; width: calc(var(--s) * 16px); height: calc(var(--s) * 11px); border-radius: 1px; background: #e8dcc0; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); animation: scrapblow calc(var(--t) * 7s) linear var(--d) infinite; }
@keyframes scrapblow { 0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; } 8% { opacity: 0.95; } 50% { transform: translate3d(-55vw, -6vh, 0) rotate(300deg); } 92% { opacity: 0.9; } 100% { transform: translate3d(-115vw, 4vh, 0) rotate(640deg); opacity: 0; } }
/* motes: soft dust drifting in lamplight; gold: the same in morning light */
.layer.html-particles.motes i, .layer.html-particles.gold i { width: calc(var(--s) * 6px); height: calc(var(--s) * 6px); background: #ffe3a8; box-shadow: 0 0 6px 2px rgba(255, 220, 150, 0.55); filter: blur(0.5px); animation: motefloat calc(var(--t) * 14s) ease-in-out var(--d) infinite; }
.layer.html-particles.gold i { background: #fff1c8; box-shadow: 0 0 10px 3px rgba(255, 240, 200, 0.7); }
@keyframes motefloat { 0% { transform: translate3d(0, 0, 0); opacity: 0; } 20% { opacity: 0.75; } 50% { transform: translate3d(2.5vw, -5vh, 0); } 80% { opacity: 0.6; } 100% { transform: translate3d(-1.5vw, -11vh, 0); opacity: 0; } }
/* leaf: a page of the open Bible hinged on the gutter; `turn` swings it over. Sized from the painting: the right page is 42% of the image wide and 86% tall */
.layer.html-leaf { left: 50%; top: 50%; translate: 0 -50%; width: max(42vw, 42vh); height: max(86vw, 86vh); transform-origin: 0 50%; }
.layer.html-leaf .leaf { position: absolute; inset: 0; box-shadow: -6px 0 18px rgba(60, 40, 20, 0.25);
  background-image: var(--lines), var(--lines), linear-gradient(90deg, #ecdfc6 0%, #f8efdc 5%, #faf3e2 100%);   /* two text columns of faint marks on warm cream, like the painting */
  --lines: repeating-linear-gradient(180deg, transparent 0 0.9%, rgba(110, 100, 90, 0.16) 0.9% 1.25%, transparent 1.25% 2.1%);
  background-size: 33% 60%, 33% 60%, 100% 100%; background-position: 12% 50%, 88% 50%, 0 0; background-repeat: no-repeat; }
/* highlight: a band of warm light crossing lines of text; `sweep` grows it from its left edge. Placed in image fractions through max(100vw,100vh), the painting's on-screen size */
.layer.html-highlight { left: calc(50% + 0.04 * max(100vw, 100vh)); top: calc(50% + (var(--row) - 0.5) * max(100vw, 100vh)); width: calc(0.35 * max(100vw, 100vh)); height: calc(0.028 * max(100vw, 100vh));
  translate: 0 -50%; transform-origin: 0 50%; border-radius: 999px; background: rgba(255, 190, 90, 0.42); mix-blend-mode: multiply; box-shadow: 0 0 14px 6px rgba(255, 190, 90, 0.35); }
@media (prefers-reduced-motion: reduce) { .layer.html-particles i { animation: none; opacity: 0.6; } }

/* chrome */
#veil { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #000; z-index: 8; }
#progress { position: fixed; top: 0; left: 0; width: 100%; height: 3px; background: var(--cream); transform-origin: 0 50%; transform: scaleX(0); z-index: 20; opacity: 0.85; }
/* the two arrows: the down chevron in the bottom-right corner (the original), with an up chevron stacked above it;
   always over the story, on every device (Yates, 2026-09-06) */
.arrow { position: fixed; right: max(16px, env(safe-area-inset-right)); width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1.5px solid rgba(246, 239, 227, 0.75);
  background: rgba(20, 21, 26, 0.38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); cursor: pointer; z-index: 20; opacity: 0.9;
  transition: opacity 0.3s, background 0.2s, transform 0.2s; -webkit-tap-highlight-color: transparent; }
.arrow:hover { background: rgba(20, 21, 26, 0.6); }
.arrow:active { transform: scale(0.92); }
.arrow::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-right: 2px solid var(--cream); border-bottom: 2px solid var(--cream); }
#next { bottom: max(18px, env(safe-area-inset-bottom)); }
#prev { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 54px); }
#next::after { transform: translate(-50%, -70%) rotate(45deg); }
#prev::after { transform: translate(-50%, -30%) rotate(-135deg); }
body.at-start #prev, body.at-end #next { opacity: 0.35; pointer-events: none; }
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) {   /* phones: the text card owns the bottom, so the pair sits on the right edge above it */
  #next { bottom: auto; top: calc(44% + 4px); }
  #prev { bottom: auto; top: calc(44% - 48px); }
}
body:not(.ready) #stage { opacity: 0; }
body.ready #stage { opacity: 1; transition: opacity 0.6s ease; }

/* sound (2026-09-23): a Listen pill on the title card and a speaker button stacked above the arrows; both toggle the
   narrator and the music. Present only when the build found narration clips (body.has-audio). */
#sound { display: none; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 108px); }
body.has-audio #sound { display: block; }
#sound::after { content: none; }
#sound svg { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; translate: -50% -50%; fill: none; stroke: var(--cream); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sound .spk { fill: var(--cream); }
#sound .wave { display: none; }
body.listening #sound .wave { display: inline; }
body.listening #sound .mute { display: none; }
.beat.effect-title .choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 1.6em; }
.beat.effect-title .choices button { display: inline-flex; align-items: center; gap: 0.55em; padding: 0.7em 1.4em; border-radius: 999px; cursor: pointer;
  font: 500 clamp(0.95rem, 0.6vw + 0.7rem, 1.1rem) Literata, Georgia, serif; letter-spacing: 0.02em; color: var(--cream); background: rgba(20, 21, 26, 0.45);
  border: 1.5px solid rgba(246, 239, 227, 0.8); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: auto; -webkit-tap-highlight-color: transparent; }
.beat.effect-title .listen::before { content: ""; width: 0; height: 0; border-left: 0.62em solid var(--cream); border-top: 0.4em solid transparent; border-bottom: 0.4em solid transparent; }
.beat.effect-title .read::before { content: ""; width: 0.45em; height: 0.45em; margin: -0.25em 0.1em 0 0; border-right: 2px solid var(--cream); border-bottom: 2px solid var(--cream); transform: rotate(45deg); }
.beat.effect-title .choices button:hover { background: rgba(20, 21, 26, 0.65); }
body.listening .beat.effect-title .choices, body:not(.at-start) .beat.effect-title .choices { visibility: hidden; opacity: 0; }
.beat.effect-title .choices { transition: opacity 0.4s, visibility 0.4s; }
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) {   /* phones: stacked, same width */
  .beat.effect-title .choices { flex-direction: column; align-items: center; }
  .beat.effect-title .choices button { width: 12.5em; justify-content: center; }
}

/* how-to card (2026-09-23): while the reader sits on the hint card, a small looping demo shows the move that turns the
   page (a mouse wheel rolling on a desktop, a finger swiping up on a touch screen) and the down arrow pulses. It stays
   until the reader makes one of those moves. */
#teach { position: fixed; left: 50%; bottom: calc(max(4vh, env(safe-area-inset-bottom)) + 76px); translate: -50% 0; z-index: 15; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
body.on-hint #teach { opacity: 1; }
#teach .mouse { width: 30px; height: 46px; border: 2px solid var(--cream); border-radius: 15px; position: relative; filter: drop-shadow(0 1px 8px rgba(0,0,0,0.6)); }
#teach .mouse::after { content: ""; position: absolute; left: 50%; top: 8px; width: 4px; height: 9px; margin-left: -2px; border-radius: 2px; background: var(--cream); animation: wheel 1.6s ease-in-out infinite; }
@keyframes wheel { 0% { translate: 0 0; opacity: 1; } 70% { translate: 0 12px; opacity: 0; } 100% { translate: 0 0; opacity: 0; } }
#teach .swipe { display: none; width: 22px; height: 22px; border-radius: 50%; background: rgba(246, 239, 227, 0.85); box-shadow: 0 0 0 6px rgba(246, 239, 227, 0.25), 0 1px 10px rgba(0,0,0,0.5); animation: swipe 1.8s ease-in-out infinite; }
@keyframes swipe { 0% { translate: 0 40px; opacity: 0; } 20% { opacity: 1; } 75% { translate: 0 -30px; opacity: 1; } 100% { translate: 0 -30px; opacity: 0; } }
@media (pointer: coarse) { #teach .mouse { display: none; } #teach .swipe { display: block; } }
body.on-hint #next { animation: pulse 1.6s ease-out infinite; opacity: 1; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(246, 239, 227, 0.7); } 100% { box-shadow: 0 0 0 16px rgba(246, 239, 227, 0); } }
@media (max-width: 720px), (max-width: 1024px) and (orientation: portrait) {
  #sound { bottom: auto; top: calc(44% - 100px); }
}
