/* System theme. The zero-flash script (theme.js) resolves a "System" preference to the
   effective light/dark value, writes data-theme accordingly, and live-updates it when the OS
   preference changes (matchMedia listener). This file is the NO-JS fallback: when no explicit
   data-theme is set and JS is unavailable, follow the OS preference. The dark role values below mirror
   themes/dark.css — this parity is ENFORCED by build/verify-css-tokens.ps1 (FND-10), not by hand: any
   drift between the two blocks fails CI. (Option B: the media-gated no-JS selector can't share a single
   rule with the unconditional [data-theme="dark"] selector without leaking dark roles into light-OS no-JS,
   so both blocks stay — but a divergence is now caught mechanically instead of by a comment.) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg-base: var(--b3g-neutral-900);
    --color-bg-surface: var(--b3g-neutral-800);
    --color-bg-elevated: #243044;
    --color-bg-subtle: #172033;

    --color-text-primary: var(--b3g-neutral-50);
    --color-text-secondary: var(--b3g-neutral-300);
    --color-text-muted: var(--b3g-neutral-400);
    --color-text-on-primary: var(--b3g-neutral-900);
    --color-text-link: var(--b3g-blue-300);

    --color-border: var(--b3g-neutral-700);
    --color-border-strong: var(--b3g-neutral-600);

    --color-primary: var(--b3g-blue-300);
    --color-primary-hover: var(--b3g-blue-200);
    --color-primary-subtle: #15324a;

    --color-success: var(--b3g-green-500);
    --color-success-subtle: #1c3318;
    --color-warning: var(--b3g-orange-500);
    --color-warning-subtle: #3a2a0c;
    --color-error: var(--b3g-red-400);
    --color-error-subtle: #3a1c1c;
    --color-info: var(--b3g-blue-300);
    --color-info-subtle: #15324a;

    --color-focus-ring: var(--b3g-blue-300);
    --color-disabled-bg: var(--b3g-neutral-700);
    --color-disabled-text: var(--b3g-neutral-500);
    --color-loading: var(--b3g-neutral-700);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.65);

    /* ── ALIAS LAYER couleur (FND-1) — dépendants du thème (indirection ⇒ réévalués par thème) ── */
    --color-text: var(--color-text-primary);
    --color-text-tertiary: var(--color-text-muted);
    --color-link: var(--color-text-link);
    --color-on-primary: var(--color-text-on-primary);
    --color-focus: var(--color-focus-ring);
    --color-brand-blue: var(--color-primary);
    --color-surface-2: var(--color-bg-subtle);
    --color-surface-variant: var(--color-bg-subtle);
    --color-bg-muted: var(--color-bg-subtle);
    --color-border-subtle: var(--color-border);
    --color-warning-text: var(--color-warning);
    --color-warning-surface: var(--color-warning-subtle);
    --color-warning-border: var(--color-warning);
    color-scheme: dark;
  }
}
