/*
================================================
tokens.css : SOURCE UNIQUE des jetons de design BlinkR
================================================
Ordre de chargement : tokens.css, base.css, components.css (zero @import).
Theme : suit l'appareil par defaut (prefers-color-scheme) ; theme-init.js pose
data-theme="light|dark" seulement quand l'utilisateur force un theme.
Les couleurs utilisent light-dark() : une seule declaration par jeton
(repli genere plus bas pour les navigateurs qui ne le connaissent pas).

Accent : bleu encre, valeurs identiques a la charte Claryon (clair / sombre).
Contrastes mesures (WCAG, texte >= 4.5:1, composants >= 3:1) : voir le rapport de refonte.
================================================
*/

@layer reset, tokens, base, components, utilities;

/* Polices auto-hebergees (aucun appel externe). Sous-ensemble latin :
   accents francais, oe/OE et euro couverts. */
@font-face {
  font-family: "Geist";
  src: url("../fonts/geist/Geist-Variable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  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: "Geist Mono";
  src: url("../fonts/geist/GeistMono-Variable-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  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;
}

@layer tokens {
  :root {
    color-scheme: light dark;

    /* ---------- Surfaces ---------- */
    --bg: light-dark(#f4f5f8, #0d0f13);
    --surface: light-dark(#fcfcfd, #15181e);
    --surface-2: light-dark(#f0f2f6, #1c2027);
    --surface-3: light-dark(#e6e9ef, #252a33);
    --surface-nav: light-dark(#eceff4, #0d0f13);
    --surface-hover: light-dark(#dde1e9, #2d323c);
    --line: light-dark(#e2e5eb, #252a33);
    --line-strong: light-dark(#cdd2db, #363c47);
    /* Bordure des champs et controles : >= 3:1 (WCAG 1.4.11) */
    --control-border: light-dark(#636a77, #8f96a4);

    /* ---------- Texte ---------- */
    --text: light-dark(#14161b, #f0f2f5);
    --text-2: light-dark(#464c58, #b7bdc9);
    --text-3: light-dark(#636a77, #8f96a4);

    /* ---------- Accent : bleu encre (identique Claryon) ---------- */
    --accent: light-dark(#1f5fd1, #6a9df2);
    --accent-hover: light-dark(#1a52b8, #82aef5);
    --accent-press: light-dark(#15459c, #5589e0);
    --accent-soft: light-dark(#e3ecfb, #1b2a45);
    --accent-soft-hover: light-dark(#d3e1f8, #2d323c);
    --accent-text: light-dark(#1648a8, #8db3f6);
    --on-accent: light-dark(#fcfcfd, #07101f);
    --focus: light-dark(#1f5fd1, #6a9df2);

    /* ---------- Statuts ---------- */
    --success: light-dark(#17784a, #52cb93);
    --success-soft: light-dark(#dff3e8, #133224);
    --warning: light-dark(#935300, #f0b455);
    --warning-soft: light-dark(#fbeed6, #3a2b10);
    --danger: light-dark(#bb2f29, #f58179);
    --danger-soft: light-dark(#fbe4e2, #3d1c1a);
    --danger-press: light-dark(#9d2520, #f8a09a);
    --on-danger: light-dark(#fcfcfd, #240d0c);

    /* Fond sombre des apercus video (lettrebox) */
    --preview-bg: light-dark(#14161b, #0d0f13);
    --scrim: light-dark(rgb(15 23 42 / 0.45), rgb(2 6 23 / 0.6));

    /* ---------- Ombres multicouches ---------- */
    --shadow-ink: light-dark(rgb(20 22 27 / 0.07), rgb(0 0 0 / 0.5));
    --shadow-edge: light-dark(rgb(20 22 27 / 0.05), rgb(255 255 255 / 0.07));
    --shadow-sm: 0 0 0 1px var(--shadow-edge), 0 1px 2px var(--shadow-ink);
    --shadow-md: 0 0 0 1px var(--shadow-edge), 0 1px 2px var(--shadow-ink), 0 8px 20px -8px var(--shadow-ink);
    --shadow-lg: 0 0 0 1px var(--shadow-edge), 0 2px 4px var(--shadow-ink), 0 18px 40px -14px var(--shadow-ink), 0 48px 80px -40px var(--shadow-ink);

    /* ---------- Alias semantiques (design system) ---------- */
    --color-primary: var(--accent);
    --color-surface: var(--surface);
    --color-text: var(--text);

    /* ---------- Typographie fluide ---------- */
    --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --text-xs: clamp(0.75rem, 0.73rem + 0.1vw, 0.8125rem);
    --text-sm: clamp(0.8125rem, 0.79rem + 0.12vw, 0.875rem);
    --text-base: clamp(0.9375rem, 0.91rem + 0.14vw, 1rem);
    --text-lg: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
    --text-2xl: clamp(1.5rem, 1.2rem + 1.4vw, 2.125rem);
    --text-3xl: clamp(1.875rem, 1.3rem + 2.6vw, 3rem);
    --leading-tight: 1.2;
    --leading-base: 1.55;

    /* ---------- Espacements ---------- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* ---------- Rayons ---------- */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1.125rem;
    --radius-xl: 1.5rem;
    --radius-full: 999px;

    /* ---------- Mouvement ---------- */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --transition-fast: 120ms var(--ease-out);
    --transition-base: 200ms var(--ease-out);
    --transition-slow: 360ms var(--ease-out);

    /* ---------- Gabarits ---------- */
    --tap: 2.75rem;            /* cible tactile minimale : 44px */
    --nav-height: 4rem;        /* barre d'onglets mobile */
    --rail-width: 5.5rem;      /* rail tablette */
    --content-max: 72rem;
  }

  /* Repli navigateurs sans light-dark() (avant Safari 17.5 / Chrome 123 / Firefox 120) :
     jetons clairs par defaut, sombres via prefers-color-scheme ou data-theme="dark".
     BLOC GENERE depuis les paires light-dark() ci-dessus : a regenerer si un jeton change. */
  @supports not (color: light-dark(#000, #fff)) {
  :root {
    --bg: #f4f5f8;
    --surface: #fcfcfd;
    --surface-2: #f0f2f6;
    --surface-3: #e6e9ef;
    --surface-nav: #eceff4;
    --surface-hover: #dde1e9;
    --line: #e2e5eb;
    --line-strong: #cdd2db;
    --control-border: #636a77;
    --text: #14161b;
    --text-2: #464c58;
    --text-3: #636a77;
    --accent: #1f5fd1;
    --accent-hover: #1a52b8;
    --accent-press: #15459c;
    --accent-soft: #e3ecfb;
    --accent-soft-hover: #d3e1f8;
    --accent-text: #1648a8;
    --on-accent: #fcfcfd;
    --focus: #1f5fd1;
    --success: #17784a;
    --success-soft: #dff3e8;
    --warning: #935300;
    --warning-soft: #fbeed6;
    --danger: #bb2f29;
    --danger-soft: #fbe4e2;
    --danger-press: #9d2520;
    --on-danger: #fcfcfd;
    --preview-bg: #14161b;
    --scrim: rgb(15 23 42 / 0.45);
    --shadow-ink: rgb(20 22 27 / 0.07);
    --shadow-edge: rgb(20 22 27 / 0.05);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0d0f13;
      --surface: #15181e;
      --surface-2: #1c2027;
      --surface-3: #252a33;
      --surface-nav: #0d0f13;
      --surface-hover: #2d323c;
      --line: #252a33;
      --line-strong: #363c47;
      --control-border: #8f96a4;
      --text: #f0f2f5;
      --text-2: #b7bdc9;
      --text-3: #8f96a4;
      --accent: #6a9df2;
      --accent-hover: #82aef5;
      --accent-press: #5589e0;
      --accent-soft: #1b2a45;
      --accent-soft-hover: #2d323c;
      --accent-text: #8db3f6;
      --on-accent: #07101f;
      --focus: #6a9df2;
      --success: #52cb93;
      --success-soft: #133224;
      --warning: #f0b455;
      --warning-soft: #3a2b10;
      --danger: #f58179;
      --danger-soft: #3d1c1a;
      --danger-press: #f8a09a;
      --on-danger: #240d0c;
      --preview-bg: #0d0f13;
      --scrim: rgb(2 6 23 / 0.6);
      --shadow-ink: rgb(0 0 0 / 0.5);
      --shadow-edge: rgb(255 255 255 / 0.07);
    }
  }

  :root[data-theme="dark"] {
    --bg: #0d0f13;
    --surface: #15181e;
    --surface-2: #1c2027;
    --surface-3: #252a33;
    --surface-nav: #0d0f13;
    --surface-hover: #2d323c;
    --line: #252a33;
    --line-strong: #363c47;
    --control-border: #8f96a4;
    --text: #f0f2f5;
    --text-2: #b7bdc9;
    --text-3: #8f96a4;
    --accent: #6a9df2;
    --accent-hover: #82aef5;
    --accent-press: #5589e0;
    --accent-soft: #1b2a45;
    --accent-soft-hover: #2d323c;
    --accent-text: #8db3f6;
    --on-accent: #07101f;
    --focus: #6a9df2;
    --success: #52cb93;
    --success-soft: #133224;
    --warning: #f0b455;
    --warning-soft: #3a2b10;
    --danger: #f58179;
    --danger-soft: #3d1c1a;
    --danger-press: #f8a09a;
    --on-danger: #240d0c;
    --preview-bg: #0d0f13;
    --scrim: rgb(2 6 23 / 0.6);
    --shadow-ink: rgb(0 0 0 / 0.5);
    --shadow-edge: rgb(255 255 255 / 0.07);
  }
  }

  /* Theme force par l'utilisateur (bascule manuelle) */
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }

  /* Bureau : le rail devient une barre laterale */
  @media (min-width: 72rem) {
    :root { --rail-width: 15.5rem; }
  }
}
