/* ==========================================================================
   SPLT : jetons de design (étape L1, octobre 2026).
   Valeurs recopiées de la maquette validée (analyses/design-splt-2026-10-11/
   maquettes/kit.css), sans les jetons propres à la maquette (--proto-*).
   Thème clair par défaut ; sombre si <html data-theme="dark">, ou si
   data-theme="auto" et l'appareil est réglé en sombre.
   Seul fichier où une couleur s'écrit en clair (test tests/l1Css.test.js).
   ========================================================================== */

/* 1. Couleurs, thème clair */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e2e7ee;
  --border: #dde3ea;
  --border-strong: #7b8698;
  --text: #111827;
  --fg: var(--text);
  --text-muted: #4b5563;
  --text-subtle: #5f6b7a;
  --brand: #183a76;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --link: #1d4ed8;
  --primary-text: #1d4ed8;
  --focus: #2563eb;
  --danger: #b42318;
  --danger-bg: #fdecec;
  --danger-solid: #b42318;
  --danger-solid-hover: #912018;
  --on-danger: #ffffff;
  --success: #166534;
  --success-bg: #e7f6ec;
  --warning: #854d0e;
  --warning-bg: #fef3c7;
  --info: #1d4ed8;
  --info-bg: #e8f0fe;
  --nav-bg: #183a76;
  --nav-fg: #ffffff;
  --nav-fg-muted: #c9d6f0;
  --nav-active-bg: #2c4f8f;
  --nav-hover-bg: #224580;
  --nav-border: #183a76;
  --nav-focus: #ffffff;
  --nav-count-bg: #ffffff;
  --nav-count-fg: #183a76;
  --nav-cta-bg: #2c4f8f;
  --nav-cta-fg: #ffffff;
  --nav-cta-border: #c9d6f0;
  --action-bg: #eef4ff;
  --action-border: #2563eb;
  --action-line: #cddcfb;
  --scrim: rgb(17 24 39 / .45);
  --signature-bg: #ffffff;
  --signature-line: #c3cad5;
  --signature-ink: #1b2a4a;
  --signature-fg: #4b5563;
  --badge-bg: #b42318;
  --badge-fg: #ffffff;
  --logo-bg: #183a76;
  --logo-fg: #ffffff;
  --tone-neutral-bg: #eef0f3;
  --tone-neutral-fg: #374151;
  --tone-published-bg: #e8f0fe;
  --tone-published-fg: #1d4ed8;
  --tone-accepted-bg: #f3e8ff;
  --tone-accepted-fg: #6b21a8;
  --tone-transit-bg: #e3f4f5;
  --tone-transit-fg: #0f5f66;
  --tone-tosign-bg: #fef3c7;
  --tone-tosign-fg: #854d0e;
  --tone-delivered-bg: #e7f6ec;
  --tone-delivered-fg: #166534;
  --tone-cancelled-bg: #fdecec;
  --tone-cancelled-fg: #991b1b;
  --tone-alert-bg: #b42318;
  --tone-alert-fg: #ffffff;
  --space-expediteur: #1d4ed8;
  --space-transporteur: #b45309;
  --space-destinataire: #15803d;
  --space-admin: #374151;
  --space-on-nav-expediteur: #93b4ff;
  --space-on-nav-transporteur: #ffc58a;
  --space-on-nav-destinataire: #86efac;
  --space-on-nav-admin: #cbd5e1;
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .10);
  --shadow-2: 0 4px 12px rgb(16 24 40 / .08);
  --shadow-3: 0 12px 32px rgb(16 24 40 / .16);
  --tone-neutral-bd: rgba(55, 65, 81, 0.35);
  --tone-published-bd: rgba(29, 78, 216, 0.35);
  --tone-accepted-bd: rgba(107, 33, 168, 0.35);
  --tone-transit-bd: rgba(15, 95, 102, 0.35);
  --tone-tosign-bd: rgba(133, 77, 14, 0.35);
  --tone-delivered-bd: rgba(22, 101, 52, 0.35);
  --tone-cancelled-bd: rgba(153, 27, 27, 0.35);
  --tone-alert-bd: rgba(180, 35, 24, 1);
  --qr-bg: #ffffff;
  --qr-fg: #111827;
  color-scheme: light;
}

/* 2. Couleurs, thème sombre (appareil en sombre, sauf choix « Clair »), puis choix « Sombre » */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #1a2438;
    --surface-3: #222e45;
    --border: #26324a;
    --border-strong: #64748f;
    --text: #f1f5fb;
    --text-muted: #a9bde0;
    --text-subtle: #8b9bb8;
    --brand: #93b4ff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --on-primary: #ffffff;
    --link: #93b4ff;
    --primary-text: #93b4ff;
    --focus: #93b4ff;
    --danger: #ff8a7a;
    --danger-bg: #3d1f27;
    --danger-solid: #b42318;
    --danger-solid-hover: #c9301f;
    --on-danger: #ffffff;
    --success: #86efac;
    --success-bg: #173a2c;
    --warning: #fde68a;
    --warning-bg: #38331f;
    --info: #a8c4ff;
    --info-bg: #1a2c50;
    --nav-bg: #0e1729;
    --nav-fg: #f1f5fb;
    --nav-fg-muted: #a9bde0;
    --nav-active-bg: #1f2d4a;
    --nav-hover-bg: #172339;
    --nav-border: #1f2b42;
    --nav-focus: #93b4ff;
    --nav-count-bg: #f1f5fb;
    --nav-count-fg: #0e1729;
    --nav-cta-bg: #1f2d4a;
    --nav-cta-fg: #f1f5fb;
    --nav-cta-border: #a9bde0;
    --action-bg: #16264a;
    --action-border: #5b8def;
    --action-line: #24365e;
    --scrim: rgb(0 0 0 / .6);
    --signature-bg: #ffffff;
    --signature-line: #c3cad5;
    --signature-ink: #1b2a4a;
    --signature-fg: #4b5563;
    --badge-bg: #b42318;
    --badge-fg: #ffffff;
    --logo-bg: #2563eb;
    --logo-fg: #ffffff;
    --tone-neutral-bg: #252e3e;
    --tone-neutral-fg: #cbd5e1;
    --tone-published-bg: #1a2c50;
    --tone-published-fg: #a8c4ff;
    --tone-accepted-bg: #2e1f4a;
    --tone-accepted-fg: #d8b4fe;
    --tone-transit-bg: #133338;
    --tone-transit-fg: #7dd3d8;
    --tone-tosign-bg: #38331f;
    --tone-tosign-fg: #fde68a;
    --tone-delivered-bg: #173a2c;
    --tone-delivered-fg: #86efac;
    --tone-cancelled-bg: #3d1f27;
    --tone-cancelled-fg: #ffb4a8;
    --tone-alert-bg: #b42318;
    --tone-alert-fg: #ffffff;
    --space-expediteur: #93b4ff;
    --space-transporteur: #ffc58a;
    --space-destinataire: #86efac;
    --space-admin: #cbd5e1;
    --space-on-nav-expediteur: #93b4ff;
    --space-on-nav-transporteur: #ffc58a;
    --space-on-nav-destinataire: #86efac;
    --space-on-nav-admin: #cbd5e1;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 4px 12px rgb(0 0 0 / .45);
    --shadow-3: 0 12px 32px rgb(0 0 0 / .55);
    --tone-neutral-bd: rgba(203, 213, 225, 0.35);
    --tone-published-bd: rgba(168, 196, 255, 0.35);
    --tone-accepted-bd: rgba(216, 180, 254, 0.35);
    --tone-transit-bd: rgba(125, 211, 216, 0.35);
    --tone-tosign-bd: rgba(253, 230, 138, 0.35);
    --tone-delivered-bd: rgba(134, 239, 172, 0.35);
    --tone-cancelled-bd: rgba(255, 180, 168, 0.35);
    --tone-alert-bd: rgba(180, 35, 24, 1);
    --qr-bg: #ffffff;
    --qr-fg: #111827;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1a2438;
  --surface-3: #222e45;
  --border: #26324a;
  --border-strong: #64748f;
  --text: #f1f5fb;
  --text-muted: #a9bde0;
  --text-subtle: #8b9bb8;
  --brand: #93b4ff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --on-primary: #ffffff;
  --link: #93b4ff;
  --primary-text: #93b4ff;
  --focus: #93b4ff;
  --danger: #ff8a7a;
  --danger-bg: #3d1f27;
  --danger-solid: #b42318;
  --danger-solid-hover: #c9301f;
  --on-danger: #ffffff;
  --success: #86efac;
  --success-bg: #173a2c;
  --warning: #fde68a;
  --warning-bg: #38331f;
  --info: #a8c4ff;
  --info-bg: #1a2c50;
  --nav-bg: #0e1729;
  --nav-fg: #f1f5fb;
  --nav-fg-muted: #a9bde0;
  --nav-active-bg: #1f2d4a;
  --nav-hover-bg: #172339;
  --nav-border: #1f2b42;
  --nav-focus: #93b4ff;
  --nav-count-bg: #f1f5fb;
  --nav-count-fg: #0e1729;
  --nav-cta-bg: #1f2d4a;
  --nav-cta-fg: #f1f5fb;
  --nav-cta-border: #a9bde0;
  --action-bg: #16264a;
  --action-border: #5b8def;
  --action-line: #24365e;
  --scrim: rgb(0 0 0 / .6);
  --signature-bg: #ffffff;
  --signature-line: #c3cad5;
  --signature-ink: #1b2a4a;
  --signature-fg: #4b5563;
  --badge-bg: #b42318;
  --badge-fg: #ffffff;
  --logo-bg: #2563eb;
  --logo-fg: #ffffff;
  --tone-neutral-bg: #252e3e;
  --tone-neutral-fg: #cbd5e1;
  --tone-published-bg: #1a2c50;
  --tone-published-fg: #a8c4ff;
  --tone-accepted-bg: #2e1f4a;
  --tone-accepted-fg: #d8b4fe;
  --tone-transit-bg: #133338;
  --tone-transit-fg: #7dd3d8;
  --tone-tosign-bg: #38331f;
  --tone-tosign-fg: #fde68a;
  --tone-delivered-bg: #173a2c;
  --tone-delivered-fg: #86efac;
  --tone-cancelled-bg: #3d1f27;
  --tone-cancelled-fg: #ffb4a8;
  --tone-alert-bg: #b42318;
  --tone-alert-fg: #ffffff;
  --space-expediteur: #93b4ff;
  --space-transporteur: #ffc58a;
  --space-destinataire: #86efac;
  --space-admin: #cbd5e1;
  --space-on-nav-expediteur: #93b4ff;
  --space-on-nav-transporteur: #ffc58a;
  --space-on-nav-destinataire: #86efac;
  --space-on-nav-admin: #cbd5e1;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 4px 12px rgb(0 0 0 / .45);
  --shadow-3: 0 12px 32px rgb(0 0 0 / .55);
  --tone-neutral-bd: rgba(203, 213, 225, 0.35);
  --tone-published-bd: rgba(168, 196, 255, 0.35);
  --tone-accepted-bd: rgba(216, 180, 254, 0.35);
  --tone-transit-bd: rgba(125, 211, 216, 0.35);
  --tone-tosign-bd: rgba(253, 230, 138, 0.35);
  --tone-delivered-bd: rgba(134, 239, 172, 0.35);
  --tone-cancelled-bd: rgba(255, 180, 168, 0.35);
  --tone-alert-bd: rgba(180, 35, 24, 1);
  --qr-bg: #ffffff;
  --qr-fg: #111827;
  color-scheme: dark;
}

/* 3. Jetons hors couleur */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-12: .75rem;   --lh-12: 1rem;
  --fs-14: .875rem;  --lh-14: 1.25rem;
  --fs-16: 1rem;     --lh-16: 1.5rem;
  --fs-18: 1.125rem; --lh-18: 1.625rem;
  --fs-20: 1.25rem;  --lh-20: 1.75rem;
  --fs-24: 1.5rem;   --lh-24: 2rem;
  --fs-30: 1.875rem; --lh-30: 2.375rem;
  --fs-36: 2.25rem;  --lh-36: 2.75rem;
  --sp-4: 4px; --sp-8: 8px; --sp-12: 12px; --sp-16: 16px; --sp-20: 20px;
  --sp-24: 24px; --sp-32: 32px; --sp-40: 40px; --sp-48: 48px; --sp-64: 64px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --dur-fast: 120ms; --dur-base: 200ms; --ease: cubic-bezier(.2, 0, 0, 1);
  --sidebar-w: 248px;
  --topbar-h: 64px; --tabbar-h: 64px;
  --content-max: 1120px;
  --content-pad: 32px;
  --page-gap: 32px;
  --card-pad: 24px;
  --card-bw: 1px;
  --control-h: 44px;
}
:root {
  --z-sticky: 100; --z-dropdown: 200; --z-header: 300; --z-sheet: 400; --z-toast: 600;
  --print-bg: #ffffff; --print-fg: #000000;
}
/* Le fond des fenêtres (::backdrop) n'hérite pas des variables dans les navigateurs d'avant 2024 : il porte les siennes. */
::backdrop { --scrim: rgb(17 24 39 / .45); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) ::backdrop { --scrim: rgb(0 0 0 / .6); } }
:root[data-theme="dark"] ::backdrop { --scrim: rgb(0 0 0 / .6); }
@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0ms; --dur-base: 0ms; }
}

/* 4. Anciens noms de variables, pour que l'ancienne feuille (styles.css, couche « legacy »)
   suive les deux thèmes. À retirer quand styles.css aura disparu. */
:root {
  --ink: var(--text);
  --muted: var(--text-muted);
  --line: var(--border);
  --card: var(--surface);
  --card-solid: var(--surface);
  --accent: var(--primary);
  --bg-2: var(--bg);
  --brand-2: var(--warning);
  --brand-3: var(--success);
  --shadow: var(--shadow-2);
}
