/* =====================================================================
   KAYA — Jetons de design v2 (refonte 2026-09)
   Identité AMANA Transport VIP : teal dominant, orange réservé à l'alerte
   d'action, neutres pour la hiérarchie. Palette AA vérifiée dans les deux
   thèmes (texte ≥ 4,5:1, bordures de champ et focus ≥ 3:1) — voir
   scratchpad/refonte/B1.md pour le tableau des contrastes.

   Thème : attribut data-theme sur <html> = light | dark | auto (clé
   localStorage « kaya_theme », posée avant le premier rendu par le script
   anti-flash en tête de chaque vue). « auto » suit le système.

   Règle : aucune couleur en dur hors de ce fichier. Les anciens noms
   (--color-*, --bg-*, --text-*, --space-*, --fs-*, --radius-*, --shadow-*)
   restent valides ; les nouveaux (--on-primary, --surface-brand, --r-*,
   --fs-h1…) sont à privilégier.
   ===================================================================== */

/* Ordre des couches : tout ce qui n'est pas en couche (layout.css, shell)
   l'emporte sur les couches ; les utilitaires l'emportent sur les composants. */
@layer reset, base, components, pages, utilities;

/* --- Police Inter auto-hébergée (sous-ensemble latin, OFL) --- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-latin-400-normal.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: 500;
  font-display: swap;
  src: url('../fonts/inter-latin-500-normal.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: 600;
  font-display: swap;
  src: url('../fonts/inter-latin-600-normal.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: 700;
  font-display: swap;
  src: url('../fonts/inter-latin-700-normal.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;
}

/* Police de repli aux dimensions d'Inter (A6, 2026-10-03). Seules les graisses
   400 et 600 sont préchargées (bin/version-assets.php) ; 500 et 700 arrivent
   après le premier affichage. Arial ajusté (taille, ascendante, descendante)
   occupe la même place qu'Inter : le texte ne se réagence pas à l'arrivée de
   la vraie police. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('Helvetica'), local('Liberation Sans');
  size-adjust: 107.4%;
  ascent-override: 90.2%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

/* =====================================================================
   Thème clair (défaut)
   ===================================================================== */
:root {
  color-scheme: light;

  /* Marque — cyan du logo AMANA (#47DCEC, demande client 2026-10-04).
     Le cyan est clair : il sert de FOND (texte foncé dessus, 9,7:1). Pour le
     texte, les contours et les traits sur fond clair, on prend son encre
     --color-primary-ink (6,2:1 sur blanc) — jamais le cyan pur (1,65:1). */
  --color-primary: #47DCEC;          /* fond : texte --on-primary 9,7:1 */
  --color-primary-hover: #2CCBDD;    /* fond au survol : texte --on-primary 8,1:1 */
  --color-primary-dark: #075A66;     /* encre appuyée : 7,9:1 sur blanc */
  --color-primary-light: #8BE9F3;    /* décoratif uniquement (jamais sous du texte) */
  --color-primary-soft: #E3F8FB;     /* fond actif/sélection ; encre 5,6:1 */
  --color-primary-ink: #0A6B78;      /* texte, bordures, traits : 6,2:1 sur blanc */
  --on-primary: #04262B;
  --color-on-primary: var(--on-primary);

  /* Surface de marque (bandeau supérieur) : cyan profond, le logo blanc reste net */
  --surface-brand: #0A3A42;          /* blanc 12,4:1 */
  --on-brand: #FFFFFF;
  --on-brand-muted: #BDEFF5;

  /* Accent orange — alerte d'action, rare (CTA guichet, « à verser ») */
  --color-accent: #C2410C;           /* blanc 5,2:1 */
  --color-accent-hover: #9A3412;
  --color-accent-soft: #FFEDD5;
  --color-accent-ink: #7C2D12;       /* texte sur accent-soft */
  --on-accent: #FFFFFF;

  /* États sémantiques : couleur pleine (icône/texte sur surface ≥ 4,5:1),
     fond doux, encre (texte sur fond doux ≥ 6:1) */
  --color-success: #15803D;
  --color-success-soft: #DCFCE7;
  --color-success-ink: #166534;
  --color-warning: #B45309;
  --color-warning-soft: #FEF3C7;
  --color-warning-ink: #92400E;
  --color-danger: #B91C1C;
  --color-danger-soft: #FEE2E2;
  --color-danger-ink: #991B1B;
  --color-danger-hover: #991B1B;
  --on-danger: #FFFFFF;
  --color-info: #1D4ED8;
  --color-info-soft: #DBEAFE;
  --color-info-ink: #1E40AF;

  /* Surfaces */
  --bg-canvas: #F4F8F8;
  --bg-surface: #FFFFFF;
  --bg-surface-raised: #FFFFFF;
  --bg-muted: #EEF4F3;
  --bg-hover: #F1F6F6;
  --backdrop: rgb(8 20 19 / 0.55);

  /* Texte */
  --text-primary: #101826;           /* 16,6:1 */
  --text-secondary: #3F4B5B;         /* 8,3:1 */
  --text-muted: #5B6B7F;             /* 5,1:1 sur canevas, 4,9:1 sur fond muet */

  /* Bordures */
  --border-color: #DCEAE8;           /* séparateurs, cartes */
  --border-strong: #B9CFCC;          /* séparateurs appuyés */
  --border-input: #7A8B91;           /* contour des champs : 3,5:1 (WCAG 1.4.11) */

  /* Focus : anneau de 2 px décalé de 2 px, ≥ 3:1 contre tout fond */
  --focus-ring: #2563EB;

  --shadow-color: 178 30% 15%;

  /* Graphiques (cockpit) — teintes dédiées aux traits de données */
  --chart-teal: #47DCEC;
  --chart-orange: #EA6A0E;
  --chart-grid: var(--border-color);
  --chart-surface: var(--bg-surface);
  /* Catégories du chiffre d'affaires (pilotage, 2026-10-04) : une couleur par
     activité, partout (accueil, tableau de bord). Validées au script dataviz
     (toutes paires : CVD ΔE ≥ 12, vision normale ≥ 20). Billetterie = cyan
     de la marque, un cran plus profond sur fond clair (2,8:1, d'où valeurs
     écrites au bout des barres et « Vue tableau »). Remplissages seulement :
     le texte reste en encre de texte. */
  --cat-billets: #0FA9BC;
  --cat-colis: #6A55D8;
  --cat-bagages: #DB7426;
  --chart-ref: #C3D0D2;              /* référence (hier, période précédente) */
  --chart-ref-ink: #5B6B7F;          /* repère, moyenne */

  /* Aperçu non appliqué (numérotation des Types de bus, 2026-10-03) : violet,
     jamais l'orange de l'avertissement. Texte sur fond doux ≥ 7:1. */
  --color-preview: #6D28D9;
  --color-preview-soft: #F3E8FF;
  --color-preview-ink: #5B21B6;
}

/* =====================================================================
   Thème sombre — les mêmes noms, redéfinis. Bloc dupliqué pour « auto »
   (préférence système) : garder les deux blocs identiques.
   ===================================================================== */
:root[data-theme='dark'] {
  color-scheme: dark;
  --color-primary: #47DCEC;
  --color-primary-hover: #73E6F2;
  --color-primary-dark: #0A2F35;
  --color-primary-light: #8BE9F3;
  --color-primary-soft: #0F3238;
  --color-primary-ink: #47DCEC;
  --on-primary: #04262B;             /* 9,7:1 */
  --surface-brand: #0A2328;          /* blanc 15:1 */
  --on-brand: #FFFFFF;
  --on-brand-muted: #A9D9DF;
  --color-accent: #FB923C;
  --color-accent-hover: #FDBA74;
  --color-accent-soft: #3A2410;
  --color-accent-ink: #FDBA74;
  --on-accent: #2E0F03;
  --color-success: #4ADE80;
  --color-success-soft: #123222;
  --color-success-ink: #86EFAC;
  --color-warning: #FBBF24;
  --color-warning-soft: #3A2A0F;
  --color-warning-ink: #FCD34D;
  --color-danger: #F87171;
  --color-danger-soft: #3A1818;
  --color-danger-ink: #FCA5A5;
  --color-danger-hover: #FCA5A5;
  --on-danger: #1A0505;
  --color-info: #60A5FA;
  --color-info-soft: #142A44;
  --color-info-ink: #93C5FD;
  --bg-canvas: #0D1615;
  --bg-surface: #13201F;
  --bg-surface-raised: #182B29;
  --bg-muted: #182B29;
  --bg-hover: #1A2F2D;
  --backdrop: rgb(0 0 0 / 0.65);
  --text-primary: #EDF5F4;
  --text-secondary: #B6CAC7;
  --text-muted: #86A09C;
  --border-color: #223836;
  --border-strong: #2F4C49;
  --border-input: #5E7A76;
  --focus-ring: #93C5FD;
  --shadow-color: 178 60% 2%;
  --chart-teal: #47DCEC;
  --chart-orange: #DB6A0B;
  --cat-billets: #47DCEC;
  --cat-colis: #9D92F6;
  --cat-bagages: #EE9450;
  --chart-ref: #34504E;
  --chart-ref-ink: #9FB6B3;
  --color-preview: #C4B5FD;
  --color-preview-soft: #2A1F45;
  --color-preview-ink: #DDD6FE;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='auto'],
  :root:not([data-theme]) {
    color-scheme: dark;
    --color-primary: #47DCEC;
    --color-primary-hover: #73E6F2;
    --color-primary-dark: #0A2F35;
    --color-primary-light: #8BE9F3;
    --color-primary-soft: #0F3238;
    --color-primary-ink: #47DCEC;
    --on-primary: #04262B;
    --surface-brand: #0A2328;
    --on-brand: #FFFFFF;
    --on-brand-muted: #A9D9DF;
    --color-accent: #FB923C;
    --color-accent-hover: #FDBA74;
    --color-accent-soft: #3A2410;
    --color-accent-ink: #FDBA74;
    --on-accent: #2E0F03;
    --color-success: #4ADE80;
    --color-success-soft: #123222;
    --color-success-ink: #86EFAC;
    --color-warning: #FBBF24;
    --color-warning-soft: #3A2A0F;
    --color-warning-ink: #FCD34D;
    --color-danger: #F87171;
    --color-danger-soft: #3A1818;
    --color-danger-ink: #FCA5A5;
    --color-danger-hover: #FCA5A5;
    --on-danger: #1A0505;
    --color-info: #60A5FA;
    --color-info-soft: #142A44;
    --color-info-ink: #93C5FD;
    --bg-canvas: #0D1615;
    --bg-surface: #13201F;
    --bg-surface-raised: #182B29;
    --bg-muted: #182B29;
    --bg-hover: #1A2F2D;
    --backdrop: rgb(0 0 0 / 0.65);
    --text-primary: #EDF5F4;
    --text-secondary: #B6CAC7;
    --text-muted: #86A09C;
    --border-color: #223836;
    --border-strong: #2F4C49;
    --border-input: #5E7A76;
    --focus-ring: #93C5FD;
    --shadow-color: 178 60% 2%;
    --chart-teal: #47DCEC;
    --chart-orange: #DB6A0B;
    --cat-billets: #47DCEC;
    --cat-colis: #9D92F6;
    --cat-bagages: #EE9450;
    --chart-ref: #34504E;
    --chart-ref-ink: #9FB6B3;
    --color-preview: #C4B5FD;
    --color-preview-soft: #2A1F45;
    --color-preview-ink: #DDD6FE;
  }
}

:root[data-theme='auto'] { color-scheme: light dark; }

/* =====================================================================
   Échelles (indépendantes du thème)
   ===================================================================== */
:root {
  /* Espacement — échelle de 4 px */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Rayons v2 */
  --r-sm: 6px;       /* badges, cases */
  --r-md: 10px;      /* boutons, champs */
  --r-lg: 14px;      /* cartes */
  --r-xl: 20px;      /* modales, feuilles */
  --r-pill: 999px;
  /* Alias historiques */
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);

  /* Typographie v2 (Inter, 16 px de base) */
  --font-sans: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-display: 2.5rem;   /* 40 / 44 — montant héros */
  --fs-h1: 1.75rem;       /* 28 / 34 — titre de page */
  --fs-h2: 1.25rem;       /* 20 / 28 — titre de carte / section */
  --fs-h3: 1.0625rem;     /* 17 / 24 — sous-section */
  --fs-body: 1rem;        /* 16 / 24 — texte, champs (évite le zoom iOS) */
  --fs-ui: 0.9375rem;     /* 15 / 20 — menu, boutons, cellules */
  --lh-tight: 1.2;
  --lh-body: 1.5;
  /* Alias historiques */
  --fs-xs: 0.75rem;       /* 12 — sur-titres, en-têtes de tableau */
  --fs-sm: 0.875rem;      /* 14 — méta, aide */
  --fs-md: var(--fs-body);
  --fs-lg: 1.125rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 2rem;
  --fs-3xl: var(--fs-display);

  /* Commandes (boutons, champs) */
  --control-h-sm: 36px;   /* tableaux uniquement */
  --control-h: 44px;      /* standard, cible tactile minimale */
  --control-h-lg: 52px;   /* actions de guichet */

  /* Élévation : cartes = bordure + ombre xs ; md/lg pour menus, modales */
  --shadow-xs: 0 1px 2px hsl(var(--shadow-color) / 0.06);
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / 0.06), 0 1px 3px hsl(var(--shadow-color) / 0.08);
  --shadow-md: 0 4px 10px hsl(var(--shadow-color) / 0.08), 0 2px 4px hsl(var(--shadow-color) / 0.06);
  --shadow-lg: 0 16px 36px hsl(var(--shadow-color) / 0.16), 0 4px 10px hsl(var(--shadow-color) / 0.08);

  /* Plan de bus (Types de bus, 2026-10-03) : la porte n'est jamais verte (le
     vert veut dire « libre » à la vente) — dalle neutre, seuil vert seul. */
  --color-door: var(--text-secondary);
  --color-door-soft: var(--bg-muted);
  --color-door-sill: var(--color-success);
  /* Maquette 3D : caisse et pneus de teinte fixe, lisibles sur fond clair et sombre. */
  --bus-body-3d: #E9EFEE;
  --bus-trim-3d: #B9C9C6;
  --bus-tyre-3d: #1C2526;

  /* Mouvement */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-out-quint: cubic-bezier(.23, 1, .32, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --transition-fast: var(--dur-fast) var(--ease-out);
  --transition-base: var(--dur-base) var(--ease-out);
  --transition-slow: 250ms var(--ease-out);

  /* Empilement */
  --z-sticky: 20;
  --z-topbar: 50;
  --z-drawer: 70;
  --z-dropdown: 80;
  --z-modal: 900;
  --z-toast: 1000;

  /* Points de rupture (documentation : les media queries ne lisent pas les
     variables) — mobile < 640, tablette < 1024, desktop ≥ 1280. */
  --bp-sm: 640px;
  --bp-md: 1024px;
  --bp-lg: 1280px;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur-base: 0ms;
    --transition-fast: 0ms linear;
    --transition-base: 0ms linear;
    --transition-slow: 0ms linear;
  }
}

/* =====================================================================
   Socle minimal (hors couche : doit s'appliquer même sans components.css,
   ex. pages d'impression)
   ===================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* [hidden] gagne toujours, y compris sur une classe qui fixe `display`. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
