/* SPDX-License-Identifier: GPL-3.0-only */
/* Copyright © 2026 infraBuilder SASU and contributors */

/*
 * Tobby UI — design tokens (FR-064).
 *
 * Single source of truth for the web UI palette, typography, spacing and
 * geometry. The canonical theme is dark (`:root`); the light theme is an
 * override selected with `data-theme="light"` on the root element.
 *
 * Token contract:
 *   - `*-text` tokens are for TEXT and must hold WCAG AA (>= 4.5:1) on both
 *     --tobby-bg and --tobby-bg-raise of their theme (enforced by
 *     internal/ui/contrast_test.go).
 *   - The same tokens without `-text` are for badge backgrounds, borders and
 *     graphic accents. Solid badges/buttons paint their text with
 *     --tobby-on-accent (#0b0d12), which must hold >= 4.5:1 on
 *     --tobby-accent and --tobby-success in both themes.
 */

:root {
  color-scheme: dark;

  /* ---- Surfaces ------------------------------------------------------- */
  --tobby-bg: #0b0d12;
  --tobby-bg-raise: #12151d;

  /* ---- Text ----------------------------------------------------------- */
  --tobby-text: #e8eaf0;
  --tobby-muted: #949aab;

  /* ---- Accent (amber identity) ---------------------------------------- */
  --tobby-accent: #f0a92e;
  --tobby-accent-soft: #ffc25c; /* hover of solid accent controls */
  --tobby-accent-text: #f0a92e;

  /* ---- Status --------------------------------------------------------- */
  --tobby-success: #6fce93;
  --tobby-success-text: #6fce93;
  --tobby-danger: #e0656f;
  --tobby-danger-text: #e0656f;

  /* Ink used on top of solid --tobby-accent / --tobby-success fills. */
  --tobby-on-accent: #0b0d12;

  /* Tinted status washes (banner and badge backgrounds). */
  --tobby-warning-bg: rgba(240, 169, 46, 0.1);
  --tobby-danger-bg: rgba(224, 101, 111, 0.1);
  --tobby-success-bg: rgba(111, 206, 147, 0.12);

  /* ---- Borders --------------------------------------------------------- */
  /* Hairline: decorative separators (cards, table rules). Not a control
     boundary, so it may stay below 3:1. */
  --tobby-border-hairline: rgba(255, 255, 255, 0.09);
  /* Control boundary (inputs, pills, outline buttons): composited on
     --tobby-bg this reaches >= 3:1 (WCAG 1.4.11 non-text contrast); the
     mockup's 0.28 alpha only reached 2.4:1 and was raised on purpose. */
  --tobby-border-control: rgba(255, 255, 255, 0.38);

  /* ---- Chips & skeletons ---------------------------------------------- */
  --tobby-chip-bg: rgba(255, 255, 255, 0.05);
  --tobby-skeleton-base: rgba(255, 255, 255, 0.06);
  --tobby-skeleton-sheen: rgba(255, 255, 255, 0.12);

  /* ---- Geometry -------------------------------------------------------- */
  --tobby-radius: 0.8rem; /* cards, tables, dialogs */
  --tobby-radius-sm: 0.55rem; /* buttons, inputs */
  --tobby-radius-xs: 0.3rem; /* inline code */

  /* ---- Focus ----------------------------------------------------------- */
  /* Used as `outline: var(--tobby-focus-ring)` with outline-offset. */
  --tobby-focus-ring: 2px solid var(--tobby-accent);

  /* ---- Typography ------------------------------------------------------ */
  --tobby-font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --tobby-font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Text scale (base 14px = 0.875rem, matching the validated mockup). */
  --tobby-text-2xs: 0.66rem; /* kickers, table headers, tile labels */
  --tobby-text-xs: 0.72rem; /* chips, form labels, metadata */
  --tobby-text-sm: 0.8rem; /* table cells, buttons, body-dense */
  --tobby-text-md: 0.875rem; /* base body */
  --tobby-text-lg: 1rem; /* brand, card titles */
  --tobby-text-xl: 1.15rem; /* page titles */
  --tobby-text-2xl: 1.25rem; /* dashboard tile values */

  /* ---- Spacing scale --------------------------------------------------- */
  --tobby-space-1: 0.25rem;
  --tobby-space-2: 0.5rem;
  --tobby-space-3: 0.75rem;
  --tobby-space-4: 1rem;
  --tobby-space-5: 1.5rem;
  --tobby-space-6: 2.5rem;
}

:root[data-theme="light"] {
  color-scheme: light;

  /* ---- Surfaces ------------------------------------------------------- */
  --tobby-bg: #faf9f6;
  --tobby-bg-raise: #ffffff;

  /* ---- Text ----------------------------------------------------------- */
  --tobby-text: #1a1d24;
  --tobby-muted: #5f6472;

  /* ---- Accent --------------------------------------------------------- */
  /* #c97e12 drew a focus ring of 2.97:1 on the light surfaces (WCAG 1.4.11
     asks 3:1); this shade reaches 3.7:1 there and keeps 5:1 with the badge
     ink (verified by contrast_test.go and the browser pass). */
  --tobby-accent: #b8710d;
  --tobby-accent-soft: #a9660b; /* light theme darkens on hover */
  --tobby-accent-text: #8c5a05; /* 5:1 on the tinted washes it also sits on (chips, partial badges): #9a6206 gave 4.4:1 */

  /* ---- Status --------------------------------------------------------- */
  /* Adjusted from the site palette's #1c7d43: with the #0b0d12 badge ink
     that green only reached 3.76:1; #259254 reaches 4.92:1 while staying
     in the same hue (verified by contrast_test.go). */
  --tobby-success: #259254;
  --tobby-success-text: #27704a; /* 5:1 on its own wash, which #2e7d4f missed (4.4:1) */
  --tobby-danger: #b3323e;
  --tobby-danger-text: #b3323e;

  /* Tinted status washes. */
  --tobby-warning-bg: rgba(201, 126, 18, 0.1);
  --tobby-danger-bg: rgba(179, 50, 62, 0.08);
  --tobby-success-bg: rgba(46, 125, 79, 0.1);

  /* ---- Borders --------------------------------------------------------- */
  --tobby-border-hairline: rgba(0, 0, 0, 0.1);
  /* >= 3:1 on --tobby-bg and --tobby-bg-raise (see dark theme note). */
  --tobby-border-control: rgba(0, 0, 0, 0.48);

  /* ---- Chips & skeletons ---------------------------------------------- */
  --tobby-chip-bg: rgba(0, 0, 0, 0.04);
  --tobby-skeleton-base: rgba(0, 0, 0, 0.05);
  --tobby-skeleton-sheen: rgba(0, 0, 0, 0.1);
}

/*
 * Operator theme override (ui.themeOverride).
 *
 * When the operator configures `ui.themeOverride`, the referenced stylesheet
 * is served AFTER this file, so any custom property redeclared there (on
 * `:root` / `:root[data-theme="light"]`) wins by source order. Only override
 * tokens; component rules in app.css consume them and need no change.
 *
 * CONTRAST WARNING: the values shipped here satisfy WCAG AA and are pinned
 * by internal/ui/contrast_test.go. An operator override bypasses that test:
 * whoever overrides a `*-text` token (or a surface it sits on) is
 * responsible for keeping >= 4.5:1 on --tobby-bg and --tobby-bg-raise, and
 * >= 4.5:1 for --tobby-on-accent on solid accent/success fills.
 */
