/* V5 · CONTRÔLES — complète primitives.css : champs, interrupteur, case à cocher, bouton radio, curseur,
   progression, avatar, chargement, bandeau, feuille et alerte.
   Classes v5-* seulement, aucune couleur en dur, tous les états (repos, appui, focus clavier, désactivé).
   Accent (violet) : interrupteur allumé, case et radio cochés, partie remplie du curseur et de la progression. */

/* ------------------------------------------------------------------ champs : tailles et variantes */
.v5-champ-l{ height: var(--v5-ctrl-l); padding: 0 10px; }
.v5-champ-xl{ height: var(--v5-ctrl-xl); padding: 0 12px; border-radius: var(--v5-r-sel); font-size: var(--v5-t-15); }
textarea.v5-champ{ height: auto; min-height: 72px; padding: 6px 7px; line-height: 1.4; resize: vertical; }
.v5-champ:disabled{ opacity: var(--v5-opacite-inactif); }
.v5-champ[aria-invalid="true"]{ box-shadow: inset 0 0 0 1px var(--v5-rouge); }

/* ------------------------------------------------------------------ interrupteur : <button role="switch" aria-checked>
   « Toggles - Switches » Regular : piste 54×24 en capsule, bouton 32×20 ; Small : 40×18, bouton 24×14. */
.v5-interrupteur{
  position: relative; flex: none; box-sizing: border-box; width: 54px; height: 24px; padding: 0; margin: 0; border: 0; border-radius: 12px;
  background: var(--v5-rempli-1); cursor: default;
  transition: background-color var(--v5-duree-feuille) var(--v5-courbe);
}
.v5-interrupteur::after{
  content: ""; position: absolute; top: 2px; left: 2px; width: 32px; height: 20px; border-radius: 10px;
  background: var(--v5-bouton-interrupteur); box-shadow: var(--v5-ombre-poignee);
  transition: transform var(--v5-duree-feuille) var(--v5-courbe), width var(--v5-duree) var(--v5-courbe);
}
.v5-interrupteur:active::after{ width: 36px; }
.v5-interrupteur[aria-checked="true"]{ background: var(--v5-violet); }
.v5-interrupteur[aria-checked="true"]::after{ transform: translateX(18px); background: var(--v5-sur-violet); }
.v5-interrupteur[aria-checked="true"]:active::after{ transform: translateX(14px); }
.v5-interrupteur[data-taille="s"]{ width: 40px; height: 18px; border-radius: 9px; }
.v5-interrupteur[data-taille="s"]::after{ width: 24px; height: 14px; border-radius: 7px; }
.v5-interrupteur[data-taille="s"][aria-checked="true"]::after{ transform: translateX(12px); }
.v5-interrupteur, .v5-case, .v5-radio{ --v5-focus-decalage: 1px; }
.v5-interrupteur:focus-visible{ outline: var(--v5-focus-l) solid var(--v5-focus); outline-offset: var(--v5-focus-decalage); }
/* contour : la piste éteinte (remplissage 10 %) ne se distingue du fond de page qu'à 1,2:1 ; la forme doit s'identifier sans dépendre du fond. */
.v5-interrupteur:not([aria-checked="true"]){ box-shadow: inset 0 0 0 var(--v5-trait-fort) var(--v5-texte-3); }
.v5-interrupteur:disabled{ opacity: var(--v5-opacite-inactif); pointer-events: none; box-shadow: inset 0 0 0 var(--v5-trait-fort) var(--v5-texte); }

/* ------------------------------------------------------------------ case à cocher : 16×16, r5,5 ; cochée = accent, coche blanche (« Toggles - Checkboxes ») */
.v5-case{
  appearance: none; -webkit-appearance: none; flex: none; position: relative; box-sizing: border-box; width: 16px; height: 16px; margin: 0; padding: 0; border: 0;
  border-radius: var(--v5-r-case); background: var(--v5-rempli-1); cursor: default;
  transition: background-color var(--v5-duree);
}
.v5-case::before{ content: none; }
.v5-case:active{ background: var(--v5-bouton-presse); }
.v5-case:checked, .v5-case:indeterminate{ background: var(--v5-violet); box-shadow: none; }
/* la coche du système (kit macOS 27, « Checkbox / Check » : glyphe de 9,3 × 8,9 dans la case de 16, trait plein à bouts ronds) */
.v5-case:checked::after{
  content: ""; position: absolute; inset: 0; background: var(--v5-sur-violet);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.3 8.5l2.7 2.8 4.8-6.6' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.3 8.5l2.7 2.8 4.8-6.6' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px 16px no-repeat;
}
.v5-case:indeterminate::after{ content: ""; position: absolute; left: 4.75px; top: 7px; width: 6.5px; height: 2px; border-radius: 1px; background: var(--v5-sur-violet); }
.v5-case:focus-visible{ outline: var(--v5-focus-l) solid var(--v5-focus); outline-offset: var(--v5-focus-decalage); }
.v5-case:not(:checked):not(:indeterminate){ box-shadow: inset 0 0 0 var(--v5-trait-fort) var(--v5-texte-3); }
.v5-case:disabled{ opacity: var(--v5-opacite-inactif); }
.v5-case:disabled:not(:checked){ box-shadow: inset 0 0 0 var(--v5-trait-fort) var(--v5-texte); }

/* ------------------------------------------------------------------ bouton radio : 16×16 rond ; coché = accent, point blanc de 4,8 (« Toggles - Radio Buttons ») */
.v5-radio{
  appearance: none; -webkit-appearance: none; flex: none; position: relative; box-sizing: border-box; width: 16px; height: 16px; margin: 0; padding: 0; border: 0;
  border-radius: 50%; background: var(--v5-rempli-1); cursor: default; transition: background-color var(--v5-duree);
}
.v5-radio::before{ content: none; }
.v5-radio:checked{ background: var(--v5-violet); box-shadow: none; }
.v5-radio:checked::after{ content: ""; position: absolute; left: 5.5px; top: 5.5px; width: 5px; height: 5px; border-radius: 50%; background: var(--v5-sur-violet); }
.v5-radio:focus-visible{ outline: var(--v5-focus-l) solid var(--v5-focus); outline-offset: var(--v5-focus-decalage); }
.v5-radio:not(:checked){ box-shadow: inset 0 0 0 var(--v5-trait-fort) var(--v5-texte-3); }
.v5-radio:disabled{ opacity: var(--v5-opacite-inactif); }
/* libellé d'une case ou d'un radio : ligne de 24, écart de 5 (kit) */
.v5-choix{ display: inline-flex; align-items: center; gap: 6px; min-height: var(--v5-ctrl-h); font-size: var(--v5-t-13); font-weight: var(--v5-g-moyen); color: var(--v5-texte); cursor: default; }

/* ------------------------------------------------------------------ curseur (« Sliders ») : piste de 6, partie remplie à la couleur d'accent, poignée blanche allongée
   La partie remplie lit --v5-p (0 % → 100 %), tenue à jour par js/v5/ui.js. */
.v5-curseur{ appearance: none; -webkit-appearance: none; width: 140px; height: var(--v5-ctrl-h); margin: 0; padding: 0; border: 0; background: none; cursor: default; }
.v5-curseur::-webkit-slider-runnable-track{ height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--v5-violet) var(--v5-p, 50%), var(--v5-rempli-1) var(--v5-p, 50%)); }
.v5-curseur::-webkit-slider-thumb{
  appearance: none; -webkit-appearance: none; width: 22px; height: 16px; margin-top: -5px; border: 0; border-radius: 8px;
  background: var(--v5-bouton-interrupteur); box-shadow: var(--v5-ombre-poignee);
}
.v5-curseur::-moz-range-track{ height: 6px; border-radius: 3px; background: var(--v5-rempli-1); }
.v5-curseur::-moz-range-progress{ height: 6px; border-radius: 3px; background: var(--v5-violet); }
.v5-curseur::-moz-range-thumb{ width: 22px; height: 16px; border: 0; border-radius: 8px; background: var(--v5-bouton-interrupteur); box-shadow: var(--v5-ombre-poignee); }
.v5-curseur{ --v5-focus-decalage: 2px; }
.v5-curseur:focus-visible{ outline: var(--v5-focus-l) solid var(--v5-focus); outline-offset: var(--v5-focus-decalage); border-radius: var(--v5-r-ctrl); }
.v5-curseur:disabled{ opacity: var(--v5-opacite-inactif); }
/* curseur neutre (zoom d'une grille : réglage d'affichage, pas une valeur) */
.v5-curseur[data-neutre]::-webkit-slider-runnable-track{ background: var(--v5-rempli-1); }
.v5-curseur[data-neutre]::-moz-range-progress{ background: var(--v5-rempli-1); }

/* ------------------------------------------------------------------ pas-à-pas (« Steppers ») : deux demi-boutons empilés de 20×12, r6 */
.v5-pas{ display: inline-flex; flex-direction: column; flex: none; width: 20px; height: var(--v5-ctrl-h); border-radius: var(--v5-r-ctrl); background: var(--v5-bouton); overflow: hidden; }
.v5-pas button{ flex: 1; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--v5-texte); cursor: default; }
.v5-pas button:active{ background: var(--v5-bouton-presse); }
.v5-pas button svg{ width: 9px; height: 9px; }

/* ------------------------------------------------------------------ progression (« Progress Indicators / Linear ») : 6 px en capsule, accent */
.v5-progression{ display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--v5-rempli-1); overflow: hidden; }
.v5-progression > i{ display: block; height: 100%; width: var(--v5-p, 0%); border-radius: inherit; background: var(--v5-violet); transition: width 300ms var(--v5-courbe); }
.v5-progression[data-indetermine] > i{ width: 40%; animation: v5-va-et-vient 1.4s ease-in-out infinite; }
@keyframes v5-va-et-vient{ 0%{ transform: translateX(-100%); } 100%{ transform: translateX(250%); } }
/* jauge d'utilisation (quota) : même tracé, 8 px, avec seuils */
.v5-jauge{ display: block; width: 100%; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--v5-violet) 12%, transparent); overflow: hidden; }
.v5-jauge > i{ display: block; height: 100%; width: var(--v5-p, 0%); border-radius: inherit; background: var(--v5-violet); }
.v5-jauge[data-etat="attente"] > i{ background: var(--v5-orange); }
.v5-jauge[data-etat="erreur"] > i{ background: var(--v5-rouge-plein); }

/* ------------------------------------------------------------------ avatar : 32 (défini dans navigation.css) */
.v5-avatar > img{ width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }

/* ------------------------------------------------------------------ squelette : ligne type */
.v5-squelette-ligne{ display: flex; align-items: center; gap: 10px; height: var(--v5-ligne-m); padding: 0 10px; }
.v5-squelette-ligne .v5-squelette:first-child{ width: 28px; height: 28px; border-radius: var(--v5-r-photo); flex: none; }
.v5-squelette-ligne .v5-squelette:last-child{ flex: 1; }

/* ------------------------------------------------------------------ bandeau : ce qui persiste (limite, session, hors ligne) */
.v5-bandeau{
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 8px 6px 14px; margin: 8px 12px; border-radius: var(--v5-r-groupe);
  background: var(--v5-fond-groupe); box-shadow: inset 0 0 0 var(--v5-trait) var(--v5-separateur-fort);
  font-size: var(--v5-t-13); color: var(--v5-texte);
}
.v5-bandeau-texte{ flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ feuille (sheet) et alerte
   feuille : fenêtre modale, deux largeurs ; alerte : compacte, opaque et lisible, avec actions clairement hiérarchisées. */
.v5-dialogue[data-taille="s"]{ width: min(360px, calc(100vw - 48px)); }
.v5-dialogue[data-taille="m"]{ width: min(480px, calc(100vw - 48px)); }
.v5-dialogue[data-taille="l"]{ width: min(640px, calc(100vw - 48px)); }
.v5-dialogue:focus{ outline: none; }
.v5-dialogue-corps{ margin-top: 12px; }
.v5-dialogue-corps > * + *{ margin-top: 12px; }

/* 22/10 (Lucas : « un panneau comme Claude / Notion, pas les boutons au milieu ») : panneau large, titre et texte à gauche, boutons
   rectangulaires en bas à droite, le bouton par défaut (Supprimer, en rouge) tout à droite, Annuler juste avant. */
.v5-alerte{
  width: min(440px, calc(100vw - 48px)); box-sizing: border-box; padding: 20px 20px 16px; border-radius: var(--v5-r-groupe); text-align: left;
  border: 0; background: var(--v5-surface-elevee);
  box-shadow: var(--v5-ombre-popover); color: var(--v5-texte); font-family: var(--v5-police);
  animation: v5-alerte 160ms var(--v5-courbe);
}
@keyframes v5-alerte{ from{ opacity: 0; transform: scale(.98); } }
.v5-alerte:focus{ outline: none; }
.v5-alerte-icone{ display: block; width: 40px; height: 40px; margin: 0 0 12px; }
.v5-alerte-titre{ margin: 0; font-size: var(--v5-t-15); font-weight: var(--v5-g-fort); line-height: var(--v5-i-15); }
.v5-alerte-texte{ margin: 6px 0 0; font-size: var(--v5-t-13); line-height: 18px; color: var(--v5-texte-2); overflow-wrap: anywhere; }
.v5-alerte-actions{ display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 20px; }
html.v5 .v5-alerte-actions .v5-btn:not(#_){ flex: none; min-width: 0; height: var(--v5-ctrl-l); padding: 0 14px; border-radius: var(--v5-r-action); white-space: nowrap; }   /* :not(#_) : passe devant la capsule de formes.css */

@media (prefers-reduced-motion: reduce){
  .v5-menu, .v5-dialogue, .v5-alerte, .pal, .pal-fond, .v5-voile{ animation-duration: 0s; }
  .v5-interrupteur::after, .v5-progression > i{ transition-duration: 0s; }
}
@media (forced-colors: active){
  .v5-interrupteur[aria-checked="true"], .v5-case:checked, .v5-radio:checked{ background: Highlight; }
  .v5-interrupteur, .v5-case, .v5-radio{ outline: 1px solid ButtonBorder; outline-offset: -1px; }
}
