:root {
  --ink: #f4ede2;
  --ink-dim: rgba(244, 237, 226, 0.55);
  --amber: #ffb06b;
  --amber-dim: rgba(255, 176, 107, 0.75);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --serif-display: 'Cormorant Garamond', Georgia, serif;
  --serif-body: 'Newsreader', Georgia, serif;
}

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

html { scroll-behavior: auto; }

body {
  background: #000;
  color: var(--ink);
  font-family: var(--serif-body);
  overflow-x: hidden;
}

::selection { background: var(--amber); color: #000; }

#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
}
body.loaded #gl { opacity: 1; }

body.no-webgl #gl { display: none; }
body.no-webgl::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 55%, rgba(255, 140, 60, 0.28), transparent 60%),
    radial-gradient(circle 90px at 50% 55%, #000 60%, rgba(255, 170, 90, 0.5) 72%, transparent 78%),
    #000;
}

#veil {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}

#ember {
  position: fixed;
  left: 50%;
  top: 44%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffc890;
  box-shadow: 0 0 22px 5px rgba(255, 160, 70, 0.55), 0 0 70px 18px rgba(255, 120, 40, 0.18);
  opacity: 0;
  transition: opacity 2.5s ease;
  z-index: 3;
  pointer-events: none;
}
#ember.on { opacity: 1; animation: breathe 4.5s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); filter: brightness(0.75); }
  50% { transform: scale(1.35); filter: brightness(1.2); }
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.1rem 1.5rem 2.2rem;
  z-index: 20;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease 0.6s;
}
body.loaded #hud { opacity: 1; }

.hud-left { display: flex; flex-direction: column; gap: 0.35rem; }
.hud-title { color: var(--ink-dim); }
.hud-sub { color: var(--amber-dim); font-size: 0.6rem; }

.hud-right { display: flex; gap: 1.8rem; text-align: right; }
.ro { display: flex; flex-direction: column; gap: 0.35rem; }
.ro label { color: rgba(244, 237, 226, 0.35); font-size: 0.6rem; }
.ro span { color: var(--amber-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- rail ---------- */

#rail {
  position: fixed;
  right: 1.6rem;
  top: 14vh;
  bottom: 14vh;
  width: 1px;
  background: rgba(255, 246, 230, 0.12);
  z-index: 20;
  opacity: 0;
  transition: opacity 2s ease 1s;
}
body.loaded #rail { opacity: 1; }

.tick {
  position: absolute;
  right: 0;
  width: 7px;
  height: 1px;
  background: rgba(255, 246, 230, 0.28);
}
.tick i {
  position: absolute;
  right: 13px;
  top: -0.45em;
  font-family: var(--mono);
  font-style: normal;
  font-size: 0.55rem;
  letter-spacing: 0.14em;
  color: rgba(244, 237, 226, 0.38);
  white-space: nowrap;
}
#railDot {
  position: absolute;
  right: -2.5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 2px rgba(255, 176, 107, 0.5);
}

/* ---------- sections ---------- */

main { position: relative; z-index: 10; }

section.beat {
  min-height: 185vh;
  display: grid;
  align-items: center;
  position: relative;
}

section.beat.hero { min-height: 100vh; }
section.beat.interlude { min-height: 210vh; }

.card {
  width: min(37rem, 88vw);
  margin-left: clamp(1.5rem, 9vw, 11rem);
  padding: 2.4rem 2.6rem;
  background: rgba(4, 5, 9, 0.44);
  border: 1px solid rgba(255, 246, 230, 0.08);
  border-radius: 3px;
  -webkit-backdrop-filter: blur(14px) saturate(0.9);
  backdrop-filter: blur(14px) saturate(0.9);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.card.in { opacity: 1; transform: none; }

section.right .card { margin-left: auto; margin-right: clamp(1.5rem, 9vw, 11rem); }

section.center .card,
.herocard {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  background: none;
  border: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.kicker {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  color: var(--amber-dim);
  margin-bottom: 1.3rem;
}

h2 {
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  line-height: 1.15;
  margin-bottom: 1.1rem;
  letter-spacing: 0.01em;
}

.card p:not(.kicker):not(.data):not(.sources):not(.fine):not(.endnote) {
  font-size: 1.06rem;
  font-weight: 300;
  line-height: 1.78;
  color: rgba(244, 237, 226, 0.92);
}

.data {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: rgba(244, 237, 226, 0.42);
  border-top: 1px solid rgba(255, 246, 230, 0.1);
  margin-top: 1.6rem;
  padding-top: 1.1rem;
}

/* ---------- hero ---------- */

.herocard { padding-top: 0; }

h1 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(2.7rem, 7.5vw, 6rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0.45em 0 0.55em;
  text-shadow: 0 2px 26px rgba(0, 0, 0, 0.7), 0 0 70px rgba(255, 150, 80, 0.3);
}

.hero .sub {
  font-style: italic;
  font-size: clamp(1rem, 2vw, 1.2rem);
  color: rgba(244, 237, 226, 0.78);
  max-width: 34rem;
  margin: 0 auto;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.5);
}
.hero .kicker { text-shadow: 0 1px 14px rgba(0, 0, 0, 0.8); }

#hint {
  position: absolute;
  bottom: 3.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.3em;
  color: rgba(244, 237, 226, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  transition: opacity 0.8s ease;
}
#hint .line {
  display: block;
  width: 1px;
  height: 44px;
  background: linear-gradient(rgba(255, 176, 107, 0), var(--amber));
  animation: drop 2.2s ease-in-out infinite;
}
@keyframes drop {
  0% { transform: scaleY(0); transform-origin: top; opacity: 0; }
  40% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1) translateY(10px); opacity: 0; }
}

/* ---------- interlude / end ---------- */

.lastline {
  font-family: var(--serif-body);
  font-style: italic;
  font-size: clamp(1.2rem, 2.4vw, 1.5rem);
  color: rgba(244, 237, 226, 0.75);
}

.endcard .endnote {
  font-size: 1.02rem;
  font-weight: 300;
  line-height: 1.75;
  color: rgba(244, 237, 226, 0.8);
  max-width: 32rem;
  margin: 0 auto 1.6rem;
}
.endcard .sources {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: rgba(244, 237, 226, 0.4);
  margin-bottom: 2.4rem;
}
.endcard .fine {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  line-height: 1.9;
  color: rgba(244, 237, 226, 0.32);
  max-width: 28rem;
  margin: 2.6rem auto 0;
}

#again {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
  background: none;
  border: 1px solid rgba(255, 176, 107, 0.55);
  padding: 0.85em 1.9em;
  cursor: pointer;
  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}
#again:hover {
  background: var(--amber);
  color: #000;
  box-shadow: 0 0 34px rgba(255, 176, 107, 0.35);
}

/* ---------- responsive / motion ---------- */

@media (max-width: 760px) {
  #rail { display: none; }
  #roVwrap { display: none; }
  .hud-right { gap: 1.1rem; }
  .card {
    margin-left: auto;
    margin-right: auto;
    padding: 1.7rem 1.5rem;
  }
  section.right .card { margin-left: auto; margin-right: auto; }
  section.beat { min-height: 165vh; }
}

.dbg *, .dbg #gl, .dbg #hud, .dbg #rail { transition: none !important; animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .card { transition: opacity 0.4s ease; transform: none; }
  #hint .line { animation: none; }
  #ember.on { animation: none; }
}
