/* Movimento: token e animazioni condivise.
   Regole: solo transform/opacity (clip-path per il login), niente ease-in, niente scale(0),
   hover solo con (hover:hover) and (pointer:fine), prefers-reduced-motion = meno e più dolce. */
/* Durate e curve sono token in tokens.css: qui solo animazioni condivise. */

/* Ingresso a scaglioni: solo al primo caricamento di una vista (classe aggiunta da JS) */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
/* "backwards": a fine animazione non resta alcun transform (altrimenti i figli position: fixed si agganciano alla card) */
.is-first-load [data-stagger] {
  animation: rise-in var(--d-enter) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* Righe importate da Excel: l'evidenziazione è statica (views.css), l'ingresso avviene una volta sola subito dopo l'import */
@keyframes row-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}
.row-imported.is-entering {
  animation: row-in var(--d-slow) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}

/* Pulsazione dei giorni scaduti: un anello che si espande, il dato resta fermo */
@keyframes pulse-ring {
  0% { opacity: 0.55; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(2.4); }
}
.pulse {
  position: relative;
}
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  animation: pulse-ring 1.8s var(--ease-out) infinite;
  pointer-events: none;
}

/* Tratteggio stradale che scorre */
@keyframes road-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-120px); }
}
@keyframes skyline-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@keyframes wheel-spin {
  to { transform: rotate(360deg); }
}
@keyframes van-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1.5px); }
}

/* Spunte che si disegnano */
.draw-check path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  transition: stroke-dashoffset var(--d-enter) var(--ease-out);
}
.draw-check.is-on path { stroke-dashoffset: 0; }
.draw-check.is-on path:nth-child(2) { transition-delay: 140ms; }

/* Scheletri di caricamento */
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* Barra a tratteggio indeterminata */
@keyframes dash-move {
  to { transform: translateX(24px); }
}

/* View Transitions: cambio di vista breve, con ripiego in JS se non supportate */
::view-transition-old(vista) {
  animation: var(--d-fast) var(--ease-out) both vt-out;
}
::view-transition-new(vista) {
  animation: var(--d-std) var(--ease-out) both vt-in;  /* massimo 200 ms */
}
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  .is-first-load [data-stagger] { animation: fade-only var(--d-std) var(--ease-out) backwards; animation-delay: 0ms; }
  .row-imported.is-entering { animation: fade-only var(--d-std) var(--ease-out) backwards; animation-delay: 0ms; }
  .pulse::after { animation: none; }
  ::view-transition-new(vista) { animation: var(--d-fast) var(--ease-out) both fade-only; }
  ::view-transition-old(vista) { animation: var(--d-fast) var(--ease-out) both vt-out; }
}
@keyframes fade-only { from { opacity: 0; } }
