/* SPDX-License-Identifier: MIT OR CC-BY-SA-4.0 */
/* tokens.css – Build a CubeSat design tokens as CSS custom properties.

   Written by bac-design-tokens from tools/bac-design-tokens/src/bac_design_tokens/tokens.json,
   the canonical copy of the BAC Identity Guide 1.0 tokens (§3 typography, §4 color, §5 form,
   §7 Mission surfaces) and the state, hero and chart tokens of the BAC Interface Design
   Guide 1.0. Change tokens.json and run `uv run --no-sync bac-design-tokens`; edits made here
   are overwritten. The bac-suite index page serves an identical copy, and the marimo style
   cells and the Rich colors in bac-common are written from the same file.

   Light and dark: the semantic tokens follow prefers-color-scheme, and a
   data-theme="light" or data-theme="dark" attribute on any element pins its
   subtree to one mode, text color included (Interface Design Guide §3). */

/* Fonts: this copy loads none. The site that uses it serves Nunito Sans and IBM Plex Mono itself
   (the files are in bac-design `fonts/`), so a visitor's browser makes no request to a font service. */

/* 1. Canonical tokens – the same in light and dark */
:root {
  /* Typography – Identity Guide §3: Nunito wordmark, Nunito Sans headings (500) and body (400), IBM Plex Mono for labels, figures and code */
  --font-logo: 'Nunito', system-ui, sans-serif; /* wordmark only, uppercase */
  --font-display: 'Nunito Sans', system-ui, sans-serif;
  --font-body: 'Nunito Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace; /* labels, figures, identifiers, code – never body prose */
  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-heading: 500; /* headings and display */
  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.375rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.25rem;
  --text-3xl: 3rem;
  --text-4xl: 4rem;
  --text-5xl: 5.5rem;
  --lh-tight: 1.05;
  --lh-snug: 1.2;
  --lh-normal: 1.45;
  --lh-relaxed: 1.65;
  --ls-tight: -0.02em; /* display headings */
  --ls-normal: 0;
  --ls-label: 0.03em; /* uppercase mono labels, eyebrows, chips, buttons */

  /* Brand and status – Identity Guide §4.1; status fills are the same in both modes, text uses the inks below */
  --bac-yellow: #F7D400; /* light-mode primary action; caution in both modes */
  --bac-yellow-press: #EED228;
  --bac-green: #3FB950; /* nominal, pass */
  --bac-red: #E94538; /* alarm, fail */
  --bac-blue: #004C8B; /* info; the hero card's fill */
  --bac-blue-press: #0B5CAD;

  /* Nebula triad – Identity Guide §4.2; Mission and marketing only, never next to status colors */
  --nebula-teal: #0E9594; /* Orbital Teal */
  --nebula-violet: #7A5AF8; /* Ion Violet */
  --nebula-rose: #C64677; /* Plasma Rose – also Mission draft labels and ornamental bars */
  --nebula-teal-tint: #E1F3F2;
  --nebula-violet-tint: #ECEBFF;
  --nebula-rose-tint: #FFE7ED;
  --mission-teal-ink: #007878; /* text on paper, white and the tint, AA */
  --mission-violet-ink: #6E4BE8;
  --mission-rose-ink: #B8396B;
  --mission-teal-on-dark: #1A9A99; /* text on space-ink and space-surface, AA */
  --mission-violet-on-dark: #8F73FF;
  --mission-rose-on-dark: #DE5C8C;

  /* Neutral ramp – Identity Guide §4.3; the light family (dark-mode surfaces are in the semantic block) */
  --neutral-0: #FFFFFF;
  --neutral-50: #F9F9F9;
  --neutral-100: #F1F1F1;
  --neutral-200: #E6E6E6;
  --neutral-300: #D0D0D0;
  --neutral-400: #A9A9A9;
  --neutral-500: #8A8A8A;
  --neutral-600: #6D6D6D;
  --neutral-700: #4F4F4F;
  --neutral-800: #3F3F3F;
  --neutral-900: #282828;
  --neutral-950: #1F1F1F;

  /* Mission surfaces – Identity Guide §7 */
  --space-ink: #171320;
  --space-surface: #241B3F;
  --space-paper: #F4F1EA;
  --space-muted: #8F879E;
  --mission-viewport-bg: var(--space-ink);
  --mission-viewport-border: rgba(14, 149, 148, 0.38);
  --mission-viewport-glow: inset 0 0 24px rgba(14, 149, 148, 0.16), inset 0 0 72px rgba(122, 90, 248, 0.14);
  --mission-paper-well-bg: rgba(255, 255, 255, 0.42);
  --mission-paper-well-border: rgba(36, 27, 63, 0.14);
  --mission-paper-well-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.70), inset 0 -1px 3px rgba(23, 19, 32, 0.08);

  /* Hero card – Interface Design Guide §6; one per view, same in both modes; the red rule is decorative, not an alarm */
  --hero-bg: var(--bac-blue);
  --hero-text: #FFFFFF;
  --hero-rule: var(--bac-red);
  --kicker: var(--bac-yellow); /* the small brand bar before an eyebrow, both modes */

  /* One chart palette for surfaces of unknown theme (marimo notebooks) – about 4:1 on white and on #1F1E1D */
  --chart-shared-1: #2E7ED8;
  --chart-shared-2: #7D7D7D;
  --chart-shared-3: #9D7800;
  --chart-shared-4: #0E903A;
  --chart-shared-5: #E4463E;
  --chart-seq-1: #D6E6F8; /* sequential ramp, low end */
  --chart-seq-2: var(--chart-shared-1);
  --chart-seq-3: var(--bac-blue); /* sequential ramp, high end */

  /* Spacing and containers – Identity Guide §5.1 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;
  --container: 1200px; /* documents, storefront, reading pages */
  --container-wide: 1540px; /* dashboards and dense data views */
  --container-narrow: 760px;

  /* Corners and borders – Identity Guide §5.2, §5.4; no shadows, depth comes from background steps and hairlines */
  --radius-sm: 6px; /* inputs, tags, small elements */
  --radius-md: 10px; /* cards, panels, surfaces */
  --radius-pill: 100px; /* buttons, chips, tabs */
  --border-w: 1px;
  --border-w-thick: 1.5px;

  /* Motion – Interface Design Guide §4.1 */
  --ease-standard: cubic-bezier(0.2, 0, 0.1, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-normal: 200ms;
  --dur-slow: 320ms;
}

/* 2. Semantic tokens, light – the default, and anything under data-theme="light" */
:root,
[data-theme='light'] {
  color-scheme: light;
  /* Surfaces and text */
  --bg: #F9F9F9;
  --bg-raised: #FFFFFF;
  --surface-card: #FFFFFF;
  --surface-sunken: #F1F1F1;
  --surface-hover: #E6E6E6;
  --text: #3F3F3F;
  --text-strong: #1F1F1F;
  --text-muted: #6D6D6D;
  --text-faint: #8A8A8A; /* disabled and decorative only, never content */
  --text-on-accent: #3F3F3F; /* text on yellow */
  --border: #E6E6E6;
  --border-strong: #D0D0D0;
  --link: #0B5CAD;
  --focus-ring: #0B5CAD;

  /* Actions and state marks – yellow in light, neutral in dark (Interface Design Guide §3) */
  --btn-primary-bg: #F7D400;
  --btn-primary-hover: #EED228;
  --btn-primary-text: #3F3F3F;
  --accent-state: #F7D400; /* switch on, selected segment, current card, progress fill; a product's accent setting overrides only this pair */
  --accent-state-text: #3F3F3F;

  /* Status inks (text on cards and tints) and tints */
  --bac-green-ink: #1A7F37;
  --bac-red-ink: #C9302C;
  --bac-blue-ink: #0B5CAD;
  --bac-yellow-ink: #7A5F00;
  --bac-green-tint: #E8F7EA; /* green 12 % into white; dark: 16 % into #1F1E1D */
  --bac-red-tint: #FCE9E7; /* red 12 %; dark 16 % */
  --bac-blue-tint: #E6EDF3; /* blue 10 %; dark 22 % */
  --bac-yellow-tint: #FEF7D1; /* yellow 18 %; dark 14 % */

  /* Ops chart series in order – Interface Design Guide §8.1; green and red stay out of a chart that also carries pass/fail */
  --chart-1: #0B5CAD;
  --chart-2: #3F3F3F;
  --chart-3: #B58F00;
  --chart-4: #1A7F37;
  --chart-5: #C9302C;
  --chart-6: #8A8A8A;
}

/* 3. Semantic tokens, dark – the same block twice: once for the system
   preference, once for data-theme="dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    /* Surfaces and text */
    --bg: #1F1E1D;
    --bg-raised: #232221;
    --surface-card: #282726;
    --surface-sunken: #2F2E2D;
    --surface-hover: #353433;
    --text: #E5E5E5;
    --text-strong: #FFFFFF;
    --text-muted: #A9A8A6;
    --text-faint: #858483;
    --text-on-accent: #1F1E1D;
    --border: #353433;
    --border-strong: #3F3E3D;
    --link: #4C9AFF;
    --focus-ring: #4C9AFF;

    /* Actions and state marks – yellow in light, neutral in dark (Interface Design Guide §3) */
    --btn-primary-bg: #353433;
    --btn-primary-hover: #3F3E3D;
    --btn-primary-text: #E5E5E5;
    --accent-state: #E5E5E5;
    --accent-state-text: #1F1E1D;

    /* Status inks (text on cards and tints) and tints */
    --bac-green-ink: #3FB950;
    --bac-red-ink: #FF5A4F;
    --bac-blue-ink: #4C9AFF;
    --bac-yellow-ink: #F7D400;
    --bac-green-tint: #243725;
    --bac-red-tint: #3F2421;
    --bac-blue-tint: #182835;
    --bac-yellow-tint: #3D3719;

    /* Ops chart series in order – Interface Design Guide §8.1; green and red stay out of a chart that also carries pass/fail */
    --chart-1: #4C9AFF;
    --chart-2: #E5E5E5;
    --chart-3: #F7D400;
    --chart-4: #3FB950;
    --chart-5: #FF5A4F;
    --chart-6: #6B6B6B;
  }
}

[data-theme='dark'] {
  color-scheme: dark;
  /* Surfaces and text */
  --bg: #1F1E1D;
  --bg-raised: #232221;
  --surface-card: #282726;
  --surface-sunken: #2F2E2D;
  --surface-hover: #353433;
  --text: #E5E5E5;
  --text-strong: #FFFFFF;
  --text-muted: #A9A8A6;
  --text-faint: #858483;
  --text-on-accent: #1F1E1D;
  --border: #353433;
  --border-strong: #3F3E3D;
  --link: #4C9AFF;
  --focus-ring: #4C9AFF;

  /* Actions and state marks – yellow in light, neutral in dark (Interface Design Guide §3) */
  --btn-primary-bg: #353433;
  --btn-primary-hover: #3F3E3D;
  --btn-primary-text: #E5E5E5;
  --accent-state: #E5E5E5;
  --accent-state-text: #1F1E1D;

  /* Status inks (text on cards and tints) and tints */
  --bac-green-ink: #3FB950;
  --bac-red-ink: #FF5A4F;
  --bac-blue-ink: #4C9AFF;
  --bac-yellow-ink: #F7D400;
  --bac-green-tint: #243725;
  --bac-red-tint: #3F2421;
  --bac-blue-tint: #182835;
  --bac-yellow-tint: #3D3719;

  /* Ops chart series in order – Interface Design Guide §8.1; green and red stay out of a chart that also carries pass/fail */
  --chart-1: #4C9AFF;
  --chart-2: #E5E5E5;
  --chart-3: #F7D400;
  --chart-4: #3FB950;
  --chart-5: #FF5A4F;
  --chart-6: #6B6B6B;
}

/* 4. A pinned subtree sets its own text color: color is inherited as a
   computed value, so without this a data-theme="light" area inside a dark
   page would keep the page's light text. */
[data-theme] { color: var(--text); }
