/* The animated matrix site: one full-screen scene, and text set straight on
   it without panels. */
:root {
  --ink: #f4ecdc;
  --dim: rgba(244, 236, 220, 0.62);
  --gold: #e8c78c;
  --line: rgba(244, 236, 220, 0.42);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #03050b; color: var(--ink); font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* The opening film lies over the scene. On a wide screen its box is the whole
   screen. On an upright phone the box is a near-square across the middle, so
   about half of the film's width is in view (the toono, the ger and both
   animals whole), and its top and bottom melt into
   the dark. The script sizes the box and slides the film inside it. */
.filmbox { position: fixed; left: 0; top: 0; overflow: hidden; background: #03050b; pointer-events: none; }
.filmbox video { position: absolute; left: 0; top: 0; max-width: none; will-change: transform; }
/* Above and below the box the screen carries on the film's own edge colours, sinking
   into the dark (main.js, drawGlow: a few patches of colour on a tiny canvas, which
   the browser spreads smoothly over the screen). The film melts into them at its top
   and bottom along an eased curve, so the screen is one picture and the box has no edge. */
.filmglow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; background: #03050b; }
.filmbox--tall { background: none; }
.filmbox--tall video {
  --melt: linear-gradient(transparent, rgba(0,0,0,0.1) 4%, rgba(0,0,0,0.5) 10%, rgba(0,0,0,0.9) 16%, #000 20%,
    #000 80%, rgba(0,0,0,0.9) 84%, rgba(0,0,0,0.5) 90%, rgba(0,0,0,0.1) 96%, transparent);
  -webkit-mask-image: var(--melt); mask-image: var(--melt);
}
#veil { position: fixed; inset: 0; pointer-events: none; background: #03050b; opacity: 1; }

.ghost {
  background: none; border: 0; padding: 10px 6px; cursor: pointer;
  font: 500 12px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
  transition: color 0.3s;
}
.ghost:hover { color: var(--ink); }
/* the top right corner: leaving the intro, and the song */
.corner { position: fixed; top: 12px; right: 22px; z-index: 2; display: flex; align-items: center; gap: 10px; }

/* The song's button. The picture shows how things are now (a speaker that
   sounds, or a silenced one), the words say what a press will do. Closed, it
   is gold and asks to be pressed; open, it steps back and only its waves move. */
.sound {
  display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 16px 0 13px; cursor: pointer;
  background: rgba(3, 5, 11, 0.55); border: 1px solid var(--gold); border-radius: 999px;
  font: 500 11px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold);
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.sound:hover { background: rgba(232, 199, 140, 0.14); }
.sound:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sound__icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound__body { fill: currentColor; stroke-width: 1; }
.sound__wave, .sound__mute { transition: opacity 0.3s; }
.sound__wave { opacity: 0; }
.sound__label { white-space: nowrap; }

.sound[data-state="on"] { border-color: var(--line); color: var(--ink); }
.sound[data-state="on"]:hover { border-color: var(--ink); background: rgba(244, 236, 220, 0.08); }
.sound[data-state="on"] .sound__mute, .sound[data-state="loading"] .sound__mute { opacity: 0; }
.sound[data-state="on"] .sound__wave { opacity: 1; stroke: var(--gold); animation: sound-wave 1.8s ease-in-out infinite; }
.sound[data-state="on"] .sound__wave--2 { animation-delay: 0.3s; }
.sound[data-state="loading"] .sound__wave { animation: sound-wave 0.9s ease-in-out infinite; }
.sound[data-state="loading"] .sound__wave--2 { animation-delay: 0.3s; }
@keyframes sound-wave { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* a visitor who has not chosen yet: three slow rings ask for a press */
.sound--invite { animation: sound-invite 2.6s ease-out 1.2s 3; }
@keyframes sound-invite {
  0% { box-shadow: 0 0 0 0 rgba(232, 199, 140, 0.55); }
  70%, 100% { box-shadow: 0 0 0 14px rgba(232, 199, 140, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .sound--invite, .sound .sound__wave { animation: none !important; }
}

.caption {
  position: fixed; left: 0; right: 0; bottom: 11vh; margin: 0; padding: 0 24px;
  text-align: center; pointer-events: none; opacity: 0;
  font: italic 500 clamp(21px, 2.7vw, 32px)/1.3 var(--serif);
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.85);
}
.loader {
  position: fixed; inset: 0; margin: 0; display: grid; place-items: center; pointer-events: none;
  font: italic 500 22px var(--serif); color: var(--dim); transition: opacity 0.4s;
}
.loader.gone { opacity: 0; }

/* the start screen: one gold ring that fills as the song and the films load, and
   opens into a press when they are in */
.start {
  --p: 0;
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 50%, rgba(232, 199, 140, 0.06), transparent 40%), #03050b;
  transition: opacity 0.9s ease;
}
.start.gone { opacity: 0; pointer-events: none; }
.start__go {
  position: relative; width: 132px; height: 132px; border: 0; border-radius: 50%; padding: 0;
  background: none; cursor: pointer; color: var(--dim);
}
.start__go:disabled { cursor: progress; }
.start__ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--p) * 360deg), rgba(232, 199, 140, 0.14) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 1.5px), #000 calc(100% - 1px));
  transition: background 0.3s;
}
.start__word {
  position: relative; font: 500 12px/1 var(--sans); letter-spacing: 0.24em; text-transform: uppercase;
  opacity: 0.35; transition: opacity 0.6s, color 0.6s;
}
.start.ready .start__word { opacity: 1; color: var(--gold); }
.start.ready .start__ring { box-shadow: 0 0 28px rgba(232, 199, 140, 0.25); animation: start-breathe 2.6s ease-in-out infinite; }
.start.ready .start__go:hover .start__ring { box-shadow: 0 0 36px rgba(232, 199, 140, 0.45); }
@keyframes start-breathe { 50% { box-shadow: 0 0 40px rgba(232, 199, 140, 0.4); } }

.cta {
  background: none; border: 1px solid var(--gold); border-radius: 999px; padding: 13px 28px; cursor: pointer;
  font: 500 12px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold);
  transition: background 0.3s, color 0.3s;
}
.cta:hover, .cta:focus-visible { background: var(--gold); color: #0a0d16; outline: 0; }
.cta--small { padding: 10px 20px; font-size: 11px; }

/* the birth form */
.birth {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 0 24px 34px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  opacity: 0; transform: translateY(14px); transition: opacity 1s, transform 1s;
}
.birth.on { opacity: 1; transform: none; }
.birth__lead { margin: 0; font: italic 500 24px/1.2 var(--serif); }
.birth__row { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 18px 22px; }
.birth label {
  display: flex; flex-direction: column; gap: 7px;
  font: 500 10px/1 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--dim);
}
.birth input {
  width: 62px; padding: 5px 2px 7px; background: none; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  font: 400 17px/1 var(--sans); color: var(--ink); outline: 0; transition: border-color 0.3s;
}
.birth .wide input { width: 132px; }
.birth input:focus { border-color: var(--gold); }
.gender { display: flex; gap: 6px; }
.gender button {
  background: none; border: 0; border-bottom: 1px solid transparent; padding: 9px 4px 8px; cursor: pointer;
  font: 500 12px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim);
  transition: color 0.3s, border-color 0.3s;
}
.gender button[aria-checked="true"] { color: var(--gold); border-color: var(--gold); }
.birth__error { margin: -6px 0 0; min-height: 16px; font: 400 13px/1.2 var(--sans); color: #ffb49a; }

/* the amin too */
.amin {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 0 24px 38px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  opacity: 0; transition: opacity 1.4s 1.5s;
}
.amin.on { opacity: 1; }
.amin__who { margin: 0; font: 500 11px/1.4 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.kicker { margin: 8px 0 0; font: 500 11px/1.4 var(--sans); letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold); }
.amin h1 { margin: 0; font: 600 clamp(36px, 5.2vw, 60px)/1.05 var(--serif); }
.amin__name { margin: 0; font: italic 500 21px/1.2 var(--serif); color: var(--gold); }
.amin__text p { margin: 0; }
.amin__text p:empty { display: none; }
.amin__figure { margin: 12px auto; max-width: 520px; }
.amin__figure-head {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 2px 10px;
  font: 500 10px/1.4 var(--sans); letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold);
}
.amin__figure-head span { font: 500 20px/1.2 var(--serif); letter-spacing: 0.02em; text-transform: none; color: #f4ecdc; }
.amin__figure-story { margin-top: 4px !important; font: italic 400 17px/1.5 var(--serif); color: rgba(244, 236, 220, 0.78); }
.amin__figure-more { display: none; }
.amin__keys { margin: 4px 0 0; font: 500 11px/1.5 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
.amin__text { max-width: 580px; margin: 6px 0 12px; font: 400 15px/1.7 var(--sans); color: rgba(244, 236, 220, 0.84); }
.amin__actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }

/* travelling the matrix */
.journey {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 70px 24px 26px; text-align: center;
  background: linear-gradient(rgba(3, 5, 11, 0), rgba(3, 5, 11, 0.86) 62%);
  opacity: 0; transition: opacity 0.9s;
}
.journey.on { opacity: 1; }
.journey__hint { margin: 0 0 10px; font: italic 500 22px/1.2 var(--serif); }
.journey__pay {
  margin: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px;
  font: 400 13px/1.4 var(--sans); color: var(--dim);
}
/* the chapters of one stop */
.reading {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(47vw, 660px); padding: 84px 48px 22px 110px;
  display: flex; flex-direction: column;
  background: linear-gradient(to right, rgba(3, 5, 11, 0), rgba(3, 5, 11, 0.86) 30%);
  opacity: 0; transition: opacity 0.8s;
}
.reading.on { opacity: 1; }
.reading__scroll {
  flex: 1; overflow-y: auto; padding: 18px 16px 34px 0;
  scrollbar-width: thin; scrollbar-color: rgba(244, 236, 220, 0.25) transparent;
  -webkit-mask-image: linear-gradient(transparent, #000 26px, #000 calc(100% - 38px), transparent);
  mask-image: linear-gradient(transparent, #000 26px, #000 calc(100% - 38px), transparent);
}
.reading__scroll { transition: opacity 0.3s ease; }
.reading__scroll.swap { opacity: 0; transition-duration: 0.2s; }
.reading .kicker { margin: 0; }
.reading h2 { margin: 8px 0 26px; font: 600 clamp(36px, 4vw, 54px)/1.05 var(--serif); }
.chapter { margin: 0 0 38px; }
.chapter h3 { margin: 0 0 4px; font: 600 28px/1.15 var(--serif); color: var(--gold); }
.chapter__asks { margin: 0 0 6px; font: italic 500 18px/1.35 var(--serif); color: var(--dim); }
.chapter h4 { margin: 16px 0 5px; font: 500 10px/1 var(--sans); letter-spacing: 0.26em; text-transform: uppercase; color: var(--dim); }
.chapter p:not(.chapter__asks) { margin: 0; font: 400 15px/1.72 var(--sans); color: rgba(244, 236, 220, 0.9); }
.reading__p, .blessing { margin: 0 0 16px; font: 400 15px/1.72 var(--sans); color: rgba(244, 236, 220, 0.9); }
.reading__p + .chapter { margin-top: 30px; }
.chapter__open {
  margin: 4px 0 0; padding: 6px 14px; border: 1px solid rgba(232, 199, 140, 0.5); border-radius: 999px; background: none; cursor: pointer;
  font: 500 11px/1.4 var(--sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold);
}
.blessing { margin-top: -10px; font: italic 500 21px/1.4 var(--serif); color: var(--gold); }
.reading__ask { margin: -14px 0 24px; font: italic 500 19px/1.35 var(--serif); color: var(--dim); }
.reading__list { margin: 8px 0 0; padding-left: 18px; font: 400 15px/1.7 var(--sans); color: rgba(244, 236, 220, 0.9); }
.reading__list li { margin-bottom: 6px; }
.famous { margin: 10px 0 0; padding: 0; list-style: none; }
.famous li { margin: 0 0 14px; }
.famous b { margin-right: 10px; font: 600 20px/1.2 var(--serif); }
.famous span { font: 500 11px/1 var(--sans); letter-spacing: 0.08em; color: var(--gold); }
.famous small { display: block; margin-top: 2px; font: 400 13px/1.45 var(--sans); color: var(--dim); }
.scores { margin: 0 0 24px; padding: 0; list-style: none; }
.scores li { display: grid; grid-template-columns: 130px 1fr 34px; align-items: center; gap: 12px; margin-bottom: 10px; font: 400 13px/1.2 var(--sans); color: var(--dim); }
.scores i { height: 3px; border-radius: 2px; background: rgba(244, 236, 220, 0.14); overflow: hidden; }
.scores b { display: block; height: 100%; background: var(--gold); }
.scores small { font-size: 12px; color: var(--ink); text-align: right; }
.toc { margin: 0 0 30px; }
.toc h3 { margin: 0 0 6px; font: 600 24px/1.2 var(--serif); color: var(--gold); }
.toc__row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; width: 100%; padding: 10px 0;
  background: none; border: 0; border-bottom: 1px solid rgba(244, 236, 220, 0.12); cursor: pointer;
  font: 400 15px/1.3 var(--sans); color: var(--ink); text-align: left; transition: color 0.2s;
}
.toc__row:hover, .toc__row:focus-visible { color: var(--gold); outline: 0; }
.toc__row em { font: 500 12px/1 var(--sans); letter-spacing: 0.06em; color: var(--dim); white-space: nowrap; }
.reading__nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding-top: 12px; }
#r-count { font: 500 11px/1 var(--sans); letter-spacing: 0.14em; color: var(--dim); }

@media (max-width: 640px) {
  /* on a phone the song's button keeps its words; leaving the intro sits under it */
  .corner { top: 8px; right: 10px; flex-direction: column-reverse; align-items: flex-end; gap: 2px; }
  .sound { min-height: 44px; padding: 0 14px 0 11px; gap: 7px; font-size: 10px; letter-spacing: 0.12em; }
  .birth { padding-bottom: 22px; gap: 14px; }
  .birth__lead { font-size: 21px; }
  .birth__row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 14px; width: 100%; max-width: 360px; }
  .birth input, .birth .wide input { width: 100%; }
  .gender { grid-column: 1 / 3; }
  .birth .cta { grid-column: 1 / 4; }
  .amin { padding-bottom: 24px; }
  .amin__keys { margin: 4px 0 0; font: 500 11px/1.5 var(--sans); letter-spacing: 0.2em; text-transform: uppercase; color: var(--dim); }
  .amin { gap: 6px; }
  .amin__text { font-size: 14px; line-height: 1.6; }
  .amin__figure { margin: 8px auto; }
  .amin__figure-head span { font-size: 18px; }
  .amin__figure-story { font-size: 15px; line-height: 1.45; }
}
/* a short phone keeps the figure and its story in view: the keywords and the second
   line of character wait for the reading, where both are told in full */
@media (max-width: 640px) and (max-height: 780px) {
  .amin__keys, #amin-more { display: none; }
}
/* on a phone or a short screen the figure's story opens in two lines; the whole of it
   on a tap, so the figure above keeps its room. The panel never rises above 70% of the
   screen: the figure keeps the top 30% (the scene leaves it that much, see fitDistance),
   and a long story scrolls inside the panel instead of climbing over the figure. */
@media (max-width: 640px), (max-height: 1000px) {
  .amin {
    max-height: 70dvh; overflow-y: auto; overscroll-behavior: contain; padding-top: 22px;
    -webkit-mask-image: linear-gradient(transparent, #000 22px);
    mask-image: linear-gradient(transparent, #000 22px);
  }
  .amin__figure-story.short { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .amin__figure-more {
    display: inline-block; margin: 2px auto 0; padding: 4px 10px; border: 0; background: none; cursor: pointer;
    font: 500 10px/1.4 var(--sans); letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold);
  }
}
@media (max-width: 340px) {
  /* the narrowest phones: the picture alone, the words stay for screen readers */
  .sound { padding: 0 11px; }
  .sound__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (max-width: 860px) {
  .reading {
    top: auto; left: 0; width: auto; height: 60vh; padding: 44px 20px 12px;
    background: linear-gradient(rgba(3, 5, 11, 0), rgba(3, 5, 11, 0.92) 12%);
  }
  .reading h2 { margin-bottom: 18px; font-size: 34px; }
  .chapter h3 { font-size: 24px; }
}
