/* ============================================================================
   OTT-SYS DS — tokens (Portal, P4-E1)

   Seul endroit qui définit l'identité visuelle : couleurs, typographie,
   espacements, rayons, ombres, mouvements. layouts.css et components.css ne
   consomment que ces variables. Référence : docs/architecture/P4_PRODUCT_ARCHITECTURE.md § 19.

   Thèmes : clair par défaut ; sombre selon la préférence système, ou forcé par
   data-theme="dark" sur <html> (choix mémorisé localement par /js/theme.js,
   jamais transmis au serveur). data-theme="light" force le clair.

   Polices auto-hébergées (SIL OFL 1.1, licences dans public/fonts/<police>/LICENSE.txt) :
   aucune requête externe (CSP font-src 'self').
   ========================================================================== */

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-wght.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;
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter/inter-latin-ext-wght.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: "JetBrains Mono";
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url("../fonts/jetbrains-mono/jetbrains-mono-latin-wght.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;
}

/* ---------------------------------------------------------------------------
   Thème clair (défaut)
   ------------------------------------------------------------------------- */
:root {
    /* Typographie */
    --ott-font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --ott-font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
    --ott-text-xs: 0.75rem;      /* 12 — méta, badges */
    --ott-text-sm: 0.8125rem;    /* 13 — aide, en-têtes de tableaux */
    --ott-text-md: 0.875rem;     /* 14 — contrôles, tableaux */
    --ott-text-base: 0.9375rem;  /* 15 — corps du Portal */
    --ott-text-lg: 1rem;         /* 16 — titres de cartes */
    --ott-text-xl: 1.25rem;      /* 20 */
    --ott-text-2xl: 1.5rem;      /* 24 — titres de pages */
    --ott-text-3xl: 1.875rem;    /* 30 — chiffres clés */
    --ott-text-display: clamp(2.25rem, 5vw, 3.5rem); /* site public */
    --ott-weight-regular: 400;
    --ott-weight-medium: 500;
    --ott-weight-semibold: 600;
    --ott-weight-bold: 700;
    --ott-leading: 1.55;
    --ott-leading-tight: 1.25;
    --ott-measure: 68ch;         /* longueur de ligne des textes */

    /* Espacements (base 4) */
    --ott-space-1: 0.25rem;
    --ott-space-2: 0.5rem;
    --ott-space-3: 0.75rem;
    --ott-space-4: 1rem;
    --ott-space-5: 1.25rem;
    --ott-space-6: 1.5rem;
    --ott-space-8: 2rem;
    --ott-space-10: 2.5rem;
    --ott-space-14: 3.5rem;
    --ott-space-20: 5rem;

    /* Rayons */
    --ott-radius-xs: 4px;
    --ott-radius-sm: 6px;
    --ott-radius-md: 8px;
    --ott-radius-lg: 12px;
    --ott-radius-xl: 16px;
    --ott-radius-pill: 999px;

    /* Contrôles */
    --ott-control-h-sm: 2rem;      /* 32 */
    --ott-control-h: 2.5rem;       /* 40 */
    --ott-control-h-lg: 2.75rem;   /* 44 — cible tactile */

    /* Mouvement */
    --ott-ease: cubic-bezier(0.2, 0, 0, 1);
    --ott-dur-fast: 120ms;
    --ott-dur: 180ms;

    /* Marque */
    --ott-brand-navy: #0b1f3a;
    --ott-brand-blue: #2563eb;
    --ott-brand-cyan: #38bdf8;
    --ott-rail: linear-gradient(90deg, #2563eb, #38bdf8);
    --ott-rail-v: linear-gradient(180deg, #2563eb, #38bdf8);

    /* Neutres */
    --ott-bg: #f3f5f9;
    --ott-surface: #ffffff;
    --ott-surface-2: #f7f9fc;
    --ott-surface-3: #eef2f7;
    --ott-surface-inset: #f1f4f9;
    --ott-border: #e2e7ef;
    --ott-border-strong: #cdd5e1;
    --ott-control-border: #8190a6;
    --ott-text: #0f172a;
    --ott-text-body: #334155;
    --ott-text-muted: #56657b;
    --ott-text-faint: #8a98ad;

    /* Sémantique : texte / remplissage / fond léger / bordure */
    --ott-primary: #1d4ed8;
    --ott-primary-hover: #1e40af;
    --ott-primary-fill: #2563eb;
    --ott-primary-fill-hover: #1d4ed8;
    --ott-primary-subtle: #e9f0fe;
    --ott-primary-border: #b9cefb;
    --ott-on-primary: #ffffff;

    --ott-success: #157a3c;
    --ott-success-subtle: #e7f6ec;
    --ott-success-border: #b5e2c4;

    --ott-warning: #a14a08;
    --ott-warning-subtle: #fdf3e2;
    --ott-warning-border: #f3d29b;

    --ott-danger: #c81e1e;
    --ott-danger-fill: #dc2626;
    --ott-danger-fill-hover: #b91c1c;
    --ott-danger-subtle: #fdecec;
    --ott-danger-border: #f5c2c2;
    --ott-on-danger: #ffffff;

    --ott-info: #03649a;
    --ott-info-subtle: #e4f2fb;
    --ott-info-border: #b3dbf2;

    --ott-neutral: #4b5a70;
    --ott-neutral-subtle: #eef2f7;
    --ott-neutral-border: #d6dde8;

    /* Focus */
    --ott-focus: #2563eb;
    --ott-focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.3);

    /* États de lignes */
    --ott-row-hover: #f5f8fd;

    /* Élévation */
    --ott-shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --ott-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.05);
    --ott-shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.14), 0 2px 6px -2px rgba(15, 23, 42, 0.08);
    --ott-shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.25), 0 4px 12px -4px rgba(15, 23, 42, 0.08);
    --ott-backdrop: rgba(8, 15, 30, 0.52);

    /* Shell (barre latérale bleu nuit dans les deux thèmes) */
    --ott-nav-bg: #0b1f3a;
    --ott-nav-bg-2: #0d2547;
    --ott-nav-border: rgba(148, 170, 205, 0.14);
    --ott-nav-text: #c3cfe2;
    --ott-nav-text-strong: #ffffff;
    --ott-nav-icon: #93a7c7;
    --ott-nav-caption: #8ba0c2;
    --ott-nav-hover: rgba(255, 255, 255, 0.06);
    --ott-nav-active-bg: linear-gradient(90deg, rgba(56, 189, 248, 0.18), rgba(37, 99, 235, 0.1));
    --ott-nav-accent: #38bdf8;
    --ott-nav-w: 16.5rem;          /* 264 */
    --ott-nav-w-compact: 4.5rem;   /* 72 */
    --ott-topbar-h: 3.75rem;       /* 60 */
    --ott-content-max: 76rem;      /* 1216 */
    --ott-content-pad: 2rem;

    /* Flèche des listes déroulantes (img-src data: autorisé par la CSP) */
    --ott-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356657b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");

    color-scheme: light;
}

/* ---------------------------------------------------------------------------
   Thème sombre : préférence système (sauf choix « clair ») ou choix explicite.
   Les deux blocs portent les mêmes valeurs.
   ------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ott-bg: #0a0f1a;
        --ott-surface: #111a2b;
        --ott-surface-2: #152036;
        --ott-surface-3: #1a2740;
        --ott-surface-inset: #0c1322;
        --ott-border: #1f2b41;
        --ott-border-strong: #2c3b57;
        --ott-control-border: #61728f;
        --ott-text: #e6ebf3;
        --ott-text-body: #c7d1e0;
        --ott-text-muted: #9aa8bf;
        --ott-text-faint: #6b7a93;

        --ott-primary: #60a5fa;
        --ott-primary-hover: #93c5fd;
        --ott-primary-fill: #2563eb;
        --ott-primary-fill-hover: #1d4ed8;
        --ott-primary-subtle: #14264a;
        --ott-primary-border: #1f3e78;

        --ott-success: #4ade80;
        --ott-success-subtle: #0f2a1b;
        --ott-success-border: #1c4a31;

        --ott-warning: #fbbf24;
        --ott-warning-subtle: #2c2212;
        --ott-warning-border: #564016;

        --ott-danger: #f87171;
        --ott-danger-fill: #dc2626;
        --ott-danger-fill-hover: #b91c1c;
        --ott-danger-subtle: #2a1215;
        --ott-danger-border: #5a2227;

        --ott-info: #38bdf8;
        --ott-info-subtle: #0f2638;
        --ott-info-border: #1a4461;

        --ott-neutral: #aab6c9;
        --ott-neutral-subtle: #1a2740;
        --ott-neutral-border: #2c3b57;

        --ott-focus: #60a5fa;
        --ott-focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.38);
        --ott-row-hover: #16223a;

        --ott-shadow-xs: none;
        --ott-shadow-sm: none;
        --ott-shadow-md: 0 12px 28px -8px rgba(0, 0, 0, 0.6);
        --ott-shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.72);
        --ott-backdrop: rgba(2, 6, 14, 0.7);

        --ott-nav-bg: #0a1628;
        --ott-nav-bg-2: #0c1a31;
        --ott-nav-border: rgba(148, 170, 205, 0.1);

        --ott-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa8bf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ott-bg: #0a0f1a;
    --ott-surface: #111a2b;
    --ott-surface-2: #152036;
    --ott-surface-3: #1a2740;
    --ott-surface-inset: #0c1322;
    --ott-border: #1f2b41;
    --ott-border-strong: #2c3b57;
    --ott-control-border: #61728f;
    --ott-text: #e6ebf3;
    --ott-text-body: #c7d1e0;
    --ott-text-muted: #9aa8bf;
    --ott-text-faint: #6b7a93;

    --ott-primary: #60a5fa;
    --ott-primary-hover: #93c5fd;
    --ott-primary-fill: #2563eb;
    --ott-primary-fill-hover: #1d4ed8;
    --ott-primary-subtle: #14264a;
    --ott-primary-border: #1f3e78;

    --ott-success: #4ade80;
    --ott-success-subtle: #0f2a1b;
    --ott-success-border: #1c4a31;

    --ott-warning: #fbbf24;
    --ott-warning-subtle: #2c2212;
    --ott-warning-border: #564016;

    --ott-danger: #f87171;
    --ott-danger-fill: #dc2626;
    --ott-danger-fill-hover: #b91c1c;
    --ott-danger-subtle: #2a1215;
    --ott-danger-border: #5a2227;

    --ott-info: #38bdf8;
    --ott-info-subtle: #0f2638;
    --ott-info-border: #1a4461;

    --ott-neutral: #aab6c9;
    --ott-neutral-subtle: #1a2740;
    --ott-neutral-border: #2c3b57;

    --ott-focus: #60a5fa;
    --ott-focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.38);
    --ott-row-hover: #16223a;

    --ott-shadow-xs: none;
    --ott-shadow-sm: none;
    --ott-shadow-md: 0 12px 28px -8px rgba(0, 0, 0, 0.6);
    --ott-shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.72);
    --ott-backdrop: rgba(2, 6, 14, 0.7);

    --ott-nav-bg: #0a1628;
    --ott-nav-bg-2: #0c1a31;
    --ott-nav-border: rgba(148, 170, 205, 0.1);

    --ott-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa8bf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");

    color-scheme: dark;
}
