/* You Make Me Motus. Black on white, one face, one weight ladder.
   Nothing here moves except by transform and opacity. */
:root {
  --ink: #000;
  --paper: #fff;
  --ease: cubic-bezier(0.22, 0.9, 0.3, 1);
  --arrive: 640ms;
  --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;
  --center: 44vh;               /* where the sung line lives: the centre of gravity */
}
* { 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 list scrolls */
  font-family: var(--face);
  font-weight: 500;
  color: var(--ink);
  background: var(--paper);
}
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 night, and the field over it ── */
#night {
  position: fixed; z-index: 0; left: 50%; top: var(--center);
  width: 300vmax; height: 300vmax; margin: -150vmax 0 0 -150vmax;
  border-radius: 50%;
  background: radial-gradient(circle at center, #171c4f 0%, #090c2a 22%, #04051a 45%, #02030c 70%);
  transform: scale(0);
  transition: transform 1100ms var(--ease);
  pointer-events: none;
}
body.night #night { transform: scale(1); }
#field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
/* in the night the words are white, the mark is white, the way out is white */
body, .txt, .label, .top, .sung, .mark .ring, .mark .prog, .mark .pause rect, .mark .play, .act { transition: color 900ms, background-color 900ms, stroke 900ms, fill 900ms; }
body.night { color: #fff; }
body.night .mark .ring, body.night .mark .prog { stroke: #fff; }
body.night .mark .pause rect, body.night .mark .play { fill: #fff; }
body.night .act { background: #fff; color: #000; }
body.night .sung { text-shadow: 0 0 28px rgba(110, 200, 255, .55), 0 0 2px rgba(255, 255, 255, .6); }
body.night ::selection { background: #fff; color: #000; }

/* ── the header ── */
.top {
  position: fixed; z-index: 3; top: var(--top); left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
}
.home { text-decoration: none; }
.title { text-align: right; }

/* ── the mark: the album art, and the control ── */
.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%;
  transform-origin: 50% 50%;
  transition: transform var(--arrive) var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.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 400ms var(--ease); }
.mark .prog { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 289 289; stroke-dashoffset: 289; transform: rotate(-90deg); transform-origin: 50% 50%;
  opacity: 0; transition: opacity 300ms; }
.mark .pause rect, .mark .play { fill: var(--ink); transition: opacity 200ms, transform 300ms var(--ease); transform-origin: 50% 50%; }
.mark .play { opacity: 0; transform: scale(.7); }
/* at rest the mark is the art, large, near the centre of the page */
.room[data-state="rest"] .mark { transform: translateY(calc(var(--center) - var(--top) - 44px - var(--mark) / 2)) scale(2.6); }
.room[data-state="play"] .mark, .room[data-state="pause"] .mark { transform: translateY(0) scale(1); }
.room[data-state="play"] .mark .ring { stroke-width: 2.4; }
.room[data-state="play"] .mark .prog, .room[data-state="pause"] .mark .prog { opacity: 1; }
.room[data-state="pause"] .mark .ring { stroke-width: 2.4; }
.room[data-state="pause"] .mark .pause rect { opacity: 0; transform: scale(.7); }
.room[data-state="pause"] .mark .play { opacity: 1; transform: scale(1); }

/* ── a cover, when the art is a photograph ── */
.cover {
  position: fixed; z-index: 3; left: 50%; top: var(--center);
  width: min(62vw, 300px); height: min(62vw, 300px);
  margin: calc(min(62vw, 300px) / -2) 0 0 calc(min(62vw, 300px) / -2);
  border-radius: 28px; object-fit: cover;
  transform: scale(1); opacity: 1;
  transition: transform var(--arrive) var(--ease), opacity 420ms;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.has-cover .room[data-state="rest"] .mark { transform: translateY(0) scale(1); }
body.has-cover .room:not([data-state="rest"]) .cover { transform: scale(.72); opacity: 0; pointer-events: none; }

/* ── 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 {
  margin: 0 auto; max-width: 14ch;
  font-size: clamp(2.1rem, 8.6vw, 4.4rem);
  font-weight: 800; line-height: 1.04; letter-spacing: -0.02em;
  text-wrap: balance;
  transition: transform 320ms var(--ease), opacity 260ms;
}
.sung .w { display: inline-block; opacity: 0; transform: translateY(.45em); transition: transform 360ms var(--ease), opacity 220ms; }
.sung .w.on { opacity: 1; transform: none; }
.sung.gone { position: absolute; left: 22px; right: 22px; top: 0; opacity: 0; transform: translateY(-.4em) scale(.94); }
.sung.gone .w { transition: none; }

/* ── the words carry their scene: time slows, the world goes, the hole takes ── */
.room[data-scene="slow"] .sung .w { transition-duration: 900ms, 700ms; }
.room[data-scene="freeze"] .sung .w { transition-duration: 0ms, 120ms; }
.room[data-scene="fade"] .sung.gone { transform: scale(1.35); transition-duration: 700ms, 600ms; }
.room[data-scene="collapse"] .sung.gone { transform: translateY(.3em) scale(.86); }
.room[data-scene="blackhole"] .sung.gone { transform: scale(.12); transition-duration: 600ms, 500ms; }
.room[data-scene="burst"] .sung.gone { transform: scale(1.5); }

/* ── every line ── */
.lines {
  position: fixed; z-index: 1;
  left: 0; right: 0;
  top: calc(var(--center) + 17vh);
  bottom: calc(var(--bottom) + 58px);
  margin: 0; padding: 22px 20px 0;
  list-style: none;
  overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth;
  -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; }
/* room under the last line, so it too can rise to the top */
.lines::after { content: ''; display: block; height: 60vh; }
.line { margin: 0; }
.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;
  transform-origin: 0 50%;
  transition: transform 320ms var(--ease);
  -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.14); }
.line.past .txt { font-weight: 500; }

/* ── 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);
}
.act:active { transform: scale(.96); }
.act:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* ── wider rooms ── */
@media (min-width: 720px) {
  :root { --mark: 84px; }
  .sung { max-width: 18ch; font-size: clamp(3rem, 6vw, 5.2rem); }
  .lines { left: 50%; right: auto; width: min(680px, 92vw); transform: translateX(-50%); padding-left: 0; padding-right: 0; }
  .txt { font-size: 1.12rem; }
  .top { padding: 0 32px; }
}

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