/* ==========================================
   Design tokens: the theme, and nothing else
   ==========================================

   CHANGING THE THEME: this file and nothing else. Colours are edited in the
   tier 0 primitives (a hue) or by re-pointing a tier 1 role (a decision);
   type, radii, spacing and shadows are tier 1 roles. Then run
   `uv run pytest frontend/tests/test_design_tokens.py`, which recomputes the
   contrasts and lists any stray value left in another file.

   Three things live outside this file and follow a change of brand:
   - the text face is preloaded by templates/base.html,
     templates/users/login.html and templates/users/home.html: another typeface changes (or drops) that
     preload too, and the guard checks that the preloaded file is the
     @font-face of the first family of --font-sans;
   - static/img/favicon.svg carries the literal values of --accent-fill,
     --spark and --text-on-fill (the browser reads it outside the page), and
     the guard checks that it still matches them;
   - --type-float and --viz-series-1 are data colours tied to a violet
     primitive, not to --accent: after a change of hue, check that they stay
     distinct from the other types and series.

   Two tiers, one rule:
   - Tier 0, `--_family-step`: the raw palette. Literals only, read by nobody
     outside this file.
   - Tier 1, roles: `var(--_*)`, `color-mix(in srgb, var(--_x) N%, transparent)`
     (a translucent role), or composites (shadows) built from those. Sizes,
     radii, spaces, font stacks and durations are literal roles directly.
   Stylesheets, templates and scripts read ROLES only. JS reads them through
   SotisTheme (static/js/theme.js), and only roles that resolve to an opaque hex:
   translucency in JS goes through SotisTheme.alpha().

   One theme, light. No toggle, no data-theme, no prefers-color-scheme: a
   different look is a different version of this file.

   Loaded by base.html, users/login.html and users/home.html BEFORE base.css and components.css.
   The values are those of the Sotis AI site (sotis_pj1, app 1 tokens.css). */

/* ---- SELF-HOSTED TYPEFACES ----
   Red Hat Text (text and small headings), Red Hat Display (large titles: page
   titles, the mission title, the preview title, the login pitch) and Geist Mono (technical
   signage: eyebrows, tags, counters, figures), all SIL Open Font License 1.1
   (fonts/OFL-red-hat-text.txt, fonts/OFL-red-hat-display.txt and fonts/OFL.txt;
   provenance of the Red Hat subsets in fonts/SOURCES-red-hat-text.md and
   fonts/SOURCES-red-hat-display.md).
   Self-hosted rather than pulled from the Google Fonts CDN: the CDN discloses
   every visitor's IP to a third party, and it adds a render-blocking round trip.

   Both families are VARIABLE, so one file covers the whole weight range.
   Red Hat Text and Red Hat Display ship as a single latin + French typography
   subset each; Geist Mono as its latin and latin-ext subsets. Only the text face
   is preloaded: until Red Hat Display arrives, a title falls back to the
   preloaded Red Hat Text, a near twin, so the swap barely shows.

   The url() paths are relative to THIS file, on purpose:
   CompressedManifestStaticFilesStorage rewrites them to hashed names at
   collectstatic time, and a path it cannot resolve makes collectstatic exit
   non-zero (entrypoint.sh runs it before gunicorn). Never make them absolute. */

@font-face {
  font-family: 'Red Hat Text';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("../fonts/red-hat-text.2f7ed2767f12.woff2") format('woff2');
}

@font-face {
  font-family: 'Red Hat Display';
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../fonts/red-hat-display.b9c1351f9663.woff2") format('woff2');
}

@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("../fonts/geist-mono-latin-ext.a27466d06912.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;
}

@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url("../fonts/geist-mono-latin.cd5b25781181.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;
}

/* ==========================================
   TIER 0: PRIMITIVES (private, literals only)
   ========================================== */
:root {
  /* Neutrals: a cool grey-blue family, graphite at the dark end. */
  --_white: #FFFFFF;
  --_neutral-25: #F6F8FA;
  --_neutral-50: #F2F5F8;
  --_neutral-100: #EAEFF4;
  --_neutral-150: #E1E6EC;
  --_neutral-200: #DDE3EA;
  --_neutral-300: #C3CCD6;
  --_neutral-350: #B8C1CC;
  --_neutral-400: #9AA5B1;
  --_neutral-450: #8A95A1;
  --_neutral-500: #77838F;
  --_neutral-600: #5B6675;
  --_neutral-650: #566170;
  --_neutral-700: #46515F;
  --_neutral-750: #3D4856;
  --_neutral-800: #2E3A47;
  --_neutral-900: #1F2933;

  /* Violet: the brand hue. 300 is the logo violet. */
  --_violet-50: #EFEEFF;
  --_violet-250: #BBB6EF;
  --_violet-300: #C09CF0;
  --_violet-500: #7B5CD6;
  --_violet-600: #6441C9;
  --_violet-700: #5531B2;

  /* Yellow: the spark. 400 is the logo yellow. */
  --_yellow-50: #FFF9D9;
  --_yellow-400: #F7E64D;
  --_yellow-500: #E5D43E;
  --_yellow-800: #7A6400;

  --_green-600: #2B8048;
  --_green-700: #1B6B3F;
  --_amber-300: #F5B26B;
  --_amber-600: #B8740B;
  --_amber-700: #8A5300;
  --_red-600: #C8322B;
  --_red-700: #B42318;
  --_teal-600: #0F8F84;
  --_teal-700: #0B6E66;
  --_ochre-600: #B7791F;
  --_rose-600: #D0476F;
  --_rose-700: #B03A5E;
  --_blue-700: #1E5AA0;
}

/* ==========================================
   TIER 1: ROLES (public)
   Ratios: WCAG 2.x, recomputed by test_design_tokens.py.
   ========================================== */
:root {
  /* ---- ACCENT ----
     Violet is spent on links, meaningful eyebrows, numbers and focus, not on
     every title. */
  --accent: var(--_violet-600);            /* links, eyebrows that matter, numbers, focus. 6.1:1 on canvas */
  --accent-strong: var(--_violet-700);     /* hover of accent fills, accent ink on a wash */
  --accent-fill: var(--_violet-600);       /* the accent fill that carries white text (6.7:1) */
  --accent-soft: var(--_violet-50);        /* flat lavender surface. Never ink */
  --accent-line: var(--_violet-250);       /* accent hairline */
  --accent-on-inverse: var(--_violet-300); /* the only accent readable on graphite */
  --accent-wash: color-mix(in srgb, var(--accent) 8%, transparent);
  --accent-wash-strong: color-mix(in srgb, var(--accent) 14%, transparent);

  /* ---- SPARK ----
     Rare: at most one filled use per screen, and never alone on a light
     surface (always ringed by ink: a graphite block or chip). */
  --spark: var(--_yellow-400);
  --spark-hover: var(--_yellow-500);
  --spark-soft: var(--_yellow-50);
  --spark-ink: var(--_yellow-800);         /* the spark as readable ink, 5.3:1 on canvas */

  /* ---- SURFACES ----
     A cool canvas; white sheets float on it. Depth comes from hairlines plus
     long ink-tinted shadows, never from grey fills. */
  --bg-primary: var(--_neutral-50);        /* the canvas (= theme-color of base.html) */
  --bg-secondary: var(--_neutral-100);     /* tray: sunken wells, chip grids */
  --card-bg: var(--_white);
  --surface-raised: var(--_white);         /* popovers, toasts, dialogs */
  --input-bg: var(--_white);
  --well-bg: var(--_neutral-25);           /* quiet inset on a white panel (key facts) */
  --header-bg: color-mix(in srgb, var(--_white) 78%, transparent);   /* glass rail, with blur */

  /* ---- INVERSE ----
     At most one dark block per page, and graphite chips. A surface inverted
     locally re-points the ink roles to these (components.css, .card-inverse). */
  --surface-inverse: var(--_neutral-900);
  --surface-inverse-hover: var(--_neutral-800);
  --text-inverse: var(--_neutral-50);
  --text-inverse-secondary: var(--_neutral-350);
  --border-inverse: color-mix(in srgb, var(--_white) 12%, transparent);
  --hover-bg-inverse: color-mix(in srgb, var(--_white) 8%, transparent);
  --warning-on-inverse: var(--_amber-300); /* a warning readable on graphite (sidebar source alert) */

  /* ---- SELECTED CHIP ----
     The active state of every selection chip, tab and pill: graphite, the
     current choice is ink. One place to change it for all of them. */
  --chip-active-bg: var(--surface-inverse);
  --chip-active-text: var(--text-on-fill);
  --chip-active-border: var(--surface-inverse);

  /* ---- TAB BAND ----
     Tabs set into the head of a white sheet (Profile): a grey band split by
     --border-strong hairlines; the active tab is the sheet itself (--card-bg)
     underlined in --accent. 7.4 / 5.0:1 on the band. */
  --tab-band-bg: var(--_neutral-150);
  --tab-ink: var(--_neutral-750);
  --tab-sub-ink: var(--_neutral-650);
  --savebar-bg: color-mix(in srgb, var(--_white) 88%, transparent);   /* glass save bar, with blur */

  /* ---- HAIRLINES ----
     Solid greys: a translucent line goes muddy on the tray. Decorative
     (1.2-1.6:1); controls use --border-control. */
  --border-color: var(--_neutral-200);
  --border-strong: var(--_neutral-300);
  --border-hover: var(--_neutral-400);
  --border-control: var(--_neutral-500);   /* input outlines, 3.9:1 on white */

  /* ---- HOVER, STRIPES ---- */
  --hover-bg: color-mix(in srgb, var(--_neutral-900) 5%, transparent);
  --row-stripe: color-mix(in srgb, var(--_neutral-900) 3%, transparent);

  /* ---- INK ---- 13.5 / 7.4 / 5.3:1 on canvas */
  --text-primary: var(--_neutral-900);
  --text-secondary: var(--_neutral-700);
  --text-tertiary: var(--_neutral-600);
  --text-on-fill: var(--_white);           /* ink on an accent, status or graphite fill */
  --text-on-spark: var(--_neutral-900);    /* ink on the spark (11.5:1) */

  --fill-muted: var(--_neutral-450);       /* neutral fill (inactive dot, scrollbar thumb) */
  --focus-ring: var(--accent);

  /* ---- VEILS ---- */
  --scrim: color-mix(in srgb, var(--_neutral-900) 45%, transparent);   /* modal backdrop */
  --veil: color-mix(in srgb, var(--_white) 85%, transparent);          /* light loading veil */

  /* ---- STATUS ---- quartets: mark, background, ink on that background, line */
  --success: var(--_green-600);
  --success-bg: color-mix(in srgb, var(--success) 10%, transparent);
  --success-text: var(--_green-700);
  --success-line: color-mix(in srgb, var(--success) 30%, transparent);
  --warning: var(--_amber-600);
  --warning-bg: color-mix(in srgb, var(--warning) 12%, transparent);
  --warning-text: var(--_amber-700);
  --warning-line: color-mix(in srgb, var(--warning) 30%, transparent);
  --danger: var(--_red-600);
  --danger-bg: color-mix(in srgb, var(--danger) 8%, transparent);
  --danger-text: var(--_red-700);
  --danger-line: color-mix(in srgb, var(--danger) 30%, transparent);
  --info: var(--accent);
  --info-bg: color-mix(in srgb, var(--accent) 8%, transparent);
  --info-text: var(--_neutral-750);
  --info-line: var(--accent-line);

  /* ---- CODE ---- a light well for JSON and logs */
  --code-bg: var(--_neutral-25);
  --code-text: var(--_neutral-900);

  /* ---- DATA TYPES ----
     Badges of data columns and categories: ink on white or on its own wash
     (color-mix of the role), all >= 4.5:1 on white. */
  --type-integer: var(--_blue-700);
  --type-float: var(--_violet-600);
  --type-categorical: var(--_rose-700);
  --type-datetime: var(--_amber-700);
  --type-boolean: var(--_green-700);

  /* ---- VERDICTS ----
     The score of a mission: figure, mini bar and chip share one hue per
     verdict. Ink is readable on white and on its own wash. */
  --verdict-top: var(--success-text);
  --verdict-top-bg: var(--success-bg);
  --verdict-good: var(--accent);
  --verdict-good-bg: var(--accent-soft);
  --verdict-maybe: var(--warning-text);
  --verdict-maybe-bg: var(--warning-bg);
  --verdict-none: var(--text-tertiary);
  --verdict-none-bg: var(--bg-secondary);
  --subscore-low: var(--warning);          /* a sub-score under 50 */

  /* ---- JOURNAL ----
     One hue per category of the activity journal: the row takes the wash,
     the category label the ink (>= 4.5:1 on white and on its wash). */
  --journal-collect: var(--_teal-700);
  --journal-collect-bg: color-mix(in srgb, var(--_teal-600) 11%, transparent);
  --journal-scoring: var(--_violet-600);
  --journal-scoring-bg: color-mix(in srgb, var(--_violet-600) 9%, transparent);
  --journal-tracking: var(--_blue-700);
  --journal-tracking-bg: color-mix(in srgb, var(--_blue-700) 9%, transparent);
  --journal-profile: var(--_amber-700);
  --journal-profile-bg: color-mix(in srgb, var(--_amber-600) 13%, transparent);
  --journal-auth: var(--_neutral-600);
  --journal-auth-bg: color-mix(in srgb, var(--_neutral-900) 5%, transparent);

  /* ---- DATA-VIZ ---- calibrated on the light canvas */
  /* Categorical: >= 3.3:1 against canvas at 2px stroke. */
  --viz-series-1: var(--_violet-500);
  --viz-series-2: var(--_teal-600);
  --viz-series-3: var(--_ochre-600);
  --viz-series-4: var(--_rose-600);
  /* Plot chrome. */
  --viz-axis: var(--_neutral-450);
  --viz-grid: var(--_neutral-150);
  --viz-tick: var(--_neutral-650);

  /* ---- TYPOGRAPHY ---- */
  --font-sans: 'Red Hat Text', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Red Hat Display', 'Red Hat Text', -apple-system,
    BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, 'Liberation Mono', monospace;

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;   /* buttons, labels */
  --font-weight-bold: 650;       /* headings (variable font: a static one rounds it) */
  --font-weight-heavy: 700;

  --text-2xs: 0.6875rem;   /* 11px, micro labels */
  --text-xs: 0.75rem;      /* 12px, mono labels, eyebrows */
  --text-sm: 0.8125rem;    /* 13px, metadata, chips */
  --text-ui: 0.875rem;     /* 14px, dense UI, code */
  --text-base: 0.9375rem;  /* 15px, UI text, buttons, fields */
  --text-md: 1rem;         /* 16px, body copy */
  --text-lg: 1.1875rem;    /* 19px, card titles, lead paragraphs */
  --text-xl: 1.375rem;     /* 22px */
  --text-2xl: 1.75rem;     /* 28px */
  --text-3xl: 2.25rem;     /* 36px, page titles */
  --text-4xl: 3rem;        /* 48px, metrics */

  --leading-tight: 1.08;
  --leading-snug: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.7;

  --tracking-tighter: -0.032em;  /* h1, page titles */
  --tracking-tight: -0.015em;    /* h2-h6, card titles, buttons */
  --tracking-normal: 0;
  --tracking-wide: 0.08em;       /* uppercase mono eyebrows */

  /* ---- SPACING ---- (tighter under 768px, see the end of this file) */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 3rem;
  --space-xl: 4rem;

  /* ---- RADII ---- */
  --radius-2xs: 2px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ---- ELEVATION ----
     Ink-tinted (never pure black), long blur, NEGATIVE spread: altitude
     without a grey halo. --ring-inset is the lit top edge of a white card. */
  --shadow-sm: 0 1px 2px color-mix(in srgb, var(--_neutral-900) 6%, transparent),
    0 1px 1px color-mix(in srgb, var(--_neutral-900) 4%, transparent);
  --shadow-md: 0 12px 28px -16px color-mix(in srgb, var(--_neutral-900) 30%, transparent),
    0 1px 2px color-mix(in srgb, var(--_neutral-900) 5%, transparent);
  --shadow-lg: 0 28px 56px -28px color-mix(in srgb, var(--_neutral-900) 38%, transparent),
    0 2px 6px color-mix(in srgb, var(--_neutral-900) 6%, transparent);
  --shadow-hover: 0 22px 44px -22px color-mix(in srgb, var(--_neutral-900) 40%, transparent),
    0 1px 2px color-mix(in srgb, var(--_neutral-900) 6%, transparent);
  --shadow-button: 0 10px 22px -12px color-mix(in srgb, var(--_neutral-900) 60%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--_white) 12%, transparent);
  --shadow-spark: 0 10px 24px -12px color-mix(in srgb, var(--_yellow-400) 55%, transparent);
  --shadow-header: 0 10px 28px -22px color-mix(in srgb, var(--_neutral-900) 35%, transparent);
  --shadow-focus: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  --ring-inset: inset 0 1px 0 color-mix(in srgb, var(--_white) 90%, transparent);

  /* ---- MOTION ---- */
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.4s ease;

  color-scheme: light;
}

@media (max-width: 768px) {
  :root {
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 2.5rem;
  }
}
