/* ════════════════════════════════════════════════════════════════════
   h12s - Composants de formulaire faits maison. Moteur : h12s.js.
   Thème via variables CSS (fallbacks fournis). Compatible m14r.
   ════════════════════════════════════════════════════════════════════ */
/* ── Adaptation au corps (harmonie « cap:platform ») ──
   h12s.js relève --h12s-row / --h12s-swatch sous enveloppe mobile (a10l) et les
   resserre sur desktop (a13p / a10lt). Hors enveloppe, ces défauts s'appliquent :
   le moteur reste autonome sur le Web. */
:root{ --h12s-row:32px; --h12s-swatch:20px; }

/* Le contrôle natif remplacé sort du FLUX, sans exception. `min-width` et
   `max-width` doivent être neutralisés aussi : ils l'emportent sur `width`,
   même en !important, et une feuille d'hôte qui pose `select { min-width:9rem }`
   suffit alors à faire déborder la page d'un champ invisible. */
.h12s-native-hidden{ position:absolute !important; width:1px !important; min-width:0 !important; max-width:none !important; height:1px !important; min-height:0 !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0 0 0 0) !important; white-space:nowrap !important; border:0 !important; }

:where(.h12s-select,.h12s-color,.h12s-date,.h12s-time,.h12s-range,.h12s-num,.h12s-pop){
  --_card:var(--color-surface, var(--card,#fff));
  --_txt:var(--color-text, var(--txt,#0f172a));
  --_mut:var(--color-muted, var(--mut,#64748b));
  --_line:var(--color-line, var(--line,#e2e8f0));
  --_accent:var(--color-primary, var(--accent,#2563eb));
  /* --h12s-on-accent : posée par h12s.js sur le popover (#000 ou #fff selon la luminance de l'accent), #fff en repli.
     Déclarée par l'hôte sur :root, elle a le dernier mot (1.9.4). */
  --_radius:var(--radius-md, 10px);
}

/* ── Déclencheurs (boutons-champs) ── */
.h12s-select,.h12s-color,.h12s-date,.h12s-time{
  display:inline-flex; align-items:center; gap:9px; min-height:38px; width:100%;
  padding:7px 11px; border:1px solid var(--_line); border-radius:var(--_radius);
  background:var(--_card); color:var(--_txt); font:inherit; font-size:14px; cursor:pointer; text-align:start;
  transition:border-color .12s, box-shadow .12s;
}
.h12s-select:hover,.h12s-color:hover,.h12s-date:hover,.h12s-time:hover{ border-color:color-mix(in srgb, var(--_accent) 50%, var(--_line)); }
.h12s-select:focus-visible,.h12s-color:focus-visible,.h12s-date:focus-visible,.h12s-time:focus-visible,
.h12s-select[aria-expanded="true"]{ outline:0; border-color:var(--_accent); box-shadow:0 0 0 3px color-mix(in srgb, var(--_accent) 22%, transparent); }
.h12s-select:disabled,.h12s-color:disabled,.h12s-date:disabled,.h12s-time:disabled{ opacity:.5; cursor:not-allowed; }
.h12s-val{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; display:flex; gap:4px; flex-wrap:wrap; }
.h12s-chev{ display:inline-flex; color:var(--_mut); flex:0 0 auto; transition:transform .15s; }
.h12s-select[aria-expanded="true"] .h12s-chev{ transform:rotate(180deg); }
.h12s-ph{ color:var(--_mut); }
.h12s-tag{ background:color-mix(in srgb, var(--_accent) 14%, transparent); color:var(--_accent); font-size:12.5px; font-weight:600; padding:2px 8px; border-radius:999px; }
.h12s-di{ display:inline-flex; color:var(--_mut); flex:0 0 auto; }
.h12s-dv{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ── Popover générique ── */
.h12s-pop{
  position:fixed; z-index:var(--z-dropdown,1000); box-sizing:border-box;
  background:color-mix(in srgb, var(--_card,#fff) 96%, transparent);
  -webkit-backdrop-filter:saturate(1.6) blur(16px); backdrop-filter:saturate(1.6) blur(16px);
  border:1px solid color-mix(in srgb, var(--_line,#e2e8f0) 80%, transparent);
  border-radius:13px; box-shadow:0 20px 56px -16px rgba(0,0,0,.4), 0 4px 12px -6px rgba(0,0,0,.2);
  color:var(--_txt,#0f172a); font:14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  opacity:0; transform:translateY(-6px) scale(.98); transition:opacity .12s, transform .12s cubic-bezier(.22,1,.36,1);
}
.h12s-pop.in{ opacity:1; transform:none; }

/* ── Liste déroulante ── */
.h12s-listwrap{ padding:5px; max-width:min(92vw,360px); }
.h12s-search{ display:flex; align-items:center; gap:8px; padding:6px 9px; margin:1px 1px 5px; border-radius:9px;
  background:color-mix(in srgb, var(--_line) 30%, transparent); }
.h12s-search span{ display:inline-flex; color:var(--_mut); } .h12s-search input{ flex:1; border:0; outline:0; background:transparent; font:inherit; color:var(--_txt); }
.h12s-list{ max-height:min(48vh,320px); overflow-y:auto; scrollbar-width:thin; }
.h12s-list::-webkit-scrollbar{ width:8px } .h12s-list::-webkit-scrollbar-thumb{ background:var(--_line); border-radius:8px; border:2px solid transparent; background-clip:padding-box }
.h12s-optg{ padding:7px 11px 3px; font-size:10.5px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:var(--_mut); }
.h12s-opt{ display:flex; align-items:center; gap:9px; padding:8px 10px; min-height:var(--h12s-row,32px); border-radius:9px; cursor:pointer; white-space:nowrap; }
.h12s-oc{ width:15px; height:15px; flex:0 0 15px; display:inline-flex; color:var(--_accent); }
.h12s-ol{ flex:1; overflow:hidden; text-overflow:ellipsis; }
.h12s-opt.hi{ background:color-mix(in srgb, var(--_accent) 12%, transparent); }
.h12s-opt.on{ font-weight:600; }
.h12s-opt.off{ opacity:.4; pointer-events:none; }
.h12s-empty{ padding:18px; text-align:center; color:var(--_mut); font-size:13px; }

/* ── Sélecteur de couleur (type Figma) ── */
.h12s-color{ width:auto; min-width:120px; }
.h12s-sw{ width:var(--h12s-swatch,20px); height:var(--h12s-swatch,20px); flex:0 0 var(--h12s-swatch,20px); border-radius:6px; box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);
  background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%); background-size:8px 8px; background-position:0 0,0 4px,4px -4px,-4px 0; }
.h12s-hex{ flex:1; font-variant-numeric:tabular-nums; font-size:13px; }
.h12s-cp{ width:240px; padding:10px; }
.h12s-cp-sv{ position:relative; height:150px; border-radius:9px; overflow:hidden; cursor:crosshair; touch-action:none; }
.h12s-cp-svc{ position:absolute; inset:0; }
.h12s-cp-svw{ position:absolute; inset:0; background:linear-gradient(90deg,#fff,transparent),linear-gradient(0deg,#000,transparent); }
.h12s-cp-dot{ position:absolute; width:14px; height:14px; border-radius:50%; transform:translate(-50%,-50%); box-shadow:0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.3); pointer-events:none; }
/* Les trois curseurs sont atteignables au Tab (role=slider posé par h12s.js) :
   l'anneau de focus vit dans l'ombre portée, le carré étant en overflow:hidden. */
.h12s-cp-dot:focus-visible,.h12s-cp-ht:focus-visible,.h12s-cp-at:focus-visible{ outline:0; box-shadow:0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, var(--_accent) 70%, transparent); }
.h12s-cp-sliders{ display:flex; gap:10px; align-items:center; margin-top:11px; }
.h12s-cp-prev{ width:34px; height:34px; flex:0 0 34px; border-radius:8px; box-shadow:inset 0 0 0 1px rgba(0,0,0,.15);
  background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%); background-size:10px 10px; background-position:0 0,0 5px,5px -5px,-5px 0; }
.h12s-cp-bars{ flex:1; display:grid; gap:11px; }
.h12s-cp-hue,.h12s-cp-alpha{ position:relative; height:12px; border-radius:999px; cursor:pointer; touch-action:none; }
.h12s-cp-hue{ background:linear-gradient(90deg,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); }
.h12s-cp-alpha{ background-image:linear-gradient(45deg,#ccc 25%,transparent 25%),linear-gradient(-45deg,#ccc 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ccc 75%),linear-gradient(-45deg,transparent 75%,#ccc 75%); background-size:10px 10px; background-position:0 0,0 5px,5px -5px,-5px 0; }
.h12s-cp-ag{ position:absolute; inset:0; border-radius:999px; }
.h12s-cp-ht,.h12s-cp-at{ position:absolute; top:50%; width:14px; height:14px; border-radius:50%; transform:translate(-50%,-50%); background:#fff; box-shadow:0 0 0 1px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.3); pointer-events:none; }
.h12s-cp-foot{ display:flex; gap:8px; align-items:center; margin-top:11px; }
.h12s-cp-hex{ flex:1; min-width:0; border:1px solid var(--_line); border-radius:8px; padding:7px 9px; font:inherit; font-size:13px; text-transform:uppercase; background:var(--_card); color:var(--_txt); outline:0; }
.h12s-cp-hex:focus{ border-color:var(--_accent); }
.h12s-cp-sw{ display:grid; grid-template-columns:repeat(6,1fr); gap:5px; margin-top:10px; }
.h12s-cp-sw button{ aspect-ratio:1; border:1px solid rgba(0,0,0,.12); border-radius:6px; cursor:pointer; padding:0; }
.h12s-cp-sw button:hover{ transform:scale(1.12); }

/* ── Calendrier ── */
.h12s-cal{ padding:10px; width:264px; }
.h12s-cal-h{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.h12s-cal-t{ font-weight:600; text-transform:capitalize; }
.h12s-cal-nav{ display:inline-flex; padding:5px; border:0; background:transparent; color:var(--_mut); border-radius:8px; cursor:pointer; }
.h12s-cal-nav:hover{ background:color-mix(in srgb, var(--_line) 40%, transparent); color:var(--_txt); }
/* La grille est annoncée (role=grid) : chaque semaine est une ligne, d'où
   .h12s-cal-r ; les 7 colonnes vivent maintenant sur la ligne, pas sur la grille. */
.h12s-cal-g{ display:grid; gap:2px; }
.h12s-cal-r{ display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.h12s-dow{ text-align:center; font-size:10.5px; font-weight:700; color:var(--_mut); padding:4px 0; text-transform:uppercase; }
.h12s-day{ aspect-ratio:1; border:0; background:transparent; color:var(--_txt); border-radius:8px; cursor:pointer; font:inherit; font-size:13px; }
.h12s-day:hover{ background:color-mix(in srgb, var(--_accent) 14%, transparent); }
.h12s-day:focus-visible{ outline:2px solid var(--_accent); outline-offset:-2px; }
.h12s-day.out{ color:var(--_mut); opacity:.45; }
/* Hors bornes (min, max, step) : visible mais non choisissable, et toujours atteignable au clavier. */
.h12s-day.off{ opacity:.3; cursor:not-allowed; text-decoration:line-through; }
.h12s-day.off:hover{ background:transparent; }
.h12s-day.today{ box-shadow:inset 0 0 0 1.5px color-mix(in srgb, var(--_accent) 55%, transparent); font-weight:700; }
.h12s-day.on{ background:var(--_accent); color:var(--h12s-on-accent,#fff); font-weight:700; }
.h12s-cal-nav[disabled]{ opacity:.35; cursor:not-allowed; }
.h12s-cal-f button[disabled]{ opacity:.45; cursor:not-allowed; }
.h12s-cal-f{ display:flex; gap:8px; margin-top:9px; padding-top:9px; border-top:1px solid color-mix(in srgb, var(--_line) 60%, transparent); }
.h12s-cal-f button{ flex:1; font:inherit; font-size:12.5px; padding:7px; border:1px solid var(--_line); background:var(--_card); color:var(--_txt); border-radius:8px; cursor:pointer; }
.h12s-cal-f button:hover{ border-color:var(--_accent); color:var(--_accent); }

/* ── Heure ── */
.h12s-tp{ display:flex; align-items:stretch; padding:8px; gap:4px; }
.h12s-tp-col{ height:180px; overflow-y:auto; scrollbar-width:thin; display:grid; gap:2px; padding:0 4px; }
.h12s-tp-col::-webkit-scrollbar{ width:6px } .h12s-tp-col::-webkit-scrollbar-thumb{ background:var(--_line); border-radius:6px }
.h12s-tp-sep{ display:flex; align-items:center; font-weight:700; color:var(--_mut); }
.h12s-tp-i{ border:0; background:transparent; color:var(--_txt); font:inherit; font-variant-numeric:tabular-nums; padding:6px 12px; border-radius:8px; cursor:pointer; }
.h12s-tp-i:hover{ background:color-mix(in srgb, var(--_accent) 12%, transparent); }
.h12s-tp-i.on{ background:var(--_accent); color:var(--h12s-on-accent,#fff); font-weight:700; }

/* ── Curseur (range) ── */
.h12s-range{ position:relative; height:32px; display:flex; align-items:center; padding:0 9px; min-width:140px; }
.h12s-rt{ position:relative; height:6px; flex:1; border-radius:999px; background:color-mix(in srgb, var(--_line) 90%, transparent); cursor:pointer; touch-action:none; }
.h12s-rf{ position:absolute; left:0; top:0; bottom:0; border-radius:999px; background:var(--_accent); }
.h12s-rk{ position:absolute; top:50%; width:18px; height:18px; border-radius:50%; transform:translate(-50%,-50%); background:var(--_card); border:2px solid var(--_accent); cursor:grab; box-shadow:0 1px 4px rgba(0,0,0,.2); outline:0; }
.h12s-rk:focus-visible{ box-shadow:0 0 0 4px color-mix(in srgb, var(--_accent) 25%, transparent); }
.h12s-range.drag .h12s-rk{ cursor:grabbing; }
.h12s-rb{ position:absolute; bottom:140%; left:50%; transform:translateX(-50%); background:var(--_txt); color:var(--_card); font-size:11px; font-weight:600; padding:2px 7px; border-radius:6px; opacity:0; transition:opacity .12s; white-space:nowrap; font-variant-numeric:tabular-nums; pointer-events:none; }
.h12s-rk:hover .h12s-rb,.h12s-rk:focus-visible .h12s-rb,.h12s-range.drag .h12s-rb{ opacity:1; }
.h12s-range.off{ opacity:.5; pointer-events:none; }

/* ── Nombre (pas-à-pas) ── */
.h12s-num{ display:inline-flex; align-items:stretch; border:1px solid var(--_line); border-radius:var(--_radius); overflow:hidden; background:var(--_card); }
.h12s-num:focus-within{ border-color:var(--_accent); box-shadow:0 0 0 3px color-mix(in srgb, var(--_accent) 22%, transparent); }
.h12s-num-b{ display:inline-flex; align-items:center; justify-content:center; width:34px; border:0; background:transparent; color:var(--_mut); cursor:pointer; }
.h12s-num-b:hover{ background:color-mix(in srgb, var(--_line) 40%, transparent); color:var(--_txt); }
.h12s-num-f{ width:64px; border:0; outline:0; background:transparent; text-align:center; font:inherit; font-size:14px; color:var(--_txt); font-variant-numeric:tabular-nums; }
.h12s-num.off{ opacity:.5; }

/* ── Textarea auto-extensible ── */
.h12s-textarea{ resize:none; overflow:hidden; transition:height .04s linear; }

/* ── Mode sombre ── */
html[data-theme="dark"] .h12s-pop, .dark .h12s-pop{ box-shadow:0 24px 64px -16px rgba(0,0,0,.7), 0 4px 14px -6px rgba(0,0,0,.5); }

@media (prefers-reduced-motion: reduce){
  .h12s-pop,.h12s-chev,.h12s-rb{ transition:none; }
}

/* ── RTL : le curseur part de la droite (le JS pose right:% au lieu de left:%) ── */
[dir="rtl"] .h12s-rf{ left:auto; right:0; }
[dir="rtl"] .h12s-rk{ transform:translate(50%,-50%); }

/* ── Téléphone : l'indicatif et le numéro, d'une seule pièce ──
   Le bouton et le champ partagent une bordure : deux contrôles à l'œil, un
   seul objet. Le focus s'affiche sur l'ensemble, comme sur un champ simple.
   La pastille du pays est un pavé de texte tant que les drapeaux n'existent
   pas (lot C2) : sa taille est déjà celle qu'un drapeau prendra, pour que
   rien ne bouge le jour où il arrive. */
.h12s-tel{
  display:flex; align-items:stretch; width:100%; min-height:38px;
  border:1px solid var(--_line); border-radius:var(--_radius);
  background:var(--_card); overflow:hidden;
  transition:border-color .12s, box-shadow .12s;
}
.h12s-tel:hover{ border-color:color-mix(in srgb, var(--_accent) 50%, var(--_line)); }
.h12s-tel:focus-within{ outline:0; border-color:var(--_accent); box-shadow:0 0 0 3px color-mix(in srgb, var(--_accent) 22%, transparent); }
.h12s-tel-ind{
  display:inline-flex; align-items:center; gap:6px; flex:0 0 auto;
  padding:7px 9px; border:0; border-inline-end:1px solid var(--_line);
  background:color-mix(in srgb, var(--_line) 22%, transparent);
  color:var(--_txt); font:inherit; font-size:14px; cursor:pointer; text-align:start;
}
.h12s-tel-ind:hover{ background:color-mix(in srgb, var(--_line) 38%, transparent); }
.h12s-tel-ind:focus-visible{ outline:2px solid var(--_accent); outline-offset:-2px; }
.h12s-tel-ind:disabled{ opacity:.5; cursor:not-allowed; }
.h12s-tel-ind[aria-expanded="true"] .h12s-chev{ transform:rotate(180deg); }
.h12s-tel-pav{
  display:inline-flex; align-items:center; justify-content:center;
  width:22px; height:16px; flex:0 0 22px; border-radius:3px;
  background:color-mix(in srgb, var(--_line) 55%, transparent);
  font-size:9.5px; font-weight:700; letter-spacing:.02em; color:var(--_mut);
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);
}
/* Le drapeau occupe EXACTEMENT la place de la pastille de texte : passer de
   l'un à l'autre ne déplace rien dans la rangée. */
.h12s-tel-pav:has(> .h12s-tel-drapeau){ background:none; box-shadow:none; padding:0; }
.h12s-tel-drapeau{ width:22px; height:16px; display:block; border-radius:3px; object-fit:cover;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.06); }
.h12s-tel-code{ font-variant-numeric:tabular-nums; color:var(--_mut); flex:0 0 auto; }
.h12s-tel-num{
  flex:1; min-width:0; padding:7px 11px; border:0; outline:0;
  background:transparent; color:var(--_txt); font:inherit; font-size:14px;
  font-variant-numeric:tabular-nums;
}
.h12s-tel-num:disabled{ opacity:.5; cursor:not-allowed; }
.h12s-opt .h12s-tel-code{ margin-inline-start:auto; }
