/* ============================================================
   HUP E LA COSTELLAZIONE (`components/hup.js`)

   Le regole del concept, che qui diventano movimento:
   - **uno per volta**: su una schermata si muove Hup o la Costellazione;
   - **come il tempo**: fili, barre e riempimenti vanno da sinistra a
     destra, a scaglioni, come nel Gantt del marchio;
   - **niente aloni**: nessun glow, nessun riflesso;
   - **poi si ferma**: le reazioni (ciao, trovato, ops, festa) girano una
     volta; in loop vanno solo le attese (ascolta, pensa, lavora, riposo,
     e la Costellazione che pensa o cerca).
   Con «riduci movimento» resta il fotogramma fermo di ogni stato.
   ============================================================ */
.hup-defs{position:absolute;width:0;height:0;overflow:hidden;}
.hup-s0{stop-color:var(--hup-from);}
.hup-s1{stop-color:var(--hup-to);}

.hup,.cst{position:relative;display:inline-block;flex:none;vertical-align:middle;line-height:0;}
.hup svg,.cst svg{width:100%;height:100%;overflow:visible;display:block;}
.hup *,.cst *{transform-box:fill-box;transform-origin:center;animation-timing-function:ease-in-out;}
.hup [transform]{transform-box:view-box;transform-origin:0 0;}
.hup-24{width:24px;height:24px;} .hup-32{width:32px;height:32px;} .hup-36{width:36px;height:36px;}
.hup-52{width:52px;height:52px;} .hup-72{width:72px;height:72px;} .hup-96{width:96px;height:96px;}
.cst-14{width:14px;height:14px;} .cst-16{width:16px;height:16px;} .cst-18{width:18px;height:18px;} .cst-20{width:20px;height:20px;}
.cst-24{width:24px;height:24px;} .cst-28{width:28px;height:28px;} .cst-32{width:32px;height:32px;} .cst-40{width:40px;height:40px;} .cst-48{width:48px;height:48px;}

/* ---- Hup: i colori ---- */
.h-corpo,.h-grad{fill:url(#hupG);}
.h-ink{fill:var(--on-accent);}
.h-ink-s{fill:none;stroke:var(--on-accent);stroke-linecap:round;}
.h-bocca{opacity:.85;}
.h-dorme{opacity:.7;}
.h-nb{fill:var(--hup-node);}
.h-trk{fill:none;stroke:var(--hup-node);}
.h-ln{fill:none;stroke:var(--hup-from);stroke-linecap:round;stroke-dasharray:1;}
.h-nd{fill:var(--hup-node);}
.h-amb{fill:var(--hup-to);} .h-cor{fill:var(--hup-from);} .h-deep{fill:var(--primary-deep);}
.zz{font-family:'Bricolage Grotesque','Inter',system-ui,sans-serif;font-weight:800;fill:var(--muted);opacity:0;}
.hup .wk-c,.hup .spk,.hup .cf{opacity:0;}
/* Sopra un pieno arancio Hup diventa bianco, con occhi e bocca arancio. */
.hup.bianco .h-corpo,.hup.bianco .h-grad{fill:var(--on-accent);}
.hup.bianco .h-nb{fill:color-mix(in srgb,var(--on-accent) 55%,transparent);}
.hup.bianco .h-ink{fill:var(--primary);}
.hup.bianco .h-ink-s{stroke:var(--primary);}

/* ---- Hup: le espressioni ---- */
.h-body{transform-origin:24px 42px;transform-box:view-box;}
.h-eyes{transform-origin:24px 25px;transform-box:view-box;}
.x-idle .h-body{animation:hup-hop 3.4s infinite;}
.x-idle .h-a1{animation:hup-slide 2.4s infinite alternate;}
.x-idle .h-a2{transform-origin:left center;animation:hup-grow 2.4s infinite alternate;}
.x-idle .h-e{animation:hup-blink 4.4s infinite;}
.x-idle .h-eyes{animation:hup-look 6s infinite;}
/* Ciao: un saltello e l'occhiolino, una volta. */
.x-ciao .h-body{animation:hup-hop 1.4s 1;}
.x-ciao .h-e{animation:hup-blink 1.4s 1;}
.x-ciao .wk-o{animation:hup-wk-o 1.4s 1 both;}
.x-ciao .wk-c{animation:hup-wk-c 1.4s 1 both;}
/* Ascolta: gli occhi in alto, l'antenna che riceve, la bocca a «o». */
.x-ascolta .h-eyes{transform:translateY(-1.6px);}
.x-ascolta .h-a1{transform-origin:left center;animation:hup-sig 1.1s infinite;}
.x-ascolta .h-a2{transform-origin:left center;animation:hup-sig 1.1s .18s infinite;}
.x-ascolta .h-body{animation:hup-tilt 3s infinite;}
.x-ascolta .h-o{animation:hup-oo 1.1s infinite;}
/* Pensa: l'antenna diventa una piccola costellazione. */
.x-pensa .h-eyes{animation:hup-look-up 2.4s infinite;}
.x-pensa .h-ln{animation:hup-draw-loop 2.4s cubic-bezier(.5,0,.3,1) infinite;}
.x-pensa .h-ln.l2,.x-pensa .h-nd.n2{animation-delay:.2s;}
.x-pensa .h-ln.l3,.x-pensa .h-nd.n3{animation-delay:.4s;}
.x-pensa .h-nd{animation:hup-nd-loop 2.4s infinite;}
/* Lavora: gli occhi in basso, la barra dell'antenna che si riempie. */
.x-lavora .h-eyes{transform:translateY(1.8px);}
.x-lavora .h-a2f{transform-origin:left center;animation:hup-fill 1.8s cubic-bezier(.5,0,.3,1) infinite;}
.x-lavora .h-e{animation:hup-blink 3.6s infinite;}
.x-lavora .h-a1{animation:hup-slide .9s infinite alternate;}
/* Trovato: un salto grande e tre scintille. */
.x-trovato .h-body{animation:hup-big-hop 1.3s 1;}
.x-trovato .spk{animation:hup-spark 1.3s 1;}
.x-trovato .spk.s2{animation-delay:.06s;} .x-trovato .spk.s3{animation-delay:.12s;}
/* Ops: occhi piatti, bocca a onda, uno scossone. */
.x-ops .h-body{animation:hup-ops 1.1s 1;}
.x-ops .h-a1{transform-origin:right center;animation:hup-droop 1.1s 1;}
/* Riposo: le «z» che salgono, piano. */
.x-riposo .zz{animation:hup-zz 3.6s linear infinite;}
.x-riposo .zz.z2{animation-delay:1.2s;} .x-riposo .zz.z3{animation-delay:2.4s;}
.x-riposo .h-a1{transform-origin:right center;transform:rotate(-10deg);}
/* Festa: due salti e i coriandoli. */
.x-festa .h-body{animation:hup-jump 1.9s 1;}
.x-festa .cf{animation:hup-conf 1.9s 1;}
.x-festa .cf.c2{animation-delay:.08s;} .x-festa .cf.c3{animation-delay:.16s;} .x-festa .cf.c4{animation-delay:.04s;} .x-festa .cf.c5{animation-delay:.12s;}
/* Sotto i 32px, e dove si chiede: fermo. */
.hup.fermo *{animation:none!important;}
.hup.fermo .zz{opacity:0;}

@keyframes hup-hop{0%,58%,100%{transform:translateY(0) scaleY(1);}64%{transform:translateY(0) scaleY(.94);}72%{transform:translateY(-3.5px) scaleY(1.02);}82%{transform:translateY(0) scaleY(.97);}88%{transform:translateY(0) scaleY(1);}}
@keyframes hup-blink{0%,44%,50%,100%{transform:scaleY(1);}47%{transform:scaleY(.12);}}
@keyframes hup-look{0%,28%{transform:translateX(0);}36%,54%{transform:translateX(-2.5px);}62%,80%{transform:translateX(2.5px);}88%,100%{transform:translateX(0);}}
@keyframes hup-slide{0%{transform:translateX(0);}100%{transform:translateX(3px);}}
@keyframes hup-grow{0%{transform:scaleX(.55);}100%{transform:scaleX(1);}}
@keyframes hup-wk-o{0%,62%,84%,100%{opacity:1;}66%,80%{opacity:0;}}
@keyframes hup-wk-c{0%,62%,84%,100%{opacity:0;}66%,80%{opacity:1;}}
@keyframes hup-sig{0%,100%{transform:scaleX(.45);}50%{transform:scaleX(1);}}
@keyframes hup-tilt{0%,100%{transform:rotate(0);}50%{transform:rotate(-4deg);}}
@keyframes hup-oo{0%,100%{transform:scaleY(1);}50%{transform:scaleY(.6);}}
@keyframes hup-look-up{0%,100%{transform:translate(1.6px,-1.6px);}50%{transform:translate(-1.6px,-1.6px);}}
@keyframes hup-draw-loop{0%{stroke-dashoffset:1;}40%,80%{stroke-dashoffset:0;}100%{stroke-dashoffset:-1;}}
@keyframes hup-nd-loop{0%,15%{fill:var(--hup-node);}35%,85%{fill:var(--hup-from);}100%{fill:var(--hup-node);}}
@keyframes hup-fill{0%{transform:scaleX(0);opacity:1;}65%,85%{transform:scaleX(1);opacity:1;}100%{transform:scaleX(1);opacity:0;}}
@keyframes hup-big-hop{0%,100%{transform:translateY(0) scaleY(1);}12%{transform:translateY(0) scaleY(.9);}30%{transform:translateY(-6px) scaleY(1.04);}48%{transform:translateY(0) scaleY(.95);}58%{transform:translateY(0) scaleY(1);}}
@keyframes hup-spark{0%,20%{transform:scale(0);opacity:1;}40%{transform:scale(1);opacity:1;}60%,100%{transform:scale(1);opacity:0;}}
@keyframes hup-ops{0%,100%{transform:rotate(0);}10%{transform:rotate(-8deg);}18%{transform:rotate(5deg);}26%{transform:rotate(-3deg);}34%,90%{transform:rotate(0);}}
@keyframes hup-droop{0%,100%{transform:rotate(0);}15%,80%{transform:rotate(-12deg);}}
@keyframes hup-zz{0%{transform:translate(0,0);opacity:0;}15%{opacity:1;}100%{transform:translate(5px,-9px);opacity:0;}}
@keyframes hup-jump{0%,100%{transform:translateY(0) rotate(0);}15%{transform:translateY(0) scaleY(.88);}35%{transform:translateY(-8px) rotate(-6deg);}50%{transform:translateY(-8px) rotate(6deg);}68%{transform:translateY(0) scaleY(.95);}78%{transform:translateY(0);}}
@keyframes hup-conf{0%,25%{transform:translateY(-6px) rotate(0);opacity:0;}35%{opacity:1;}85%{opacity:1;}100%{transform:translateY(16px) rotate(220deg);opacity:0;}}

/* ---- La Costellazione: i colori ---- */
.k-trk{fill:none;stroke:var(--hup-node);}
.k-ln{fill:none;stroke:url(#hupG);stroke-linecap:round;stroke-dasharray:1;stroke-dashoffset:0;}
.k-nd{fill:var(--hup-from);}
.k-cc{fill:url(#hupG);}
.k-ck{fill:none;stroke:var(--on-accent);stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1;}
.k-ex rect{fill:var(--on-accent);}
.k-pz rect{fill:var(--text);}
.k-ex,.k-pz,.k-br{opacity:0;}
.k-ba{fill:none;stroke:var(--red);stroke-linecap:round;}
.k-bb{fill:none;stroke:url(#hupG);stroke-linecap:round;}
.k-rot{transform-origin:24px 24px;transform-box:view-box;}
/* Sopra un pieno arancio: tutto bianco, la spunta arancio. */
.cst.bianco .k-trk{stroke:color-mix(in srgb,var(--on-accent) 35%,transparent);}
.cst.bianco .k-ln,.cst.bianco .k-bb{stroke:var(--on-accent);}
.cst.bianco .k-nd,.cst.bianco .k-cc{fill:var(--on-accent);}
.cst.bianco .k-ck{stroke:var(--primary);}
.cst.bianco .k-ex rect{fill:var(--primary);}

/* ---- La Costellazione: gli stati ---- */
/* Pensa: i fili a scaglioni verso il nucleo, le tessere si accendono. */
.k-pensa .k-ln{animation:hup-draw-loop 2.4s cubic-bezier(.5,0,.3,1) infinite;}
.k-pensa .k-nd{animation:hup-nd-loop 2.4s infinite;}
/* Cerca: ruota piano, le tessere si accendono a turno. */
.k-cerca .k-rot{animation:hup-spin 9s linear infinite;}
.k-cerca .k-ln{stroke-dashoffset:1;}
.k-cerca .k-nd{animation:hup-scan 2.5s infinite;}
.k-cerca .k-cc{animation:hup-spin-step 2.5s cubic-bezier(.6,0,.2,1) infinite;}
/* Fatto: tutti i fili, poi la spunta nel nucleo; e si ferma lì. */
.k-fatto .k-ln{animation:hup-draw-once .9s cubic-bezier(.5,0,.3,1) 1 both;}
.k-fatto .k-nd{animation:hup-nd-once .9s 1 both;}
.k-fatto .k-ck{animation:hup-ck .9s cubic-bezier(.5,0,.3,1) .5s 1 both;}
/* Interrotto: i fili si fermano a metà e si ritirano, il nucleo va in
   pausa. Niente rosso: non è un guasto. */
.k-int .k-ln{animation:hup-int-ln 1.6s cubic-bezier(.5,0,.3,1) 1 both;}
.k-int .k-nd{animation:hup-int-nd 1.6s 1 both;}
.k-int .k-cc{animation:hup-int-core 1.6s 1 both;}
.k-int .k-pz{animation:hup-int-pz 1.6s cubic-bezier(.3,0,.2,1) 1 both;}
/* Errore: un filo si spezza, la tessera trema, il nucleo diventa rosso con «!». */
.k-err .k-ln{animation:hup-draw-once 1.4s cubic-bezier(.5,0,.3,1) 1 both;}
.k-err .k-ln.l5{animation:hup-err-ln 1.4s cubic-bezier(.5,0,.3,1) 1 both;}
.k-err .k-br{animation:hup-err-br 1.4s 1 both;}
.k-err .k-ba{animation:hup-err-a 1.4s cubic-bezier(.2,.8,.3,1) 1 both;}
.k-err .k-bb{animation:hup-err-b 1.4s cubic-bezier(.2,.8,.3,1) 1 both;}
.k-err .k-nd{animation:hup-nd-once 1.4s 1 both;}
.k-err .k-nd.n5{animation:hup-nd-err 1.4s 1 both;}
.k-err .k-cc{animation:hup-err-core 1.4s 1 both;}
.k-err .k-ex{animation:hup-ex-in 1.4s 1 both;}
/* Gli scaglioni dei fili, dopo gli stati: la scorciatoia `animation` li azzererebbe. */
.cst .k-ln.l2,.cst .k-nd.n2{animation-delay:.18s;} .cst .k-ln.l3,.cst .k-nd.n3{animation-delay:.36s;}
.cst .k-ln.l4,.cst .k-nd.n4{animation-delay:.54s;} .cst .k-ln.l5,.cst .k-nd.n5{animation-delay:.72s;}
.cst.k-err .k-ln.l5,.cst.k-err .k-nd.n5{animation-delay:0s;}

@keyframes hup-spin{to{transform:rotate(360deg);}}
@keyframes hup-scan{0%,100%{fill:var(--hup-node);transform:scale(.8);}10%,22%{fill:var(--hup-from);transform:scale(1.1);}34%{fill:var(--hup-node);transform:scale(.8);}}
@keyframes hup-spin-step{0%,60%{transform:rotate(0);}85%,100%{transform:rotate(-90deg);}}
@keyframes hup-draw-once{0%{stroke-dashoffset:1;}30%,100%{stroke-dashoffset:0;}}
@keyframes hup-nd-once{0%,10%{fill:var(--hup-node);}30%,100%{fill:var(--hup-from);}}
@keyframes hup-ck{0%{stroke-dashoffset:1;}100%{stroke-dashoffset:0;}}
@keyframes hup-int-ln{0%{stroke-dashoffset:1;}26%,46%{stroke-dashoffset:.5;}72%,100%{stroke-dashoffset:1;}}
@keyframes hup-int-nd{0%,8%{fill:var(--hup-node);}22%,44%{fill:var(--hup-from);}60%,100%{fill:var(--hup-node);}}
@keyframes hup-int-core{0%,40%{fill:url(#hupG);}48%,100%{fill:var(--hup-node);}}
@keyframes hup-int-pz{0%,42%{opacity:0;transform:scaleY(.2);}54%,100%{opacity:1;transform:scaleY(1);}}
@keyframes hup-err-ln{0%{stroke-dashoffset:1;opacity:1;}30%{stroke-dashoffset:0;opacity:1;}36%,100%{stroke-dashoffset:0;opacity:0;}}
@keyframes hup-err-br{0%,35%{opacity:0;}36%,100%{opacity:1;}}
@keyframes hup-err-a{0%,36%{transform:translate(0,0);}52%,100%{transform:translate(1.4px,2px);}}
@keyframes hup-err-b{0%,36%{transform:translate(0,0);}52%,100%{transform:translate(-1.2px,-1.6px);}}
@keyframes hup-nd-err{0%,30%{fill:var(--hup-from);transform:rotate(0);}36%{fill:var(--red);transform:rotate(-16deg);}42%{transform:rotate(12deg);}48%{transform:rotate(-6deg);}54%,100%{fill:var(--red);transform:rotate(0);}}
@keyframes hup-err-core{0%,40%{fill:url(#hupG);}46%,100%{fill:var(--red);}}
@keyframes hup-ex-in{0%,44%{opacity:0;}52%,100%{opacity:1;}}

/* ---- Il fotogramma fermo ----
   Con «riduci movimento» (del sistema o di Hupla) ogni stato mostra il
   suo punto d'arrivo: la spunta del fatto, la pausa dell'interrotto, il
   nucleo rosso dell'errore. */
@media (prefers-reduced-motion:reduce){
  .hup *,.cst *{animation:none!important;}
  .x-riposo .zz{opacity:1;}
  .k-fatto .k-ck{stroke-dashoffset:0;}
  .k-int .k-cc{fill:var(--hup-node);} .k-int .k-pz{opacity:1;} .k-int .k-nd{fill:var(--hup-node);}
  .k-err .k-cc{fill:var(--red);} .k-err .k-ex,.k-err .k-br{opacity:1;} .k-err .k-ln.l5{opacity:0;}
}
:root[data-motion="off"] .hup *,:root[data-motion="off"] .cst *{animation:none!important;}
:root[data-motion="off"] .k-fatto .k-ck{stroke-dashoffset:0;}
:root[data-motion="off"] .k-int .k-pz,:root[data-motion="off"] .k-err .k-ex,:root[data-motion="off"] .k-err .k-br{opacity:1;}
:root[data-motion="off"] .k-err .k-cc{fill:var(--red);}
:root[data-motion="off"] .k-err .k-ln.l5{opacity:0;}

/* Hup negli stati vuoti (`components/hup-vuoti.js`): al posto dell'icona,
   con il suo respiro sotto. */
.empty-state > .vuoto-hup,.pj-empty > .vuoto-hup{display:block;margin:0 auto 10px;}

/* Hup come persona del team: il tondo con Hup dentro, e il chip «IA». */
.hup-av{position:relative;display:inline-flex;align-items:flex-start;justify-content:center;flex:none;border-radius:50%;overflow:hidden;
  background:var(--primary-soft);vertical-align:middle;}
.hup-av > .hup{width:90%;height:90%;margin-top:16%;}
.hup-av-20{width:20px;height:20px;} .hup-av-22{width:22px;height:22px;} .hup-av-24{width:24px;height:24px;}
.hup-av-26{width:26px;height:26px;} .hup-av-28{width:28px;height:28px;} .hup-av-32{width:32px;height:32px;}
.ia-chip{display:inline-flex;align-items:center;gap:4px;padding:2px 8px 2px 6px;border-radius:999px;background:var(--primary-soft);color:var(--primary-dark);
  font-size:11px;font-weight:700;line-height:1.4;white-space:nowrap;vertical-align:middle;}
/* «Scritto con Hupla AI» sotto la descrizione di un ticket finché nessuno
   l'ha rivista (`iaScrittoHtml`, AI Act art. 50(2)). */
.ia-scritto{display:inline-flex;align-items:center;gap:5px;margin-top:6px;font-size:11.5px;font-weight:600;color:var(--primary-dark);}
