:root {
  --paper: #f3efe7;
  --ink: #1e1c19;
  --ink-2: #5f5a52;
  --rule: rgba(30, 28, 25, 0.28);
  --red: #b8321f;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --gutter: clamp(16px, 2.6vw, 40px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
p { margin: 0; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.scroll { width: 1px; height: 700vh; }

/* the printed sheet: a hairline border, the text column, the title block */
.frame {
  position: fixed; inset: 12px; border: 1px solid var(--rule); pointer-events: none;
  transition: opacity 0.6s ease;
}
html:not(.ready) .frame { opacity: 0.4; }

.top {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(12px + 18px) calc(12px + var(--gutter)) 0; pointer-events: none;
}
.brand { display: flex; align-items: baseline; gap: 12px; font-family: var(--serif); font-size: 26px; line-height: 1; }
.brand small { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.hud {
  display: flex; gap: 18px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-2); border: 1px solid var(--rule); padding: 7px 12px; background: rgba(243, 239, 231, 0.78);
}
.hud b { color: var(--ink); font-weight: 500; margin-left: 6px; font-variant-numeric: tabular-nums; }

.sheet {
  position: fixed; left: calc(12px + var(--gutter)); top: clamp(96px, 15vh, 170px); width: min(31vw, 440px);
  pointer-events: none;
}
.sheet .kicker, .cap-k, .titleblock dt, .chapters li, .cue, .endcard {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
}
.sheet .kicker { color: var(--ink-2); margin-bottom: 26px; }
.sheet h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(56px, min(7.4vw, 12vh), 118px); line-height: 0.9; letter-spacing: -0.015em; margin: 0 0 30px; }
.sheet h1 em { font-style: italic; color: var(--red); }
.sheet .lede { font-size: 16px; line-height: 1.55; max-width: 34ch; color: #3b3732; }
.cue { margin-top: 38px; display: flex; align-items: center; gap: 12px; color: var(--ink); }
.cue-line { width: 46px; height: 1px; background: var(--ink); transform-origin: left; animation: cue 2.4s ease-in-out infinite; }
@keyframes cue { 0%, 100% { transform: scaleX(0.25); } 50% { transform: scaleX(1); } }
/* while finish() loads the rooms (js/main.js): quiet on the sheet, plain once the walk waits for it at HOLD */
.loading {
  position: fixed; left: 50%; bottom: calc(12px + 18px); transform: translateX(-50%); display: flex; align-items: center;
  gap: 12px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-2); opacity: 0; transition: opacity 0.6s ease; pointer-events: none; white-space: nowrap;
}
html.ready:not(.loaded) .loading { opacity: 0.55; }
html.held:not(.loaded) .loading { opacity: 1; color: var(--ink); }
html.record .loading { display: none; }

.titleblock {
  position: fixed; left: calc(12px + var(--gutter)); bottom: calc(12px + 18px); width: min(31vw, 440px);
  border-top: 1px solid var(--ink); pointer-events: none;
}
.titleblock dl { margin: 0; display: grid; grid-template-columns: 1fr 1fr 1fr; }
.titleblock div { padding: 8px 10px 9px 0; border-bottom: 1px solid var(--rule); }
.titleblock dt { color: var(--ink-2); font-size: 9.5px; margin-bottom: 3px; }
.titleblock dd { margin: 0; font-size: 13px; }

.chapters { position: fixed; right: calc(12px + var(--gutter)); top: 50%; transform: translateY(-50%); }
.chapters ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.chapters li { color: var(--ink-2); cursor: pointer; padding: 5px 9px; border: 1px solid transparent; background: rgba(243, 239, 231, 0.7); transition: color 0.3s, border-color 0.3s; }
.chapters li b { font-weight: 500; margin-right: 6px; }
.chapters li.on { color: var(--ink); border-color: var(--ink); }
.chapters li.on b { color: var(--red); }
@media (max-height: 560px) { .chapters ol { gap: 4px; } .chapters li { padding: 3px 8px; } }

.caption {
  position: fixed; left: calc(12px + var(--gutter)); bottom: calc(12px + 26px); width: min(420px, calc(100vw - 2 * (12px + var(--gutter))));
  padding: 16px 20px 18px; background: rgba(243, 239, 231, 0.9); border: 1px solid var(--ink);
  opacity: 0; visibility: hidden; pointer-events: none;
}
.cap-k { color: var(--red); margin-bottom: 8px; }
.cap-t { font-family: var(--serif); font-size: 22px; line-height: 1.22; }
.endcard {
  position: fixed; right: calc(12px + var(--gutter)); bottom: calc(12px + 26px); color: var(--ink);
  border: 1px solid var(--ink); padding: 9px 14px; background: rgba(243, 239, 231, 0.9); opacity: 0; visibility: hidden;
}

.fallback { display: none; position: fixed; inset: 0; place-items: center; padding: 32px; text-align: center; font-family: var(--serif); font-size: 24px; }
.no-webgl .fallback { display: grid; }
.no-webgl #gl, .no-webgl .scroll { display: none; }

@media (max-width: 760px) {
  .hud { gap: 10px; font-size: 9px; padding: 6px 8px; }
  .hud span:first-child { display: none; }
  .brand { font-size: 21px; }
  .brand small { display: none; }
  .sheet { top: auto; bottom: calc(12px + 26px); transform: none; width: calc(100vw - 2 * (12px + var(--gutter))); }
  .sheet h1 { font-size: 64px; margin-bottom: 16px; }
  .sheet .kicker { margin-bottom: 14px; }
  .sheet .lede { font-size: 15px; }
  .cue { margin-top: 18px; }
  .titleblock, .chapters { display: none; }
  .cap-t { font-size: 19px; }
  /* under the brand, clear of any caption at the foot however many lines it runs to */
  .endcard { left: calc(12px + var(--gutter)); right: auto; top: calc(12px + 58px); bottom: auto; max-width: calc(100vw - 2 * (12px + var(--gutter))); }
}

.record *, .record *::before, .record *::after { transition: none !important; animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .cue-line { animation: none; }
}
