:root {
  --font-term: 'VT323', monospace;
  --font-arcade: 'Press Start 2P', monospace;
  --font-body: 'Archivo', sans-serif;

  --sky-1: #070912;
  --sky-2: #141a3a;
  --text: #e8ecff;
  --text-dim: #6b7299;
  --accent: #6182ff;
  --st-cyan: #18c7e6;

  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-linear: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: radial-gradient(120% 120% at 50% 20%, var(--sky-2), var(--sky-1) 70%);
  color: var(--text);
  font-family: var(--font-term);
  overflow-x: hidden;
}

body { min-height: 100vh; }

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.4;
  transition: opacity 2s var(--ease-linear);
  pointer-events: none;
  z-index: 0;
}
.stage[data-phase="imminent"] ~ #starfield,
body:has(.stage[data-phase="imminent"]) #starfield,
body[data-phase="imminent"] #starfield { opacity: 1; }

.scan {
  position: fixed;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
  opacity: 0;
  top: -2px;
  pointer-events: none;
  z-index: 5;
}
.scan.active {
  opacity: 0.5;
  animation: sweep 10s linear infinite;
}
@keyframes sweep {
  from { transform: translateY(0); }
  to { transform: translateY(100vh); }
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vh 5vw 12vh;
  gap: 1.2rem;
}

.eyebrow {
  font-family: var(--font-arcade);
  font-size: 11px;
  letter-spacing: 0.25em;
  color: var(--text-dim);
}

.headline {
  font-family: var(--font-term);
  font-weight: 400;
  font-size: clamp(28px, 6vw, 56px);
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--text);
}

.subline {
  font-size: clamp(16px, 3vw, 24px);
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.countdown {
  font-family: var(--font-term);
  font-size: clamp(48px, 14vmin, 180px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.act-line {
  min-height: 1.6em;
  font-size: clamp(18px, 3.4vw, 30px);
  letter-spacing: 0.08em;
  color: var(--text);
}

.waveform-wrap {
  width: min(90vw, 640px);
  height: 90px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.6s var(--ease-linear);
}
.waveform-wrap.visible { opacity: 1; }
#waveform { width: 100%; height: 100%; }

.carrier-bar {
  margin-top: 1rem;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15em;
}
.carrier-line1 {
  font-size: clamp(20px, 4vw, 30px);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.carrier-line2 {
  font-size: clamp(14px, 2.4vw, 18px);
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* Digit flip — only the changed column moves */
.digit {
  display: inline-block;
  transition: transform 340ms var(--ease-spring), opacity 340ms var(--ease-spring);
}
.digit.flip {
  animation: flip-decay 1200ms var(--ease-linear);
}
@keyframes flip-decay {
  0%   { transform: translateY(-0.4em); opacity: 0.2; }
  30%  { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(0); opacity: 1; text-shadow: 0 0 0 transparent; }
}

.audio-enable {
  margin-top: 1.5rem;
  background: transparent;
  border: 1px solid var(--text-dim);
  color: var(--text-dim);
  font-family: var(--font-term);
  font-size: 16px;
  letter-spacing: 0.08em;
  padding: 0.5em 1.2em;
  border-radius: 2px;
  cursor: pointer;
}
.audio-enable:hover { color: var(--text); border-color: var(--accent); }

.foot {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0.8em 1.4em;
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  z-index: 1;
}

/* Phase-specific rules */
.stage[data-phase="approach"] .act-line,
.stage[data-phase="approach"] .waveform-wrap { display: none; }

.stage[data-phase="imminent"] .carrier-line1,
.stage[data-phase="imminent"] .carrier-line2 { opacity: 0.5; }

.stage[data-phase="afterglow"] .countdown,
.stage[data-phase="afterglow"] .waveform-wrap,
.stage[data-phase="afterglow"] .carrier-bar,
.stage[data-phase="afterglow"] .audio-enable { display: none; }

/* Reduced motion: kill decoration, keep the moment firing on schedule */
@media (prefers-reduced-motion: reduce) {
  #starfield, .scan, .digit, .digit.flip {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-color-scheme: light) {
  /* This page forces midnight regardless of system theme — a 1977 terminal
     does not follow your OS light/dark switch. */
}
