/* Ash Tree Lane. The book is paper; the house is dark. Deliberately no dark theme for the paper. */

@property --burn { syntax: '<percentage>'; inherits: true; initial-value: 0%; }
@property --open { syntax: '<percentage>'; inherits: true; initial-value: 45%; }

:root {
  --paper: #f6f6f3;
  --paper-2: #ecece6;
  --ink: #17171a;
  --ink-2: #45454d;
  --ink-3: #66666e;
  --rule: #d4d4cc;
  --house: #2447d6;
  --mino: #c0282d;
  --night: #0b0b0d;
  --moon: #d9d8d2;
  --ember: #ff8a3d;

  --z: "Times New Roman", Times, Tinos, serif;
  --j: "Courier Prime", "Courier New", Courier, monospace;
  --e: "Bookman Old Style", Bookman, "URW Bookman", "Libre Baskerville", Georgia, serif;
  --p: "Sorts Mill Goudy", "Goudy Old Style", Georgia, serif;

  --measure: 34rem;
  --gutter: clamp(20px, 5vw, 64px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  font-family: var(--z);
  font-size: 1.1875rem;
  line-height: 1.62;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* paper grain, fixed so it never repaints on scroll */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--house); color: var(--paper); }

a { color: inherit; }
button { font: inherit; color: inherit; }
cite { font-style: italic; }

:focus-visible { outline: 2px solid var(--house); outline-offset: 4px; }
.game :focus-visible, .dark :focus-visible { outline-color: #7d96ff; } /* the blue that reads on black */
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 16px; top: -60px;
  z-index: 100;
  background: var(--ink);
  color: var(--paper);
  padding: .5em 1em;
  font-size: .8rem;
}
.skip:focus { top: 16px; }
body.in-house .skip, body.journal-open .skip { display: none; }
.js .book { display: none; } /* with script the book is read through the journal; without it, it is the page */

/* the two words the book colours */
.house { color: var(--house); }
.minotaur { color: var(--mino); text-decoration: line-through; text-decoration-thickness: 1px; }
.struck { color: var(--mino); text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--mino) 70%, transparent); }

/* voices */
.voice-zampano { font-family: var(--z); }
.voice-johnny { font-family: var(--j); font-size: .9em; line-height: 1.62; }
.voice-editors { font-family: var(--e); font-size: .86em; line-height: 1.66; }
.voice-pelafina { font-family: var(--p); }

.journal-page > section {
  width: min(100%, var(--measure));
  margin-inline: auto;
}
body.in-house { overflow: hidden; }

p { margin: 0 0 1.05em; hyphens: auto; -webkit-hyphens: auto; }

/* ---------- threshold ---------- */

main > .threshold {
  width: auto;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 26px var(--gutter) 34px;
}
.threshold-site {
  margin: 0;
  font-size: .8rem;
  font-variant: all-small-caps;
  letter-spacing: .2em;
  color: var(--ink-2);
}
.threshold-core {
  align-self: center;
  justify-self: center;
  width: min(100%, 46rem);
  padding-block: 6vh;
}
.threshold-word {
  margin: 0 0 .28em;
  font-weight: 400;
  font-size: clamp(4.2rem, 16vw, 10.5rem);
  line-height: .9;
  letter-spacing: -.015em;
  color: var(--house);
  transform: translateX(-4%);
}
.rulers { display: grid; gap: 3px; margin-bottom: 1.1rem; }
.ruler {
  height: 13px;
  background:
    linear-gradient(to right, var(--ink) 1px, transparent 1px) left bottom / 50px 13px repeat-x,
    linear-gradient(to right, var(--ink) 1px, transparent 1px) left bottom / 10px 6px repeat-x;
}
/* the inside ruler is a hair longer per tick; by the right edge it no longer agrees */
.ruler-in {
  transform: scaleY(-1);
  background:
    linear-gradient(to right, var(--house) 1px, transparent 1px) left bottom / 50.35px 13px repeat-x,
    linear-gradient(to right, var(--house) 1px, transparent 1px) left bottom / 10.07px 6px repeat-x;
}
.measure {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 0;
  font-family: var(--j);
  font-size: .82rem;
}
.measure div:last-child { text-align: right; }
.measure dt { color: var(--ink-3); }
.measure dd { margin: .15em 0 0; font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.measure div:last-child dd { color: var(--house); }
.measure-note {
  margin: 1.4rem 0 0;
  font-family: var(--e);
  font-size: .8rem;
  color: var(--ink-3);
}
.threshold-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1.5rem 3rem;
  flex-wrap: wrap;
}
.threshold-foot p { margin: 0; max-width: 34rem; font-size: 1rem; color: var(--ink-2); }
.threshold-actions { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.read-instead {
  background: none;
  border: 0;
  padding: .4em 0;
  font-size: .85rem;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: .2em;
  cursor: pointer;
}
.read-instead:hover { color: var(--house); }
.enter {
  display: inline-block;
  background: none;
  cursor: pointer;
  padding: .75em 1.5em;
  border: 1px solid var(--ink);
  text-decoration: none;
  font-size: .9rem;
  font-variant: all-small-caps;
  letter-spacing: .18em;
  white-space: nowrap;
  transition: background .35s, color .35s;
}
.enter:hover { background: var(--ink); color: var(--paper); }
.enter:active { transform: translateY(1px); }
.enter:disabled { opacity: .5; cursor: wait; }

/* ---------- edition note + introduction ---------- */

.edition { padding-block: 1rem 0; }
.edition-title,
.intro-title {
  margin: 0 0 1.4em;
  font-weight: 400;
  font-size: 1rem;
}
.edition-title { font-variant: all-small-caps; letter-spacing: .14em; }
.edition p { color: var(--ink-2); }

.intro { padding-block: 1rem 0; }
.intro-title { font-weight: 700; font-size: 1.05rem; }
.intro p { margin-bottom: 1.1em; }
.signature { margin-top: 2em; text-align: right; }

/* ---------- the record ---------- */

.record-head { padding-block: 28vh 6vh; text-align: center; }
.record-kicker {
  margin: 0 0 .6em;
  font-variant: all-small-caps;
  letter-spacing: .2em;
  font-size: .85rem;
  color: var(--ink-3);
}
.record-title {
  margin: 0;
  font-weight: 400;
  font-size: clamp(2.3rem, 6.5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: .01em;
}

.chapter { padding-top: 1rem; }
.ch-head {
  display: grid;
  gap: .25rem;
  margin: 0 0 2.2em;
  font-weight: 400;
}
.ch-num { font-size: clamp(3.6rem, 9vw, 5.8rem); line-height: 1; letter-spacing: -.01em; }
.ch-title { font-size: 1rem; font-variant: all-small-caps; letter-spacing: .16em; color: var(--ink-2); }

/* book paragraphs: indented, no gaps */
.chapter > p { margin: 0; text-indent: 1.5em; text-align: justify; }
.chapter > .ch-head + p,
.chapter > p:first-of-type { text-indent: 0; }
.chapter > p + p { margin-top: 0; }
.chapter > :is(div, figure) + p,
html:not(.js) .chapter > aside + p { text-indent: 0; }

/* ---------- note references and notes ---------- */

sup { line-height: 0; }
a.ref {
  display: inline-block; /* a real box, so the small numerals are something a finger can hit */
  min-width: 1.4em;
  padding: .45em .12em .45em .06em;
  margin: -.45em -.1em -.45em 0;
  font-family: var(--z);
  font-size: .72em;
  text-align: center;
  text-indent: 0;
  text-decoration: none;
  color: var(--ink);
}
a.ref[data-voice="johnny"] { font-family: var(--j); }
a.ref[data-voice="editors"] { font-family: var(--e); font-style: italic; }
a.ref:hover { color: var(--house); }

/* without script, notes simply sit in the text */
.note {
  display: block;
  margin: .7em 0 1.3em 1.4em;
  padding-left: 1em;
  border-left: 1px solid var(--rule);
  font-size: .86em;
  text-indent: 0;
  text-align: left;
}
.note[data-voice="johnny"] { font-family: var(--j); font-size: .8em; }
.note[data-voice="editors"] { font-family: var(--e); font-size: .8em; }
.note::before { content: attr(data-num) "."; display: block; font-family: var(--z); color: var(--ink-3); }
.note p { text-indent: 0; margin-bottom: .8em; }
.js .journal-page .note { display: none; }

/* leaves: notes as sheets of paper stacking over the text */
.leaves {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.leaves.open { pointer-events: auto; }
.leaf {
  --bg: #fbfbf9;
  position: absolute;
  top: calc(10vh + var(--i) * 44px);
  right: calc(var(--gutter) + var(--i) * 30px);
  width: min(31rem, calc(100vw - 32px));
  max-height: 78vh;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px 26px 26px;
  background: var(--bg);
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.6;
  box-shadow: 0 1px 0 rgba(23, 23, 26, .05), 0 30px 70px -24px rgba(23, 23, 26, .38);
  opacity: 0;
  transform: translateX(46px) rotate(var(--tilt));
  transition: transform .5s var(--ease), opacity .35s;
}
.leaf.in { opacity: 1; transform: rotate(var(--tilt)); }
.leaf[data-voice="johnny"] { --bg: #efefe9; font-family: var(--j); font-size: .95rem; }
.leaf[data-voice="editors"] { --bg: #f4f4f0; font-family: var(--e); font-size: .92rem; }
.leaf-head {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.leaf-num { font-family: var(--z); font-size: 1.5rem; line-height: 1; }
.leaf-voice {
  flex: 1;
  font-family: var(--z);
  font-size: .8rem;
  font-variant: all-small-caps;
  letter-spacing: .16em;
  color: var(--ink-3);
}
.leaf-close {
  background: none;
  border: 1px solid var(--rule);
  padding: .3em .8em;
  font-family: var(--z);
  font-size: .75rem;
  font-variant: all-small-caps;
  letter-spacing: .14em;
  cursor: pointer;
}
.leaf-close:hover { border-color: var(--ink); }
.leaf-body p { margin: 0 0 .85em; text-indent: 0; hyphens: auto; }
.leaf-body .note { display: none; }
.leaf-body a:not(.ref) { color: var(--house); }

@media (max-width: 700px) {
  .leaf {
    top: auto;
    left: 0; right: 0;
    bottom: calc(var(--i) * 12px);
    width: auto;
    max-height: 74vh;
    transform: translateY(60px);
    box-shadow: 0 -20px 60px -20px rgba(23, 23, 26, .4);
  }
  .leaf.in { transform: none; }
}

/* ---------- II. self-measure ---------- */

.self-measure { margin: 2.2em 0; }
.measure-small {
  padding: .9em 0;
  border-block: 1px solid var(--rule);
  font-size: .78rem;
}
.measure-small dd { font-size: .95rem; }

/* ---------- IV. echoes ---------- */

.echoes p { margin: 0 0 .4em; text-align: justify; }
.echoes .echo { margin: 0 0 1.8em; text-align: left; color: var(--ink-3); font-style: italic; }
.echo span { display: block; }
.echo span:nth-child(1) { margin-left: 28%; opacity: .75; font-size: .92em; }
.echo span:nth-child(2) { margin-left: 46%; opacity: .45; font-size: .84em; }
.echo span:nth-child(3) { margin-left: 62%; opacity: .22; font-size: .76em; }
.echoes .echo-last { margin-top: 3.4em; font-style: italic; }

/* ---------- VI. the labyrinth ---------- */

.struck-p { text-indent: 0 !important; margin: 1.2em 0 !important; }

.maze {
  width: 100%;
  margin: 3.5em 0;
  display: grid;
  gap: 3.5rem;
}
.inventory { margin: 0 auto; width: min(100%, 27rem); perspective: 1600px; text-align: center; }
.inventory-card {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  transition: transform 1.2s cubic-bezier(.2, .75, .2, 1);
}
.inventory.flipped .inventory-card { transform: rotateY(180deg); }
.inventory-face {
  position: relative;
  grid-area: 1 / 1;
  padding: 1.5em 1.7em 3.2em;
  border: 2px solid var(--house);
  background: var(--paper);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: left;
}
.inventory-front::after {
  content: "In the house. Whoever is holding the light.";
  position: absolute;
  left: 1.7em; right: 1.7em; bottom: 1.2em;
  transform: scaleX(-1);
  font-size: .8em;
  color: var(--ink);
  opacity: .07;
  text-align: right;
}
.inventory-back {
  transform: rotateY(180deg);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  font-size: 1.3em;
}
.inventory-title {
  margin: 0 0 .8em;
  font-size: .8rem;
  font-variant: all-small-caps;
  letter-spacing: .2em;
  color: var(--house);
}
.inventory-front p:last-child { font-size: .95em; line-height: 1.75; }

.turn {
  margin-top: 1.3em;
  padding: .6em 1.2em;
  background: none;
  border: 1px solid var(--ink);
  font-size: .8rem;
  font-variant: all-small-caps;
  letter-spacing: .18em;
  cursor: pointer;
  transition: background .3s, color .3s;
}
.turn:hover { background: var(--ink); color: var(--paper); }

.maze-cols { display: grid; grid-template-columns: 1fr 1fr auto; gap: 2rem; align-items: start; }
.maze-col { margin: 0; text-align: justify; }
.upside-wrap { display: grid; justify-items: start; }
.upside { transform: rotate(180deg); transition: transform 1.2s var(--ease); }
.upside.turned { transform: none; }

.margin-scrawl {
  justify-self: end;
  margin: 0;
  max-height: 24rem;
  writing-mode: vertical-rl;
  text-orientation: sideways;
  font-size: .82rem;
  color: var(--ink-2);
}
.descent { margin: 0; line-height: 1.95; }
.descent span {
  display: block;
  margin-left: calc(var(--i) * 5.5%);
  font-size: calc(1em - var(--i) * .035em);
  opacity: calc(1 - var(--i) * .07);
}

@media (max-width: 760px) {
  .maze-cols { grid-template-columns: 1fr; }
  .margin-scrawl { writing-mode: horizontal-tb; justify-self: stretch; max-height: none; padding-left: 1em; border-left: 1px solid var(--rule); }
}

/* ---------- VII. the corridor narrows ---------- */

.narrowing { margin: 2em 0; }
.narrowing p {
  max-width: min(100%, var(--w));
  margin: 0 auto 1.5em;
  text-indent: 0;
  text-align: left;
}
.narrowing p:last-child { text-align: center; font-style: italic; }

.tape { width: 100%; margin: 3.5em 0; }
.tape-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 55%, #1c1c1f, #0c0c0e 70%);
  color: #e6e4dd;
  font-family: var(--j);
}
.tape-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px);
}
.tape-rec, .tape-tc { position: absolute; top: 5%; z-index: 3; font-size: .82rem; letter-spacing: .08em; }
.tape-rec { left: 5%; display: flex; align-items: center; gap: .5em; }
.tape-rec::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: #e0352b; animation: rec 1s steps(2) infinite; }
@keyframes rec { 50% { opacity: 0; } }
.tape-tc { right: 5%; font-variant-numeric: tabular-nums; }
.tape-desc {
  position: absolute;
  left: 12%; right: 12%; top: 50%;
  z-index: 1;
  margin: 0;
  transform: translateY(-50%);
  text-align: center;
  font-size: clamp(.8rem, 1.9vw, .98rem);
  line-height: 1.75;
}
/* the blackness at the edges of the frame, closing in as you read */
.tape-dark {
  position: absolute;
  inset: -2px;
  z-index: 2;
  background:
    radial-gradient(ellipse 60% 55% at 50% 50%, transparent var(--open), #050506 calc(var(--open) + 28%)),
    radial-gradient(ellipse 14% 30% at 8% 70%, #050506 20%, transparent 70%),
    radial-gradient(ellipse 18% 22% at 92% 30%, #050506 20%, transparent 70%);
}
.tape figcaption { margin-top: .8em; font-size: .78rem; font-style: italic; color: var(--ink-3); }

/* ---------- VIII. torn text ---------- */

.torn { margin: 1.6em 0 2.4em; }
.torn p { margin: 0 0 1.4em; text-indent: 0; text-align: left; }
.chapter > .aftermath { margin: 0 0 2.6em; text-indent: 0; text-align: left; font-style: italic; }
.shard {
  display: inline-block;
  white-space: nowrap;
  transform: translate(calc(var(--dx) * .3), calc(var(--dy) * .3)) rotate(calc(var(--r) * .3));
}

/* ---------- IX. film strip ---------- */

.strip {
  width: 100%;
  margin: 3em 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: min(17rem, 72vw);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 34px 20px;
  background:
    repeating-linear-gradient(to right, transparent 0 12px, var(--paper) 12px 22px) left 11px / 100% 11px no-repeat,
    repeating-linear-gradient(to right, transparent 0 12px, var(--paper) 12px 22px) left calc(100% - 11px) / 100% 11px no-repeat,
    #111113;
  scrollbar-width: thin;
  scrollbar-color: #45454d #111113;
}
.frame {
  margin: 0;
  scroll-snap-align: center;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  padding: 1.4em;
  border-inline: 6px solid #111113;
  background: radial-gradient(ellipse at 50% 45%, #2b2b30, #19191c 75%);
  color: #e6e4dd;
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.5;
  text-align: center;
}
.frame p { margin: 0; }
.frame:last-child { background: radial-gradient(ellipse at 50% 45%, #3a3935, #1c1b1a 75%); }

/* ---------- appendix ---------- */

.appendix { padding-top: 1rem; }
.appendix-head { text-align: center; margin-bottom: 4em; }
.appendix-kicker { margin: 0 0 .5em; font-variant: all-small-caps; letter-spacing: .2em; font-size: .85rem; color: var(--ink-3); font-family: var(--z); }
.appendix-title { margin: 0 0 1.4em; font-weight: 400; font-size: clamp(2rem, 5.5vw, 3.2rem); line-height: 1.1; }
.appendix-ed { text-align: left; color: var(--ink-2); }
.letter { max-width: 30rem; margin: 0 auto 6em; font-size: 1.12rem; line-height: 1.72; }
.letter-salute { font-style: italic; }
.letter-close { text-align: right; font-style: italic; }
.letter-late { transform: rotate(-.5deg); }
.letter-late p:nth-child(2) { margin-left: .6em; }
.cipher .ini { transition: color .8s, font-weight .8s; }
.cipher .rest { transition: color .8s; }
.cipher.decoding .rest { color: color-mix(in srgb, var(--ink) 22%, transparent); }
.cipher.decoding .ini { color: var(--house); }
.decoded {
  margin-top: 1em;
  font-style: italic;
  font-size: 1.3rem;
  letter-spacing: .06em;
  text-align: center;
  color: var(--house);
}

/* ---------- colophon ---------- */

main > .colophon {
  margin-top: 26vh;
  padding: 3em 0 10em;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
}
.colophon-meta { color: var(--ink-3); }
.colophon-time { margin-top: 2em; font-family: var(--j); font-size: .9em; color: var(--ink-3); }

/* ---------- the dark (explorations) ---------- */

.dark {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--night);
  color: var(--moon);
  opacity: 0;
  transition: opacity 1s ease;
  touch-action: none;
  overscroll-behavior: contain;
}
.dark.in { opacity: 1; }
.dark.leaving { opacity: 0; transition-duration: 1.4s; }
.dark-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dark-words {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.dark-words p {
  position: absolute;
  width: min(22rem, 80vw);
  margin: 0;
  transform: translate(-50%, -50%);
  font-family: var(--z);
  font-size: clamp(1.05rem, 2.3vw, 1.4rem);
  line-height: 1.5;
  text-align: center;
  color: #e7e5de;
  opacity: 0;
  transition: opacity .7s ease;
}
.dark-words p.in { opacity: 1; transition-duration: 1.8s; transition-delay: .55s; }
.dark-words .house { color: #7d96ff; }
.dark-hud {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 18px var(--gutter) 22px;
  font-family: var(--j);
  font-size: .8rem;
  color: rgba(217, 216, 210, .62);
  cursor: default;
}
.dark-meter { margin: 0; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.dark-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.dark-btn {
  padding: .6em 1.1em;
  background: rgba(11, 11, 13, .6);
  border: 1px solid rgba(217, 216, 210, .5);
  font-family: var(--j);
  font-size: .8rem;
  color: var(--moon);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .3s;
}
.dark-btn:hover { border-color: rgba(217, 216, 210, .75); }
.dark-btn[data-act="primary"] { border-color: rgba(255, 170, 90, .6); color: #ffd2a8; }
.dark-btn[data-act="primary"]:hover { border-color: #ffb070; }
.dark-hint {
  position: absolute;
  top: 20px;
  left: 50%;
  z-index: 3;
  width: min(90vw, 36rem);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--j);
  font-size: .78rem;
  color: rgba(217, 216, 210, .55);
  transition: opacity 1.6s;
}
.dark-hint.off { opacity: 0; }

/* Exploration #5: a page, read by the light of the one before it */
.dark-page {
  position: absolute;
  left: 50%;
  top: 53%;
  z-index: 1;
  width: min(23rem, 80vw);
  aspect-ratio: 5 / 7;
  max-height: 64vh;
  overflow: hidden;
  padding: 2.2em 2em;
  background: #ecebe4;
  color: #1c1c1f;
  font-family: var(--z);
  font-size: clamp(.8rem, 2.2vw, .95rem);
  line-height: 1.55;
  transform: translate(-50%, -50%) rotate(-1.4deg);
  filter: brightness(var(--light, 1));
  box-shadow: 0 40px 90px -30px #000;
  cursor: pointer;
  -webkit-mask-image:
    radial-gradient(circle at 16% 106%, transparent var(--burn), #000 calc(var(--burn) + 2%)),
    radial-gradient(circle at 44% 118%, transparent calc(var(--burn) * .82), #000 calc(var(--burn) * .82 + 2%));
  mask-image:
    radial-gradient(circle at 16% 106%, transparent var(--burn), #000 calc(var(--burn) + 2%)),
    radial-gradient(circle at 44% 118%, transparent calc(var(--burn) * .82), #000 calc(var(--burn) * .82 + 2%));
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.dark-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 106%, transparent calc(var(--burn) - 1%), rgba(255, 130, 40, .95) calc(var(--burn) + 1%), rgba(60, 30, 10, .8) calc(var(--burn) + 3%), transparent calc(var(--burn) + 7%)),
    radial-gradient(circle at 44% 118%, transparent calc(var(--burn) * .82 - 1%), rgba(255, 130, 40, .8) calc(var(--burn) * .82 + 1%), transparent calc(var(--burn) * .82 + 6%));
}
.dark-page.burning { animation: burn 2.1s cubic-bezier(.5, 0, .9, .6) forwards; }
@keyframes burn { to { --burn: 150%; } }
.dark-page p { margin: 0 0 .9em; hyphens: auto; }
.dark-page .voice-johnny { font-size: .9em; }
.dark-page.title-page { display: grid; place-content: center; text-align: center; }
.dark-page.title-page p { margin: 0; }
.dark-page .page-title { font-size: 2em; line-height: 1.1; }
.dark-page .page-foot { position: absolute; bottom: 1.2em; left: 0; right: 0; text-align: center; font-size: .8em; color: #5f5f66; }

/* ---------- motion preferences + scroll-driven extras ---------- */

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .tape-dark {
      animation: close-in linear both;
      animation-timeline: view();
      animation-range: contain 0% exit 70%;
    }
    @keyframes close-in { 0% { --open: 80%; } 55% { --open: 38%; } 100% { --open: -10%; } }

    .shard {
      animation: tear linear both;
      animation-timeline: view();
      animation-range: entry 40% cover 60%;
    }
    @keyframes tear {
      from { transform: none; }
      to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: var(--fade, 1); }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- the house ---------- */

.game { position: fixed; inset: 0; z-index: 20; background: #030304; color: var(--moon); }
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--j); }
.hud::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 3px; height: 3px;
  margin: -1px;
  background: rgba(255, 255, 255, .55);
}
.hud-meter { position: absolute; left: calc(var(--gutter) + env(safe-area-inset-left, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); margin: 0; font-size: .8rem; color: rgba(217, 216, 210, .8); text-shadow: 0 1px 6px #000, 0 0 2px #000; font-variant-numeric: tabular-nums; }
.hud-sub {
  position: absolute;
  left: 50%;
  bottom: calc(7vh + 5rem + env(safe-area-inset-bottom, 0px)); /* above the prompt, however many lines it has */
  width: min(90vw, 36rem);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--z);
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  line-height: 1.5;
  color: #e7e5de;
  text-shadow: 0 1px 14px #000, 0 0 3px #000;
  opacity: 0;
  transition: opacity .9s ease;
}
.hud-sub.in { opacity: 1; }
.hud-sub .house { color: #7d96ff; }
.hud-prompt {
  position: absolute;
  left: 50%;
  bottom: calc(7vh + env(safe-area-inset-bottom, 0px));
  max-width: min(90vw, 30rem);
  transform: translateX(-50%);
  pointer-events: auto;
  padding: .75em 1.3em;
  background: rgba(11, 11, 13, .72);
  border: 1px solid rgba(217, 216, 210, .45);
  color: var(--moon);
  font-family: var(--j);
  font-size: .85rem;
  line-height: 1.4;
  cursor: pointer;
}
.hud-prompt:hover { border-color: rgba(217, 216, 210, .9); }
.hud-corner { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(var(--gutter) + env(safe-area-inset-right, 0px)); display: flex; gap: 8px; pointer-events: auto; }
.hud-btn {
  padding: .55em 1em;
  background: rgba(11, 11, 13, .6);
  border: 1px solid rgba(217, 216, 210, .5);
  font-family: var(--j);
  font-size: .78rem;
  color: var(--moon);
  cursor: pointer;
}
.hud-btn:hover { border-color: rgba(217, 216, 210, .75); }
.veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: rgba(3, 3, 4, .55);
  font-family: var(--j);
  font-size: .9rem;
  color: var(--moon);
  cursor: pointer;
}
.card {
  position: absolute;
  left: 50%; top: 50%;
  z-index: 3;
  width: min(90vw, 30rem);
  padding: 2em 2.2em 2.2em;
  transform: translate(-50%, -50%);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--z);
  font-size: 1.05rem;
  line-height: 1.55;
  text-align: center;
  box-shadow: 0 40px 90px -30px #000;
  opacity: 0;
  transition: opacity 1.2s ease;
  pointer-events: auto;
}
.card.in { opacity: 1; }
.card p { margin: 0 0 .9em; }
.card-kicker { font-variant: all-small-caps; letter-spacing: .2em; font-size: .85rem; color: var(--ink-3); }
.card-help { font-family: var(--j); font-size: .78rem; color: var(--ink-3); }
.card-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 1.6em; }
.card-actions button, .journal-continue {
  padding: .6em 1.2em;
  background: none;
  border: 1px solid var(--ink);
  font-family: var(--z);
  font-size: .8rem;
  font-variant: all-small-caps;
  letter-spacing: .18em;
  color: var(--ink);
  cursor: pointer;
  transition: background .3s, color .3s;
}
.card-actions button:hover, .journal-continue:hover { background: var(--ink); color: var(--paper); }

/* ---------- the journal ---------- */

.journal { position: fixed; inset: 0; z-index: 40; background: var(--paper); color: var(--ink); }
.journal-frame { height: 100%; display: grid; grid-template-rows: auto 1fr; grid-template-columns: 17rem 1fr; }
.journal-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 46px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--rule);
  font-size: .78rem;
  font-variant: all-small-caps;
  letter-spacing: .14em;
  color: var(--ink-2);
}
.journal-count { flex: 1; text-align: center; }
.journal-close, .leaf-close {
  background: none;
  border: 1px solid var(--rule);
  padding: .3em .8em;
  font-family: var(--z);
  font-size: .75rem;
  font-variant: all-small-caps;
  letter-spacing: .14em;
  color: var(--ink);
  cursor: pointer;
}
.journal-close:hover, .leaf-close:hover { border-color: var(--ink); }
.journal-nav { overflow: auto; padding: 1.6rem var(--gutter); border-right: 1px solid var(--rule); font-family: var(--z); }
.journal-nav ol { list-style: none; margin: 0; padding: 0; }
.journal-nav li { padding: .15em 0; }
.journal-nav button { display: block; width: 100%; background: none; border: 0; padding: .25em 0; text-align: left; font-size: .95rem; color: var(--ink); cursor: pointer; }
.journal-nav button:hover { color: var(--house); }
.journal-nav button[aria-current] { color: var(--house); }
.journal-nav .locked { padding: .4em 0; font-size: .75rem; letter-spacing: .1em; color: var(--ink-3); }
.journal-page { overflow: auto; overscroll-behavior: contain; padding: 2.5rem var(--gutter) 6rem; }
.journal-page:focus { outline: none; }
.journal-continue { display: block; margin: 4em auto 0; }
.colophon { padding-bottom: 2em; color: var(--ink-2); }
.colophon-meta { color: var(--ink-3); }
.band-lines { display: flex; justify-content: space-around; gap: 1em; margin: 2.4em 0; text-indent: 0 !important; font-family: var(--j); font-size: .8rem; letter-spacing: .06em; color: var(--ink-3); }

@media (max-width: 760px) {
  .journal-frame { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .journal-nav { padding: .7rem var(--gutter); border-right: 0; border-bottom: 1px solid var(--rule); }
  .journal-nav ol { display: flex; gap: 0 1.2rem; overflow-x: auto; white-space: nowrap; -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .journal-nav button { width: auto; font-size: .9rem; }
  .journal-nav .locked { padding: .3em 0; }
  .hud-sub { bottom: calc(12vh + 5rem + env(safe-area-inset-bottom, 0px)); }
  .hud-prompt { bottom: calc(12vh + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 1.09rem; }
  .chapter > p { text-align: left; }
  .measure { grid-template-columns: 1fr; gap: .8rem; }
  .measure div:last-child { text-align: left; }
  .threshold-foot { flex-direction: column; align-items: start; }
  .echo span:nth-child(1) { margin-left: 14%; }
  .echo span:nth-child(2) { margin-left: 30%; }
  .echo span:nth-child(3) { margin-left: 46%; }
  .threshold-word { transform: none; margin-left: -.04em; }
  .maze-col { text-align: left; }
}

/* ---------- loading, recording ---------- */

.loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  gap: 18px;
  background: #030304;
  color: var(--moon);
  text-align: center;
  font-family: var(--j);
  transition: opacity 1.4s ease;
}
.loading.off { opacity: 0; pointer-events: none; }
.loading-word { margin: 0; font-family: var(--z); font-size: clamp(3rem, 9vw, 5.5rem); line-height: 1; color: #7d96ff; letter-spacing: -.01em; }
.loading-bar { width: min(60vw, 22rem); height: 1px; margin: 0 auto; background: rgba(217, 216, 210, .18); }
.loading-bar i { display: block; height: 100%; width: 0; background: var(--moon); transition: width .4s ease; }
.loading-text { margin: 0; font-size: .78rem; color: rgba(217, 216, 210, .6); font-variant-numeric: tabular-nums; }
.hud-rec {
  position: absolute;
  left: calc(var(--gutter) + env(safe-area-inset-left, 0px)); top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: .6em;
  margin: 0;
  font-size: .78rem;
  letter-spacing: .1em;
  color: rgba(217, 216, 210, .8);
  text-shadow: 0 1px 6px #000, 0 0 2px #000;
  font-variant-numeric: tabular-nums;
}
.rec-dot { width: .6em; height: .6em; border-radius: 50%; background: #e0352b; animation: rec 1.2s steps(2) infinite; }
.hud-corner { top: calc(12px + env(safe-area-inset-top, 0px)); }
@media (max-width: 640px) { .hud-rec { top: auto; bottom: calc(44px + env(safe-area-inset-bottom, 0px)); } .hud-corner { flex-wrap: wrap; justify-content: end; max-width: 60vw; } }

/* ---------- X. Tom's jokes, XII. the rope ---------- */

.jokes { margin: 2em 0 2.2em; padding-left: 1.4em; border-left: 1px solid var(--rule); font-size: .9em; }
.jokes p { margin: 0 0 .9em; text-indent: 0; color: var(--ink-2); }
.chapter > .jokes + p { text-indent: 0; }

/* ---------- appendix II, index ---------- */

.appendix-sub { margin: 4em 0 .6em; font-weight: 400; font-size: 1rem; font-variant: all-small-caps; letter-spacing: .18em; text-align: center; }
.exhibits, .contrary { margin: 2.5em 0; padding: 0; list-style: none; counter-reset: none; }
.exhibits li { margin: 0 0 1.3em; padding-left: 1.4em; text-indent: -1.4em; }
.ex-num { font-variant: all-small-caps; letter-spacing: .12em; }
.ex-missing { display: block; margin-top: .3em; padding-left: 1.4em; text-indent: 0; font-size: .82em; color: var(--ink-2); }
.contrary { max-width: 30rem; margin-inline: auto; counter-reset: contrary; }
.contrary li { position: relative; margin: 0 0 1em; padding-left: 2.2em; counter-increment: contrary; }
.contrary li::before { content: counter(contrary) "."; position: absolute; left: 0; color: var(--ink-3); font-family: var(--z); }
.contrary li:last-child { font-style: italic; }
.contrary-close { margin-top: 3em; text-align: center; }
.index-section { padding-top: 1rem; }
.index-list { display: grid; grid-template-columns: 1fr 1fr; gap: .35em 2.5em; margin: 0; font-size: .86em; line-height: 1.5; }
.index-list div { break-inside: avoid; }
.index-list dt { display: inline; }
.index-list dt::after { content: ", "; }
.index-list dd { display: inline; margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.index-list abbr { text-decoration: none; letter-spacing: .06em; }
@media (max-width: 640px) { .index-list { grid-template-columns: 1fr; } }
.letter-shout { font-variant-caps: normal; }
.letter-shout .letter-salute { font-style: normal; letter-spacing: .1em; }
