/* GamerStarz design tokens. The only file allowed to hold raw hex and px values.
   Source of truth: docs/DESIGN_SYSTEM.md. Components use the semantic tokens only. */

@layer reset, base, layout, components, utilities;

/* ---------------------------------------------------------------- fonts (self-hosted, Latin subset, OFL) */
@font-face {
  font-family: "Chakra Petch";
  src: url("../fonts/chakra-petch-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-var-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Metric-matched fallbacks (computed against Arial with fontTools; see docs/DECISIONS.md). */
@font-face {
  font-family: "Chakra Petch Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Arial");
  font-weight: 700;
  size-adjust: 101.02%;
  ascent-override: 98.2%;
  descent-override: 30.49%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Figtree Fallback";
  src: local("Arial"), local("ArialMT");
  size-adjust: 100.29%;
  ascent-override: 94.73%;
  descent-override: 24.93%;
  line-gap-override: 0%;
}

@layer base {
  :root {
    color-scheme: light;

    /* ---------- primitive colors (hex fallback) */
    --green-500: #83d437;
    --green-400: #9fe85c;
    --green-700: #4a8f0f;
    --ink-on-green: #0b1206;
    --violet-500: #6d4dff;
    /* Surfaces lifted 2026-11-17 (Issac: "the black feels too dark"). */
    --surface-0: #1a2118;
    --surface-1: #212a1e;
    --surface-2: #2a3326;
    --surface-3: #34402f;
    --border: #46533f;
    --border-strong: #7c8b6e;
    --text: #f1f5ec;
    --text-muted: #b3bcaa;
    --surface-deep: #0b0d0a; /* hero/ticker backdrop only */

    /* Light "paper" sections (old site rhythm). Ink on paper; accents use green-800. */
    --paper-0: #eef2ea;
    --paper-1: #ffffff;
    --paper-border: #d3dccb;
    --ink: #10160d;
    --ink-muted: #4a5443;
    --green-800: #356a0a;
    --paper-alt: #e4f0d6;    /* light green tint for alternating sections */
    --paper-raised: #f6f9f2;

    /* Genre tag colors from the old site (green, violet, blue, orange). */
    --tag-violet: #5b3df0; /* white text, 6.2:1 */
    --tag-blue: #40abf5;   /* ink text, 7.6:1 */
    --tag-orange: #fb6e10; /* ink text, 6.7:1 */
    --on-violet: #ffffff;

    /* ---------- semantic colors (components use these only)
       Light by default (Issac 2026-11-17: "make the site light and fun"); the dark spots
       (header, banner, ticker, inside the truck, service band, final call, footer) remap
       these in the dark-scope rule below. */
    --color-bg: var(--paper-0);
    --color-bg-alt: var(--paper-alt);
    --color-card: var(--paper-1);
    --color-raised: var(--paper-raised);
    --color-border: var(--paper-border);
    --color-border-strong: var(--ink-muted);
    --color-text: var(--ink);
    --color-text-muted: var(--ink-muted);
    --color-action: var(--green-500);
    --color-action-hover: var(--green-400);
    --color-action-pressed: var(--green-700);
    --color-on-action: var(--ink-on-green);
    --color-focus: var(--green-800);
    --color-glow: var(--violet-500);
    --color-brand: var(--green-800); /* star, HUD accents (green-500 in dark spots) */
    --color-link: var(--green-800);

    /* translucent mixes used for glow, scrims and overlays */
    --glow-green-soft: color-mix(in srgb, var(--green-500) 35%, transparent);
    --glow-green-faint: color-mix(in srgb, var(--green-500) 14%, transparent);
    --glow-violet-soft: color-mix(in srgb, var(--violet-500) 30%, transparent);
    --scrim-strong: color-mix(in srgb, var(--surface-0) 92%, transparent);
    --scrim-mid: color-mix(in srgb, var(--surface-0) 70%, transparent);
    --scrim-clear: color-mix(in srgb, var(--surface-0) 0%, transparent);
    --header-bg: color-mix(in srgb, var(--surface-0) 88%, transparent);
    --scrim-deep: color-mix(in srgb, var(--surface-deep) 78%, transparent);
    --scrim-deep-soft: color-mix(in srgb, var(--surface-deep) 35%, transparent);
    --hud-line: color-mix(in srgb, var(--green-500) 9%, transparent);
    --glow-violet-faint: color-mix(in srgb, var(--violet-500) 16%, transparent);
    --dot-color: color-mix(in srgb, var(--green-700) 22%, transparent);
    --glow-char: drop-shadow(0 0 var(--space-24) var(--glow-green-soft));

    /* ---------- type */
    --font-display: "Chakra Petch", "Chakra Petch Fallback", "Arial Narrow", sans-serif;
    --font-body: "Figtree", "Figtree Fallback", system-ui, sans-serif;
    --weight-body: 450;
    --weight-strong: 650;
    --weight-display: 700;

    /* Fluid scale: 1.2 ratio at 320px viewport -> 1.25 at 1440px; body 16 -> 20px. */
    --step--1: clamp(0.8333rem, 0.7857rem + 0.2381vw, 1rem);
    --step-0: clamp(1rem, 0.9286rem + 0.3571vw, 1.25rem);
    --step-1: clamp(1.2rem, 1.0964rem + 0.5179vw, 1.5625rem);
    --step-2: clamp(1.44rem, 1.2934rem + 0.733vw, 1.9531rem);
    --step-3: clamp(1.728rem, 1.5242rem + 1.0192vw, 2.4414rem);
    --step-4: clamp(2.0736rem, 1.7941rem + 1.3974vw, 3.0518rem);
    --step-5: clamp(2.4883rem, 2.1094rem + 1.8948vw, 3.8147rem);
    --step-6: clamp(2.986rem, 2.4767rem + 2.5463vw, 4.7684rem);

    --leading-display: 1.05;
    --leading-heading: 1.15;
    --leading-body: 1.6;
    --leading-tight: 1.3;
    --tracking-display: -0.02em;
    --tracking-label: 0.1em;
    --measure: 65ch;

    /* ---------- space (named by px value) */
    --space-2: 0.125rem;
    --space-4: 0.25rem;
    --space-8: 0.5rem;
    --space-12: 0.75rem;
    --space-16: 1rem;
    --space-24: 1.5rem;
    --space-32: 2rem;
    --space-40: 2.5rem;
    --space-48: 3rem;
    --space-64: 4rem;
    --space-80: 5rem;
    --space-96: 6rem;
    --space-128: 8rem;
    --space-160: 10rem;
    --section-pad: clamp(4rem, 2.86rem + 5.71vw, 8rem); /* 64 mobile -> 128 desktop */
    --gutter: clamp(1rem, 0.64rem + 1.79vw, 2rem);

    /* ---------- sizes */
    --max-width: 75rem; /* 1200 */
    --max-width-narrow: 50rem;
    --tap-min: 2.75rem; /* 44px */
    --header-h: 4.5rem;
    --header-h-compact: 3.5rem;
    --action-bar-h: 4.5rem;
    --icon-sm: 1.125rem;
    --icon-md: 1.5rem;
    --icon-lg: 2rem;
    --photo-max: 45rem; /* ~720 CSS px cap for 1080 px photos */
    --tile-min: 9.5rem;
    --card-min: 18rem;
    --blur-glass: 12px;
    --hero-min-h: min(52rem, 92svh);
    --hero-band-ratio: 4 / 3;  /* phone art band above the banner copy */
    --hero-band-ratio-wide: 16 / 9; /* tablet art band (keeps Call in the first view) */
    --hud-cell: 48px;
    --poster-w: 18rem;
    --poster-w-sm: 9rem;
    --poster-tilt: 4deg;
    --dot-w: 2.25rem;
    --dot-h: 6px;
    --game-card-ratio: 500 / 723;
    --contact-min: 10rem;
    --pay-label-w: 7rem;
    --char-side-sm: 11rem;     /* play-section figures below 1024px: a pair above the heading */
    --char-side-md: clamp(9rem, 16vw, 15rem); /* 1024-1799px: side columns flanking the heading */
    --char-side-lg: 28rem;     /* 1800px+: in the page margins */
    --cameo-sm: 4.5rem;
    --cameo-md: 7rem;
    --cameo-lg: 8rem;
    --cameo-xl: 11rem;
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Logo display sizes: must match LOGO_SIZES in scripts/build-images.mjs. */
    --logo-header-w: 200px;
    --logo-header-h: 34px;
    --logo-footer-w: 283px;
    --logo-footer-h: 48px;
    --logo-hero-w: 280px;
    --logo-hero-h: 171px;

    /* Star motif (mask shape; color comes from background). */
    --star-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l3.1 7.2 7.8.7-5.9 5.2 1.8 7.7L12 18.3l-6.8 4 1.8-7.7-5.9-5.2 7.8-.7z'/%3E%3C/svg%3E");

    /* ---------- lines, radius, corners */
    --line-hair: 1px;
    --line-glow: 2px;
    --focus-width: 2px;
    --focus-offset: 3px;
    --radius-chip: 4px;
    --radius-card: 10px;
    --radius-full: 999px;
    --cut-card: 16px;
    --cut-hero: 24px;

    /* ---------- elevation (lighter surface plus glow, never black shadows) */
    --glow-featured: 0 0 0 var(--line-hair) var(--color-border), 0 12px 40px -12px var(--glow-green-soft);
    --glow-underline: 0 6px 18px 0 var(--glow-green-soft);
    --glow-text: none;
    --glow-text-dark: 0 0 24px var(--glow-green-soft);
    --shadow-poster: color-mix(in srgb, var(--ink) 35%, transparent);
    --press-depth: 2px;
    --rise: 16px;

    /* ---------- motion */
    --ease-signature: cubic-bezier(0.22, 1, 0.36, 1);
    --dur-feedback: 150ms;
    --dur-transition: 250ms;
    --dur-entrance: 400ms;
    --dur-pulse: 3600ms;
    --stagger: 50ms;
    --dur-burst: 1100ms;
    --dur-fade: 1200ms;
    --dur-slide: 6000ms; /* keep in step with SLIDE_MS in main.js */
    --dur-glitch: 700ms;
    --dur-kenburns: 9000ms;
    --dur-ticker: 45s;
    --dur-float: 4200ms;
    --dur-spin: 6s;
    /* Step 6b effects (docs/effects-plan.md). JS timings that must match are noted in main.js. */
    --dur-park-drive: 1600ms;   /* truck drives in */
    --dur-park-measure: 900ms;  /* tape measure + 0 -> 35 FT; keep in step with PARK_COUNT_MS */
    --dur-park-glow: 500ms;
    --dur-power: 900ms;         /* logo neon flicker */
    --dur-power-line: 700ms;    /* underglow lights left to right */
    --dur-roll: 250ms;          /* calculator total roll */
    --dur-toast: 4000ms;        /* keep in step with TOAST_MS */
    --park-wheel-turns: -3turn;
    --park-start: -115%;        /* trailer starts off the left edge (fraction of its own width) */
    --holo-max: 6deg;           /* max tilt, mirrored by HOLO_MAX in main.js */
    --holo-depth: 60rem;        /* perspective */
    --spot-size: 9rem;          /* spotlight radius */
    --wall-h: clamp(13rem, 52vw, 20rem);
    --lightbox-max: min(92vw, 70rem);
    --lightbox-max-h: 78svh;
    --xp-h: var(--space-8);
    --vt-shift: var(--space-24);
    --foil-a: color-mix(in srgb, var(--paper-1) 28%, transparent);
    --foil-b: color-mix(in srgb, var(--tag-blue) 18%, transparent);
    --foil-c: color-mix(in srgb, var(--violet-500) 18%, transparent);
    --backdrop: color-mix(in srgb, var(--surface-deep) 88%, transparent);

    /* ---------- layering */
    --z-base: 0;
    --z-raised: 1;
    --z-header: 50;
    --z-action-bar: 60;
    --z-toast: 90;
    --z-skip: 100;
  }

  /* Dark spots: same components, dark tokens. */
  .theme-dark, .site-header, .site-footer, .action-bar, .hero, .page-hero, .ticker,
  .final-call, .service-band, .section--dark {
    color-scheme: dark;
    --color-bg: var(--surface-0);
    --color-bg-alt: var(--surface-1);
    --color-card: var(--surface-2);
    --color-raised: var(--surface-3);
    --color-border: var(--border);
    --color-border-strong: var(--border-strong);
    --color-text: var(--text);
    --color-text-muted: var(--text-muted);
    --color-focus: var(--green-400);
    --color-brand: var(--green-500);
    --color-link: var(--green-500);
    --glow-text: var(--glow-text-dark);
    background-color: var(--color-bg);
    color: var(--color-text);
  }

  /* OKLCH authoring values where supported (same colors as the hex fallbacks above). */
  @supports (color: oklch(0% 0 0)) {
    :root {
      --green-500: oklch(78.87% 0.2009 133.35);
      --green-400: oklch(85.47% 0.1868 132.4);
      --green-700: oklch(58.17% 0.1654 135.35);
      --ink-on-green: oklch(17.06% 0.0269 132.35);
      --violet-500: oklch(56.58% 0.2481 283.31);
      --surface-0: oklch(23.75% 0.0197 138.77);
      --surface-1: oklch(27.22% 0.0251 137.94);
      --surface-2: oklch(30.82% 0.0259 136.11);
      --surface-3: oklch(35.52% 0.0327 136.58);
      --border: oklch(42.47% 0.0362 134.73);
      --border-strong: oklch(61.64% 0.0459 129.97);
      --text: oklch(96.46% 0.0126 126.37);
      --text-muted: oklch(78.31% 0.0269 128.85);
    }
  }
}
