/* 00-tokens.css — the design system's tokens (task 100). Linked FIRST, before every other stylesheet.
   Layer 1 is the palette: raw colours, read by nothing but layer 2. Layer 2 is the semantics a component reads
   (--bg, --surface-1, --text, --up …), set once per theme. A component never names a palette colour or a hex:
   `DesignSystemTests` fails on a colour literal in 01-components.css, and on a text / surface pair under 4.5:1
   (--text-faint 3:1) in either theme. The figures are on /Design and in Tasks/100-design-system.md.

   Theme: dark is the default (`:root`), `[data-theme="light"]` is light, and with no attribute the system decides
   (`prefers-color-scheme: light`). `_Layout` writes the attribute from the `theme` cookie, so a chosen theme paints
   on the first frame; `theme.js` keeps the cookie and localStorage. /Design nests both themes on one page, so every
   block below is a selector an element can carry, not only `:root`. */

:root {
  /* Layer 1 — palette. */
  --gray-0: #ffffff;
  --gray-50: #f5f6f8;
  --gray-100: #eef0f3;
  --gray-150: #eaecef;
  --gray-200: #dcdfe4;
  --gray-300: #b7bdc6;
  --gray-400: #929aa5;
  --gray-500: #767e8c;
  --gray-600: #5e6673;
  --gray-700: #474d57;
  --gray-750: #363c45;
  --gray-800: #2b3139;
  --gray-850: #1e2329;
  --gray-900: #181a20;
  --gray-950: #0b0e11;

  --green-50: #e6f4ee;
  --green-400: #0ecb81;
  --green-600: #00754e;
  --green-900: #0f2a20;

  --red-50: #fdecef;
  --red-400: #ff5c70;
  --red-600: #c22a43;
  --red-900: #3a1c23;

  --amber-50: #fbf3dc;
  --amber-400: #fcd535;
  --amber-500: #f0b90b;
  --amber-600: #d9a400;
  --amber-700: #8a5a00;
  --amber-900: #33280a;

  --blue-50: #e8f0fd;
  --blue-400: #5b9dff;
  --blue-600: #1f63d6;
  --blue-900: #142640;

  --orange-400: #ffa940;
  --orange-700: #c2410c;
  --teal-400: #2dd4bf;
  --teal-700: #0f766e;
  --violet-400: #a78bfa;
  --violet-600: #7a52cc;

  /* Spacing on a 4 px grid, radii, type, control heights — the same in both themes. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --radius-1: 4px;
  --radius-2: 6px;
  --radius-3: 10px;
  --radius-pill: 999px;

  /* A provider's mark (task 163, .ui-provider): four steps and nothing between — 20 the .tag's / .ui-chip's height, 24 a
     table row's, 32 a card's head, 48 a phone row's picture —, a tile with the app icon's 22 % corners. */
  --mark-20: 20px;
  --mark-24: 24px;
  --mark-32: 32px;
  --mark-48: 48px;
  --mark-radius: 22%;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.625rem;

  /* Mobile first (task 105): these are the phone's and the tablet's sizes — every control a finger's 44 px, a field's
     text 16 px (iOS zooms into anything smaller) — and the block after this one makes them the desktop's 28 / 36 / 44
     from 901 px. The breakpoints are numbers, not tokens (a custom property cannot sit in @media): ≤ 480 phone,
     481 – 900 tablet or a phone on its side, ≥ 901 desktop; nothing scrolls sideways from 360. */
  --control-sm: 44px;
  --control-md: 44px;
  --control-lg: 48px;
  --touch: 44px;
  --field-font: 16px;

  /* The desktop header's height (.app-header-inner, 01-base.css), and what is held under it reads it: the catalogue's
     bar (02-catalog.css, task 134). */
  --app-header: 56px;

  /* The phone's bottom bar (_Layout, .ui-tabbar) and what the page leaves free under its content for it. */
  --tabbar-height: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-space: calc(var(--tabbar-height) + var(--safe-bottom));

  /* No webfont is fetched (wwwroot has none, and the CSP's font-src stays 'self'); Inter is used where installed. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --duration-1: 120ms;
  --duration-2: 200ms;
  --duration-sheet: 260ms;
}

/* The desktop: wide, and a mouse — a dense terminal. A tablet held sideways is wide but keeps a finger's sizes. */
@media (min-width: 901px) {
  :root {
    --tabbar-space: 0px;
  }
}

@media (min-width: 901px) and (pointer: fine) {
  :root {
    --control-sm: 28px;
    --control-md: 36px;
    --control-lg: 44px;
    --field-font: var(--text-md);
  }
}

/* Layer 2 — dark, the default. */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  /* A set photo sits on white in both themes (owner, 22.11.2026): the pictures are product shots on white, and a
     dark box around a white photo read as a different card in the dark theme. Not redefined by the light theme. */
  --photo-bg: var(--gray-0);
  /* …and never touches its frame's edge (task 128): the padding of the picture (the img) inside its frame. 7 % is of
     the img's containing block, i.e. the frame's width: 4 px up to a 57 px frame (the 48 px rows), 5 px at 72,
     6.7 at 96, 8 px from 115 px up. */
  --photo-inset: clamp(4px, 7%, 8px);
  --bg: var(--gray-950);
  --surface-1: var(--gray-900);
  --surface-2: var(--gray-850);
  --surface-3: var(--gray-800);
  --border: var(--gray-750);
  --border-strong: var(--gray-700);
  --text: var(--gray-150);
  --text-muted: var(--gray-400);
  --text-faint: var(--gray-500);
  --accent: var(--amber-500);
  --accent-hover: var(--amber-400);
  --accent-contrast: var(--gray-900);
  --down-contrast: var(--gray-900);
  --accent-text: var(--amber-500);
  --up: var(--green-400);
  --up-bg: var(--green-900);
  --down: var(--red-400);
  --down-bg: var(--red-900);
  --warn: var(--amber-400);
  --warn-bg: var(--amber-900);
  --info: var(--blue-400);
  --info-bg: var(--blue-900);
  --focus-ring: var(--amber-500);
  --overlay: rgba(0, 0, 0, 0.6);
  --chart-1: var(--blue-400);
  --chart-2: var(--orange-400);
  --chart-3: var(--gray-400);
  --chart-4: var(--teal-400);
  --chart-5: var(--violet-400);
  --chart-6: var(--red-400);
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 12px 32px rgba(0, 0, 0, 0.5);
  /* How much of a pale glass highlight shows (task 182, /Minifigures' display case, 08-minifigures.css): its white and
     pale rgba() are mixed with transparent at this share — the light theme's 100 % is task 118's glass as it was. */
  --glass-light: 30%;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: var(--gray-100);
  --surface-1: var(--gray-0);
  --surface-2: var(--gray-50);
  --surface-3: var(--gray-150);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-850);
  --text-muted: var(--gray-600);
  --text-faint: var(--gray-500);
  --accent: var(--amber-500);
  --accent-hover: var(--amber-600);
  --accent-contrast: var(--gray-850);
  --down-contrast: var(--gray-0);
  --accent-text: var(--amber-700);
  --up: var(--green-600);
  --up-bg: var(--green-50);
  --down: var(--red-600);
  --down-bg: var(--red-50);
  --warn: var(--amber-700);
  --warn-bg: var(--amber-50);
  --info: var(--blue-600);
  --info-bg: var(--blue-50);
  --focus-ring: var(--blue-600);
  --overlay: rgba(11, 14, 17, 0.45);
  --chart-1: var(--blue-600);
  --chart-2: var(--orange-700);
  --chart-3: var(--gray-500);
  --chart-4: var(--teal-700);
  --chart-5: var(--violet-600);
  --chart-6: var(--red-600);
  --shadow-1: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-2: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.14);
  --glass-light: 100%;
}

/* The system's own choice, when nobody picked one: the same values as [data-theme="light"]. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: var(--gray-100);
    --surface-1: var(--gray-0);
    --surface-2: var(--gray-50);
    --surface-3: var(--gray-150);
    --border: var(--gray-200);
    --border-strong: var(--gray-300);
    --text: var(--gray-850);
    --text-muted: var(--gray-600);
    --text-faint: var(--gray-500);
    --accent: var(--amber-500);
    --accent-hover: var(--amber-600);
    --accent-contrast: var(--gray-850);
    --down-contrast: var(--gray-0);
    --accent-text: var(--amber-700);
    --up: var(--green-600);
    --up-bg: var(--green-50);
    --down: var(--red-600);
    --down-bg: var(--red-50);
    --warn: var(--amber-700);
    --warn-bg: var(--amber-50);
    --info: var(--blue-600);
    --info-bg: var(--blue-50);
    --focus-ring: var(--blue-600);
    --overlay: rgba(11, 14, 17, 0.45);
    --chart-1: var(--blue-600);
    --chart-2: var(--orange-700);
    --chart-3: var(--gray-500);
    --chart-4: var(--teal-700);
    --chart-5: var(--violet-600);
    --chart-6: var(--red-600);
    --shadow-1: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-2: 0 0 0 1px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.14);
    --glass-light: 100%;
  }
}

/* The pre-100 names, kept so the pages 101+ have not redone yet follow the theme. Declared on every theme scope,
   because a var() resolves where it is declared: on :root alone a light pane inside a dark page would keep the dark
   values. New code reads the layer-2 names above, never these. */
:root,
[data-theme] {
  --surface: var(--surface-1);
  --muted: var(--text-muted);
  --good: var(--up);
  --good-bg: var(--up-bg);
  --accent-2: var(--amber-500);
  --shadow: var(--shadow-2);

  /* Bootstrap 5.3 reads these; pointing them at the tokens themes its tables, forms, cards and menus without
     data-bs-theme. The -rgb triples are for its translucent fills (stripes, hovers). */
  --bs-body-bg: var(--surface-1);
  --bs-body-color: var(--text);
  --bs-emphasis-color: var(--text);
  --bs-heading-color: var(--text);
  --bs-secondary-color: var(--text-muted);
  --bs-tertiary-color: var(--text-faint);
  --bs-secondary-bg: var(--surface-2);
  --bs-tertiary-bg: var(--surface-2);
  --bs-border-color: var(--border);
  --bs-border-color-translucent: var(--border);
  --bs-link-color: var(--accent-text);
  --bs-link-hover-color: var(--accent-text);
  --bs-code-color: var(--down);
  --bs-body-font-family: var(--font-sans);
}

:root,
[data-theme="dark"] {
  --bs-body-color-rgb: 234, 236, 239;
  --bs-body-bg-rgb: 24, 26, 32;
  --bs-emphasis-color-rgb: 234, 236, 239;
  --bs-secondary-bg-rgb: 30, 35, 41;
  --bs-tertiary-bg-rgb: 30, 35, 41;
  --bs-link-color-rgb: 240, 185, 11;
  --bs-link-hover-color-rgb: 252, 213, 53;
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23929aa5' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  --bs-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="light"] {
  --bs-body-color-rgb: 30, 35, 41;
  --bs-body-bg-rgb: 255, 255, 255;
  --bs-emphasis-color-rgb: 30, 35, 41;
  --bs-secondary-bg-rgb: 245, 246, 248;
  --bs-tertiary-bg-rgb: 245, 246, 248;
  --bs-link-color-rgb: 138, 90, 0;
  --bs-link-hover-color-rgb: 138, 90, 0;
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235e6673' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  --bs-btn-close-filter: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bs-body-color-rgb: 30, 35, 41;
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-emphasis-color-rgb: 30, 35, 41;
    --bs-secondary-bg-rgb: 245, 246, 248;
    --bs-tertiary-bg-rgb: 245, 246, 248;
    --bs-link-color-rgb: 138, 90, 0;
    --bs-link-hover-color-rgb: 138, 90, 0;
    --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%235e6673' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    --bs-btn-close-filter: none;
  }
}

/* Bootstrap sets the select arrow per element, and the close button's filter only under data-bs-theme. */
.form-select {
  --bs-form-select-bg-img: inherit;
}

.btn-close {
  filter: var(--bs-btn-close-filter);
}
