/* Base et composants — lisent jetons.css, n'y ajoutent aucune couleur en dur.
 * Classes en français, composant--variante. Les états viennent des attributs ARIA
 * (aria-selected, aria-busy, aria-invalid, aria-disabled) : l'écran et l'accessibilité
 * disent la même chose.
 */

/* ---- Socle ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--fond);
  scrollbar-color: var(--surface-3) transparent;
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--texte);
  background: var(--fond);
  font-family: var(--police-texte);
  font-size: var(--t-corps);
  line-height: var(--interligne-corps);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  caret-color: var(--accent);
}

::selection {
  color: var(--sur-accent);
  background: var(--accent);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 3px solid var(--fond);
  border-radius: var(--r-pilule);
}

::-webkit-scrollbar-track {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1, h2, h3, h4, p, figure, blockquote, ol, ul {
  margin: 0;
}

h1, h2, h3, h4 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: color-mix(in oklab, var(--accent) 45%, transparent);
  transition: text-decoration-color var(--duree-1) var(--courbe-standard);
}

a:hover {
  text-decoration-color: currentColor;
}

code, kbd, samp, pre {
  font-family: var(--police-mono);
  font-size: 0.92em;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

hr {
  height: 1px;
  margin: var(--e-6) 0;
  border: 0;
  background: var(--filet);
}

/* 🔑 Un composant qui pose display (flex, grid) l'emporterait sur [hidden] du
   navigateur : le bandeau ne se cacherait JAMAIS (défaut vu le 01/10, tour 129). */
[hidden] {
  display: none !important;
}

.visuellement-cache {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lien-evitement {
  position: fixed;
  z-index: var(--plan-toast);
  top: var(--e-3);
  left: var(--e-3);
  padding: var(--e-2) var(--e-4);
  color: var(--sur-accent);
  background: var(--accent);
  border-radius: var(--r-controle);
  transform: translateY(-160%);
  transition: transform var(--duree-2) var(--courbe-sortie);
}

.lien-evitement:focus {
  transform: translateY(0);
}

/* ---- Typographie ---- */
.titre-heros {
  font-family: var(--police-titre);
  font-variant-numeric: lining-nums;
  font-size: var(--t-heros);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.02em;
}

.titre-1,
.titre-2 {
  font-family: var(--police-texte);
  font-weight: 500;
  line-height: var(--interligne-titre);
  letter-spacing: -0.035em;
}

/* Le dégradé blanc → gris des titres Resend. Pages vitrines seulement (page publique,
   catalogue) : dans l'application, un titre reste un titre plein. */
.titre-degrade {
  color: var(--texte);
  background: linear-gradient(to right bottom, var(--texte) 30%, color-mix(in oklab, var(--texte) 50%, transparent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Les trois IA dans un mot : le dégradé de marque. */
.mot-marque {
  color: var(--ia-codex);
  background: var(--marque);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.titre-1 { font-size: var(--t-1); }
.titre-2 { font-size: var(--t-2); }

.titre-3 {
  font-size: var(--t-3);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.012em;
}

.titre-serif {
  font-family: var(--police-titre);
  font-variant-numeric: lining-nums;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.chapeau {
  max-width: 52ch;
  color: var(--texte-2);
  font-size: var(--t-chapeau);
  line-height: 1.55;
}

.texte-2 { color: var(--texte-2); }
.texte-3 { color: var(--texte-3); }
.petit { font-size: var(--t-petit); }
.mesure { max-width: var(--mesure); }

.mono {
  font-family: var(--police-mono);
  font-size: 0.9em;
  letter-spacing: -0.01em;
}

.chiffres {
  font-variant-numeric: tabular-nums;
}

/* Le mot clé coloré d'un titre (EBX) : couleur d'action, ou celle d'une IA. */
.mot-cle { color: var(--accent); }
.mot-cle[data-ia="claude"] { color: var(--ia-claude); }
.mot-cle[data-ia="codex"] { color: var(--ia-codex); }
.mot-cle[data-ia="locale"] { color: var(--ia-locale); }

/* Étiquette de donnée (n° de tour, de version, de tâche, rôle) : texte courant, chiffres alignés.
 * Plus de crochets ni de capitales en mono (DESIGN.md, 16/10) : c'était un costume « technique ». */
.etiquette {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  color: var(--texte-2);
  font-size: var(--t-micro);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Mise en page ---- */
.pile {
  display: flex;
  flex-direction: column;
  gap: var(--espace, var(--e-4));
}

.rangee {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--espace, var(--e-3));
}

.icone {
  flex: none;
  width: 1.25em;
  height: 1.25em;
}

/* ---- Marque ---- */
.marque {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  color: var(--texte);
  font-family: var(--police-titre);
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.marque-embleme {
  width: 1.15em;
  height: 1.15em;
  overflow: visible;
}

.marque-embleme .arc { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.marque-embleme .arc-claude { stroke: var(--ia-claude); }
.marque-embleme .arc-codex { stroke: var(--ia-codex); }
.marque-embleme .arc-locale { stroke: var(--ia-locale); }
.marque-embleme .centre { fill: var(--decision); }

/* ---- Boutons ---- */
.bouton {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--e-2);
  min-height: 40px;
  padding: 0 1.1rem;
  color: var(--texte);
  background: var(--verre);
  border: 1px solid var(--filet-fort);
  border-radius: var(--r-controle);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    transform var(--duree-1) var(--courbe-sortie),
    background-color var(--duree-1) var(--courbe-standard),
    border-color var(--duree-1) var(--courbe-standard),
    box-shadow var(--duree-2) var(--courbe-sortie),
    color var(--duree-1) var(--courbe-standard);
}

.bouton:hover {
  border-color: color-mix(in oklab, var(--texte) 28%, transparent);
  transform: translateY(-1px);
}

.bouton:active {
  transform: translateY(0) scale(0.98);
}

/* Principal : blanc plein (noir en clair). Tout ce que fait l'humain est blanc —
   trancher, créer, prendre la main. La couleur reste aux IA. */
.bouton--principal,
.bouton--decision {
  color: var(--sur-decision);
  background: var(--decision);
  border-color: transparent;
  box-shadow: var(--ombre-2);
}

.bouton--principal:hover,
.bouton--decision:hover {
  border-color: transparent;
  background: color-mix(in oklab, var(--decision) 88%, var(--accent));
}

/* Signal : le bouton lumineux d'EBX. UN seul par page, sur la page publique. */
.bouton--signal {
  color: var(--sur-accent);
  background: linear-gradient(180deg, var(--accent), var(--accent-fort));
  border-color: transparent;
  box-shadow: var(--lueur-action), inset 0 1px 0 var(--reflet);
}

.bouton--signal:hover {
  border-color: transparent;
  box-shadow: 0 14px 34px -12px color-mix(in oklab, var(--accent) 70%, transparent), inset 0 1px 0 var(--reflet);
}

.bouton--fantome {
  color: var(--texte-2);
  background: transparent;
  border-color: transparent;
}

.bouton--fantome:hover {
  color: var(--texte);
  background: var(--surface-2);
  border-color: transparent;
}

.bouton--danger {
  color: var(--refus);
  background: transparent;
  border-color: color-mix(in oklab, var(--refus) 40%, transparent);
}

.bouton--danger:hover {
  background: var(--refus-doux);
  border-color: var(--refus);
}

.bouton--petit { min-height: 32px; padding: 0 0.8rem; font-size: var(--t-petit); border-radius: var(--r-petit); }
.bouton--grand { min-height: 48px; padding: 0 1.5rem; font-size: 1rem; }
.bouton--carre { width: 40px; padding: 0; }
.bouton--petit.bouton--carre { width: 32px; }
.bouton--bloc { width: 100%; }

.bouton:disabled,
.bouton[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Demande envoyée : le libellé reste, un anneau tourne à sa place d'icône. */
.bouton[aria-busy="true"] {
  cursor: progress;
}

.bouton[aria-busy="true"] .icone {
  visibility: hidden;
}

.bouton[aria-busy="true"]::before {
  content: "";
  position: absolute;
  left: 1.1rem;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: tourne 0.7s linear infinite;
}

/* ---- Champs ---- */
.champ {
  display: flex;
  flex-direction: column;
  gap: var(--e-2);
}

.champ-libelle {
  color: var(--texte);
  font-size: var(--t-petit);
  font-weight: 600;
}

.champ-aide {
  color: var(--texte-2);
  font-size: var(--t-petit);
}

.champ-erreur {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  color: var(--refus);
  font-size: var(--t-petit);
}

.saisie {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--filet-fort);
  border-radius: var(--r-controle);
  outline: none;
  transition: border-color var(--duree-1) var(--courbe-standard), box-shadow var(--duree-2) var(--courbe-sortie);
}

textarea.saisie {
  min-height: 7.5rem;
  line-height: 1.55;
  resize: vertical;
}

.saisie::placeholder {
  color: var(--texte-3);
  opacity: 1;
}

.saisie:hover {
  border-color: color-mix(in oklab, var(--texte) 30%, transparent);
}

.saisie:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-doux);
}

.saisie[aria-invalid="true"] {
  border-color: var(--refus);
}

.saisie[aria-invalid="true"]:focus-visible {
  box-shadow: 0 0 0 3px var(--refus-doux);
}

.saisie:disabled {
  color: var(--texte-3);
  background: var(--surface-2);
  cursor: not-allowed;
}

/* ---- Surfaces ---- */
.carte {
  padding: var(--e-5);
  background: var(--surface);
  border: 1px solid var(--filet);
  border-radius: var(--r-carte);
}

.panneau {
  padding: clamp(var(--e-5), 3vw, var(--e-7));
  background: var(--halo-panneau), var(--surface);
  border: 1px solid var(--filet);
  border-radius: var(--r-panneau);
}

.carte--interactive {
  cursor: pointer;
  transition:
    border-color var(--duree-1) var(--courbe-standard),
    transform var(--duree-2) var(--courbe-sortie),
    background-color var(--duree-1) var(--courbe-standard);
}

.carte--interactive:hover {
  border-color: var(--filet-fort);
  background: var(--surface-2);
  transform: translateY(-2px);
}

/* ---- Pastilles et points ---- */
.pastille {
  --c: var(--texte-2);
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  min-height: 26px;
  padding: 0 0.55rem;
  color: color-mix(in oklab, var(--c) 72%, var(--texte));
  background: color-mix(in oklab, var(--c) 15%, transparent);
  border: 0;
  border-radius: 10px;
  font-size: var(--t-micro);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.pastille[data-ia="claude"] { --c: var(--ia-claude); }
.pastille[data-ia="codex"] { --c: var(--ia-codex); }
.pastille[data-ia="locale"] { --c: var(--ia-locale); }
.pastille[data-etat="fait"] { --c: var(--texte-2); }
.pastille[data-etat="demande"] { --c: var(--attente); }
.pastille[data-etat="travail"] { --c: var(--accent); }
.pastille[data-etat="refus"] { --c: var(--refus); }
.pastille[data-etat="decision"] { --c: var(--decision); }
.pastille[data-etat="non-branche"] { --c: var(--texte-3); }

.point {
  --c: var(--texte-3);
  position: relative;
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--c);
  border-radius: 50%;
}

.point[data-ia="claude"] { --c: var(--ia-claude); }
.point[data-ia="codex"] { --c: var(--ia-codex); }
.point[data-ia="locale"] { --c: var(--ia-locale); }
.point[data-etat="travail"] { --c: var(--accent); }
.point[data-etat="fait"] { --c: var(--texte-2); }
.point[data-etat="refus"] { --c: var(--refus); }

/* Au travail : une onde part du point. */
.point[data-vivant]::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--c);
  animation: onde 1.8s var(--courbe-sortie) infinite;
}

/* Une IA en train d'écrire : trois points dans sa couleur. */
.ecrit {
  --c: var(--accent);
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ecrit[data-ia="claude"] { --c: var(--ia-claude); }
.ecrit[data-ia="codex"] { --c: var(--ia-codex); }
.ecrit[data-ia="locale"] { --c: var(--ia-locale); }

.ecrit span {
  width: 5px;
  height: 5px;
  background: var(--c);
  border-radius: 50%;
  animation: rebond 1.2s var(--courbe-standard) infinite;
}

.ecrit span:nth-child(2) { animation-delay: 0.15s; }
.ecrit span:nth-child(3) { animation-delay: 0.3s; }

/* ---- Onglets ---- */
.onglets {
  display: flex;
  gap: var(--e-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--filet);
  scrollbar-width: none;
}

.onglet {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--e-2);
  min-height: 44px;
  padding: 0 var(--e-4);
  color: var(--texte-2);
  background: none;
  border: 0;
  font-size: var(--t-petit);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duree-1) var(--courbe-standard);
}

.onglet::after {
  content: "";
  position: absolute;
  right: var(--e-3);
  bottom: -1px;
  left: var(--e-3);
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transition: transform var(--duree-2) var(--courbe-sortie);
}

.onglet:hover {
  color: var(--texte);
}

.onglet[aria-selected="true"] {
  color: var(--texte);
}

.onglet[aria-selected="true"]::after {
  transform: scaleX(1);
}

.onglet-compte {
  color: var(--texte-3);
  font-family: var(--police-mono);
  font-size: var(--t-micro);
  font-variant-numeric: tabular-nums;
}

/* ---- Fenêtre (dialog natif) ---- */
.fenetre {
  width: min(560px, calc(100vw - 2 * var(--gouttiere)));
  max-height: calc(100vh - 4rem);
  padding: 0;
  color: var(--texte);
  background: var(--halo-panneau), var(--surface);
  border: 1px solid var(--filet-fort);
  border-radius: var(--r-panneau);
  box-shadow: var(--ombre-3);
}

.fenetre[open] {
  animation: fenetre-arrive var(--duree-2) var(--courbe-sortie);
}

.fenetre::backdrop {
  background: var(--voile);
  backdrop-filter: blur(6px);
}

.fenetre-corps {
  display: flex;
  flex-direction: column;
  gap: var(--e-5);
  padding: var(--e-6);
}

.fenetre-tete {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--e-4);
}

.fenetre-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--e-3);
}

/* ---- Bandeaux ---- */
.bandeau {
  --c: var(--accent);
  display: flex;
  align-items: flex-start;
  gap: var(--e-3);
  padding: var(--e-3) var(--e-4);
  color: var(--texte);
  background: color-mix(in oklab, var(--c) 9%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--c) 30%, transparent);
  border-radius: var(--r-controle);
  font-size: var(--t-petit);
}

.bandeau > .icone {
  margin-top: 0.1em;
  color: var(--c);
}

.bandeau[data-ton="attente"] { --c: var(--attente); }
.bandeau[data-ton="refus"] { --c: var(--refus); }
.bandeau[data-ton="fait"] { --c: var(--texte-2); }

.bandeau-titre {
  font-weight: 600;
}

.bandeau-corps {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ---- Info-bulle : data-bulle="texte" sur un élément qui reçoit le focus ----
 * Le texte est AUSSI dans aria-label ou le contenu de l'élément : la bulle double ce
 * qu'un lecteur d'écran entend déjà, elle ne le remplace jamais. */
[data-bulle] {
  position: relative;
}

/* 🪤 La bulle n'existe QUE pendant le survol ou le focus : même transparente, une
   bulle posée au repos déborde de l'écran quand l'élément est en bout de ligne. */
[data-bulle]:hover::after,
[data-bulle]:focus-visible::after {
  content: attr(data-bulle);
  position: absolute;
  z-index: var(--plan-menu);
  bottom: calc(100% + 8px);
  left: 50%;
  width: max-content;
  max-width: 260px;
  padding: var(--e-2) var(--e-3);
  color: var(--texte);
  background: var(--surface-3);
  border: 1px solid var(--filet-fort);
  border-radius: var(--r-petit);
  box-shadow: var(--ombre-2);
  font-size: var(--t-micro);
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  transform: translateX(-50%);
  animation: bulle-arrive var(--duree-2) var(--courbe-sortie) 350ms both;
}

/* En bout de ligne : la bulle s'aligne sur le bord droit de l'élément. */
[data-bulle-pos="fin"]:hover::after,
[data-bulle-pos="fin"]:focus-visible::after {
  right: 0;
  left: auto;
  transform: none;
  animation-name: bulle-arrive-fin;
}

@keyframes bulle-arrive {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes bulle-arrive-fin {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---- Notification « demandé → fait » ---- */
.toast {
  display: flex;
  align-items: center;
  gap: var(--e-3);
  max-width: 420px;
  padding: var(--e-3) var(--e-4);
  background: var(--surface-2);
  border: 1px solid var(--filet-fort);
  border-radius: var(--r-carte);
  box-shadow: var(--ombre-2);
  font-size: var(--t-petit);
  animation: toast-arrive var(--duree-2) var(--courbe-sortie);
}

/* ---- Chargement ---- */
.squelette {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--r-petit);
}

.squelette::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--texte) 7%, transparent), transparent);
  transform: translateX(-100%);
  animation: balaye 1.6s var(--courbe-standard) infinite;
}

.squelette-ligne { height: 0.8rem; }
.squelette-titre { height: 1.5rem; width: 55%; }

/* ---- État vide ---- */
.vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e-4);
  padding: var(--e-7) var(--e-5);
  text-align: center;
}

.vide-embleme {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: var(--texte-2);
  background: var(--halo-panneau), var(--surface-2);
  border: 1px solid var(--filet);
  border-radius: 20px;
}

.vide-embleme .icone {
  width: 28px;
  height: 28px;
}

.vide-titre {
  font-family: var(--police-titre);
  font-size: var(--t-2);
  font-weight: 400;
  line-height: 1.1;
}

.vide-texte {
  max-width: 44ch;
  color: var(--texte-2);
}

/* ---- Mouvements ---- */
@keyframes tourne {
  to { transform: rotate(360deg); }
}

@keyframes onde {
  from { opacity: 0.7; transform: scale(1); }
  to { opacity: 0; transform: scale(3.2); }
}

@keyframes rebond {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@keyframes balaye {
  to { transform: translateX(100%); }
}

@keyframes fenetre-arrive {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-arrive {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .point[data-vivant]::after,
  .squelette::after {
    display: none;
  }
}
