/* ==========================================================================
   STATE WARS — base.css
   Resets, design tokens, page shell, animated background layers, footer.
   ========================================================================== */

/* ---------- 1. Reset ---------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

/* Both, not just body. body already said overflow:hidden, but the root element
   scrolls independently of it — so on a short screen the whole page could still
   be nudged up and down by a few pixels while every screen inside believed it
   was pinned. Screens that genuinely need to scroll do their own scrolling. */
html, body { height: 100%; overflow: hidden; }

body,
h1, h2, h3, p, ol, ul, figure {
  margin: 0;
  padding: 0;
}

ol, ul { list-style: none; }

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

/* THE HIDDEN ATTRIBUTE MUST ACTUALLY HIDE.
   The browser's own rule is `[hidden] { display: none }`, but any author rule
   that sets a display — `.outcome { display: grid }`, `.deploy { display: grid }`
   — beats it, because author styles win over the user agent's regardless of
   specificity. The result is silent and nasty: `el.hidden = true` reads as true
   in JavaScript while the element sits there full-size on top of everything.
   That is exactly what put the victory card over the battlefield from the
   moment a fight opened, swallowing every click behind it. */
[hidden] { display: none !important; }

img, canvas { display: block; max-width: 100%; }


/* ---------- 2. Design tokens ------------------------------------------- */

:root {
  /* Surfaces — deep navy, cool but not pitch black */
  --c-void:      #04070e;
  --c-deep:      #070d1a;
  --c-base:      #0b1526;
  --c-raised:    #0f1e35;
  --c-line:      #1d3252;

  /* Accents */
  --c-ice:       #7fd8ff;   /* state border glow / secondary */
  --c-ice-soft:  #3f7fa8;
  --c-gold:      #ffc25c;   /* primary action */
  --c-gold-deep: #d98d17;
  --c-ember:     #ff6a4d;   /* sparingly, for heat */

  /* Text */
  --c-text:      #e9f1fc;
  --c-dim:       #93a8c6;
  --c-muted:     #62779a;

  /* Type */
  --font-display: "Bahnschrift", "DIN Alternate", "Oswald",
                  "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-ui:      "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  --font-mono:    "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;

  /* Motion */
  --ease-out:  cubic-bezier(.16, .84, .34, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --t-fast:    140ms;
  --t-mid:     280ms;
  --t-slow:    520ms;

  /* Parallax offsets, written by js/fx/parallax.js (range -1 .. 1) */
  --px: 0;
  --py: 0;

  /* Global effect strength, written by the settings store (0 .. 1) */
  --fx: 1;
}

/* Layout scale — one knob for the whole menu */
:root {
  --gutter: clamp(1.25rem, 4vw, 4rem);
}


/* ---------- 3. Page shell ---------------------------------------------- */

body {
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-void);
  overflow: hidden;                 /* the stage scrolls, not the page */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  height: 100%;
  isolation: isolate;
}


/* ---------- 4. Background layers ---------------------------------------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 4a. Base sky gradient */
.bg__sky {
  position: absolute;
  inset: -6%;
  background:
    radial-gradient(120% 90% at 50% 8%,  #14294a 0%,  rgba(20,41,74,0) 62%),
    radial-gradient(90%  70% at 12% 92%, #1a2340 0%,  rgba(26,35,64,0) 60%),
    radial-gradient(90%  70% at 88% 88%, #10243c 0%,  rgba(16,36,60,0) 60%),
    linear-gradient(180deg, var(--c-deep) 0%, var(--c-base) 45%, var(--c-void) 100%);
  transform: translate3d(calc(var(--px) * 6px), calc(var(--py) * 5px), 0);
  transition: transform 700ms var(--ease-soft);
}

/* 4b. Slow drifting cloud / haze blobs */
.bg__clouds {
  position: absolute;
  inset: -12%;
  transform: translate3d(calc(var(--px) * 14px), calc(var(--py) * 10px), 0);
  transition: transform 700ms var(--ease-soft);
}

.cloud {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: calc(.5 * var(--fx));
  will-change: transform;
}

.cloud--1 {
  width: 60vw; height: 40vw;
  top: 4%; left: -18%;
  background: radial-gradient(circle, rgba(63,127,168,.42) 0%, rgba(63,127,168,0) 70%);
  animation: drift-a 78s linear infinite;
}
.cloud--2 {
  width: 52vw; height: 38vw;
  bottom: -6%; right: -14%;
  background: radial-gradient(circle, rgba(255,194,92,.16) 0%, rgba(255,194,92,0) 70%);
  animation: drift-b 96s linear infinite;
}
.cloud--3 {
  width: 44vw; height: 30vw;
  top: 34%; left: 42%;
  background: radial-gradient(circle, rgba(120,90,200,.20) 0%, rgba(120,90,200,0) 70%);
  animation: drift-c 120s linear infinite;
}

@keyframes drift-a {
  0%   { transform: translate3d(0,0,0)          scale(1); }
  50%  { transform: translate3d(9vw,3vh,0)      scale(1.14); }
  100% { transform: translate3d(0,0,0)          scale(1); }
}
@keyframes drift-b {
  0%   { transform: translate3d(0,0,0)          scale(1.08); }
  50%  { transform: translate3d(-7vw,-4vh,0)    scale(.94); }
  100% { transform: translate3d(0,0,0)          scale(1.08); }
}
@keyframes drift-c {
  0%   { transform: translate3d(0,0,0)          scale(.95); }
  50%  { transform: translate3d(-5vw,5vh,0)     scale(1.12); }
  100% { transform: translate3d(0,0,0)          scale(.95); }
}

/* 4c. Soft halo sitting behind the map so it reads as lit from within */
.bg__halo {
  position: absolute;
  inset: 0;
  background: radial-gradient(58% 46% at 50% 52%,
              rgba(127,216,255,.13) 0%, rgba(127,216,255,0) 70%);
  opacity: var(--fx);
  transform: translate3d(calc(var(--px) * 8px), calc(var(--py) * 6px), 0);
  transition: transform 700ms var(--ease-soft);
}

/* 4d. The canvas — hex map of the 50 states + drifting particles */
.bg__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 4e. Faint tactical grid */
.bg__grid {
  position: absolute;
  inset: -4%;
  background-image:
    linear-gradient(rgba(127,216,255,.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127,216,255,.055) 1px, transparent 1px);
  background-size: 78px 78px;
  mask-image:      radial-gradient(72% 62% at 50% 50%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(72% 62% at 50% 50%, #000 20%, transparent 78%);
  opacity: calc(.9 * var(--fx));
  transform: translate3d(calc(var(--px) * 26px), calc(var(--py) * 18px), 0);
  transition: transform 700ms var(--ease-soft);
}

/* 4f. Film grain — keeps the flat gradients from banding */
.bg__noise {
  position: absolute;
  inset: 0;
  opacity: calc(.30 * var(--fx));
  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='.85' numOctaves='3'/>\
<feColorMatrix type='saturate' values='0'/></filter>\
<rect width='160' height='160' filter='url(%23n)' opacity='.5'/></svg>");
}

/* 4g. Vignette — darkens the rim, and puts a soft scrim right behind the
       menu column so the title and buttons always have something calm to sit
       on no matter which states happen to be glowing. */
.bg__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(46% 56% at 50% 50%, rgba(4,7,14,.5) 0%,
                                        rgba(4,7,14,.2) 58%,
                                        rgba(4,7,14,0) 100%),
    radial-gradient(78% 68% at 50% 46%, rgba(4,7,14,0) 38%, rgba(4,7,14,.72) 100%),
    linear-gradient(180deg, rgba(4,7,14,.55) 0%, rgba(4,7,14,0) 22%,
                            rgba(4,7,14,0) 66%, rgba(4,7,14,.78) 100%);
}


/* ---------- 5. Stage ---------------------------------------------------- */

.stage {
  position: relative;
  z-index: 1;
  height: 100%;
}


/* ---------- 6. Footer --------------------------------------------------- */

.footer {
  position: fixed;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--gutter) clamp(.85rem, 2vh, 1.4rem);
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: clamp(.58rem, 1.1vw, .7rem);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.footer__tag { opacity: .72; }

.footer__version {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .32em .72em;
  border: 1px solid rgba(127,216,255,.16);
  border-radius: 3px;
  background: rgba(7,13,26,.55);
  color: var(--c-dim);
  backdrop-filter: blur(6px);
}

.footer__version::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c-gold);
  box-shadow: 0 0 8px var(--c-gold);
  animation: pip 3.4s var(--ease-soft) infinite;
}

@keyframes pip {
  0%, 78%, 100% { opacity: 1; }
  86%           { opacity: .18; }
}

@media (max-width: 520px) {
  .footer__tag { display: none; }
  .footer { justify-content: flex-end; }
}


/* ---------- 7. Focus visibility ---------------------------------------- */

:focus-visible {
  outline: 2px solid var(--c-ice);
  outline-offset: 3px;
}


/* ---------- 8. Motion preferences --------------------------------------
   `.reduce-motion` is set on <html> by the settings store, and mirrors the
   OS-level preference on first load. Everything expensive keys off it.      */

.reduce-motion .cloud { animation: none; }

.reduce-motion .bg__sky,
.reduce-motion .bg__clouds,
.reduce-motion .bg__halo,
.reduce-motion .bg__grid { transition: none; transform: none; }

.reduce-motion .footer__version::before { animation: none; }
