/* Pile ou Face — frontend-design variant.
   Idea: the page is one evening. Lantern faces are pools of lamplight that
   shrink chapter after chapter; Shadow faces are the night around them.
   Layout mirrors itself: Lantern text sits left, Shadow text sits right. */

:root {
  --parchment: #F2EBDC;
  --bone: #E6DCC6;
  --ink: #1C1712;
  --ink-soft: #4A3F33;
  --ember: #E8590C;
  --wax: #C9962B;
  --peat: #0B0A0C;
  --bog: #121614;
  --moon: #A9BACB;
  --bone-dim: #B9B0A0;
  --wisp: #A6E35C;
  --blood: #7A1E1A;
  --bronze-a: #8A5A2B;
  --bronze-b: #E0B067;

  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'Spline Sans Mono', ui-monospace, monospace;

  --gutter: clamp(16px, 4.5vw, 72px);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ui-fg: var(--bone);
  --ui-line: rgba(230, 220, 198, .28);
}

body[data-tone="light"] { --ui-fg: var(--ink); --ui-line: rgba(28, 23, 18, .25); }

html { background: var(--peat); }
body {
  background: var(--peat);
  color: var(--bone);
  font-family: var(--serif);
  font-size: clamp(16px, 1.15vw, 19px);
  line-height: 1.55;
  font-optical-sizing: auto;
}

::selection { background: var(--ember); color: var(--parchment); }

/* ---------- Entrance ---------- */
.intro {
  position: fixed; inset: 0; z-index: 90; background: #000;
  display: grid; place-items: center; cursor: pointer;
}
.intro-flame { width: 46px; height: 92px; position: relative; opacity: 0; }
.intro-flame::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(50% 62% at 50% 70%, #fff6d8 0 18%, #ffc35a 34%, var(--ember) 58%, transparent 72%);
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  filter: blur(1.5px);
  animation: flicker 1.6s infinite alternate ease-in-out;
}
.intro-flame::after {
  content: ''; position: absolute; left: 50%; bottom: -14px; width: 2px; height: 22px;
  background: #2b231c; transform: translateX(-50%);
}
.intro-date {
  position: absolute; left: 50%; top: calc(50% + 86px); transform: translateX(-50%);
  font-family: var(--mono); font-size: 13px; letter-spacing: .3em; color: var(--bone-dim); opacity: 0;
}
.intro-skip {
  position: absolute; right: var(--gutter); bottom: 28px; font-family: var(--mono); font-size: 12px;
  color: var(--bone-dim); padding: 8px 0; border-bottom: 1px solid transparent; transition: color .3s, border-color .3s;
}
.intro-skip:hover { color: var(--parchment); border-color: currentColor; }
@keyframes flicker {
  0% { transform: scale(1, 1) skewX(0deg); opacity: .95; }
  35% { transform: scale(.96, 1.04) skewX(-2deg); }
  70% { transform: scale(1.03, .97) skewX(1.5deg); opacity: 1; }
  100% { transform: scale(.98, 1.02) skewX(-1deg); opacity: .9; }
}

/* ---------- Fixed UI ---------- */
.ui { position: fixed; z-index: 60; color: var(--ui-fg); transition: color .6s var(--ease-out); }
.ui-top { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 22px var(--gutter); pointer-events: none; }
.ui-top > * { pointer-events: auto; }
.wordmark { font-size: 19px; font-style: italic; letter-spacing: -.01em; font-variation-settings: 'opsz' 24; }
.wordmark b { font-weight: 400; font-style: normal; }
.ui-actions { display: flex; gap: 10px; align-items: center; }
.pill {
  height: 38px; min-width: 38px; padding: 0 14px; border-radius: 19px; border: 1px solid var(--ui-line);
  font-family: var(--mono); font-size: 12px; display: inline-flex; align-items: center; gap: 8px;
  transition: border-color .3s, background-color .3s, color .3s, transform .3s var(--ease-out);
}
.pill:hover { border-color: currentColor; transform: translateY(-1px); }
.pill:active { transform: translateY(0) scale(.97); }
.pill .bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.pill .bars i { width: 2px; height: 4px; background: currentColor; transition: height .3s; }
.pill[aria-pressed="true"] .bars i { animation: eq 1s infinite ease-in-out alternate; }
.pill[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -.3s; }
.pill[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { from { height: 3px; } to { height: 12px; } }

.clock {
  left: var(--gutter); bottom: 22px; font-family: var(--mono); font-size: 12px; display: flex; gap: 14px; align-items: center;
}
.clock-time { font-size: 15px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.clock-face { opacity: .7; }

.rim { right: calc(var(--gutter) * .5); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 0; }
.rim::before { content: ''; position: absolute; left: 50%; top: 8px; bottom: 8px; width: 1px; background: var(--ui-line); }
.rim button { position: relative; width: 28px; height: 34px; display: grid; place-items: center; }
.rim button i {
  width: 9px; height: 9px; border-radius: 50%; border: 1px solid currentColor; background: var(--peat);
  transition: transform .35s var(--ease-out), background-color .3s;
}
body[data-tone="light"] .rim button i { background: var(--parchment); }
.rim button.on i { background: linear-gradient(135deg, var(--bronze-b), var(--bronze-a)); border-color: var(--bronze-a); }
.rim button.now i { transform: scale(1.45); }
.rim button:hover i { transform: scale(1.6); }
.rim button span {
  position: absolute; right: 34px; white-space: nowrap; font-family: var(--mono); font-size: 11px;
  opacity: 0; transform: translateX(6px); transition: opacity .25s, transform .3s var(--ease-out); pointer-events: none;
}
.rim button:hover span, .rim button:focus-visible span { opacity: 1; transform: none; }

.peek-btn {
  right: var(--gutter); bottom: 18px; display: flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12px;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.peek-coin {
  width: 44px; height: 44px; border-radius: 50%; position: relative; transform-style: preserve-3d;
  transition: transform .6s var(--ease-out);
  background: radial-gradient(circle at 35% 30%, var(--bronze-b), var(--bronze-a) 70%);
  box-shadow: inset 0 0 0 3px rgba(255, 240, 210, .25), inset 0 0 0 4px rgba(60, 35, 10, .5), 0 4px 14px rgba(0,0,0,.35);
}
.peek-coin::after {
  content: ''; position: absolute; inset: 12px; border-radius: 50%;
  background: radial-gradient(50% 64% at 50% 70%, #fff3cf 0 20%, var(--ember) 60%, transparent 72%);
}
.peek-btn:hover .peek-coin { transform: rotateY(28deg) scale(1.06); }
.peek-btn.held .peek-coin { transform: rotateY(180deg); }

/* ---------- Cursor ---------- */
.cursor { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; display: none; }
@media (pointer: fine) {
  html.has-cursor, html.has-cursor * { cursor: none !important; }
  .cursor { display: block; }
}
.cursor-dot {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--ember); box-shadow: 0 0 12px 3px rgba(232, 89, 12, .45);
  transition: width .35s var(--ease-out), height .35s var(--ease-out), margin .35s var(--ease-out), background-color .4s, box-shadow .4s;
}
body[data-tone="dark"] .cursor-dot {
  background: rgba(214, 240, 170, .9); box-shadow: 0 0 18px 6px rgba(166, 227, 92, .35);
}
.cursor-label {
  position: absolute; left: 16px; top: 14px; font-family: var(--mono); font-size: 11px; white-space: nowrap;
  color: var(--ui-fg); opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .3s var(--ease-out);
}
.cursor.big .cursor-dot { width: 46px; height: 46px; margin: -23px 0 0 -23px; background: rgba(232, 89, 12, .18); box-shadow: inset 0 0 0 1px var(--ember); }
body[data-tone="dark"] .cursor.big .cursor-dot { background: rgba(166, 227, 92, .12); box-shadow: inset 0 0 0 1px rgba(214, 240, 170, .8); }
.cursor.big .cursor-label { opacity: 1; transform: none; left: 30px; top: 18px; }
.cursor-trail { position: fixed; inset: 0; z-index: 99; pointer-events: none; }

/* ---------- Hero ---------- */
.hero { position: relative; height: 320vh; }
.hero-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; background: radial-gradient(120% 80% at 50% 40%, #1a1410 0%, var(--peat) 65%); }
.gl { position: absolute; inset: 0; width: 100%; height: 100%; }
.coin-slot { position: absolute; inset: 0; pointer-events: none; }
.hero-ring { position: absolute; left: 50%; top: 50%; width: min(86vmin, 820px); aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none; }
.hero-ring text { font-family: var(--serif); font-size: 38px; letter-spacing: .38em; fill: var(--bone); font-variation-settings: 'opsz' 60; }
.hero-copy { position: absolute; left: var(--gutter); bottom: clamp(64px, 11vh, 120px); max-width: 30rem; }
.hero-kicker { font-family: var(--mono); font-size: 12px; color: var(--bone-dim); margin-bottom: 18px; }
.hero h1 { position: absolute; z-index: 1; right: var(--gutter); top: 50%; transform: translateY(-50%); text-align: right; pointer-events: none; }
.hero h1 span { display: block; font-weight: 300; font-size: clamp(56px, 8vw, 150px); line-height: .82; letter-spacing: -.045em; font-variation-settings: 'opsz' 72; }
.hero h1 span:nth-child(2) { font-style: italic; font-size: clamp(24px, 3.2vw, 60px); letter-spacing: -.01em; padding-right: .3em; color: var(--wax); line-height: 1.1; }
.hero-sub { font-size: clamp(22px, 2vw, 30px); font-style: italic; line-height: 1.2; margin-bottom: 14px; font-variation-settings: 'opsz' 36; }
.hero-lede { color: var(--bone-dim); max-width: 34ch; }
.hero-scroll { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); font-family: var(--mono); font-size: 11px; color: var(--bone-dim); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero-scroll i { width: 1px; height: 38px; background: linear-gradient(var(--bone-dim), transparent); animation: drip 2.2s infinite var(--ease-out); transform-origin: top; }
@keyframes drip { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.hero-paper { position: absolute; inset: 0; background: var(--parchment); opacity: 0; pointer-events: none; }

/* ---------- Chapters ---------- */
.ch { position: relative; }
.ch-stage { position: relative; height: 100vh; height: 100svh; overflow: hidden; background: var(--peat); isolation: isolate; }
.face { position: absolute; inset: 0; isolation: isolate; z-index: 1; }
.face-b { z-index: 2; }
.face-a { color: var(--ink); --paper: var(--parchment); }
.face-a .light {
  position: absolute; inset: -2px;
  background:
    radial-gradient(var(--pool-shape, circle) var(--pool-r, 200vmax) at var(--pool-x, 40%) var(--pool-y, 50%),
      var(--paper) 0 62%, color-mix(in srgb, var(--paper) 55%, var(--peat)) 82%, var(--peat) 100%);
}
.face-a .grain, .face-b .grain { display: none; }
.grain-fixed {
  position: fixed; inset: 0; z-index: 58; pointer-events: none; opacity: .35;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35  0 0 0 0 .28  0 0 0 0 .2  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.face-b { color: var(--bone); background: var(--peat); }
/* CSS loops only run in the chapter on screen */
.ch:not(.live) *, .ch:not(.live) *::before, .ch:not(.live) *::after { animation-play-state: paused !important; }

.face-grid {
  position: relative; height: 100%; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px;
  /* bottom padding keeps the copy clear of the fixed clock (bottom-left) */
  padding: clamp(84px, 12vh, 120px) calc(var(--gutter) + 36px) clamp(88px, 12vh, 110px) var(--gutter); align-items: center;
}
.copy { position: relative; z-index: 3; grid-row: 1; }
.face-a .copy { grid-column: 1 / span 5; }
.face-b .copy { grid-column: 8 / span 5; text-align: left; }
.art { position: relative; z-index: 1; grid-row: 1; height: 100%; min-height: 0; display: grid; place-items: center; }
.face-a .art { grid-column: 6 / span 7; }
.face-b .art { grid-column: 1 / span 7; }
.art svg { width: 100%; height: 100%; max-height: 74vh; overflow: visible; }

.kicker { font-family: var(--mono); font-size: 12px; display: flex; gap: 14px; align-items: baseline; margin-bottom: 18px; opacity: .72; }
.face-b .kicker { color: var(--moon); opacity: 1; }
.ch-title {
  font-weight: 340; font-size: clamp(32px, min(4.6vw, 8vh), 80px); line-height: .98; letter-spacing: -.028em;
  font-variation-settings: 'opsz' 72; margin-bottom: clamp(16px, 2.6vh, 28px); text-wrap: balance;
}
.face-b .ch-title { font-weight: 300; font-style: italic; }
.story { max-width: 40ch; line-height: 1.6; margin-bottom: clamp(18px, 3.4vh, 40px); }
.face-a .story { color: var(--ink-soft); }
.face-b .story { color: var(--bone-dim); }
/* short windows: tighten the reading column so it fits above the clock */
@media (min-width: 768px) and (max-height: 760px) {
  .story { font-size: 15px; line-height: 1.5; max-width: 60ch; }
  .kicker { margin-bottom: 12px; }
  .fact-text { font-size: .9em; max-width: 60ch; }
  .face-grid { padding-top: 76px; }
  .face-a .copy { grid-column: 1 / span 6; }
  .face-a .art { grid-column: 7 / span 6; }
  .face-b .copy { grid-column: 7 / span 6; }
  .face-b .art { grid-column: 1 / span 6; }
  .fact-text { max-width: 68ch; }
  /* A7: the dusk window frame is the tallest head; slim it on short windows */
  .face-a.dusk .window-frame { padding: 20px 26px; margin-bottom: 14px !important; }
  .face-a.dusk .window-frame .ch-title { font-size: clamp(28px, min(3.6vw, 6.4vh), 62px); margin-bottom: 12px; }
}
.split-line { overflow: clip; padding-bottom: .06em; margin-bottom: -.06em; }

/* facts share one grid cell, so the block is as tall as its longest fact
   and the dashes below never sit on top of a long one */
.facts { position: relative; display: grid; }
.fact { grid-area: 1 / 1; }
.fact-big {
  font-size: clamp(28px, min(3.4vw, 6.2vh), 60px); line-height: 1; letter-spacing: -.03em; font-weight: 400;
  font-variation-settings: 'opsz' 72; margin-bottom: 12px; font-variant-numeric: lining-nums;
}
.face-a .fact-big { color: var(--ink); }
.face-b .fact-big { color: var(--parchment); }
.fact-text { max-width: 44ch; font-size: .93em; line-height: 1.5; }
.face-a .fact-text { color: var(--ink-soft); }
.face-b .fact-text { color: var(--bone-dim); }
.src {
  margin-top: 12px; font-family: var(--mono); font-size: 11px; display: inline-flex; align-items: center; gap: 8px; opacity: .75;
  padding: 3px 0; border-bottom: 1px dashed transparent; transition: opacity .25s, border-color .25s;
}
.src::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--bronze-b), var(--bronze-a)); }
.src:hover { opacity: 1; border-color: currentColor; }
.fact-dots { display: flex; gap: 6px; margin-top: 18px; }
.fact-dots i { width: 18px; height: 2px; background: currentColor; opacity: .2; transition: opacity .3s, width .4s var(--ease-out); }
.fact-dots i.on { opacity: .9; width: 30px; }

/* time stamp on each chapter */
.stamp { position: absolute; z-index: 4; top: clamp(84px, 12vh, 120px); font-family: var(--mono); font-size: 12px; opacity: .6; }
.face-a .stamp { right: calc(var(--gutter) + 36px); }
.face-b .stamp { left: var(--gutter); color: var(--moon); }

/* transitions helpers */
.veil { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.spark {
  position: absolute; z-index: 6; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff7da 0 25%, #ffc35a 45%, rgba(232, 89, 12, 0) 70%); opacity: 0;
}
.door {
  position: absolute; inset: 0; z-index: 7; transform-origin: 0% 50%; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.0) 0 22%, rgba(0,0,0,.35) 22% 22.4%),
    linear-gradient(90deg, #18120d, #241a12 40%, #140f0b);
  box-shadow: inset -40px 0 80px rgba(0,0,0,.6);
}
.door::after { content: ''; position: absolute; right: 7%; top: 52%; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--bronze-b), var(--bronze-a)); }

/* ---------- Illustrations ---------- */
.ink-line { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.ink-fine { fill: none; stroke: var(--ink); stroke-width: .8; opacity: .55; }
.moon-line { fill: none; stroke: var(--moon); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.moon-fine { fill: none; stroke: var(--moon); stroke-width: .7; opacity: .45; }
.flame { animation: flicker 1.3s infinite alternate ease-in-out; transform-box: fill-box; transform-origin: 50% 100%; }
.flame:nth-of-type(2n) { animation-duration: 1.7s; animation-delay: -.4s; }
.rise { animation: rise 3.2s infinite linear; }
@keyframes rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-120px) translateX(10px); opacity: 0; } }
.mist { animation: mist 14s infinite alternate ease-in-out; }
.mist:nth-of-type(2n) { animation-duration: 19s; animation-direction: alternate-reverse; }
@keyframes mist { from { transform: translateX(-40px); } to { transform: translateX(50px); } }
.glow-flicker { animation: glow 2.4s infinite alternate ease-in-out; }
/* sparks rising off Jack's ember */
.ember-spark { transform-box: fill-box; transform-origin: center; animation: spark 2.2s infinite ease-out; opacity: 0; }
@keyframes spark { 0% { transform: translate(0, 0) scale(1); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(10px, -110px) scale(.3); opacity: 0; } }
.ember-spark:nth-of-type(even) { animation-name: spark-l; }
@keyframes spark-l { 0% { transform: translate(0, 0) scale(1); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(-14px, -90px) scale(.3); opacity: 0; } }
html.rm .ember-spark { animation: none; opacity: .8; }
@keyframes glow { 0% { opacity: .78; } 40% { opacity: 1; } 55% { opacity: .85; } 100% { opacity: .95; } }

/* A1 wheel labels */
.wheel text { font-family: var(--mono); font-size: 11px; fill: var(--ink); letter-spacing: .12em; }
.wheel .now { fill: var(--ember); }

/* Coligny tablet */
.shard { fill: url(#bronze); stroke: #3b2510; stroke-width: .6; }
.tablet-text { font-family: var(--mono); font-size: 15px; letter-spacing: .32em; fill: #2a1a0a; }

/* B3 dial */
.dial text { font-family: var(--mono); font-size: 10px; fill: var(--moon); letter-spacing: .08em; }

/* B2 initial */
.initial { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 300px; fill: var(--parchment); font-variation-settings: 'opsz' 72; }

/* A3 compression word */
.compress { font-size: clamp(30px, 4vw, 72px); font-weight: 300; letter-spacing: -.02em; display: flex; white-space: nowrap; font-variation-settings: 'opsz' 72; }
.compress span { display: inline-block; overflow: hidden; }

/* A4 doors */
.doors { display: flex; gap: clamp(10px, 1.6vw, 22px); align-items: flex-end; perspective: 700px; }
.doorway { position: relative; width: clamp(54px, 5.6vw, 92px); aspect-ratio: 1 / 2; border: 1.4px solid var(--ink); border-bottom: 0; border-radius: 999px 999px 0 0; background: #1e1711; overflow: hidden; cursor: pointer; }
.doorway::before { content: ''; position: absolute; inset: 18% 20% 0; background: radial-gradient(60% 70% at 50% 100%, #ffd27a, var(--ember) 60%, transparent 100%); opacity: .9; }
.doorway .leaf { position: absolute; inset: 0; background: linear-gradient(90deg, #6b4a2b, #8a6038 60%, #5c3e22); transform-origin: 0 50%; transition: transform .9s var(--ease-out); border-radius: inherit; }
.doorway .leaf::after { content: ''; position: absolute; right: 16%; top: 55%; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
.doorway:hover .leaf, .doorway:focus-visible .leaf, .doorway.open .leaf { transform: rotateY(-62deg); }
/* soul cake: a small spiced cake seen from three-quarters. Its faces are
   painted in cake.js; the body is squashed for the viewing angle and the top
   turns inside it, like a cake on a plate. The light (.sc-light) does not
   turn, so the shine and the shade stay where the window is. */
.soul-cake { width: clamp(160px, 17vw, 250px); aspect-ratio: 1 / .8; position: relative; }
.sc-shadow { position: absolute; left: 3%; right: -2%; bottom: 1%; height: 34%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(52, 28, 10, .5), rgba(52, 28, 10, .22) 55%, rgba(52, 28, 10, 0)); }
.sc-crumb { position: absolute; border-radius: 40% 60% 50% 45%; background: #b5763a; box-shadow: inset -1px -1px 0 rgba(80, 40, 12, .45); }
.sc-body { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 1; transform: scaleY(.6); transform-origin: 50% 0; }
.sc-side, .sc-top, .sc-light { position: absolute; background-size: 100% 100%; background-repeat: no-repeat; }
.sc-side { inset: 13% 0 -13% 0; filter: none; }
.sc-top { inset: 0; }
/* fixed light: window light from the upper left, shade lower right, a
   darker rim where the crust rolls away */
.sc-light { inset: 4%; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(48% 38% at 34% 30%, rgba(255, 244, 220, .42), rgba(255, 244, 220, 0) 70%),
    radial-gradient(70% 60% at 70% 76%, rgba(70, 34, 10, .3), rgba(70, 34, 10, 0) 70%),
    radial-gradient(circle, rgba(70, 34, 10, 0) 70%, rgba(70, 34, 10, .22) 96%, rgba(70, 34, 10, 0) 100%); }

/* B4 reign steps */
.reigns { display: flex; gap: 10px; font-family: var(--mono); font-size: 11px; margin-top: 18px; }
.reigns span { padding: 6px 10px; border: 1px solid rgba(169, 186, 203, .3); border-radius: 14px; color: var(--moon); transition: background-color .4s, color .4s, border-color .4s; }
.reigns span.on { background: var(--moon); color: var(--peat); border-color: var(--moon); }
.reigns span.off { text-decoration: line-through; opacity: .5; }

/* B5 rites */
.rites { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(14px, 2vw, 28px); width: 100%; max-width: 640px; }
.rite { position: relative; border: 1px solid rgba(169, 186, 203, .22); border-radius: 4px 4px 120px 120px / 4px 4px 60px 60px; padding: 18px 18px 26px; min-height: 260px; display: flex; flex-direction: column; justify-content: space-between; transition: border-color .3s; }
.rite:hover { border-color: rgba(169, 186, 203, .6); }
.rite h4 { font-weight: 400; font-style: italic; font-size: 22px; color: var(--parchment); }
.rite p { font-family: var(--mono); font-size: 11px; color: var(--bone-dim); min-height: 3em; }
.rite button {
  align-self: flex-start; font-family: var(--mono); font-size: 12px; padding: 9px 14px; border-radius: 18px; border: 1px solid var(--moon); color: var(--moon);
  transition: background-color .3s, color .3s, transform .3s var(--ease-out);
}
.rite button:hover { background: var(--moon); color: var(--peat); transform: translateY(-2px); }
.rite svg { width: 100%; height: 120px; }
.wisps { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }

/* A6 */
.coast-label { font-family: var(--mono); font-size: 13px; fill: var(--ink); opacity: .7; letter-spacing: .04em; }
.veg-name { display: grid; font-style: italic; font-size: clamp(22px, 2.2vw, 34px); line-height: 1; color: var(--ink); }
.veg-name span { grid-area: 1 / 1; text-align: center; }
.veg-name [data-vname="pumpkin"] { opacity: 0; color: #C2510C; }

/* B6 */
.forgery { position: relative; text-align: center; }
.forgery .title { font-size: clamp(34px, 4.2vw, 74px); font-weight: 300; font-style: italic; line-height: 1.02; color: var(--parchment); letter-spacing: -.02em; }
.forgery .stampmark {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-11deg) scale(2.2); opacity: 0;
  border: 3px solid var(--blood); color: #c5443a; padding: 8px 22px; font-family: var(--mono); font-size: clamp(18px, 2vw, 30px); letter-spacing: .3em;
  mix-blend-mode: screen;
}
.strata { width: 100%; max-width: 560px; margin-top: 36px; border-top: 1px solid var(--moon); }
.stratum { display: flex; justify-content: space-between; gap: 16px; padding: 14px 4px; font-family: var(--mono); font-size: 11px; color: var(--bone-dim); border-bottom: 1px solid rgba(169,186,203,.15); transition: color .4s, background-color .4s; }
.stratum.lit { color: var(--parchment); background: rgba(169, 186, 203, .08); }

/* A7 window */
.window-frame {
  position: relative; width: min(100%, 520px); padding: clamp(24px, 3vw, 44px); color: var(--ink);
  background: radial-gradient(120% 90% at 50% 40%, #fbe7bd, #f2c77b 70%, #d99a4c);
  box-shadow: 0 0 0 10px #1b140f, 0 0 0 11px rgba(230, 220, 198, .2), 0 0 140px 30px rgba(242, 170, 80, .28);
}
.window-frame::before, .window-frame::after { content: ''; position: absolute; background: #1b140f; }
.window-frame::before { left: 50%; top: 0; bottom: 0; width: 8px; transform: translateX(-50%); opacity: .0; }
.news { font-size: .95em; line-height: 1.45; columns: 1; }
.news-head { font-family: var(--serif); font-weight: 700; font-size: 13px; letter-spacing: .14em; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 6px 0; margin-bottom: 14px; text-align: center; }
.news mark { background: none; color: inherit; background-image: linear-gradient(var(--ember), var(--ember)); background-size: 0% 100%; background-repeat: no-repeat; transition: background-size 1s var(--ease-out); padding: 0 3px; }
.news mark.on { background-size: 100% 100%; color: var(--parchment); }

/* B7 */
.b7-zero { font-size: 150px; font-weight: 200; fill: var(--parchment); font-family: inherit; letter-spacing: -.04em; }

/* ---------- Myths ---------- */
.myths { position: relative; background: var(--peat); padding: clamp(110px, 18vh, 200px) var(--gutter) clamp(90px, 14vh, 160px); }
.myths-head { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; margin-bottom: clamp(48px, 8vh, 96px); }
.myths-head h2 { grid-column: 1 / span 7; font-weight: 300; font-size: clamp(40px, 5.4vw, 96px); line-height: .96; letter-spacing: -.035em; font-variation-settings: 'opsz' 72; }
.myths-head p { grid-column: 9 / span 4; align-self: end; color: var(--bone-dim); max-width: 34ch; }
.myth { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; padding: 26px 0; border-top: 1px solid rgba(230, 220, 198, .12); align-items: baseline; }
.myth-claim { grid-column: 1 / span 8; position: relative; font-size: clamp(22px, 2.3vw, 38px); line-height: 1.15; letter-spacing: -.015em; color: var(--bone); width: fit-content; }
.myth-claim::after { content: ''; position: absolute; left: -4px; right: -4px; top: 55%; height: 2px; background: var(--ember); transform: scaleX(var(--strike, 0)); transform-origin: left; }
.myth-why { grid-column: 10 / span 3; font-family: var(--mono); font-size: 12px; color: var(--bone-dim); }

/* ---------- Coda ---------- */
.coda { position: relative; height: 210vh; }
.coda-stage { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; background: radial-gradient(90% 70% at 50% 100%, #15110d, var(--peat) 70%); display: grid; place-items: center; }
.coda-copy { position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(56px, 10vh, 110px); display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; align-items: end; }
.coda-copy h2 { grid-column: 1 / span 5; font-weight: 300; font-style: italic; font-size: clamp(30px, 3.6vw, 60px); line-height: 1; letter-spacing: -.02em; }
.coda-end { grid-column: 8 / span 5; }
.coda-copy p { font-size: clamp(18px, 1.5vw, 24px); line-height: 1.45; color: var(--bone); }
/* the doorstep illustration sits above the closing words */
.coda-art { width: min(52vw, 620px); height: min(58vh, 560px); margin-bottom: clamp(150px, 22vh, 230px); }
.coda-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.coda-kicker { position: absolute; top: clamp(84px, 12vh, 120px); left: var(--gutter); font-family: var(--mono); font-size: 12px; color: var(--moon); }
.again { margin-top: 26px; font-family: var(--mono); font-size: 12px; padding: 11px 18px; border-radius: 20px; border: 1px solid var(--wax); color: var(--wax); transition: background-color .3s, color .3s, transform .3s var(--ease-out); }
.again:hover { background: var(--wax); color: var(--peat); transform: translateY(-2px); }

/* ---------- Footer ---------- */
.foot { background: var(--peat); border-top: 1px solid rgba(230, 220, 198, .1); padding: 64px var(--gutter) 90px; display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 24px; row-gap: 32px; font-size: 14px; color: var(--bone-dim); }
.foot > p { grid-column: 1 / span 4; max-width: 36ch; }
.foot details { grid-column: 6 / span 7; }
.foot summary { cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--bone); list-style: none; display: inline-flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid transparent; transition: border-color .3s; }
.foot summary:hover { border-color: currentColor; }
.foot summary::-webkit-details-marker { display: none; }
.foot summary::before { content: '+'; width: 1em; }
.foot details[open] summary::before { content: '–'; }
.src-groups { margin-top: 22px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.src-groups h5 { font-weight: 400; font-style: italic; color: var(--bone); font-size: 15px; margin-bottom: 8px; }
.src-groups a { display: block; font-size: 13px; padding: 3px 0; color: var(--bone-dim); transition: color .2s; }
.src-groups a:hover { color: var(--wax); text-decoration: underline; text-underline-offset: 3px; }
.foot .back { grid-column: 1 / span 4; font-family: var(--mono); font-size: 12px; color: var(--bone); }
.foot .back:hover { color: var(--wax); }

/* lang swap */
#app { transition: opacity .25s, transform .4s var(--ease-out); transform-origin: 50% 40vh; }
#app.swapping { opacity: 0; transform: perspective(900px) rotateX(8deg); }

/* peek: show the other face while held */
.ch.peek-b .face-b { clip-path: none !important; -webkit-mask: none !important; mask: none !important; opacity: 1 !important; visibility: visible !important; }
.ch.peek-b .face-b .copy > *, .ch.peek-b .face-b .fact:first-child, .ch.peek-b .face-b .art > * { opacity: 1 !important; transform: none !important; }
.ch.peek-a .face-b, .ch.peek-a .door, .ch.peek-a .veil { opacity: 0 !important; transition: opacity .3s; }

.ch.peek-a .face-a .copy { opacity: 1 !important; visibility: visible !important; transform: none !important; }
.ch.peek-b .veil, .ch.peek-b .door { opacity: 0 !important; }
.ch.peek-b .face-b .split-line { transform: none !important; }

/* A7: the Lantern is only a lit window now */
.face-a.dusk { color: var(--bone); }
.face-a.dusk .window-frame .story { color: var(--ink-soft); }
.face-a.dusk .fact-big { color: var(--parchment); }
.face-a.dusk .fact-text { color: var(--bone-dim); }
.face-a.dusk .window-frame { width: 100%; max-width: 560px; }
.face-a.dusk .window-frame .ch-title { font-size: clamp(32px, 3.6vw, 62px); }
.face-a.dusk .window-frame .story { margin-bottom: 0; }

/* ---------- Reduced motion / static layout ---------- */
html.rm .hero { height: auto; }
html.rm .hero-stage { position: relative; }
html.rm .ch-stage { height: auto; overflow: visible; }
html.rm .face { position: relative; inset: auto; min-height: 100vh; }
html.rm .face-b { clip-path: none; }
html.rm .facts { min-height: 0; display: grid; gap: 32px; }
html.rm .fact { grid-area: auto; }
html.rm .fact-dots, html.rm .door, html.rm .veil, html.rm .spark { display: none; }
html.rm .face-grid { height: auto; min-height: 100vh; }
html.rm .coda { height: auto; }
html.rm .coda-stage { position: relative; }
html.rm .coda [data-cwin], html.rm .coda [data-cdoorlight], html.rm .coda [data-cspill] { opacity: 1; }
html.rm .myth-claim { --strike: 1; }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  /* the stage is as tall as the largest viewport (browser bars hidden), so no
     band of page shows below it; the layout itself stays in the smallest one */
  .ch-stage { height: 100vh; height: 100lvh; }
  /* the art takes whatever height the copy leaves; the copy stays above the clock */
  .face-grid { height: 100vh; height: 100svh; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: 84px 16px 60px; row-gap: 12px; align-items: stretch; }
  .face-a .copy, .face-b .copy { grid-column: 1; grid-row: 2; }
  .face-a .art, .face-b .art { grid-column: 1; grid-row: 1; }
  /* a definite cell, so the drawing scales down to fit instead of being cut */
  .art { overflow: hidden; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
  .art > * { min-height: 0; max-height: 100%; }
  .art svg { height: 100%; max-height: 100%; }
  .ch-title { font-size: clamp(30px, 8.6vw, 44px); margin-bottom: 14px; }
  /* the story and the facts take turns in one cell, so the copy never grows
     past the clock and the dashes stay under the text */
  .copy { display: grid; grid-template-columns: minmax(0, 1fr); align-content: end; }
  .copy > .kicker { grid-row: 1; margin-bottom: 12px; }
  .copy > .ch-title { grid-row: 2; }
  .copy > .window-frame { grid-row: 1 / span 2; margin-bottom: 14px; padding: 18px 20px; }
  .copy > .window-frame .ch-title { margin-bottom: 0; }
  .copy > .story, .copy > .facts { grid-row: 3; grid-column: 1; align-self: start; }
  .copy > .fact-dots { grid-row: 4; }
  .story { font-size: 15px; line-height: 1.5; margin-bottom: 0; }
  .face-a.dusk .copy > .story { color: var(--bone-dim); }
  .ch.peek-b .face-b .copy > .facts { opacity: 0 !important; }
  html.rm .copy > .story, html.rm .copy > .facts { grid-row: auto; }
  .fact-big { font-size: 30px; }
  .fact-text { font-size: 14px; }
  .rim { display: none; }
  .stamp { display: none; }
  /* hero: title on one line, the coin in the space left, the copy at the foot */
  .hero-stage { height: 100vh; height: 100lvh; display: flex; flex-direction: column; padding: 76px 16px calc(100lvh - 100svh + 62px); }
  .hero h1 { position: relative; inset: auto; transform: none; text-align: left; display: flex; align-items: baseline; gap: .16em; white-space: nowrap; }
  .hero h1 span, .hero h1 span:nth-child(2) { display: inline-block; font-size: min(17vw, 76px); line-height: 1; padding: 0; }
  .hero h1 span:nth-child(2) { font-size: min(8vw, 36px); }
  .coin-slot { position: relative; inset: auto; flex: 1; min-height: 0; margin: 8px 0; container-type: size; }
  .hero-ring { width: min(92cqw, 92cqh); }
  .hero-scroll { display: none; }
  .hero-copy { position: relative; left: auto; bottom: auto; max-width: none; }
  .hero-kicker { margin-bottom: 10px; }
  .clock-face { display: none; }
  .peek-btn span { display: none; }
  .myths-head h2, .myths-head p, .myth-claim, .myth-why { grid-column: 1 / -1; }
  .myth-why { margin-top: 8px; }
  .coda-copy h2, .coda-copy p { grid-column: 1 / -1; }
  .coda-copy p { margin-top: 14px; }
  .coda-end { grid-column: 1 / -1; }
  .coda-art { width: 92vw; height: 36vh; align-self: start; margin: 13vh 0 0; }
  .coda-stage { place-items: start center; }
  .foot > p, .foot details, .foot .back { grid-column: 1 / -1; }
  .src-groups { grid-template-columns: 1fr; }
  /* B5: one full-width card per row: drawing on the left, title and button
     on the first line, the result under them */
  .rites { grid-template-columns: minmax(0, 1fr); gap: 10px; max-width: none; }
  .rite {
    display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 6px; align-items: center;
    min-height: 0; padding: 10px 12px; border-radius: 4px 40px 40px 4px; background: rgba(11, 10, 12, .78);
  }
  .rite svg { grid-column: 1; grid-row: 1 / span 2; height: auto; }
  .rite h4 { grid-column: 2; grid-row: 1; font-size: 18px; line-height: 1.1; }
  .rite button { grid-column: 3; grid-row: 1; padding: 7px 12px; font-size: 11px; white-space: nowrap; }
  .rite button:hover { transform: none; }
  .rite p { grid-column: 2 / span 2; grid-row: 2; min-height: 0; align-self: start; }
  /* the will-o'-the-wisps float behind the cards and the text */
  .wisps { z-index: 0; }
  html.rm .face-grid { grid-template-rows: auto auto; }
}
