/* bitwerk design tokens – the single source for colours, type, shape, motion and touch.
   Used by the web UI (server/control-server/ui), the kiosks (client/display, native-ui) and the
   website (docs/site). Rules and rationale: docs/brand.md. Dark is the
   default theme; light via [data-bw-theme="light"] on <html>, the website's light look via
   [data-bw-theme="gallery"]. Reduced motion (the OS setting, or
   [data-bw-motion="reduced"] on <html>) sets every --bw-duration* to 0ms and so stops loops. */

:root {
  /* Graphite – neutral greys without a colour cast, from pure black (owner decision 2026-11-05: the earlier
     blue-tinted graphite read like a developer tool) */
  --bw-graphite-950: #000000;
  --bw-graphite-900: #0a0a0a;
  --bw-graphite-850: #101010;
  --bw-graphite-800: #151515;
  --bw-graphite-700: #242424;
  --bw-graphite-600: #333333;
  --bw-graphite-500: #4d4d4d;
  --bw-graphite-400: #8e8e8e;
  --bw-graphite-300: #b6b6b6;
  --bw-graphite-200: #d8d8d8;
  --bw-graphite-100: #e8e8e8;
  --bw-graphite-50: #f4f4f4;
  /* The light theme's field: the manual on white paper */
  --bw-white: #ffffff;

  /* Signal – the live light, a pure LED green (owner decision 2026-11-05, replacing the earlier mint) */
  --bw-signal-300: #7eeba0;
  --bw-signal-400: #2bd968;
  --bw-signal-500: #1fbf58;
  --bw-signal-600: #109a45;
  --bw-signal-700: #0b7a36;

  /* Cyan – information, the analog reference curve */
  --bw-cyan-400: #4fb3d9;
  --bw-cyan-600: #2a86ab;
  --bw-cyan-700: #1f6886;

  /* Amber – DSP active / warning */
  --bw-amber-400: #f2b84b;
  --bw-amber-600: #b9831c;
  --bw-amber-700: #8a6113;

  /* Rot – errors */
  --bw-red-400: #f2545b;
  --bw-red-600: #c23138;

  /* Cable colours – jackets and label sleeves of the cable builder (website), in the order of the
     resistor colour code (0 black … 9 white). Product colours, never a UI role. */
  --bw-cable-black: #1c1c1e;
  --bw-cable-brown: #6b4226;
  --bw-cable-red: #c8302c;
  --bw-cable-orange: #e8772e;
  --bw-cable-yellow: #f2c230;
  --bw-cable-green: #2e8b4e;
  --bw-cable-blue: #2f62b5;
  --bw-cable-violet: #7b4fa6;
  --bw-cable-grey: #8a8d91;
  --bw-cable-white: #f2f2f0;

  /* Semantic roles (dark theme). The field manual (docs/brand.md, "Design language"): a black field, regions
     divided by 1 px hairlines (--bw-border) rather than filled cards. */
  --bw-bg: var(--bw-graphite-950);
  --bw-surface: var(--bw-graphite-900);
  --bw-surface-raised: var(--bw-graphite-800);
  --bw-border: var(--bw-graphite-700);
  /* Boundary of a control that is only recognisable by its outline (text field, unchecked box, switch track):
     at least 3:1 against the surfaces around it (WCAG 2.2, 1.4.11); --bw-border stays for dividers and cards. */
  --bw-border-control: var(--bw-graphite-400);
  --bw-text: var(--bw-graphite-50);
  /* Secondary lines that carry information (album, times, subtitles, eyebrow): 10.4:1 on --bw-bg.
     --bw-text-muted is for tertiary text only (counts, hints). */
  --bw-text-secondary: var(--bw-graphite-300);
  --bw-text-muted: var(--bw-graphite-400);
  /* Black and white (docs/brand.md, "Colour"): every role is the text colour or a grey, a state is told by shape
     and fill. The main action is inverted (Graphite 950 on Graphite 50: 19.1:1). */
  --bw-accent: var(--bw-graphite-50);
  --bw-accent-text: var(--bw-graphite-50);
  --bw-on-accent: var(--bw-graphite-950);
  --bw-info: var(--bw-graphite-300);
  --bw-bitperfect: var(--bw-graphite-50);
  --bw-dsp: var(--bw-graphite-50);
  --bw-danger: var(--bw-red-400);
  /* The one green: the live light, a small round point like the devices' power LED, lit while the signal is live
     and unaltered (docs/brand.md, "The live light"). Never text, never a surface. */
  --bw-live: var(--bw-signal-400);
  /* Status and warning surfaces: 10 % of the text colour in both themes (text: --bw-bitperfect / --bw-dsp) */
  --bw-bitperfect-bg: color-mix(in srgb, var(--bw-bitperfect) 10%, transparent);
  --bw-dsp-bg: color-mix(in srgb, var(--bw-dsp) 10%, transparent);
  /* 15 % of the theme's own colour (text: --bw-info; --bw-text ringed in --bw-danger) */
  --bw-info-bg: color-mix(in srgb, var(--bw-info) 15%, transparent);
  --bw-danger-bg: color-mix(in srgb, var(--bw-danger) 15%, transparent);
  --bw-focus: 0 0 0 2px var(--bw-bg), 0 0 0 4px var(--bw-text);
  /* The same ring drawn inside the box, for elements that clip what is painted outside them */
  --bw-focus-inset: inset 0 0 0 2px var(--bw-text), inset 0 0 0 4px var(--bw-bg);
  /* Floating elements only (menus, dialogs, toasts) and the backdrop behind dialogs */
  --bw-shadow: 0 16px 48px color-mix(in srgb, var(--bw-graphite-950) 60%, transparent);
  --bw-scrim: color-mix(in srgb, var(--bw-graphite-950) 72%, transparent);
  /* Placeholder cover tints (docs/brand.md "Covers"), greys only and dark in both themes: Graphite
     700, 600 and 800, then the halves between 700 and 600 and between 800 and 700, precomputed for
     the native kiosk (LVGL has no color-mix) */
  --bw-cover-tint-1: var(--bw-graphite-700);
  --bw-cover-tint-2: var(--bw-graphite-600);
  --bw-cover-tint-3: var(--bw-graphite-800);
  --bw-cover-tint-4: #2c2c2c;
  --bw-cover-tint-5: #1d1d1d;

  /* Typography */
  --bw-font-display: 'Space Grotesk', 'bitwerk Scripts', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bw-font-body: 'IBM Plex Sans', 'bitwerk Scripts', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --bw-font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  /* The weight of running text: IBM Plex Sans's Text cut, between Regular and Medium (docs/brand.md, "Typography") */
  --bw-weight-body: 450;
  --bw-text-xs: 0.75rem;
  --bw-text-sm: 0.875rem;
  --bw-text-md: 1rem;
  /* Running text on the website: 18 px (owner decision 2026-11-06, internal:design-process/website-range.md) */
  --bw-text-reading: 1.125rem;
  --bw-text-lg: 1.25rem;
  --bw-text-xl: 1.75rem;
  --bw-text-2xl: 2.5rem;
  /* Far-view title of the kiosk's Now playing (readable from 1.5–2 m on a 7" panel) */
  --bw-text-3xl: 3.5rem;
  /* Far-view title of the kiosk's "Huge" style (a 15 mm cap height, readable from 3 m on a 7" panel) */
  --bw-text-4xl: 7rem;

  /* Shape and space: the field manual has square corners, softened by 2 px on every element (one radius for
     badges, controls, cards, dialogs and covers; the three names stay so components keep their role) */
  --bw-radius-sm: 2px;
  --bw-radius: 2px;
  --bw-radius-lg: 2px;
  --bw-space-1: 4px;
  --bw-space-2: 8px;
  --bw-space-3: 12px;
  --bw-space-4: 16px;
  --bw-space-5: 24px;
  --bw-space-6: 32px;
  --bw-space-7: 48px;
  --bw-stroke: 1.5px;

  /* Motion (theme-independent): one-shot durations from short feedback up to sheets, at most
     320ms, and the period of the looping connecting and loading indicators */
  --bw-duration-fast: 100ms;
  --bw-duration: 160ms;
  --bw-duration-slow: 240ms;
  --bw-duration-sheet: 320ms;
  /* the website's crossfade from page to page (owner decision 2026-11-06) */
  --bw-duration-page: 180ms;
  --bw-duration-loop: 800ms;
  --bw-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --bw-ease-enter: cubic-bezier(0, 0, 0, 1);
  --bw-ease-exit: cubic-bezier(0.3, 0, 1, 1);

  /* Touch: the smallest touch target on every touch surface */
  --bw-touch: 48px;

  /* The web UI's settings grid (docs/interface-guidelines.md §1.8): category menu, gaps, content
     column, page index */
  --bw-settings-menu: 240px;
  --bw-settings-gap: 56px;
  --bw-settings-column: 768px;
  --bw-settings-index: 184px;
}

[data-bw-theme='light'] {
  /* The same manual on white */
  --bw-bg: var(--bw-white);
  --bw-surface: var(--bw-graphite-50);
  --bw-surface-raised: var(--bw-graphite-100);
  --bw-border: var(--bw-graphite-200);
  --bw-border-control: var(--bw-graphite-500);
  --bw-text: var(--bw-graphite-900);
  --bw-text-secondary: var(--bw-graphite-600);
  --bw-text-muted: var(--bw-graphite-500);
  --bw-accent: var(--bw-graphite-900);
  --bw-accent-text: var(--bw-graphite-900);
  --bw-on-accent: var(--bw-white);
  --bw-info: var(--bw-graphite-600);
  --bw-bitperfect: var(--bw-graphite-900);
  --bw-dsp: var(--bw-graphite-900);
  --bw-danger: var(--bw-red-600);
  /* Signal 600 on white is 3.7:1: enough for a point, never for text */
  --bw-live: var(--bw-signal-600);
  /* Declared again, so they resolve the light colours where the theme is set on an element */
  --bw-bitperfect-bg: color-mix(in srgb, var(--bw-bitperfect) 10%, transparent);
  --bw-dsp-bg: color-mix(in srgb, var(--bw-dsp) 10%, transparent);
  --bw-info-bg: color-mix(in srgb, var(--bw-info) 15%, transparent);
  --bw-danger-bg: color-mix(in srgb, var(--bw-danger) 15%, transparent);
  --bw-focus: 0 0 0 2px var(--bw-bg), 0 0 0 4px var(--bw-text);
  --bw-focus-inset: inset 0 0 0 2px var(--bw-text), inset 0 0 0 4px var(--bw-bg);
  --bw-shadow: 0 16px 48px color-mix(in srgb, var(--bw-graphite-900) 18%, transparent);
  --bw-scrim: color-mix(in srgb, var(--bw-graphite-900) 40%, transparent);
}

/* The website's light look ("Galerie", owner pick 2026-11-13, internal:design-process/website-otoka.md): a calm
   paper-grey field, hairlines, no colour. Only the website sets it (data-bw-theme="gallery" on <html>); the web UI,
   the kiosk and the apps keep dark and light above, and tokens-gen does not read this block. Text and lines are the
   near-black of the logo; the second text colour is 62 % of it on the field (5.5:1 on the field, 5.1:1 on the
   surface). The live light is the logo's square here, in the text colour. Headlines and text are set in Inter
   (fonts/fonts.css), labels and controls in the mono face like the logo. */
[data-bw-theme='gallery'] {
  --bw-bg: var(--bw-graphite-50);
  --bw-surface: #ececec;
  --bw-surface-raised: var(--bw-white);
  --bw-border: color-mix(in srgb, var(--bw-graphite-900) 14%, transparent);
  --bw-border-control: var(--bw-graphite-500);
  --bw-text: var(--bw-graphite-900);
  --bw-text-secondary: color-mix(in srgb, var(--bw-graphite-900) 62%, var(--bw-graphite-50));
  --bw-text-muted: color-mix(in srgb, var(--bw-graphite-900) 62%, var(--bw-graphite-50));
  --bw-accent: var(--bw-graphite-900);
  --bw-accent-text: var(--bw-graphite-900);
  --bw-on-accent: var(--bw-graphite-50);
  --bw-info: var(--bw-graphite-600);
  --bw-bitperfect: var(--bw-graphite-900);
  --bw-dsp: var(--bw-graphite-900);
  --bw-danger: var(--bw-red-600);
  --bw-live: var(--bw-graphite-900);
  --bw-bitperfect-bg: color-mix(in srgb, var(--bw-bitperfect) 10%, transparent);
  --bw-dsp-bg: color-mix(in srgb, var(--bw-dsp) 10%, transparent);
  --bw-info-bg: color-mix(in srgb, var(--bw-info) 15%, transparent);
  --bw-danger-bg: color-mix(in srgb, var(--bw-danger) 15%, transparent);
  --bw-focus: 0 0 0 2px var(--bw-bg), 0 0 0 4px var(--bw-text);
  --bw-focus-inset: inset 0 0 0 2px var(--bw-text), inset 0 0 0 4px var(--bw-bg);
  --bw-shadow: 0 16px 48px color-mix(in srgb, var(--bw-graphite-900) 14%, transparent);
  --bw-scrim: color-mix(in srgb, var(--bw-graphite-900) 40%, transparent);
  --bw-font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --bw-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --bw-weight-body: 400;
}

/* Reduced motion makes everything instant: every duration token becomes 0ms, whether the OS asks
   for it or the app sets data-bw-motion="reduced" on <html>. A loop with a 0ms period does not run,
   so its indicator stays visible but static. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --bw-duration-fast: 0ms;
    --bw-duration-page: 0ms;
    --bw-duration: 0ms;
    --bw-duration-slow: 0ms;
    --bw-duration-sheet: 0ms;
    --bw-duration-loop: 0ms;
  }
}

:root[data-bw-motion='reduced'] {
  --bw-duration-fast: 0ms;
  --bw-duration-page: 0ms;
  --bw-duration: 0ms;
  --bw-duration-slow: 0ms;
  --bw-duration-sheet: 0ms;
  --bw-duration-loop: 0ms;
}
