/* -----------------------------------------------------------------------------
  Auteur : Simon-Pierre Boucher — contact@spboucher.ai
  Fichier : ka-ui/tokens.css — SOURCE CANONIQUE (repo ka-ui sur spbgit)
  Desc.  : Design system commun GROUPE KA « éditorial sharp » — tokens + socle
           de composants partagés par les 12 plateformes. Chaque site importe ce
           fichier PUIS surcharge uniquement son accent (voir accents.css).

    · Typo   : display Space Grotesk / texte Inter / micro-étiquettes JetBrains Mono
    · Palette: papier #f5f3ee · encre #141814 · vert profond #1c5c41 + ACCENT du site
    · Signature : bordures encre 1,5–2 px + ombres décalées dures, grain de film,
      surlignés d'accent inclinés (néo-brutalisme raffiné)
    · Breakpoints communs : 360 / 768 / 1024 / 1440 px (mobile-first)
    · Zones tactiles ≥ 44×44 px, safe-areas iOS, typographie fluide (clamp)
----------------------------------------------------------------------------- */

:root {
  /* ---- Palette fixe Groupe KA (identique sur les 12 sites) ---- */
  --paper: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #141814;
  --ink-2: #4d5551;
  --ink-3: #8b928c;
  --line: rgba(20, 24, 20, 0.14);
  --line-strong: rgba(20, 24, 20, 0.85);
  --green: #1c5c41;
  --green-deep: #123f2e;
  --amber: #e8a33d;
  --amber-soft: #fdf3e2;
  --danger: #b3423a;
  --danger-soft: #fbe9e7;

  /* ---- ACCENT du site — SEULES variables surchargées par marque ---- */
  --accent: #d9f26b;        /* défaut : lime Groupe KA */
  --accent-soft: #f0f9d2;
  --accent-deep: #123f2e;
  --on-accent: var(--ink);  /* couleur du texte posé SUR l'accent */

  /* alias rétro-compatibles (les satellites historiques utilisent --lime) */
  --lime: var(--accent);
  --lime-soft: var(--accent-soft);

  /* ---- Géométrie sharp ---- */
  --r-card: 10px;
  --r-ctl: 6px;
  --r-pill: 999px;

  /* ---- Ombres décalées — la signature du groupe ---- */
  --shadow-flat: 0 1px 2px rgba(20, 24, 20, 0.05);
  --shadow-off: 6px 6px 0 var(--ink);
  --shadow-off-soft: 8px 8px 0 rgba(20, 24, 20, 0.08);
  --shadow-off-mid: 4px 4px 0 rgba(20, 24, 20, 0.18);

  /* ---- Typographie ---- */
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* Échelle fluide (mobile-first, clamp) */
  --fs-h1: clamp(30px, 3.2vw + 18px, 54px);
  --fs-h2: clamp(23px, 1.8vw + 14px, 34px);
  --fs-h3: clamp(17px, 0.9vw + 12px, 22px);
  --fs-body: 15px;
  --fs-small: 13px;

  /* Espacements */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Cible tactile minimale */
  --touch: 44px;

  /* ---- Échelle z-index COMMUNE (obligatoire — aucune valeur arbitraire) ----
     grain de film body::before = 9999 (pointer-events:none, toujours au-dessus,
     purement visuel). Tout composant interactif se place sous 9999 : */
  --z-content: 1;      /* contenu positionné ordinaire            */
  --z-sticky: 300;     /* éléments sticky de contenu (sous-nav…)  */
  --z-header: 500;     /* header du site                          */
  --z-bottombar: 600;  /* tab bar / barre d'action basse          */
  --z-dropdown: 700;   /* menus déroulants (au-dessus des barres) */
  --z-overlay: 800;    /* voile sous modale/panneau               */
  --z-modal: 900;      /* modales, panneaux de filtres, galeries  */
  --z-toast: 950;      /* notifications                           */

  /* ---- Hauteur de viewport DYNAMIQUE (barre du navigateur mobile qui se
     replie au scroll) : toujours var(--vh100), JAMAIS 100vh en dur. ---- */
  --vh100: 100vh;
}
@supports (height: 100dvh) { :root { --vh100: 100dvh; } }

/* ---- Socle ---- */
* { box-sizing: border-box; }
/* overflow-x: clip sur html ET body — sur WebKit iOS, clip posé sur body seul
   ne bloque PAS le défilement latéral du viewport (quirk de propagation) ;
   clip (≠ hidden) ne casse pas position:sticky. */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: clip; /* jamais de débordement horizontal */
}
img, svg, video { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.03em; margin: 0 0 0.5em; }
h1 { font-size: var(--fs-h1); line-height: 1.06; }
h2 { font-size: var(--fs-h2); line-height: 1.15; }
h3 { font-size: var(--fs-h3); line-height: 1.25; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Grain de film pleine page — ⚠️ jamais de z-index sur body > * (position:
   relative seulement), sinon les utilitaires z-* sont écrasés. */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; opacity: 0.35; z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='0.06'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; }

/* ---- Conteneur commun ---- */
.container { max-width: 1152px; margin: 0 auto; padding: 0 var(--sp-4); }
@media (min-width: 768px) { .container { padding: 0 var(--sp-5); } }

/* ---- Micro-typographie signature ---- */
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--green);
}
.kicker::before { content: ""; width: 22px; height: 2px; background: var(--green); }
.klabel {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3);
}
.hl {
  display: inline-block; background: var(--accent); color: var(--on-accent);
  border-radius: 8px; padding: 0 10px 2px; transform: rotate(-1deg);
}
.outline-txt { color: transparent; -webkit-text-stroke: 2px var(--ink); }

/* ---- Boutons (cible ≥ 44 px) ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 10px 18px;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  border: 1.5px solid var(--ink); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-off-mid); }
.btn:active { transform: translate(0, 0); box-shadow: none; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--ink); color: var(--accent); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }

/* ---- Cartes ---- */
.card {
  background: var(--surface); border: 1.5px solid var(--ink);
  border-radius: var(--r-card); box-shadow: var(--shadow-off-soft);
  overflow: hidden;
}
.card-hover { transition: transform 0.15s, box-shadow 0.15s; }
.card-hover:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-off); }

/* ---- Chips / badges ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink);
}
.chip-accent { background: var(--accent); color: var(--on-accent); }
.chip-soft { background: var(--accent-soft); border-color: var(--line); }

/* ---- Champs ---- */
.input, .select, .textarea {
  width: 100%; min-height: var(--touch); padding: 10px 14px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--ink); border-radius: var(--r-ctl);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; box-shadow: 3px 3px 0 var(--accent); border-color: var(--ink);
}
.input::placeholder { color: var(--ink-3); }

/* ---- Badge « Un service Groupe KA » (header, cliquable → hub) ---- */
.gk-badge {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 30px; padding: 3px 10px 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; text-decoration: none;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill);
  background: var(--surface); color: var(--ink-2); white-space: nowrap;
}
.gk-badge b {
  font-family: var(--font-display); font-size: 12px; letter-spacing: -0.02em;
  text-transform: none; color: var(--ink);
}
.gk-badge b .ka {
  display: inline-block; background: var(--ink); color: var(--accent);
  border-radius: 5px; padding: 0 5px 1px; margin-left: 3px; transform: rotate(-2deg);
}
.gk-badge:hover .ka { transform: rotate(0); }
.gk-badge--dark { background: transparent; border-color: rgba(245,243,238,0.4); color: rgba(245,243,238,0.75); }
.gk-badge--dark b { color: var(--paper); }

/* ---- Footer commun (fond encre — voir react/KaFooter.tsx) ---- */
.ka-footer { margin-top: var(--sp-8); background: var(--ink); padding: 44px 0; font-size: 13px; color: rgba(245,243,238,0.75); }
.ka-footer a { text-decoration: none; }
.ka-footer .wordmark { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.04em; color: var(--paper); text-decoration: none; }
.ka-footer .wordmark .ka { color: var(--accent); }
.ka-footer .desc { max-width: 640px; margin-top: var(--sp-4); }
.ka-footer .notice { max-width: 640px; margin-top: var(--sp-4); border-left: 2px solid var(--accent); padding-left: var(--sp-4); }
.ka-footer .notice b { color: var(--paper); }
.ka-footer .sites { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 26px 0 0; padding: 0; font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.ka-footer .sites a { color: rgba(245,243,238,0.65); }
.ka-footer .sites a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.ka-footer .contacts { display: grid; gap: 14px 32px; border-top: 1px solid rgba(245,243,238,0.15); margin-top: 30px; padding-top: 26px; }
@media (min-width: 768px) { .ka-footer .contacts { grid-template-columns: repeat(3, 1fr); } }
.ka-footer .contacts a { font-family: var(--font-mono); font-weight: 700; font-size: 12px; color: rgba(245,243,238,0.85); }
.ka-footer .contacts a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }
.ka-footer .contacts span { display: block; margin-top: 3px; font-size: 11px; color: rgba(245,243,238,0.5); }
.ka-footer .legal { margin-top: 30px; font-family: var(--font-mono); font-size: 11px; color: rgba(245,243,238,0.45); }
.ka-footer .legal a { color: inherit; }
.ka-footer .legal a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

/* ---- Tableaux → cartes empilées sous 768 px ---- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 767px) {
  .tbl-stack thead { display: none; }
  .tbl-stack tr { display: block; border: 1.5px solid var(--ink); border-radius: var(--r-card); margin-bottom: var(--sp-3); background: var(--surface); }
  .tbl-stack td { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 8px 12px; border: 0; }
  .tbl-stack td::before { content: attr(data-label); font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
}

/* ---- Utilitaires responsive ---- */
.only-mobile { display: initial; } .only-desktop { display: none; }
@media (min-width: 768px) { .only-mobile { display: none; } .only-desktop { display: initial; } }

/* =============================================================================
   SOCLE MOBILE OBLIGATOIRE (2026-08-19) — règles communes aux 13 sites.
   RÈGLES pour tout composant futur :
   · TAP, jamais :hover, pour ouvrir un menu (le survol n'existe pas au doigt) ;
     le :hover ne sert qu'aux effets décoratifs, sous @media (hover: hover).
   · var(--vh100) (dvh) et JAMAIS 100vh pour tout élément calé sur le viewport.
   · position:fixed exige qu'AUCUN ancêtre n'ait transform/filter/perspective/
     will-change/backdrop-filter — sinon monter l'élément à la racine (body).
   · Barre basse fixe = .ka-bottombar + classe has-bottombar sur <body>.
   · Menu/panneau ouvert = .ka-scroll-lock sur <html> (scroll arrière-plan gelé).
   · z-index : uniquement l'échelle --z-* ci-dessus.
   · Zones tactiles ≥ var(--touch) (44 px), champs ≥ 16 px (zoom iOS).
   ========================================================================== */

/* Anti-zoom iOS : au doigt, aucun champ sous 16 px (le focus d'un champ <16 px
   déclenche un zoom automatique de page sur Safari iOS). !important assumé :
   c'est un filet d'accessibilité, un champ plus petit casse le zoom quoi
   qu'il arrive — ne s'applique qu'aux écrans tactiles. */
@media (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea { font-size: max(16px, 1em) !important; }
}

/* Zone tactile du badge Groupe KA étendue à ≥44 px au doigt, sans changer
   son rendu (débord de la zone cliquable via pseudo-élément). */
@media (pointer: coarse) {
  .gk-badge { position: relative; }
  .gk-badge::after { content: ""; position: absolute; inset: -8px; }
}

/* Hauteurs viewport dynamiques */
.h-viewport { height: 100vh; height: 100dvh; }
.min-h-viewport { min-height: 100vh; min-height: 100dvh; }

/* Barre fixe basse fiable : safe-area iPhone incluse, immunisée contre les
   transforms accidentels, et compensation d'espace via body.has-bottombar. */
.ka-bottombar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--z-bottombar);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1.5px solid var(--ink);
  transform: none !important; filter: none !important;
}
body.has-bottombar { padding-bottom: calc(var(--bottombar-h, 64px) + env(safe-area-inset-bottom, 0px)); }

/* Verrou de scroll d'arrière-plan (menu mobile, modale, panneau de filtres
   ouverts) : ajouter/retirer .ka-scroll-lock sur <html>. */
html.ka-scroll-lock, html.ka-scroll-lock body { overflow: hidden !important; overscroll-behavior: none; }

/* Menu déroulant de référence : au-dessus de tout contenu (cartes Mapbox
   incluses), défilement interne avec élan, jamais plus haut que l'écran. */
.ka-menu {
  position: absolute; z-index: var(--z-dropdown);
  min-width: 180px;
  max-height: min(60vh, 420px); max-height: min(60dvh, 420px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--surface); border: 1.5px solid var(--ink);
  border-radius: var(--r-card); box-shadow: var(--shadow-off-mid);
}
.ka-menu a, .ka-menu button, .ka-menu label, .ka-menu [role="menuitem"], .ka-menu [role="option"] {
  display: flex; align-items: center; min-height: var(--touch);
  padding: 10px 14px; width: 100%; text-decoration: none;
}
/* Voile plein écran sous une modale / un panneau */
.ka-overlay {
  position: fixed; inset: 0; z-index: var(--z-overlay);
  background: rgba(20, 24, 20, 0.45);
}
