:root {
  --paper: #f4f1ea;
  --ink: #22211f;
  --ink-soft: #5d5a54;
  --serif: "Libre Caslon Text", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
#track { height: 2250vh; position: relative; }

/* ---------- the printed sheet ---------- */
#sheet { position: fixed; inset: 0; pointer-events: none; }
#sheet .frame { position: absolute; inset: 18px; border: 1.5px solid var(--ink); }
#sheet .frame::after { content: ""; position: absolute; inset: 5px; border: 0.75px solid var(--ink); }
.areas {
  position: absolute; left: 44px; bottom: 44px; font: 500 11px/1.55 var(--mono); letter-spacing: 0.02em;
}
.areas div { display: flex; justify-content: space-between; gap: 28px; min-width: 210px; }
.areas .gap { margin-top: 8px; }
.areas .u { text-decoration: underline; text-underline-offset: 3px; }
.titleblock {
  position: absolute; right: 23px; bottom: 23px; width: min(340px, 42vw);
  border-left: 1.5px solid var(--ink); border-top: 1.5px solid var(--ink); background: var(--paper);
}
.titleblock .addr { padding: 18px 20px 16px; font: 400 clamp(17px, 2vw, 25px)/1.25 var(--sans); text-align: center; border-bottom: 1px solid var(--ink); }
.titleblock .addr b { font-family: var(--serif); font-weight: 700; }
.titleblock .row { padding: 9px 14px; font: 500 10.5px/1.3 var(--mono); letter-spacing: 0.06em; border-bottom: 1px solid var(--ink); text-align: center; }
.titleblock .split { display: flex; padding: 0; border-bottom: 0; }
.titleblock .date { flex: 1; padding: 16px 14px; font-style: italic; text-align: left; border-right: 1px solid var(--ink); }
.titleblock .no { width: 90px; display: grid; place-items: center; font: 400 26px var(--sans); letter-spacing: 0; }

/* ---------- disclaimer ---------- */
.titleblock .note { font-size: 8.5px; letter-spacing: 0.04em; padding: 6px 10px; }
#legal {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  font: 400 10.5px/1.4 var(--sans); color: var(--ink-soft); text-align: center; text-wrap: balance;
  background: rgba(244, 241, 234, 0.92); border-top: 1px solid rgba(34, 33, 31, 0.25);
  opacity: 0; pointer-events: none;
}

/* ---------- guided tour ---------- */
#tour {
  position: fixed; z-index: 6; display: flex; gap: 6px;
  top: calc(30px + env(safe-area-inset-top, 0px)); right: calc(30px + env(safe-area-inset-right, 0px));
  opacity: 0; transition: opacity .4s;
}
body.has-tour #tour { opacity: 1; }
#tour button {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px;
  font: 500 11.5px var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--paper); background: var(--ink); border: 1px solid var(--ink); border-radius: 0; cursor: pointer;
}
#tour #soundBtn { width: 38px; padding: 0; justify-content: center; background: var(--paper); color: var(--ink); }
#tour button:hover { filter: brightness(1.15); }
#tour button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
#tour svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
#tour .i-pause, body[data-tour="playing"] #tour .i-play { display: none; }
body[data-tour="playing"] #tour .i-pause { display: block; }
#soundBtn .i-on, #soundBtn[aria-pressed="true"] .i-off { display: none; }
#soundBtn[aria-pressed="true"] .i-on { display: block; }
#subtitle {
  position: fixed; z-index: 5; left: 50%; top: calc(84px + env(safe-area-inset-top, 0px)); translate: -50% 0; margin: 0;
  width: max-content; max-width: min(620px, calc(100vw - 32px));
  padding: 10px 16px; font: 400 15px/1.45 var(--sans); color: var(--paper); background: rgba(34, 33, 31, 0.86);
  text-align: center; text-wrap: balance; opacity: 0; transition: opacity .35s; pointer-events: none;
}
#subtitle.on { opacity: 1; }
body.record #tour, body.record #subtitle { display: none; }

/* tile swatches inside the captions */
.cap:has(.sw) { display: flex; gap: 14px; align-items: flex-start; max-width: min(460px, calc(100vw - 64px)); }
.cap .sw { flex: none; position: relative; width: 84px; height: 84px; border: 1px solid rgba(34, 33, 31, 0.85); background-size: cover; background-position: center; }
.cap .sw em { position: absolute; left: -1px; right: -1px; bottom: -1px; padding: 2px 0; background: var(--ink); color: var(--paper); font: 500 8.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; text-align: center; }

/* ---------- scroll hint ---------- */
#hint {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  font: 500 11px var(--mono); letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
#hint span { width: 1px; height: 28px; background: var(--ink); animation: drip 1.8s ease-in-out infinite; transform-origin: top; }
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* ---------- captions: small paper cards ---------- */
.cap {
  position: fixed; left: 32px; bottom: 58px; max-width: min(400px, calc(100vw - 64px));
  background: rgba(244, 241, 234, 0.94); color: var(--ink);
  padding: 14px 18px 15px; border: 1px solid rgba(34, 33, 31, 0.85);
  opacity: 0; pointer-events: none; will-change: opacity, transform;
}
.cap b { display: block; font: 700 19px/1.2 var(--serif); margin-bottom: 5px; }
.cap span { display: block; font: 400 12.5px/1.5 var(--sans); color: var(--ink-soft); }
.cap strong { color: var(--ink); font-weight: 500; }
.cap.end b { font-size: 22px; }
.cap.end span { font-size: 15px; }
.cap.big { padding: 18px 24px 17px; }
.cap.big b { font-size: clamp(26px, 3.4vw, 40px); }
.cap.end { left: auto; right: 32px; }
#cap1 { left: 44px; bottom: auto; top: 44px; }

#nogl { display: none; position: fixed; inset: 0; place-items: center; text-align: center; padding: 40px; font: 400 16px var(--sans); }
body.no-webgl #nogl { display: grid; }

body.record #hint span { animation: none; transform: scaleY(1); }

@media (max-width: 720px) {
  .areas { display: none; }
  .titleblock { width: calc(100vw - 46px); }
  .titleblock .addr { padding: 12px; }
  .cap .sw { width: 64px; height: 64px; }
  .cap:has(.sw) { max-width: none; }
  .cap:has(.sw) { gap: 12px; }
  .cap { left: 16px; right: 16px; bottom: 74px; max-width: none; }
  #tour { top: calc(16px + env(safe-area-inset-top, 0px)); right: calc(16px + env(safe-area-inset-right, 0px)); }
  #subtitle { top: calc(66px + env(safe-area-inset-top, 0px)); font-size: 14px; }
  #legal { font-size: 9.5px; }
  #cap1 { left: 16px; top: 66px; }
  #hint { bottom: auto; top: 76px; }
  .cap.end { right: 16px; }
}
