/* Design tokens lifted directly from the server's own in-game UI system
   (racing/dist/style.css, bennys, pausemenu) - this site is meant to read
   as a direct extension of that same product, not a separately-branded
   marketing template. */
:root {
  --deep-blue:   #12325c;
  --mid-blue:    #0d1c34;
  --midnight:    #060a12;

  --text:        #eef4fb;
  --text-dim:    rgba(197, 219, 245, 0.62);
  --text-faint:  rgba(197, 219, 245, 0.34);

  --accent:      #6cc7ff;
  --accent-2:    #9fdcff;
  --accent-soft: rgba(108, 199, 255, 0.14);
  --accent-glow: rgba(108, 199, 255, 0.55);

  --danger:      #ff5d78;
  --success:     #5be0b3;
  --signal:      #ffb454;

  --font-display: 'Orbitron', system-ui, sans-serif;
  --font-body:    'Manrope', system-ui, sans-serif;

  --ease-out:    cubic-bezier(.16,.9,.32,1);
  --ease-in-out: cubic-bezier(.65,0,.35,1);

  --surface-1: rgba(255,255,255,0.03);
  --surface-2: rgba(255,255,255,0.05);
  --hairline:  rgba(255,255,255,0.10);

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--midnight);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

.accent { color: var(--accent); }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Visually hidden but reachable by screen readers / keyboard nav / no-JS.
   The 3D scene is the real interface; this is the safety net beneath it. */
.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;
}

/* ================= SCENE CANVAS ================= */

/* 4:3 analog framing. The canvas is sized by JS to a 4:3 box and centred on a
   pure-black field, producing real pillarbox bars. */
#scene-canvas {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: block;
  cursor: crosshair;
}

body {
  background: #000;
}

/* Cinematic film-grain — turns flat gradients into something with texture */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ================= LOADING SCREEN ================= */

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--midnight);
  transition: opacity .6s var(--ease-out), visibility .6s;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
}

#loading-logo {
  width: clamp(110px, 26vw, 168px);
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 0 26px rgba(108, 199, 255, 0.45));
  animation: loadingPulse 2.6s var(--ease-in-out) infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: .82; filter: drop-shadow(0 0 20px rgba(108,199,255,.34)); }
  50%      { opacity: 1;   filter: drop-shadow(0 0 34px rgba(108,199,255,.6)); }
}

.loading-bar {
  position: relative;
  width: min(260px, 62vw);
  height: 3px;
  background: rgba(255,255,255,.07);
  overflow: hidden;
}

.loading-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px var(--accent-glow);
  transition: width .3s var(--ease-out);
}

.loading-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent-2);
  text-shadow: 0 0 12px var(--accent-glow);
}

.loading-caret { animation: loadingBlink 1.05s steps(1) infinite; }
@keyframes loadingBlink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

.loading-tape {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  letter-spacing: 2.4px;
  color: rgba(197, 219, 245, 0.42);
}

/* --- VHS treatment on the loader, matching the scene's own overlay --- */
.loading-vhs { position: absolute; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }

.loading-scan {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,.16) 0px, rgba(0,0,0,.16) 1px,
    rgba(255,255,255,.014) 1px, rgba(255,255,255,.014) 3px);
  mix-blend-mode: multiply;
}

.loading-grain {
  position: absolute; inset: -30px;
  opacity: .07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  animation: loadingGrain .5s steps(3) infinite;
}

@keyframes loadingGrain {
  0%   { transform: translate(0,0); }
  33%  { transform: translate(-8px, 6px); }
  66%  { transform: translate(6px,-8px); }
  100% { transform: translate(0,0); }
}

.loading-track {
  position: absolute; left: 0; right: 0; height: 16%;
  background: linear-gradient(to bottom,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,.05) 45%,
    rgba(190,215,255,.07) 52%,
    rgba(255,255,255,0) 100%);
  mix-blend-mode: screen;
  filter: blur(1.5px);
  animation: loadingTrack 7s linear infinite;
}

@keyframes loadingTrack { 0% { top: 108%; } 100% { top: -20%; } }

/* ================= FALLBACK CONTENT ================= */

#fallback h1 { font-family: var(--font-display); }
#fallback a { text-decoration: underline; }

/* ================= DEV CREDIT ================= */

.dev-credit {
  position: fixed;
  bottom: 8px;
  right: 10px;
  z-index: 60;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--text);
  opacity: 0.1;
  pointer-events: none;
  user-select: none;
}

/* ================= MOBILE: DISABLE 4:3 FRAMING ================= */

@media (hover: none) and (pointer: coarse) {
  #scene-canvas {
    position: fixed;
    top: 0;
    left: 0;
    transform: none;
  }
}

/* ================= MOTION PREFERENCES ================= */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
