/* ============================================================
   tokens.css — design tokens (CSS custom properties).
   Dark par défaut, .light sur :root pour le thème clair.
   Conventions 2026 : typo fluide via clamp(), spacing/radius
   homogènes, breakpoints exposés comme custom properties,
   cascade @layer pilotée ici.
   ============================================================ */

/* Cascade order — déclaré ici (premier fichier CSS chargé) pour que tous
   les autres fichiers puissent simplement déclarer leur layer. Plus tard
   = plus prioritaire lors d'un conflit (mais la spécificité reste reine
   à l'intérieur d'un même layer). */
@layer tokens, base, layout, components, utilities;

@layer tokens {
  :root {
    /* Indique au navigateur le schéma natif (scrollbars OS, form controls,
     date-picker natif, autofill) — bascule auto via .light. */
    color-scheme: dark;

    /* Scrollbar custom — Firefox + WebKit. Match palette dark. */
    scrollbar-color: var(--bd2) transparent;
    scrollbar-width: thin;

    /* --- Backgrounds --- */
    --bg: #0b0f14;
    --bg2: #161b22;
    --bg3: #1f252e;
    --bg4: #2a313b;

    /* --- Borders --- */
    --bd: rgba(255, 255, 255, 0.1);
    --bd2: rgba(255, 255, 255, 0.14);

    /* --- Text --- */
    --tx: #f0f0f0;
    --tx2: #b0b6be;
    --tx3: #8b919a;

    /* --- Accent emerald --- */
    --ac: #10b981;
    --ac2: rgba(16, 185, 129, 0.1);
    --ac3: rgba(16, 185, 129, 0.18);

    /* --- Sémantique --- */
    --ok: #10b981;
    --ok2: rgba(16, 185, 129, 0.1);
    --wr: #fbbf24;
    --wr2: rgba(251, 191, 36, 0.14);
    --dn: #f87171;
    --dn2: rgba(248, 113, 113, 0.1);

    /* --- Radius --- */
    --r: 10px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* --- Elevation --- */
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.02);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-3: 0 8px 24px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.04);
    --shadow-focus: 0 0 0 3px rgba(16, 185, 129, 0.3);

    /* --- Motion --- */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 120ms var(--ease);
    --t-base: 200ms var(--ease);
    --t-slow: 320ms var(--ease);

    /* --- Typography --- */
    --font-ui: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Tailles statiques (UI dense, formulaires, légendes) */
    --text-xs: 11px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 16px;
    --text-lg: 20px;
    --text-xl: 24px;

    /* Tailles fluides (titres, KPI heroes) — s'adaptent au viewport */
    --text-fluid-title: clamp(1.375rem, 1.05rem + 1.4vw, 1.75rem); /* h1 onglets : 22 → 28 */
    --text-fluid-kpi: clamp(1.625rem, 1.2rem + 1.8vw, 2rem); /* KPI hero : 26 → 32 */
    --text-fluid-banner: clamp(1.125rem, 0.95rem + 0.7vw, 1.5rem); /* bandeaux : 18 → 24 */

    /* --- Spacing --- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 28px;
    --space-8: 32px;
    --space-9: 36px;
    --space-10: 40px;
    --space-11: 44px;
    --space-12: 48px;

    /* Padding fluide pour conteneurs principaux */
    --pad-page-x: clamp(1rem, 0.4rem + 2.4vw, 2rem); /* 16 → 32 */
    --pad-page-y: clamp(1.25rem, 0.6rem + 2.4vw, 2.5rem);
    --gap-grid: clamp(0.875rem, 0.5rem + 1vw, 1.25rem); /* 14 → 20 */

    /* --- Layout --- */
    --max-w-content: 1440px;
    --topbar-h: 56px;
    --tabsbar-h: 44px;
    --mobilenav-h: 60px;

    /* --- Breakpoints (exposés pour cohérence) ---
     sm = mobile/desktop split à 768px (matérialise mobile-nav vs tabs-bar) */
    --bp-sm: 768px;
    --bp-md: 1024px;
    --bp-lg: 1280px;
  }

  .light {
    color-scheme: light;
    scrollbar-color: var(--bd2) transparent;

    --bg: #f6f8fa;
    --bg2: #ffffff;
    --bg3: #ffffff;
    --bg4: #f0f2f5;

    --bd: #d8dae0;
    --bd2: #c8ccd2;

    --tx: #1f2328;
    --tx2: #656d76;
    --tx3: #8b949e;

    --ac: #10b981;
    --ac2: rgba(16, 185, 129, 0.08);
    --ac3: rgba(16, 185, 129, 0.16);

    --ok: #059669;
    --ok2: rgba(5, 150, 105, 0.08);
    --wr: #9a6700;
    --wr2: rgba(154, 103, 0, 0.1);
    --dn: #cf222e;
    --dn2: rgba(207, 34, 46, 0.08);

    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(15, 23, 42, 0.04);
    --shadow-2: 0 2px 8px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.05);
    --shadow-3: 0 8px 24px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(15, 23, 42, 0.06);
    --shadow-focus: 0 0 0 3px rgba(16, 185, 129, 0.22);
  }

  /* Préférences utilisateur OS — réduit les animations si demandé. */
  @media (prefers-reduced-motion: reduce) {
    :root {
      --t-fast: 0ms linear;
      --t-base: 0ms linear;
      --t-slow: 0ms linear;
    }
  }
} /* end @layer tokens */

@layer base {
  /* Scrollbar custom WebKit (Firefox utilise scrollbar-color via :root). */
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: var(--bd2);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--tx3);
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-corner {
    background: transparent;
  }

  /* Sélection de texte — accent emerald discret. */
  ::selection {
    background: color-mix(in srgb, var(--ac) 28%, transparent);
    color: var(--tx);
  }
}
