/* Visually hidden — for screen-reader-only content (e.g. route announcements). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Background atmosphere: static bottom-edge darkener. The emerald glow orbs
   that used to live here have moved into .menu-bg so they can animate
   without touching this layer. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 50% 100%, rgba(0, 0, 0, 0.55), transparent 50%);
}

/* Animated menu background: drifting glow orbs + circuit-node canvas.
   Only visible on the main menu (body is not .is-scene). */
.menu-bg {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  overflow: hidden;
}
body.is-scene .menu-bg { display: none; }

.menu-bg__glow {
  position: absolute;
  width: 90vmax;
  height: 90vmax;
  border-radius: 50%;
  filter: blur(40px);
  will-change: transform;
}
.menu-bg__glow--a {
  top: -55vmax;
  left: -45vmax;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0) 60%);
  animation: menu-bg-orbit-a 20s linear infinite;
}
.menu-bg__glow--b {
  bottom: -55vmax;
  right: -45vmax;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0) 60%);
  animation: menu-bg-orbit-b 20s linear infinite;
}

@keyframes menu-bg-orbit-a {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(14vw, 6vh); }
  50%  { transform: translate(20vw, 16vh); }
  75%  { transform: translate(6vw, 12vh); }
  100% { transform: translate(0, 0); }
}
@keyframes menu-bg-orbit-b {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-14vw, -6vh); }
  50%  { transform: translate(-20vw, -16vh); }
  75%  { transform: translate(-6vw, -12vh); }
  100% { transform: translate(0, 0); }
}

.menu-bg__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 768px) {
  .menu-bg__glow--a {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0) 60%);
  }
  .menu-bg__glow--b {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0) 60%);
  }
}

/* Grain texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.mono {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* App shell */
.app {
  position: relative;
  z-index: var(--z-content);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HUD frame: corner brackets at viewport edges */
.hud-frame {
  position: fixed;
  inset: 20px;
  pointer-events: none;
  z-index: var(--z-hud);
}
.hud-frame__corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--accent-dim);
}
.hud-frame__corner--tl { top: 0; left: 0; border-right: none; border-bottom: none; }
.hud-frame__corner--tr { top: 0; right: 0; border-left: none; border-bottom: none; }
.hud-frame__corner--bl { bottom: 0; left: 0; border-right: none; border-top: none; }
.hud-frame__corner--br { bottom: 0; right: 0; border-left: none; border-top: none; }

/* Top HUD bar */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 36px 52px;
  position: relative;
  z-index: var(--z-content);
}
.hud-top__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.hud-top__brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  background: rgba(16, 185, 129, 0.05);
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.08);
}
.hud-top__brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
}
.hud-top__brand-text strong {
  font-size: var(--fs-mono-sm);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.16em;
}
.hud-top__brand-text span {
  font-size: var(--fs-mono-xs);
  color: var(--text-muted);
  letter-spacing: 0.2em;
}
.hud-top__meta {
  display: flex;
  gap: 28px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-mono-xs);
  color: var(--text-muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hud-top__meta-item {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hud-top__meta-item--live::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  animation: pulse 2s var(--ease-smooth) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Bottom HUD bar */
.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 52px;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs-mono-xs);
  color: var(--text-muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hud-bottom__telemetry {
  display: flex;
  gap: 32px;
}
.hud-bottom__telemetry span {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.hud-bottom__telemetry strong {
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.1em;
}
.hud-bottom__hint {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-muted);
}
.hud-bottom__hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-elevated);
  font-family: inherit;
  font-size: 10px;
  color: var(--text-secondary);
}

/* Mobile HUD adjustments */
@media (max-width: 768px) {
  .hud-frame { inset: 12px; }
  .hud-top { padding: 20px 20px; flex-wrap: wrap; gap: 12px; }
  .hud-top__meta { display: none; }
  .hud-bottom { padding: 20px; flex-direction: column; align-items: flex-start; gap: 12px; }
  .hud-bottom__telemetry { flex-wrap: wrap; gap: 16px; }
  /* Selectors mirror the body.is-scene rules in components.css so we override
     them on mobile and hide both hint variants (replaced by the back button). */
  body .hud-bottom__hint,
  body.is-scene .hud-bottom__hint--menu,
  body.is-scene .hud-bottom__hint--scene { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  /* The orbit keyframes don't make sense at 0.01ms (they'd snap-loop). Pause
     them in place instead so the glows hold position. The canvas RAF loop
     is short-circuited inside circuit.js. */
  .menu-bg__glow {
    animation: none !important;
  }
}
