:root {
  --ink: #eef3ff;
  --muted: rgba(224, 233, 255, 0.68);
  --faint: rgba(224, 233, 255, 0.38);
  --accent: #7dffc0;
  --glass: rgba(10, 16, 32, 0.38);
  --line: rgba(220, 232, 255, 0.16);
  --gutter: clamp(16px, 5vw, 72px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: #04060d; scroll-behavior: auto; }

body {
  color: var(--ink);
  background: #04060d;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: pan-y;
}

/* ---------- loading veil ---------- */
#veil {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: #03050b;
  transition: opacity 2.4s cubic-bezier(.4, 0, .2, 1) .15s, visibility 0s linear 2.6s;
}
body.ready #veil { opacity: 0; visibility: hidden; }
.veil-text {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-size: 20px;
  letter-spacing: .08em;
  color: var(--faint);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; } }

/* ---------- chapters ---------- */
main { position: relative; z-index: 2; }

.chapter {
  position: relative;
  height: 100vh;
  height: 100svh;
  display: flex;
  align-items: flex-end;
  padding: 0 var(--gutter) clamp(88px, 15vh, 170px);
  pointer-events: none;
}
.chapter .inner {
  max-width: 540px;
  opacity: var(--o, 0);
  transform: translateY(calc((1 - var(--o, 0)) * 26px));
  filter: blur(calc((1 - var(--o, 0)) * 5px));
  will-change: opacity, transform, filter;
}
.hero { --o: 1; }

.eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
  text-shadow: 0 0 18px rgba(125, 255, 192, .45);
}

h1 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 300;
  font-size: clamp(58px, 11vw, 148px);
  line-height: .86;
  letter-spacing: -.015em;
  margin-bottom: 26px;
  text-shadow: 0 4px 40px rgba(0, 0, 0, .35);
}

h2 {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(44px, 6.4vw, 84px);
  line-height: 1;
  margin-bottom: 16px;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .4);
}

p {
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.7;
  color: var(--muted);
  max-width: 400px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, .55);
}

.cta {
  pointer-events: auto;
  margin-top: 26px;
  font: 500 12px/1 "Inter", sans-serif;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 15px 24px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color .3s, background .3s, box-shadow .3s;
}
.cta:hover { border-color: rgba(125, 255, 192, .55); box-shadow: 0 0 28px rgba(125, 255, 192, .18); }

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--faint);
  opacity: var(--o, 1);
}
.scroll-hint i {
  width: 1px;
  height: 42px;
  background: linear-gradient(to bottom, transparent, var(--ink));
  animation: drip 2.2s ease-in-out infinite;
  transform-origin: top;
}
@keyframes drip {
  0% { transform: scaleY(0); opacity: 0; }
  40% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1) translateY(30px); opacity: 0; }
}

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 10; }

.brand {
  top: 26px;
  left: var(--gutter);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--ink);
}
.brand span { color: var(--accent); }

.clock {
  top: 22px;
  right: var(--gutter);
  font-family: "Cormorant Garamond", serif;
  font-size: 22px;
  font-style: italic;
  letter-spacing: .04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.track {
  right: calc(var(--gutter) + 4px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.track-label {
  font-size: 9px;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--faint);
  writing-mode: vertical-rl;
}
.track-line {
  width: 1px;
  height: 22vh;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
#fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #f6a77a, #8ea4ff 55%, var(--accent));
  transform-origin: top;
  transform: scaleY(0);
}

.sound {
  right: var(--gutter);
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font: 500 10px/1 "Inter", sans-serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color .3s, border-color .3s;
}
.sound:hover { color: var(--ink); border-color: rgba(220, 232, 255, .32); }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i {
  width: 2px;
  height: 3px;
  background: currentColor;
  border-radius: 1px;
  transition: height .3s;
}
.sound[aria-pressed="true"] { color: var(--ink); }
.sound[aria-pressed="true"] .bars i { animation: eq 1.1s ease-in-out infinite; }
.sound[aria-pressed="true"] .bars i:nth-child(2) { animation-delay: -.3s; }
.sound[aria-pressed="true"] .bars i:nth-child(3) { animation-delay: -.6s; }
.sound[aria-pressed="true"] .bars i:nth-child(4) { animation-delay: -.9s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

.foot {
  left: var(--gutter);
  bottom: 28px;
  font-size: 10px;
  letter-spacing: .08em;
  color: var(--faint);
}

#no-webgl {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: #04060d;
}
#no-webgl[hidden] { display: none; }

@media (max-width: 720px) {
  .track { display: none; }
  .brand { top: 20px; font-size: 11px; }
  .clock { top: 16px; font-size: 19px; }
  .foot { bottom: 76px; max-width: 60vw; line-height: 1.5; }
  .sound { bottom: 20px; }
  .chapter { padding-bottom: 140px; }
  .scroll-hint { bottom: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-hint i, .veil-text { animation: none; }
}
