/* @popcorn245/components/tokens.css: the one token source (LOOK-02 #462, ADR 0023).

   Link this first on every page. App CSS and server templates use only var(--pop-*); no hex,
   rgb(), hsl() or px font sizes. The look is a retro game menu (day level, night level), the
   values are the signed-off UI contract (Storybook "UI contract", docs/adr/0023-ui-contract.md);
   contrast.test.ts holds every text pair at WCAG AA.

   Themes: day (light) is :root. Night (dark) applies under prefers-color-scheme unless the page
   says data-theme="light", and always under data-theme="dark". .force-day and .force-night scope
   a subtree to one theme (Storybook side by side, theme previews).

   Fonts: this file only names the families. Add the Google Fonts link to the page <head>, or
   import @popcorn245/components/fonts.css:
     <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@500;700&family=Nunito:wght@400;600;800&display=swap">

   The art (--pop-art-*: tiles, sky, sprites, about 120 KB of data URIs) is art.css, generated from
   packages/components/assets by scripts/build-art.mjs (npm run build-art -w @popcorn245/components).
   Do not edit it. It is opt-in, not imported here, so a page that draws no art does not download
   it: shell.css and the login page's login.css import it, and a page that uses --pop-art-* or
   --pop-sky-art without the shell links art.css after this file. (--pop-sky-art below names the
   art; it only resolves where art.css is loaded.)

   Added on top of the contract by LOOK-02, because the contract drew these with literals:
   --pop-ink, --pop-cream (toast, tooltip, HUD: dark box, cream text in both themes),
   --pop-hud-bg (HUD pill) and --pop-coin-hover. */
/* ---------- Day level (light theme) ---------- */
:root, .force-day {
  color-scheme: light;
  /* Brand (from the bucket palette) */
  --pop-red-300: #fc8181; --pop-red-500: #e53e3e; --pop-red-700: #c53030; --pop-red-900: #9b2c2c;
  --pop-blue-300: #63b3ed; --pop-blue-500: #4299e1; --pop-blue-600: #3182ce; --pop-blue-700: #2a69ac;
  --pop-coin: #f5b41a; --pop-coin-hover: #ffc940; --pop-coin-ink: #1a1033;
  --pop-ink: #1a1033; --pop-cream: #fff7e0; --pop-hud-bg: rgba(15, 12, 35, 0.78);
  /* Weather (spec 0142 D7): a falling flake and its one pixel edge. Decoration, not text: no contrast pair */
  --pop-weather-flake: #ffffff; --pop-weather-flake-edge: #7fa3c7;

  --pop-bg-page: #9bd4f5;
  --pop-bg-surface: #fff7e0;
  --pop-bg-subtle: #f3e6bf;
  --pop-bg-inset: #ffffff;
  --pop-border-color: #1a1033;
  --pop-bevel-light: rgba(255, 255, 255, 0.85);
  --pop-bevel-dark: rgba(91, 74, 46, 0.28);
  --pop-shadow-hard: rgba(26, 16, 51, 0.35);
  --pop-text-main: #1a1033;
  --pop-text-muted: #5b4a2e;
  --pop-color-primary: #c53030;        /* button fill: 5.47:1 with white */
  --pop-color-primary-hover: #9b2c2c;
  --pop-color-primary-text: #ffffff;
  --pop-color-primary-accent: #e53e3e; /* brand red for fills and borders: 3.86:1 on surface (UI needs 3) */
  --pop-color-secondary: #2a69ac;      /* 5.65:1 with white */
  --pop-color-secondary-hover: #1f4f84;
  --pop-color-secondary-text: #ffffff;
  --pop-color-secondary-accent: #3182ce;
  --pop-color-link: #c53030;           /* 5.11:1 on surface */
  --pop-color-focus-ring: #2a69ac;
  --pop-color-success: #276749; --pop-color-success-bg: #e3f6e8;
  --pop-color-warning: #8a5a00; --pop-color-warning-bg: #fff1cc;
  --pop-color-danger: #9b2c2c;  --pop-color-danger-bg: #fde4e4;
  --pop-color-info: #1f4f84;    --pop-color-info-bg: #e2f0fb;
  /* Trim fills (spec 0047 D3, D19): the sheet centres the sets carry, each paired with the ink
     that reads on it at AA; a trim names the fill, the dresser takes the ink from the pair. */
  --pop-fill-lip: #55ae3d;     --pop-fill-lip-ink: #1a1033;
  --pop-fill-shelf: #c08a4a;   --pop-fill-shelf-ink: #1a1033;
  --pop-fill-cloud: #ffffff;   --pop-fill-cloud-ink: #1a1033;
  --pop-fill-popcorn: #f5b41a; --pop-fill-popcorn-ink: #1a1033;
  --pop-fill-butter: #e8952c;  --pop-fill-butter-ink: #1a1033;
  --pop-fill-timber: #7a5232;  --pop-fill-timber-ink: #fff7e0;
  --pop-sky-art: var(--pop-art-clouds);

  --pop-font-display: 'Pixelify Sans', 'Courier New', ui-monospace, monospace;
  --pop-font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Numbers a child counts (popcoins, costs, balances): the pixel face draws 2 and 5 like 8 (#1560), so the digits
     are set in the body face, tabular and heavy; the words around them keep the pixel look */
  --pop-font-number: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --pop-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  --pop-font-emoji: 'Noto Emoji', 'Segoe UI Symbol', sans-serif; /* Valheim's sign font: a mark the family can carve */
  --pop-px: 4px;                      /* one art pixel at UI scale: borders, steps, press depth */
  --pop-space-1: 0.25rem; --pop-space-2: 0.5rem; --pop-space-3: 0.75rem;
  --pop-space-4: 1rem; --pop-space-5: 1.5rem; --pop-space-6: 2rem;
  --pop-font-size-xs: 0.75rem; --pop-font-size-sm: 0.875rem; --pop-font-size-md: 1rem;
  --pop-font-size-lg: 1.25rem; --pop-font-size-xl: 1.75rem; --pop-font-size-xxl: 2.5rem;
  --pop-ground-height: 2rem;
}

/* ---------- Night level (dark theme), following the system until the page picks ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --pop-bg-page: #14112a; --pop-bg-surface: #241d45; --pop-bg-subtle: #2e2656; --pop-bg-inset: #1a1535;
    --pop-border-color: #07051a; --pop-bevel-light: rgba(255, 247, 224, 0.16); --pop-bevel-dark: rgba(0, 0, 0, 0.45);
    --pop-shadow-hard: rgba(0, 0, 0, 0.6);
    --pop-text-main: #fff7e0; --pop-text-muted: #c9bfa6;
    --pop-color-primary: #fc8181; --pop-color-primary-hover: #feb2b2; --pop-color-primary-text: #14112a; --pop-color-primary-accent: #fc8181;
    --pop-color-secondary: #63b3ed; --pop-color-secondary-hover: #90cdf4; --pop-color-secondary-text: #14112a; --pop-color-secondary-accent: #63b3ed;
    --pop-color-link: #fc8181; --pop-color-focus-ring: #63b3ed;
    --pop-color-success: #9ae6b4; --pop-color-success-bg: #1d3a32;
    --pop-color-warning: #f6d27a; --pop-color-warning-bg: #3d3216;
    --pop-color-danger: #feb2b2;  --pop-color-danger-bg: #44202a;
    --pop-color-info: #90cdf4;    --pop-color-info-bg: #1c2d4d;
    --pop-fill-lip: #55ae3d;     --pop-fill-lip-ink: #1a1033;
    --pop-fill-shelf: #c08a4a;   --pop-fill-shelf-ink: #1a1033;
    --pop-fill-cloud: #ffffff;   --pop-fill-cloud-ink: #1a1033;
    --pop-fill-popcorn: #f5b41a; --pop-fill-popcorn-ink: #1a1033;
    --pop-fill-butter: #e8952c;  --pop-fill-butter-ink: #1a1033;
    --pop-fill-timber: #7a5232;  --pop-fill-timber-ink: #fff7e0;
    --pop-sky-art: var(--pop-art-stars);
    --pop-weather-flake: #f4f8ff; --pop-weather-flake-edge: transparent;
  }
}
:root[data-theme="dark"], .force-night {
  color-scheme: dark;
  --pop-bg-page: #14112a; --pop-bg-surface: #241d45; --pop-bg-subtle: #2e2656; --pop-bg-inset: #1a1535;
  --pop-border-color: #07051a; --pop-bevel-light: rgba(255, 247, 224, 0.16); --pop-bevel-dark: rgba(0, 0, 0, 0.45);
  --pop-shadow-hard: rgba(0, 0, 0, 0.6);
  --pop-text-main: #fff7e0; --pop-text-muted: #c9bfa6;
  --pop-color-primary: #fc8181; --pop-color-primary-hover: #feb2b2; --pop-color-primary-text: #14112a; --pop-color-primary-accent: #fc8181;
  --pop-color-secondary: #63b3ed; --pop-color-secondary-hover: #90cdf4; --pop-color-secondary-text: #14112a; --pop-color-secondary-accent: #63b3ed;
  --pop-color-link: #fc8181; --pop-color-focus-ring: #63b3ed;
  --pop-color-success: #9ae6b4; --pop-color-success-bg: #1d3a32;
  --pop-color-warning: #f6d27a; --pop-color-warning-bg: #3d3216;
  --pop-color-danger: #feb2b2;  --pop-color-danger-bg: #44202a;
  --pop-color-info: #90cdf4;    --pop-color-info-bg: #1c2d4d;
  --pop-fill-lip: #55ae3d;     --pop-fill-lip-ink: #1a1033;
  --pop-fill-shelf: #c08a4a;   --pop-fill-shelf-ink: #1a1033;
  --pop-fill-cloud: #ffffff;   --pop-fill-cloud-ink: #1a1033;
  --pop-fill-popcorn: #f5b41a; --pop-fill-popcorn-ink: #1a1033;
  --pop-fill-butter: #e8952c;  --pop-fill-butter-ink: #1a1033;
  --pop-fill-timber: #7a5232;  --pop-fill-timber-ink: #fff7e0;
  --pop-sky-art: var(--pop-art-stars);
  --pop-weather-flake: #f4f8ff; --pop-weather-flake-edge: transparent;
}
