/* ── byte design tokens ──
   The one source of colour, font and shadow values for the web app (index.html) and the world map
   (map.html, a sandboxed iframe, which links this same file). Neutrals and the indigo accent come
   from the enginar family palette (iz: src/constants/theme.ts); the rest is derived so every
   text/background pair passes WCAG AA. Values and contrast ratios: docs/DESIGN_TOKENS.md.
   Served from web/public: by Vite in dev, by the backend's static files in production. */

/* Manrope (OFL-1.1, fonts/manrope/OFL.txt), variable weight 200–800, self-hosted.
   latin covers ç ö ü ı, latin-ext covers ğ İ ş; the browser only downloads a subset it needs. */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/manrope/manrope-latin-wght-normal.woff2) format('woff2');
  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: 'Manrope';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(/fonts/manrope/manrope-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* JetBrains Mono (OFL-1.1, fonts/jetbrains-mono/OFL.txt), variable weight 100–800: enginar's mono label
   font, only for the "an enginar product" badge. enginar's latin + Turkish subset (ç ğ İ ı ö ş ü), copied
   from the enginar repo by scripts/sync-enginar-brand.mjs; downloaded only on a page that uses it. */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url(/fonts/jetbrains-mono/jetbrains-mono-latin-tr.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+011E-011F, U+0130-0131, U+0152-0153, U+015E-015F, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20BA, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Font */
  --font: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; /* enginar mono labels */
  --fs-body: 16px;        /* smallest body text */
  --fs-bubble: 17px;      /* Byte's chat bubbles */
  --fs-label: 14px;       /* badges, country names */

  /* Light ground: neutrals */
  --bg: #F0F4F8;          /* iz background */
  --surface: #FFFFFF;     /* iz softCard */
  --surface-2: #F8FAFB;   /* iz surfaceAlt: inputs, inner cards */
  --text: #1F2937;        /* iz text */
  --text-2: #374151;      /* enginar ink-2: secondary text, hints */
  --text-3: #6B7280;      /* enginar ink-3: only on --surface (white) or large text; 4.37:1 on --bg */
  --border: #E5EAF0;      /* iz border: decorative lines */
  --border-strong: #7B8699; /* inputs and options (≥3:1, WCAG 1.4.11) */

  /* Accent (indigo) */
  --accent: #5B6CFF;      /* iz primary: only where it carries no text (focus, selected edge, progress, map open) */
  --accent-fill: #4C5DF2; /* primary button, kid bubble: white text 5.05:1 */
  --accent-text: #3A4BD4; /* iz primaryDark: links, secondary button text, button hover/pressed */
  --accent-soft: #EEF0FF; /* iz primaryLight: Byte's bubble, selected option, tabs */
  --on-accent: #FFFFFF;
  --focus: #5B6CFF;       /* 3px ring, 2px offset */

  /* Status: fill/icon, soft surface, text. Colour never carries the meaning alone. */
  --success: #15803D;
  --success-soft: #E6F2E5;
  --success-text: #166534;
  --warning: #E8A838;     /* iz warning: fills and borders only */
  --warning-soft: #FFF4DC;
  --warning-text: #9A5B00;
  --danger: #C62828;
  --danger-soft: #FDECEC;
  --danger-text: #C62828;

  /* Player colours: sparks, map and celebrations only */
  --play-amber: #F5A524;
  --play-amber-soft: #FFF4DC;
  --play-amber-text: #9A5B00;
  --play-coral: #FF6B8B;
  --play-coral-soft: #FFE8EE;
  --play-coral-text: #C2264F;
  --play-sky: #38BDF8;
  --play-sky-soft: #E3F2FB;
  --play-sky-text: #1D6FA5;
  --spark: var(--play-amber);
  --spark-soft: var(--play-amber-soft);
  --spark-text: var(--play-amber-text);

  /* Stage: dark slate, only the world map and the play screen */
  --stage-bg: #1F2937;
  --stage-surface: #2B3647;
  --stage-border: #3B4658;
  --stage-text: #F8FAFC;
  --stage-text-2: #CBD5E1;
  --stage-accent-text: #8C99FF;
  --stage-sky: #7DD3FC;   /* air routes on the stage */
  --stage-frame: var(--border); /* outline of a stage mockup on the page (--stage-border in dark) */

  /* Map states (on --stage-bg). Strokes tell locked / neighbour / done apart without colour. */
  --map-locked: #334155;
  --map-locked-stroke: #475569;       /* solid */
  --map-neighbour: #475569;
  --map-neighbour-stroke: #94A3B8;    /* dashed */
  --map-open: #5B6CFF;
  --map-open-stroke: #FFFFFF;
  --map-current: #F5B731;             /* gold means "current country" and nothing else */
  --map-current-stroke: #FFFFFF;
  --map-new: #4ADE80;
  --map-new-stroke: #F5B731;          /* dashed */
  --map-done: #3B4658;
  --map-done-stroke: #A8B4C6;         /* dotted */
  --map-target: #FF6B8B;              /* stroke */
  --map-target-fill: #4A2E3E;
  --map-pin-text: #1F2937;            /* on gold and coral pins */

  /* Elevation (iz shadows) */
  --shadow-sm: 0 1px 4px rgba(31, 41, 55, 0.06);
  --shadow-md: 0 2px 8px rgba(31, 41, 55, 0.10);
  --shadow-lg: 0 4px 16px rgba(91, 108, 255, 0.18);
  --overlay: rgba(31, 41, 55, 0.5);
  --drop-shadow: rgba(31, 41, 55, 0.18); /* filter: drop-shadow() colour */
}

/* ── Dark theme ──
   Enginar's dark values (enginar-web packages/ui/src/styles/tokens.css) plus derived byte-only tokens.
   On <html>: no data-theme follows prefers-color-scheme; data-theme="light" | "dark" is a manual choice.
   Until the app screens are on the tokens, the app sets data-theme="light" on every route but the
   landing page (services/theme.js htmlTheme, index.html's first-paint script); map.html is always light.
   Keep both blocks identical (tests/tokens.test.js checks). The stage, map and player fills don't change. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0E131A;
    --surface: #161C25;
    --surface-2: #121821;
    --text: #F0F4F8;
    --text-2: #CBD2DC;
    --text-3: #9AA4B2;
    --border: #252E3B;
    --border-strong: #5F6B7D;
    --accent: #7B88FF;
    --accent-fill: #4C5DF2;
    --accent-text: #A3ADFF;
    --accent-soft: #212948;  /* enginar: #5B6CFF at 16% over --surface */
    --on-accent: #FFFFFF;
    --focus: #7B88FF;
    --success-soft: #162E29;
    --success-text: #86EFAC;
    --warning-soft: #3C3528;
    --warning-text: #F5C26B;
    --danger-soft: #361E26;
    --danger-text: #FF8A8A;
    --play-amber-soft: #3E3525;
    --play-amber-text: #F5B94A;
    --play-coral-soft: #402A37;
    --play-coral-text: #FF9BB0;
    --play-sky-soft: #1C394B;
    --play-sky-text: #7DD3FC;
    /* Tokens that point at other tokens are declared again, so they resolve to the dark values. */
    --spark: var(--play-amber);
    --spark-soft: var(--play-amber-soft);
    --spark-text: var(--play-amber-text);
    --stage-frame: var(--stage-border);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.65);
    --drop-shadow: rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0E131A;
  --surface: #161C25;
  --surface-2: #121821;
  --text: #F0F4F8;
  --text-2: #CBD2DC;
  --text-3: #9AA4B2;
  --border: #252E3B;
  --border-strong: #5F6B7D;
  --accent: #7B88FF;
  --accent-fill: #4C5DF2;
  --accent-text: #A3ADFF;
  --accent-soft: #212948;  /* enginar: #5B6CFF at 16% over --surface */
  --on-accent: #FFFFFF;
  --focus: #7B88FF;
  --success-soft: #162E29;
  --success-text: #86EFAC;
  --warning-soft: #3C3528;
  --warning-text: #F5C26B;
  --danger-soft: #361E26;
  --danger-text: #FF8A8A;
  --play-amber-soft: #3E3525;
  --play-amber-text: #F5B94A;
  --play-coral-soft: #402A37;
  --play-coral-text: #FF9BB0;
  --play-sky-soft: #1C394B;
  --play-sky-text: #7DD3FC;
  /* Tokens that point at other tokens are declared again, so they resolve to the dark values. */
  --spark: var(--play-amber);
  --spark-soft: var(--play-amber-soft);
  --spark-text: var(--play-amber-text);
  --stage-frame: var(--stage-border);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.65);
  --drop-shadow: rgba(0, 0, 0, 0.5);
}
