:root {
  --bg: #000;
  --text: #ece7df;
  --dim: #8c857b;
  --ember: #ff7a2e;
  --sans: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--sans); font-weight: 300; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; display: block; }
#scroll-space { height: 1400vh; }

#glare, #veil { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
#glare { background: radial-gradient(circle at 50% 40%, #fff 0%, #fff6e6 45%, #f2e6d0 100%); }
#veil { background: #000; }

/* Chapter label */
.chapter {
  position: fixed; top: 28px; left: 32px;
  display: flex; gap: 14px; align-items: baseline;
  font-size: 12px; letter-spacing: .32em; text-transform: uppercase;
  color: var(--dim); transition: opacity .6s;
}
.chapter .numeral { color: var(--text); font-weight: 500; }

/* Chapter ticks */
.progress { position: fixed; right: 28px; top: 50%; transform: translateY(-50%); }
.progress ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.progress button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  font-size: 11px; letter-spacing: .24em; color: var(--dim);
}
.progress button::after {
  content: ""; width: 18px; height: 1px; background: currentColor; transition: width .4s;
}
.progress button[aria-current="true"] { color: var(--text); }
.progress button[aria-current="true"]::after { width: 36px; }
.progress button:focus-visible { outline: 1px solid var(--text); outline-offset: 4px; }
.progress .label { opacity: 0; transition: opacity .3s; }
.progress button:hover .label, .progress button:focus-visible .label { opacity: 1; }

/* Beats */
#beats { position: fixed; inset: 0; pointer-events: none; }
.beat {
  position: absolute; left: 50%; bottom: 12vh; transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px)); text-align: center;
  opacity: 0; will-change: opacity, transform;
}
.beat p.text {
  margin: 0; font-family: var(--serif); font-size: clamp(21px, 2.3vw, 28px); line-height: 1.45;
  text-shadow: 0 0 24px #000, 0 0 8px #000;
}
.beat.long p.text { font-size: clamp(18px, 1.85vw, 23px); line-height: 1.5; }
.beat.credits { bottom: auto; top: 50%; transform: translate(-50%, -50%); }
.beat.credits p { margin: 0; text-shadow: 0 0 12px #000; }
.beat.credits .work { font-family: var(--serif); font-style: italic; font-size: clamp(19px, 2vw, 24px); }
.beat.credits .translation { margin-top: 10px; font-size: 12px; letter-spacing: .3em; text-transform: uppercase; }
.beat.credits .text-source { margin-top: 18px; font-size: 11px; letter-spacing: .2em; color: var(--dim); }
.beat .cite {
  display: block; margin-top: 14px;
  font-size: 11px; letter-spacing: .32em; color: var(--dim); text-transform: uppercase;
  text-shadow: 0 0 10px #000;
}

.title-card { bottom: auto; top: 50%; transform: translate(-50%, -50%); }
.title-card h1 {
  margin: 18px 0 26px; font-weight: 400; font-size: clamp(44px, 8vw, 92px);
  letter-spacing: .5em; margin-right: -.5em; /* optically centre tracked caps */
  text-transform: uppercase;
}
.kicker, .hint { margin: 0; font-size: 12px; letter-spacing: .34em; text-transform: uppercase; color: var(--dim); }
.hint::after { content: "↓"; display: block; margin-top: 12px; animation: drift 2.4s ease-in-out infinite; }
@keyframes drift { 50% { transform: translateY(6px); opacity: .5; } }

@media (max-width: 640px) {
  .chapter { top: 18px; left: 16px; font-size: 11px; gap: 10px; letter-spacing: .26em; }
  .progress { right: 14px; }
  .progress .label { display: none; }
  .beat { bottom: 9vh; }
}
@media (prefers-reduced-motion: reduce) {
  .hint::after { animation: none; }
}

/* Start button on the title card */
.title-card { pointer-events: auto; }
.start { display: grid; justify-items: center; gap: 18px; }
#begin {
  all: unset; cursor: pointer;
  padding: 14px 28px; border: 1px solid rgba(236, 231, 223, .35);
  font-size: 12px; letter-spacing: .34em; text-transform: uppercase; color: var(--text);
  transition: border-color .3s, background .3s;
}
#begin:hover { border-color: var(--text); background: rgba(236, 231, 223, .06); }
#begin:focus-visible { outline: 1px solid var(--text); outline-offset: 4px; }

/* Bottom-left controls */
.controls {
  position: fixed; left: 32px; bottom: 26px;
  display: flex; gap: 22px;
}
.controls button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px;
  font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--dim);
  transition: color .3s; text-shadow: 0 0 10px #000;
}
.controls button:hover, .controls button[aria-pressed="true"] { color: var(--text); }
.controls button:focus-visible { outline: 1px solid var(--text); outline-offset: 4px; }
.controls .icon { width: 9px; height: 9px; display: inline-block; position: relative; }
/* auto-play: a triangle, or two bars when playing */
#btn-auto .icon { border-left: 9px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; width: 0; height: 0; }
#btn-auto[aria-pressed="true"] .icon { border: 0; width: 9px; height: 10px; background: linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px, currentColor 6px 9px); }
/* sound: a dot that rings when on */
#btn-sound .icon { border-radius: 50%; border: 1px solid currentColor; }
#btn-sound[aria-pressed="true"] .icon { background: currentColor; box-shadow: 0 0 0 3px rgba(236, 231, 223, .15); }

@media (max-width: 640px) {
  .controls { left: 16px; bottom: max(16px, env(safe-area-inset-bottom)); gap: 16px; }
  .controls button { padding: 8px 0; } /* a finger-sized target */
  .beat { bottom: calc(12vh + env(safe-area-inset-bottom)); }

  /* The title must fit a 320px screen with its tracking. */
  .title-card h1 { font-size: min(44px, 10vw); letter-spacing: .38em; margin-right: -.38em; }
  .kicker, .hint { letter-spacing: .24em; }

  /* Chapter ticks: a row of dashes at the top right, clear of the text. */
  .progress { top: 4px; right: 10px; transform: none; }
  .progress ol { grid-auto-flow: column; gap: 0; }
  .progress button { padding: 16px 5px; gap: 0; }
  .progress button .n { display: none; }
  .progress button::after { width: 14px; }
  .progress button[aria-current="true"]::after { width: 28px; }
}
