/* Tokens
   night   #0a0e27  base sky and panels
   ink     #ecefff  text
   haze    #a3a9d4  secondary text
   bus     #5ef2ff  the message bus
   candle  #ffb347  birthday warmth
   station accents are set per card via --accent and match the 3D pad rings */
:root {
  --night: #0a0e27;
  --ink: #ecefff;
  --haze: #a3a9d4;
  --bus: #5ef2ff;
  --candle: #ffb347;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Golos Text", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--night);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

#world, #confetti, .poster {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
}
#world { z-index: 0; }
#confetti { z-index: 3; pointer-events: none; }
.poster {
  z-index: 0;
  background:
    radial-gradient(70% 45% at 50% 100%, rgba(255, 179, 71, 0.28), transparent 70%),
    linear-gradient(#05071a, var(--night) 55%, #1a1436);
}
body.webgl .poster { display: none; }

/* loader: the name, then the bus fills */
.loader {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: var(--night);
  transition: opacity 0.9s ease, visibility 0.9s;
}
.loader.done { opacity: 0; visibility: hidden; }
.loader__word { margin: 0; font: italic 600 64px/1 var(--serif); color: var(--candle); }
.loader__bar { display: block; width: 180px; height: 2px; background: rgba(94, 242, 255, 0.15); }
.loader__bar i { display: block; height: 100%; width: 0; background: var(--bus); box-shadow: 0 0 10px var(--bus); transition: width 0.3s; }

/* top bar */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px clamp(18px, 3vw, 40px);
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud__brand { font: italic 600 20px var(--serif); color: var(--ink); text-decoration: none; }
.hud__sound, .again {
  font: 500 14px var(--sans);
  color: var(--ink);
  background: rgba(10, 14, 39, 0.7);
  border: 1px solid rgba(236, 239, 255, 0.22);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
.hud__sound[aria-pressed="true"] { border-color: var(--candle); color: var(--candle); }
:focus-visible { outline: 2px solid var(--bus); outline-offset: 3px; }

/* route rail: the stations, in order */
.rail {
  position: fixed; right: clamp(14px, 2.4vw, 34px); top: 50%; transform: translateY(-50%);
  z-index: 10;
}
.rail ol { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: 18px; }
.rail ol::before {
  content: ""; position: absolute; right: 4px; top: 6px; bottom: 6px; width: 1px;
  background: linear-gradient(var(--bus), rgba(94, 242, 255, 0.15));
}
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  font: 500 13px var(--sans); color: var(--haze); text-decoration: none;
  min-height: 20px;
}
.rail a i {
  position: relative; width: 9px; height: 9px; border-radius: 50%;
  background: var(--night); border: 1px solid var(--haze);
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.rail a span { opacity: 0; transition: opacity 0.3s; }
.rail a:hover span, .rail a:focus-visible span, .rail a.active span { opacity: 1; }
.rail a.active { color: var(--ink); }
.rail a.active i { background: var(--bus); border-color: var(--bus); box-shadow: 0 0 10px var(--bus); }

/* chapters */
main { position: relative; z-index: 2; }
.chapter {
  min-height: 150vh;
  display: flex;
  align-items: center;
  padding: 12vh clamp(18px, 6vw, 100px);
}
.chapter--right { justify-content: flex-end; }
.chapter--hero { min-height: 120vh; align-items: flex-start; justify-content: center; padding-top: 0; }
.chapter--finale { min-height: 160vh; align-items: flex-end; padding-bottom: 6vh; }

/* hero: the particle name sits in the sky above; this block sits under it */
.hero {
  margin-top: 50vh;
  max-width: 640px;
  text-align: center;
  text-shadow: 0 2px 18px var(--night), 0 0 36px var(--night);
}
.hero__title {
  margin: 0;
  font: 600 clamp(40px, 6.4vw, 88px)/1 var(--serif);
  letter-spacing: -0.01em;
}
.hero__en { margin: 10px 0 26px; font: italic 500 clamp(20px, 2.2vw, 28px) var(--serif); color: var(--candle); }
.hero__lede { margin: 0 auto; max-width: 30em; font-size: 17px; color: var(--ink); }
.hero__hint { margin: 30px 0 0; font-size: 14px; color: var(--haze); }

/* message slip */
.card {
  --accent: var(--bus);
  max-width: 460px;
  padding: 22px 28px 24px;
  background: rgba(10, 14, 39, 0.86);
  border-left: 2px solid var(--accent);
  border-radius: 2px 10px 10px 2px;
  box-shadow: 0 24px 60px rgba(2, 3, 12, 0.5), inset 0 0 0 1px rgba(236, 239, 255, 0.06);
  opacity: 0;
  transition: opacity 0.8s ease;
}
.card.in { opacity: 1; }
.card--finale { max-width: 480px; }

.card__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding-bottom: 10px; margin-bottom: 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.card__place { font: italic 600 22px var(--serif); color: var(--accent); }
.card__years { font: 500 14px var(--sans); color: var(--haze); font-variant-numeric: tabular-nums; }

h2 { font: 600 clamp(30px, 3vw, 40px)/1.05 var(--serif); margin: 0 0 14px; }
.card p { margin: 0 0 12px; }
.card b { font-weight: 600; color: var(--accent); }
.card .en { color: var(--haze); font-size: 15px; margin-top: 14px; }

/* AIR chat */
.chat { margin-top: 18px; display: grid; gap: 8px; font-size: 15px; }
.chat p { margin: 0; padding: 8px 14px; max-width: 86%; border-radius: 16px; }
.chat__me { justify-self: end; background: rgba(181, 156, 255, 0.24); border-bottom-right-radius: 4px; }
.chat__air { background: rgba(94, 242, 255, 0.08); border: 1px solid rgba(94, 242, 255, 0.24); border-bottom-left-radius: 4px; }

/* finale */
.blow {
  margin-top: 8px;
  font: 600 16px var(--sans);
  padding: 13px 26px;
  color: #241300;
  background: var(--candle);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(255, 179, 71, 0.16), 0 0 34px rgba(255, 179, 71, 0.45);
  transition: transform 0.2s;
}
.blow:hover { transform: scale(1.03); }
.blow[disabled] { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }

.wish { margin-top: 22px; }
.term {
  font: 12px/1.7 var(--mono); color: #b8ffcf;
  background: rgba(0, 0, 0, 0.4); border-radius: 8px;
  padding: 14px 16px; white-space: pre-wrap; margin: 0 0 16px; min-height: 9em;
}
.badges { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.badges li {
  font: 500 13px var(--sans);
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(236, 239, 255, 0.18);
}
.badges span { color: var(--haze); margin-left: 4px; font-variant-numeric: tabular-nums; }
.badges__new {
  color: #241300; background: var(--candle); border-color: var(--candle) !important;
  animation: pop 0.6s 3s both cubic-bezier(.3, 1.6, .5, 1);
}
.badges__new span { color: #5a3500; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

.wish__ru { font: 500 22px/1.4 var(--serif); }
.sign { font: italic 600 26px var(--serif); color: var(--candle); text-align: right; margin-top: 10px !important; }

.foot { position: relative; z-index: 2; text-align: center; padding: 30px 16px 40px; font-size: 13px; color: var(--haze); }

@media (max-width: 760px) {
  body { font-size: 15px; }
  .chapter, .chapter--right { justify-content: center; align-items: flex-end; padding: 0 14px 8vh; }
  .chapter--hero { align-items: flex-start; }
  .hero { margin-top: 44vh; }
  .hero__lede { font-size: 15px; }
  .card { max-width: 100%; padding: 16px 18px 18px; }
  .card p { line-height: 1.5; margin-bottom: 8px; }
  .card .en { font-size: 13px; }
  h2 { font-size: 28px; margin-bottom: 10px; }
  .card__place { font-size: 20px; }
  .card__head { margin-bottom: 12px; }
  .chat { font-size: 13px; gap: 6px; }
  .chat p { padding: 6px 11px; }
  .term { font-size: 10px; padding: 10px 12px; min-height: 0; }
  .wish__ru { font-size: 19px; }
  .rail { display: none; }
  .hud { background: linear-gradient(var(--night), rgba(10, 14, 39, 0)); padding: 12px 14px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; opacity: 1; }
  .badges__new { animation: none; }
}
