/* motion.css - Animazioni dichiarative del restyle (fase 0, 14/11/2026), comandate da assets/js/ui-motion.js.
   Piano: docs/plans/restyle/10-motion-rollout.md.

   CONTRATTO (solo attributi data-*, nessun handler inline):
   - data-reveal="up|fade|scale|left|right"  entra in vista: .is-in. Opzionali data-reveal-delay="ms" sull'elemento
     e data-reveal-stagger="ms" sul contenitore (ritardo progressivo dei figli [data-reveal]).
   - data-count-to="42" (+ data-count-suffix, data-count-prefix, data-count-decimals)  contatore all'ingresso.
   - <svg data-draw>  path/line/polyline/circle/rect/ellipse/polygon tracciati al passaggio (.is-drawn);
     [data-draw-skip] esclude un elemento, data-draw-dur="ms" cambia la durata.
   - data-parallax="0.15"  spostamento verticale leggero allo scroll (solo >= 768 px, max +-40 px).
   - data-sticky-steps sul contenitore, data-step sui passi, data-sticky-figure sulla figura:
     il contenitore riceve data-active-step="N", il passo attivo .is-active.

   SICUREZZA DEL CONTENUTO
   - Lo stato nascosto vale SOLO sotto html.js-motion: senza JS (crawler, JS rotto) tutto resta visibile.
   - js-motion la aggiunge lo script col nonce nell'<head> con un timeout di 3 s: se ui-motion.js non parte
     la classe viene tolta e si vede tutto.
   - prefers-reduced-motion: niente movimento, tutto visibile e completo.
   - Si animano solo transform e opacity (e stroke-dashoffset negli SVG). */

/* ---------------------------------------------------------------- reveal */
html.js-motion [data-reveal] {
    opacity: 0;
    transition: opacity var(--ui-dur, .6s) var(--ui-ease, cubic-bezier(.2, .7, .2, 1)),
                transform calc(var(--ui-dur, .6s) + .15s) var(--ui-ease, cubic-bezier(.2, .7, .2, 1));
    transition-delay: var(--rv-delay, 0ms);
}
html.js-motion [data-reveal=""], html.js-motion [data-reveal="up"] { transform: translate3d(0, 16px, 0); }
html.js-motion [data-reveal="scale"] { transform: scale(.96); }
html.js-motion [data-reveal="left"] { transform: translate3d(-24px, 0, 0); }
html.js-motion [data-reveal="right"] { transform: translate3d(24px, 0, 0); }
html.js-motion [data-reveal].is-in { opacity: 1; transform: none; }
/* mostrato subito (era gia' in vista al caricamento): niente transizione */
html.js-motion [data-reveal].is-instant { transition: none; }

/* ---------------------------------------------------------------- contatori */
[data-count-to] { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- disegno SVG */
html.js-motion svg[data-draw] .ui-draw-el {
    stroke-dasharray: var(--len, 1000);
    stroke-dashoffset: var(--len, 1000);
}
html.js-motion svg[data-draw].is-drawn .ui-draw-el {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset var(--draw-dur, 1400ms) var(--ui-ease, cubic-bezier(.2, .7, .2, 1));
    transition-delay: var(--draw-delay, 0ms);
}

/* ---------------------------------------------------------------- parallasse */
[data-parallax] { will-change: auto; }
.ui-parallax-clip { overflow-x: clip; }

/* ---------------------------------------------------------------- sticky steps
   Senza JS o su mobile: lista verticale normale, tutti i passi visibili. */
@media (min-width: 900px) and (prefers-reduced-motion: no-preference) {
    [data-sticky-steps] [data-sticky-figure] { position: sticky; top: calc(var(--hn-h, 64px) + 24px); }
    html.js-motion [data-sticky-steps] [data-step] { opacity: .35; transition: opacity .4s var(--ui-ease, ease); }
    html.js-motion [data-sticky-steps] [data-step].is-active { opacity: 1; }
}
/* scroll-driven dove c'e' (Chromium): la figura si accende entrando in vista */
@supports (animation-timeline: view()) {
    @media (prefers-reduced-motion: no-preference) {
        html.js-motion [data-sticky-steps] [data-step] { animation: ui-step-in linear both; animation-timeline: view(); animation-range: entry 0% cover 40%; }
    }
}
@keyframes ui-step-in { from { transform: translate3d(0, 24px, 0); } to { transform: none; } }

/* ---------------------------------------------------------------- reduced motion: tutto fermo e visibile */
@media (prefers-reduced-motion: reduce) {
    html.js-motion [data-reveal] { opacity: 1; transform: none; transition: none; }
    html.js-motion svg[data-draw] .ui-draw-el { stroke-dasharray: none; stroke-dashoffset: 0; transition: none; }
    html.js-motion [data-sticky-steps] [data-step] { opacity: 1; animation: none; transform: none; }
    [data-parallax] { transform: none !important; }
}
