/* You Make Me Focus. Move II: Navara's Reply.
   Black on white, one face, one weight ladder; the future-night comes in with its lines.
   One theme variable (data-theme on the room) sets every colour at once: the words, the
   mark and its arcs, the header, the way out, the rail's marker. Nothing here moves
   except by transform and opacity. */
:root {
  --ink: #000;
  --paper: #fff;
  --pearl: #f7f5ef;
  --navy: #0b1440;
  --navy-lit: #4f6cff;
  --gold: #e8b84a;
  --violet: #8b5cff;
  --cyan: #3df2ff;
  --rose: #ff7aa8;
  --ease: cubic-bezier(0.22, 0.9, 0.3, 1);
  --arrive: 640ms;
  --scene: 900ms;               /* a scene comes in over about a second */
  --flip: 160ms;                /* the words and controls turn at its midpoint, at once */
  --face: 'Unbounded', 'Outfit', system-ui, sans-serif;
  --top: calc(env(safe-area-inset-top, 0px) + 14px);
  --bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  --mark: 72px;
  --pair: 27vh;                 /* where the two centres live */
  --center: 47vh;               /* where the sung line lives */
  --rail: 63vh;                 /* where the rail begins */
}
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;              /* the room is the viewport; only the rail scrolls */
  font-family: var(--face);
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
  touch-action: manipulation;    /* no double-tap zoom on the glass */
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--ink); color: var(--paper); }

/* ── the theme: one variable, every colour ── */
.room[data-theme="night"] { --ink: var(--pearl); --paper: #070b22; }
body, .txt, .label, .top, .sung, .mark .ring, .mark .arc, .mark .pause rect, .mark .play, .act, .line::before { transition: color var(--flip), background-color var(--flip), stroke var(--flip), fill var(--flip); }
body.night-words .top, body.night-words .top a { color: var(--pearl); }
body.night-words .foot .act { background: var(--pearl); color: #000; }
.room[data-theme="night"] ::selection { background: var(--pearl); color: #000; }
.room[data-theme="night"] .sung { text-shadow: 0 0 26px rgba(79, 108, 255, .45), 0 0 2px rgba(255, 255, 255, .5); }

/* ── the future-night, and the field over it ── */
#night {
  position: fixed; inset: 0; z-index: 0;
  background: radial-gradient(ellipse at 50% 30%, #121a4e 0%, #090d2e 30%, #050718 62%, #03040f 100%);
  opacity: 0;
  transition: opacity var(--scene) linear;   /* linear, so the moment black and white read alike is a known moment */
  pointer-events: none;
}
body.night #night { opacity: 1; }
#field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }

/* ── the header ── */
.top {
  position: fixed; z-index: 3; top: var(--top); left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 0 20px;
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink);
}
.home { text-decoration: none; }
.name { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
/* ── the mark: the control, and two fine arcs ── */
.mark {
  position: fixed; z-index: 4;
  top: calc(var(--top) + 44px); left: 50%;
  width: var(--mark); height: var(--mark);
  margin-left: calc(var(--mark) / -2);
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.mark:focus-visible { outline: 3px solid var(--ink); outline-offset: 6px; }
.mark svg { display: block; width: 100%; height: 100%; overflow: visible; will-change: transform; }
.mark .ring { fill: none; stroke: var(--ink); stroke-width: 7; transition: stroke-width 500ms var(--ease), opacity 500ms, stroke var(--flip); }
.mark .arc { fill: none; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; opacity: 0; transition: opacity 500ms, stroke var(--flip); }
.mark .arc-a { stroke: var(--ink); stroke-width: 3; stroke-dasharray: 289 289; stroke-dashoffset: 289; }
.mark .arc-n { stroke: var(--navy); stroke-width: 2.2; stroke-dasharray: 251 251; stroke-dashoffset: 251; }
.room[data-theme="night"] .mark .arc-n { stroke: var(--cyan); }
.mark .pause rect, .mark .play { fill: var(--ink); transition: opacity 200ms, transform 300ms var(--ease), fill var(--flip); transform-origin: 50% 50%; }
.mark .play { opacity: 0; transform: scale(.7); }
/* at rest and paused the mark offers play; playing, the ring thins and the two arcs carry the two paths */
.room[data-state="rest"] .mark .pause rect, .room[data-state="pause"] .mark .pause rect { opacity: 0; transform: scale(.7); }
.room[data-state="rest"] .mark .play, .room[data-state="pause"] .mark .play { opacity: 1; transform: scale(1); }
.room[data-state="play"] .mark .ring, .room[data-state="pause"] .mark .ring { stroke-width: 1.6; }
.room[data-state="play"] .mark .arc, .room[data-state="pause"] .mark .arc { opacity: 1; }
.mark.synced .arc-n { stroke: var(--gold); }

/* ── the relic ── */
.cover {
  position: fixed; z-index: 3; left: 50%; top: calc(var(--pair) + 8vh);
  width: min(58vw, 280px); height: min(58vw, 280px);
  margin: calc(min(58vw, 280px) / -2) 0 0 calc(min(58vw, 280px) / -2);
  border-radius: 26px; overflow: hidden;
  transform: scale(1); opacity: 1;
  transition: transform 900ms var(--ease), opacity 700ms;
  -webkit-tap-highlight-color: transparent;
}
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover:focus-visible { outline: 3px solid var(--ink); outline-offset: 6px; }
.cover.away { transform: scale(.42); opacity: 0; pointer-events: none; }
.cover.back { transform: scale(1); opacity: 1; }
/* the engraved letters, lit one after another when play is pressed */
.glints { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.glints i {
  position: absolute; top: 47%; width: 5.5%; height: 5.5%; border-radius: 50%;
  background: radial-gradient(circle, #fff5c8 0%, rgba(232, 184, 74, .85) 35%, rgba(232, 184, 74, 0) 70%);
  opacity: 0; transform: translate(-50%, -50%) scale(.4);
  transition: opacity 260ms, transform 360ms var(--ease);
}
.glints i:nth-child(1) { left: 27%; } .glints i:nth-child(2) { left: 32.5%; } .glints i:nth-child(3) { left: 38%; } .glints i:nth-child(4) { left: 43.5%; } .glints i:nth-child(5) { left: 49%; }
.cover.lit .glints i { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cover.lit .glints i:nth-child(2) { transition-delay: 140ms; } .cover.lit .glints i:nth-child(3) { transition-delay: 280ms; } .cover.lit .glints i:nth-child(4) { transition-delay: 420ms; } .cover.lit .glints i:nth-child(5) { transition-delay: 560ms; }

/* ── the sung line ── */
.stage {
  position: fixed; z-index: 2;
  left: 0; right: 0; top: var(--center);
  transform: translateY(-50%);
  padding: 0 22px;
  text-align: center;
  pointer-events: none;
}
.sung {
  --wdur: 320ms;
  margin: 0 auto; max-width: 14ch;
  font-size: clamp(2rem, 8.2vw, 4.2rem);
  font-weight: 800; line-height: 1.04; letter-spacing: -0.02em;
  text-wrap: balance;
  color: var(--ink);
  transition: transform 320ms var(--ease), opacity 260ms, color var(--flip);
}
.sung .w { display: inline-block; opacity: 0; transform: translateY(.4em); transition: transform var(--wdur) var(--ease), opacity calc(var(--wdur) * .7), color 400ms; }
.sung .w.on { opacity: 1; transform: none; }
/* the words that carry the meaning */
.sung .w.key { font-weight: 900; }
.sung .w.key.on { transform: scale(1.05); }
.sung .w.key[data-key="gold"] { color: var(--gold); }
.sung .w.key[data-key="cyan"] { color: #0aa9b9; }
.sung .w.key[data-key="rose"] { color: #e0457f; }
.sung .w.key[data-key="violet"] { color: var(--violet); }
.sung .w.key[data-key="navy"] { color: var(--navy); }
.room[data-theme="night"] .sung .w.key[data-key="cyan"] { color: var(--cyan); }
.room[data-theme="night"] .sung .w.key[data-key="rose"] { color: var(--rose); }
.room[data-theme="night"] .sung .w.key[data-key="navy"] { color: var(--pearl); }
.sung.gone { position: absolute; left: 22px; right: 22px; top: 0; opacity: 0; transform: translateY(-.35em) scale(.95); }
.sung.gone .w { transition: none; }

/* ── the rail ── */
.lines {
  position: fixed; z-index: 1;
  left: 0; right: 0;
  top: var(--rail);
  bottom: calc(var(--bottom) + 58px);
  margin: 0; padding: 18px 20px 0 28px;
  list-style: none;
  overflow-y: auto; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(transparent, #000 10%, #000 92%, transparent);
  mask-image: linear-gradient(transparent, #000 10%, #000 92%, transparent);
}
.lines::-webkit-scrollbar { width: 0; height: 0; }
.lines::after { content: ''; display: block; height: 60vh; }
.line { margin: 0; position: relative; }
.line::before { content: ''; position: absolute; left: -14px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: #0aa9b9; opacity: 0; transform: scale(.4); transition: opacity 300ms, transform 300ms var(--ease); }
.line.now::before { opacity: 1; transform: scale(1); }
.room[data-theme="night"] .line::before { background: var(--cyan); }
.room[data-scene="truth"] .line::before, .room[data-scene="believe"] .line::before, .room[data-scene="two"] .line::before { background: var(--gold); }
.label { display: block; margin: 22px 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.line:first-child .label { margin-top: 0; }
.txt {
  display: block; width: 100%; text-align: left;
  padding: 7px 0; min-height: 40px;
  font-size: 1.02rem; font-weight: 500; line-height: 1.3; letter-spacing: -0.005em;
  color: var(--ink);
  transform-origin: 0 50%;
  transition: transform 320ms var(--ease), opacity 400ms, color var(--flip);
  -webkit-tap-highlight-color: transparent;
}
.txt:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.line.now .txt { font-weight: 800; transform: scale(1.12); }
.line.past .txt { font-weight: 400; opacity: .9; }

/* ── the way out ── */
.foot {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: var(--bottom);
  display: flex; gap: 10px; justify-content: center; padding: 0 20px;
}
.act {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 20px;
  border-radius: 16px;
  background: var(--ink); color: var(--paper);
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-decoration: none;
  transition: transform 220ms var(--ease), background-color var(--flip), color var(--flip);
}
.act:active { transform: scale(.96); }
.act:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* ── rooms of other sizes ── */
@media (max-height: 700px) { :root { --pair: 25vh; --center: 45vh; --rail: 62vh; } .cover { width: min(48vw, 220px); height: min(48vw, 220px); margin: calc(min(48vw, 220px) / -2) 0 0 calc(min(48vw, 220px) / -2); } }
@media (min-width: 720px) {
  :root { --mark: 84px; --pair: 30vh; --center: 50vh; --rail: 66vh; }
  .sung { max-width: 18ch; font-size: clamp(3rem, 5.6vw, 5rem); }
  .lines { left: 50%; right: auto; width: min(680px, 92vw); transform: translateX(-50%); padding-left: 16px; padding-right: 0; }
  .txt { font-size: 1.12rem; }
  .top { padding: 0 32px; }
  .cover { width: 300px; height: 300px; margin: -150px 0 0 -150px; }
}
@media (min-width: 1200px) { :root { --pair: 32vh; --center: 52vh; --rail: 68vh; } }

/* ── less motion: things appear, nothing travels ── */
@media (prefers-reduced-motion: reduce) {
  .mark, .sung, .sung .w, .txt, .act, .cover, .line::before { transition: opacity 180ms; }
  .sung .w, .sung.gone, .line.now .txt, .sung .w.key.on { transform: none; }
  .cover.away { transform: none; }
}
