/* ===== v2: animazioni aggiuntive ===== */

/* Barra di avanzamento della lettura, dal dato (menta) all'interfaccia (viola) */
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: var(--e2e); transform-origin: left; transform: scaleX(var(--p, 0)); }

/* Slogan: sottolineatura che si disegna sotto "end to end." */
.s-e2e { width: fit-content; position: relative; }
.s-e2e::after { content: ""; position: absolute; left: 0; right: 0; bottom: -.02em; height: .07em; border-radius: 99px; background: var(--e2e); transform: scaleX(0); transform-origin: left; }
.js .hero.in .s-e2e::after { animation: draw-x .9s var(--ease) 1s forwards; }
@keyframes draw-x { to { transform: scaleX(1); } }

/* Query SQL che si scrive riga per riga */
.js .hero.in .code p { animation: type .55s steps(26, end) backwards; }
.js .hero.in .code p:nth-child(1) { animation-delay: .5s; }
.js .hero.in .code p:nth-child(2) { animation-delay: 1.05s; }
.js .hero.in .code p:nth-child(3) { animation-delay: 1.6s; }
.js .hero.in .code p:nth-child(4) { animation-delay: 2.15s; }
@keyframes type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* Pacchetti di dati che viaggiano dalla tabella all'interfaccia */
.tf { position: relative; }
.tf-chain { position: relative; }
.packets { display: block; position: absolute; pointer-events: none; z-index: 0; }
.packets i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); opacity: 0; }
.packets i:nth-child(2) { animation-delay: .8s !important; }
.packets i:nth-child(3) { animation-delay: 1.6s !important; }
/* Desktop: da sinistra a destra, sotto i badge */
@media (min-width: 1024px) {
  .packets { left: -20px; right: -20px; top: 50%; height: 0; }
  .packets i { top: -4px; left: 0; animation: travel 2.4s linear infinite; }
}
/* Telefono e tablet: dall'alto verso il basso, dalla card dei dati a quella del grafico */
@media (max-width: 1023px) {
  .tf-chain::before { content: ""; position: absolute; left: 50%; top: -14px; bottom: -14px; width: 2px; margin-left: -1px; background: linear-gradient(var(--accent), var(--ui)); opacity: .7; }
  .packets { left: 50%; top: -14px; bottom: -14px; width: 0; }
  .packets i { left: -4px; top: 0; animation: travel-y 2.4s linear infinite; }
}
@keyframes travel-y {
  0% { top: 0; opacity: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: calc(100% - 8px); opacity: 0; background: var(--ui); box-shadow: 0 0 12px var(--ui); }
}
@keyframes travel {
  0% { transform: translateX(0); opacity: 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateX(182px); opacity: 0; background: var(--ui); box-shadow: 0 0 12px var(--ui); }
}

/* Luce che segue il puntatore sulle card */
.service, .project, .lvl-group, .step, .tf-data, .tf-ui { position: relative; }
.service::after, .project::after, .lvl-group::after, .step::after, .tf-data::after, .tf-ui::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s var(--ease);
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(94, 234, 212, .09), transparent 60%);
}
.service-ui::after, .tf-ui::after { background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), rgba(180, 162, 251, .10), transparent 60%); }
.service:hover::after, .project:hover::after, .lvl-group:hover::after, .step:hover::after, .tf-data:hover::after, .tf-ui:hover::after { opacity: 1; }

/* Leggera inclinazione 3D del finto sito al passaggio del mouse */
.tf-ui { perspective: 900px; }
.mock { transition: transform .3s var(--ease); transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); will-change: transform; }

/* Metodo: i numeri si accendono mentre la linea li raggiunge */
.js .steps.in .step-n { animation: light .6s var(--ease) both; }
.js .steps.in .step:nth-child(1) .step-n { animation-delay: .25s; }
.js .steps.in .step:nth-child(2) .step-n { animation-delay: .5s; }
.js .steps.in .step:nth-child(3) .step-n { animation-delay: .75s; }
.js .steps.in .step:nth-child(4) .step-n { animation-delay: 1s; }
.js .steps.in .step:nth-child(5) .step-n { animation-delay: 1.25s; }
@keyframes light { 0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); } 40% { box-shadow: 0 0 0 10px rgba(94, 234, 212, .18); background: rgba(94, 234, 212, .12); } 100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); } }

/* Progetti: comparsa a molla quando cambi filtro */
.project.pop { animation: pop .45s var(--ease) both; animation-delay: var(--pd, 0ms); }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* Bottoni principali "magnetici" */
.btn-accent, .menu .menu-cta { transition: transform .2s var(--ease), background-color .2s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .progress { display: none; }
  .js .code p { clip-path: none !important; }
  .s-e2e::after { transform: scaleX(1) !important; }
  .packets { display: none !important; }
  .mock { transform: none !important; }
}
