/* PILOTAGE DU DÉLAI — thermomètre v2 (0.8.0 ; blocks/thermo.ejs,
   lib/thermo.js, lib/retro.js, js/thermo.js). Un seul composant :
   grand chiffre signé, zone écrite, phrase simple, prochaine action,
   barre à 4 zones avec pointe, jalons du rétroplanning posés SUR la
   barre (bulle au clic / toucher), compte à rebours vivant, LED,
   11 étapes. Tailles : complet, compact (une ligne, hauteur stable),
   mini = vignette. Mouvement : transform / opacity seulement,
   mouvement réduit respecté. Jamais la couleur seule. */
.thermo{
  --z:var(--muted); --z-rgb:90,98,112;
  display:grid; gap:14px; min-width:0; font-size:.92rem;
  container-type:inline-size; position:relative;
}
.thermo.zone-confortable{ --z:var(--ok); --z-rgb:30,127,79; }
.thermo.zone-anticiper{ --z:var(--info); --z-rgb:36,97,184; }
.thermo.zone-urgent{ --z:var(--warn); --z-rgb:184,105,10; }
.thermo.zone-depasse{ --z:var(--alert); --z-rgb:200,32,26; }
:root[data-theme="dark"] .thermo.zone-confortable{ --z-rgb:79,203,138; }
:root[data-theme="dark"] .thermo.zone-anticiper{ --z-rgb:127,176,255; }
:root[data-theme="dark"] .thermo.zone-urgent{ --z-rgb:242,176,79; }
:root[data-theme="dark"] .thermo.zone-depasse{ --z-rgb:255,90,82; }
.thermo.th-final{ --z:var(--ok); --z-rgb:30,127,79; }
.thermo.th-sortie{ --z:var(--muted); --z-rgb:90,98,112; }
/* Entrée mesurée : le composant se pose (opacity + translate 8 px) */
html.js .thermo[data-thermo-anime]:not(.th-vu){ opacity:0; transform:translateY(8px); }
.thermo{ transition:opacity calc(.5s * var(--mvt-x)) ease, transform calc(.5s * var(--mvt-x)) var(--mvt-courbe); }
/* ── Tête : LED, zone en clair, état ── */
.th-tete{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }
.thermo .led{
  width:10px; height:10px; border-radius:50%; background:var(--z); flex:none;
  box-shadow:0 0 0 3px rgba(var(--z-rgb), .2), 0 0 14px rgba(var(--z-rgb), .8);
  animation:ledPulse calc(2.2s * var(--mvt-x)) ease-in-out infinite;
}
.thermo.critique .led{ animation:ledClignote calc(1s * var(--mvt-x)) steps(2, end) infinite; }
.thermo.th-sortie .led{ animation:none; box-shadow:none; }
@keyframes ledPulse{
  0%,100%{ box-shadow:0 0 0 3px rgba(var(--z-rgb), .2), 0 0 10px rgba(var(--z-rgb), .6); }
  50%{ box-shadow:0 0 0 5px rgba(var(--z-rgb), .12), 0 0 18px rgba(var(--z-rgb), 1); }
}
@keyframes ledClignote{ 50%{ opacity:.25; } }
.th-zone-nom{
  font:800 .95rem var(--f-titre); text-transform:uppercase; letter-spacing:.08em; color:var(--z);
}
.th-sep{ color:var(--muted); }
.th-etat{ font:700 .9rem var(--f-titre); text-transform:uppercase; letter-spacing:.06em; color:var(--encre); }
/* ── Corps : grand chiffre + lecture ── */
.th-corps{ display:grid; grid-template-columns:auto minmax(0, 1fr); gap:10px 22px; align-items:start; }
@container (max-width: 480px){ .th-corps{ grid-template-columns:1fr; } }
.th-chiffre{ display:grid; justify-items:start; gap:2px; }
.th-jours{ display:inline-flex; align-items:baseline; gap:3px; color:var(--z); }
.th-jours .num{ font:500 clamp(2.6rem, 6cqi, 3.6rem)/1 var(--f-mono); letter-spacing:-.03em; font-variant-numeric:tabular-nums; }
.th-signe{ font-size:.7em; vertical-align:.1em; }
.th-jours small{ font:500 1rem var(--f-mono); }
.th-sous{ font:600 .68rem var(--f-mono); letter-spacing:.12em; text-transform:uppercase; color:var(--z); }
.th-compte{
  font:500 .72rem var(--f-mono); color:var(--muted); letter-spacing:.04em; margin-top:2px;
  padding:2px 8px; border:1px solid var(--ligne); border-radius:999px; background:rgba(var(--z-rgb), .06);
}
.th-compte::before{ content:"⏱ "; }
.th-lecture{ display:grid; gap:8px; min-width:0; align-self:center; }
.th-phrase{ margin:0; font-size:1.02rem; line-height:1.5; color:var(--encre); max-width:var(--ligne-max); }
.th-action{ margin:0; display:flex; gap:8px; align-items:flex-start; font-size:.9rem; color:var(--texte); line-height:1.5; }
.th-action .ico{ width:16px; height:16px; flex:none; margin-top:.2em; color:var(--accent); }
.th-action b{ color:var(--encre); }
.th-retard{ font-style:normal; color:var(--alert); font-weight:600; text-transform:uppercase; font-size:.72rem; letter-spacing:.06em; }
/* ── Piste : 4 zones, pointe, graduations ── */
.th-piste-wrap{ display:grid; gap:4px; position:relative; }
.th-piste{ position:relative; height:14px; border-radius:999px; overflow:visible; background:var(--ligne); }
.th-piste i{ position:absolute; display:block; }
.th-seg{ top:0; height:100%; opacity:.32; }
.th-seg:first-child{ border-radius:999px 0 0 999px; } .th-seg.z-confortable{ border-radius:0 999px 999px 0; }
.th-seg.z-depasse{ background:var(--alert); } .th-seg.z-urgent{ background:var(--warn); }
.th-seg.z-anticiper{ background:var(--info); } .th-seg.z-confortable{ background:var(--ok); }
.th-remplissage{
  top:0; left:0; height:100%; width:calc(var(--pos) * 100%); border-radius:999px;
  background:linear-gradient(90deg, var(--alert), var(--warn) 28%, var(--info) 44%, var(--ok));
  box-shadow:0 0 10px rgba(var(--z-rgb), .45);
  transition:width calc(1.2s * var(--mvt-x)) var(--mvt-courbe);
}
.th-grad{ top:-3px; width:1px; height:20px; background:var(--ligne-forte); }
.th-pointe{
  top:50%; left:calc(var(--pos) * 100%); width:22px; height:22px; margin:-11px 0 0 -11px; border-radius:50%;
  background:var(--carte); border:3px solid var(--z); box-shadow:0 0 0 4px rgba(var(--z-rgb), .18), 0 0 12px rgba(var(--z-rgb), .7);
  transition:left calc(1.2s * var(--mvt-x)) var(--mvt-courbe), border-color var(--mvt-tiroir); z-index:3;
}
html.js .thermo[data-thermo-anime]:not(.th-vu) .th-remplissage{ width:0; }
html.js .thermo[data-thermo-anime]:not(.th-vu) .th-pointe{ left:0; }
.thermo.th-sortie .th-remplissage, .thermo.th-sortie .th-pointe{ opacity:.35; box-shadow:none; }
.th-echelle{ display:flex; justify-content:space-between; font:500 .6rem var(--f-mono); color:var(--muted); letter-spacing:.08em; }
.th-ech-mid{ position:absolute; left:calc(100% / 7); transform:translateX(-50%); }
/* ── Jalons du rétroplanning posés SUR la barre ── */
.th-jalons{ list-style:none; margin:0; padding:0; position:absolute; left:0; right:0; top:0; height:14px; }
.th-jalon{ position:absolute; left:calc(var(--jp) * 100%); top:50%; transform:translate(-50%, -50%); z-index:4; }
.th-jalon-btn{
  appearance:none; border:0; background:none; padding:6px; margin:-6px; cursor:pointer; display:grid; justify-items:center; gap:4px; color:inherit;
}
.th-jalon .pt{
  width:10px; height:10px; border-radius:2px; transform:rotate(45deg); background:var(--carte);
  border:2px solid var(--encre); box-sizing:border-box; transition:transform var(--mvt-tiroir), background var(--mvt-tiroir);
}
.th-jalon.fait .pt{ background:var(--ok); border-color:var(--ok); border-radius:50%; transform:none; }
.th-jalon.retard .pt{ background:var(--alert); border-color:var(--alert); }
.th-jalon.prochain .pt{ border-color:var(--accent); box-shadow:0 0 0 4px rgba(var(--accent-rgb), .18); animation:glissePulse calc(2s * var(--mvt-x)) ease-in-out infinite; }
.th-jalon-btn:hover .pt, .th-jalon-btn:focus-visible .pt{ transform:rotate(45deg) scale(1.25); }
.th-jalon.fait .th-jalon-btn:hover .pt, .th-jalon.fait .th-jalon-btn:focus-visible .pt{ transform:scale(1.25); }
.th-jalon-btn:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:6px; }
.th-jalon .lbl{ display:none; position:absolute; top:16px; left:50%; transform:translateX(-50%); font:500 .56rem var(--f-mono); color:var(--muted); white-space:nowrap; letter-spacing:.02em; }
.th-jalon.prochain .lbl, .th-jalon-btn:hover .lbl, .th-jalon-btn:focus-visible .lbl{ display:block; color:var(--encre); font-weight:600; }
.th-bulle{
  position:absolute; bottom:calc(100% + 14px); left:50%; transform:translate(-50%, 6px); z-index:9; min-width:170px;
  display:none; gap:2px; padding:10px 12px; border-radius:10px; background:var(--encre); color:var(--carte);
  font-size:.78rem; line-height:1.45; box-shadow:0 10px 30px rgba(0,0,0,.25); pointer-events:none;
  animation:bulleIn calc(.18s * var(--mvt-x)) var(--mvt-courbe);
}
.th-bulle b{ font:700 .8rem var(--f-titre); text-transform:uppercase; letter-spacing:.05em; }
.th-bulle::after{ content:""; position:absolute; top:100%; left:50%; margin-left:-6px; border:6px solid transparent; border-top-color:var(--encre); }
.th-bulle-etat{ font:600 .62rem var(--f-mono); letter-spacing:.08em; text-transform:uppercase; opacity:.8; }
.th-jalon.retard .th-bulle-etat{ color:#FF9A94; }
.th-jalon .th-jalon-btn[aria-expanded="true"] + .th-bulle, .th-jalon:hover .th-bulle{ display:grid; transform:translate(-50%, 0); pointer-events:auto; }
@keyframes bulleIn{ from{ opacity:0; } }
.th-jalon:first-child .th-bulle{ left:0; transform:translate(0, 6px); } .th-jalon:first-child .th-bulle::after{ left:12px; }
.th-jalon:first-child .th-jalon-btn[aria-expanded="true"] + .th-bulle, .th-jalon:first-child:hover .th-bulle{ transform:translate(0, 0); }
.th-jalon:nth-child(n+6) .th-bulle{ left:auto; right:0; transform:translate(0, 6px); } .th-jalon:nth-child(n+6) .th-bulle::after{ left:auto; right:6px; }
.th-jalon:nth-child(n+6) .th-jalon-btn[aria-expanded="true"] + .th-bulle, .th-jalon:nth-child(n+6):hover .th-bulle{ transform:translate(0, 0); }
.th-jalon:last-child .th-bulle{ left:auto; right:0; transform:translate(0, 6px); } .th-jalon:last-child .th-bulle::after{ left:auto; right:6px; }
.th-jalon:last-child .th-jalon-btn[aria-expanded="true"] + .th-bulle, .th-jalon:last-child:hover .th-bulle{ transform:translate(0, 0); }
.thermo:has(.th-jalons) .th-piste-wrap{ padding:10px 0 18px; }
@container (max-width: 560px){ .thermo:has(.th-jalons) .th-piste-wrap{ padding:10px 0 18px; } }
/* ── Chips ── */
.th-chip{
  display:inline-flex; align-items:center; gap:6px;
  font:500 .7rem/1.2 var(--f-mono); letter-spacing:.08em; text-transform:uppercase;
  color:var(--z); border:1px solid rgba(var(--z-rgb), .45); padding:5px 10px;
  border-radius:999px; background:rgba(var(--z-rgb), .07); min-width:0; max-width:100%;
}
@media (min-width:1024px){ .th-chip{ white-space:nowrap; } }
.th-chip .ico{ width:14px; height:14px; }
.th-chip b{ font-weight:600; color:inherit; }
.th-chip.th-limite, .th-chip.th-jalons-chip{ --z:var(--encre); --z-rgb:27,31,38; color:var(--texte); }
:root[data-theme="dark"] .th-chip.th-limite, :root[data-theme="dark"] .th-chip.th-jalons-chip{ --z-rgb:232,234,240; }
.th-chip.th-prev.ok{ --z:var(--ok); --z-rgb:30,127,79; }
.th-chip.th-prev.ko{ --z:var(--alert); --z-rgb:200,32,26; }
:root[data-theme="dark"] .th-chip.th-prev.ok{ --z-rgb:79,203,138; }
:root[data-theme="dark"] .th-chip.th-prev.ko{ --z-rgb:255,90,82; }
.th-infos{ display:flex; flex-wrap:wrap; gap:8px; align-content:start; min-width:0; }
/* ── Timeline des 11 étapes + curseur glissant (--pas) ── */
.th-etapes{
  list-style:none; margin:4px 0 0; padding:0; display:grid;
  grid-template-columns:repeat(11, minmax(0, 1fr)); gap:2px; position:relative;
}
.th-etapes::before{ content:""; position:absolute; left:4.5%; right:4.5%; top:6px; height:2px; background:var(--ligne-forte); border-radius:2px; }
.th-etapes::after{
  content:""; position:absolute; left:4.5%; top:6px; height:2px; border-radius:2px;
  width:calc(91% * var(--pas) / 10); background:var(--accent);
  box-shadow:0 0 8px rgba(var(--accent-rgb), .6);
  transition:width calc(1.1s * var(--mvt-x)) var(--mvt-courbe);
}
.th-glisse{
  position:absolute; top:7px; left:calc(4.5% + 91% * var(--pas) / 10);
  width:20px; height:20px; margin:-10px 0 0 -10px; border-radius:50%; z-index:2;
  border:2px solid var(--accent); background:rgba(var(--accent-rgb), .12);
  transition:left calc(1.1s * var(--mvt-x)) var(--mvt-courbe);
  animation:glissePulse calc(2s * var(--mvt-x)) ease-in-out infinite;
}
@keyframes glissePulse{ 50%{ box-shadow:0 0 0 6px rgba(var(--accent-rgb), .12); } }
html.js .thermo[data-thermo-anime]:not(.th-vu) .th-etapes::after{ width:0; }
html.js .thermo[data-thermo-anime]:not(.th-vu) .th-glisse{ left:4.5%; }
.thermo.th-litige .th-glisse, .thermo.th-litige .th-etapes::after{ display:none; }
.thermo.th-sortie:not(.th-final) .th-etapes{ opacity:.6; }
.th-etapes li{ display:grid; justify-items:center; gap:6px; position:relative; min-width:0; z-index:1; }
.th-etapes .pt{
  width:12px; height:12px; border-radius:50%; background:var(--carte);
  border:2px solid var(--ligne-forte); box-sizing:border-box; margin-top:1px;
  transition:background var(--mvt-tiroir), border-color var(--mvt-tiroir);
}
.th-etapes li.fait .pt{ background:var(--accent); border-color:var(--accent); }
.th-etapes li.cur .pt{ background:var(--carte); border-color:var(--accent); }
.thermo.th-final .th-etapes li.cur .pt{ background:var(--ok); border-color:var(--ok); }
.th-etapes .lbl{
  font:500 .58rem var(--f-mono); color:var(--muted); text-align:center;
  letter-spacing:.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%;
}
.th-etapes li.cur .lbl{ color:var(--encre); font-weight:600; }
@container (max-width: 560px){
  .th-etapes .lbl{ display:none; }
  .th-etapes li.cur .lbl{ display:block; position:absolute; top:18px; background:var(--carte); padding:0 4px; max-width:none; }
  .th-etapes{ padding-bottom:18px; }
}
/* ── Compact (listes) : LED, zone, état, barre + jalons, jours signés ── */
.thermo-compact{ gap:0; }
.thermo-compact .th-tete{ gap:10px; flex-wrap:nowrap; }
.thermo-compact .th-zone-nom{ font-size:.72rem; white-space:nowrap; }
.thermo-compact .th-etat{ white-space:nowrap; }
.thermo-compact .th-sep{ display:none; }
.thermo-compact .th-etat{ display:none; }
@container (min-width: 520px){ .thermo-compact .th-etat, .thermo-compact .th-sep{ display:inline; } .thermo-compact .th-etat{ font-size:.78rem; } }
.th-barre{
  flex:1 1 60px; min-width:40px; height:6px; border-radius:999px;
  background:linear-gradient(90deg, var(--alert), var(--warn) 28%, var(--info) 44%, var(--ok));
  position:relative; opacity:.95;
}
.th-barre i{ position:absolute; display:block; }
.th-pointe-c{
  top:50%; left:calc(var(--pos) * 100%); width:12px; height:12px;
  margin:-6px 0 0 -6px; border-radius:50%; background:var(--carte); border:2px solid var(--z);
  box-shadow:0 0 6px rgba(var(--z-rgb), .7); z-index:2;
  transition:left calc(1.1s * var(--mvt-x)) var(--mvt-courbe);
}
.th-jalon-pt{ top:50%; left:calc(var(--jp) * 100%); width:6px; height:6px; margin:-3px 0 0 -3px; transform:rotate(45deg); background:var(--carte); border:1px solid var(--encre); box-sizing:border-box; }
.th-jalon-pt.fait{ background:var(--ok); border-color:var(--ok); border-radius:50%; transform:none; }
.th-jalon-pt.retard{ background:var(--alert); border-color:var(--alert); }
html.js .thermo-compact[data-thermo-anime]:not(.th-vu) .th-pointe-c{ left:0; }
.th-jours-ligne .num{ font-size:1.15rem; }
.th-jours-ligne small{ font-size:.75rem; }
.thermo-compact .th-chip{ padding:3px 8px; font-size:.64rem; }
/* ── Mini = vignette (tableau de bord) : zone, état, chiffre, piste ── */
.thermo-mini{ gap:8px; }
.thermo-mini .th-tete .th-jours-ligne{ margin-left:auto; }
.thermo-mini .th-corps{ grid-template-columns:1fr; gap:4px; }
.thermo-mini .th-chiffre{ display:none; }
.thermo-mini .th-phrase{ font-size:.86rem; color:var(--muted); }
.thermo-mini .th-compte{ display:none; }
.thermo-mini .th-piste{ height:8px; }
.thermo-mini .th-pointe{ width:16px; height:16px; margin:-8px 0 0 -8px; border-width:2px; }
.thermo-mini .th-echelle{ display:none; }
.thermo-mini .th-grad{ display:none; }
.thermo-tableau{
  list-style:none; margin:0; padding:0; display:grid;
  grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:var(--gout-2);
}
.thermo-tableau > li{ display:grid; gap:8px; min-width:0; }
.thermo-tableau .tt-nom{ font:700 .85rem var(--f-titre); text-transform:uppercase; letter-spacing:.05em; color:var(--encre); }
.thermo-tableau .tt-ct{ font:400 .74rem var(--f-mono); color:var(--muted); }
/* ── Radar (tableau de bord admin) : anneau par zone ── */
.th-radar{ display:grid; grid-template-columns:auto minmax(0, 1fr); gap:18px; align-items:center; }
@container (max-width: 480px){ .th-radar{ grid-template-columns:1fr; justify-items:center; } }
.th-radar svg{ width:150px; height:150px; display:block; }
.th-radar circle{ fill:none; stroke-width:14; transform:rotate(-90deg); transform-origin:50% 50%; transition:stroke-dasharray calc(1.2s * var(--mvt-x)) var(--mvt-courbe); }
.th-radar .r-piste{ stroke:var(--ligne); }
.th-radar .z-confortable{ stroke:var(--ok); } .th-radar .z-anticiper{ stroke:var(--info); }
.th-radar .z-urgent{ stroke:var(--warn); } .th-radar .z-depasse{ stroke:var(--alert); }
.th-radar text{ font:500 1.6rem var(--f-mono); fill:var(--encre); text-anchor:middle; }
.th-radar .r-lbl{ font:600 .55rem var(--f-mono); letter-spacing:.1em; fill:var(--muted); text-transform:uppercase; }
.th-radar-leg{ list-style:none; margin:0; padding:0; display:grid; gap:8px; }
.th-radar-leg li{ display:flex; align-items:center; gap:10px; font-size:.86rem; }
.th-radar-leg .pt{ width:10px; height:10px; border-radius:50%; flex:none; }
.th-radar-leg .pt.z-confortable{ background:var(--ok); } .th-radar-leg .pt.z-anticiper{ background:var(--info); }
.th-radar-leg .pt.z-urgent{ background:var(--warn); } .th-radar-leg .pt.z-depasse{ background:var(--alert); }
.th-radar-leg b{ font-family:var(--f-mono); margin-left:auto; }
/* ── Simulation (démo) ── */
.th-simu{ display:grid; gap:16px; }
.th-simu-ctrl{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:14px 20px; align-items:end; }
@media (max-width:767.98px){ .th-simu-ctrl{ grid-template-columns:1fr; } }
.th-simu-ctrl .field label{ display:flex; justify-content:space-between; gap:10px; }
.th-simu-ctrl input[type=range]{ width:100%; accent-color:var(--accent); }
.th-simu-ctrl output{ font-family:var(--f-mono); color:var(--accent); }
.th-temps{ display:grid; gap:10px; }
.th-temps input[type=range]{ width:100%; accent-color:var(--accent); height:28px; }
.th-temps-ech{ display:flex; justify-content:space-between; font:500 .66rem var(--f-mono); color:var(--muted); letter-spacing:.06em; }
.th-legende{ display:grid; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); gap:12px; list-style:none; margin:0; padding:0; }
.th-legende li{ display:grid; grid-template-columns:auto 1fr; gap:4px 10px; align-items:center; padding:12px 14px; border:1px solid var(--ligne); border-radius:12px; }
.th-legende .pt{ width:12px; height:12px; border-radius:50%; }
.th-legende b{ font:700 .8rem var(--f-titre); text-transform:uppercase; letter-spacing:.06em; }
.th-legende small{ grid-column:2; color:var(--muted); line-height:1.45; }
@media (prefers-reduced-motion:reduce){
  .th-bulle{ animation:none; }
  .thermo .led, .thermo.critique .led, .th-glisse, .th-jalon.prochain .pt{ animation:none; }
  .thermo, .th-remplissage, .th-pointe, .th-pointe-c, .th-etapes::after, .th-glisse, .th-bulle, .th-radar circle{ transition:none; }
  html.js .thermo[data-thermo-anime]:not(.th-vu){ opacity:1; transform:none; }
  html.js .thermo[data-thermo-anime]:not(.th-vu) .th-remplissage{ width:calc(var(--pos) * 100%); }
  html.js .thermo[data-thermo-anime]:not(.th-vu) .th-pointe{ left:calc(var(--pos) * 100%); }
  html.js .thermo[data-thermo-anime]:not(.th-vu) .th-etapes::after{ width:calc(91% * var(--pas) / 10); }
  html.js .thermo[data-thermo-anime]:not(.th-vu) .th-glisse{ left:calc(4.5% + 91% * var(--pas) / 10); }
  html.js .thermo-compact[data-thermo-anime]:not(.th-vu) .th-pointe-c{ left:calc(var(--pos) * 100%); }
}
/* compact dans une cellule de table : largeur bornée, rien ne se
   chevauche, l'état entier reste dans aria-label */
td .thermo-compact{ min-width:260px; max-width:420px; }
td .thermo-compact .th-chip{ flex:none; }
