/* Movimento della pagina. Il 3D si muove da scena/avvio.js; qui testi, linee e riquadri. */

@keyframes sale { from { transform: translateY(18px); } }
@keyframes compare { from { opacity: 0; } }
@keyframes cresce-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes cresce-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes entra-menu { from { opacity: 0; translate: 28px 0; } }

/* Barra di avanzamento della lettura */
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--legno); transform: scaleX(0); transform-origin: left; }
@supports (animation-timeline: scroll()) {
  .top::after { animation: cresce-x linear both; animation-timeline: scroll(root); }
}

/* Apertura: i testi salgono (senza partire trasparenti) */
.apertura__testo .eyebrow, .apertura__testo h1, .apertura__testo .lead, .apertura__testo .actions { animation: sale 0.9s var(--ease) both; }
.apertura__testo h1 { animation-delay: 0.08s; }
.apertura__testo .lead { animation-delay: 0.18s; }
.apertura__testo .actions { animation-delay: 0.28s; }

/* La scena 3D compare con dolcezza quando è pronta */
.palco__tela { animation: compare 1s ease both; }
.con-3d .comandi { animation: compare 0.9s 0.6s ease both; }

/* Comparsa allo scorrimento, solo se lo script è attivo */
.anima .reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
.anima .reveal.in { opacity: 1; transform: none; }
.anima .d1 { transition-delay: 0.1s; }
.anima .d2 { transition-delay: 0.2s; }
.anima .d3 { transition-delay: 0.3s; }

/* Il disegno nel riquadro si traccia quando compare */
.anima .reveal .traccia path { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 2s 0.25s var(--ease); }
.anima .reveal.in .traccia path { stroke-dashoffset: 0; }

/* La linea del metodo avanza scorrendo */
@supports (animation-timeline: view()) {
  .js .percorso { view-timeline: --passi block; }
  .js .percorso::after { animation: cresce-x linear both; animation-timeline: --passi; animation-range: cover 12% cover 48%; }
  @media (max-width: 900px) {
    .js .percorso::after { animation-name: cresce-y; animation-range: cover 12% cover 62%; }
  }
}

@media (max-width: 900px) {
  .js .top.aperto .nav a { animation: entra-menu 0.5s var(--ease) both; }
  .js .top.aperto .nav a:nth-child(2) { animation-delay: 60ms; }
  .js .top.aperto .nav a:nth-child(3) { animation-delay: 120ms; }
  .js .top.aperto .nav a:nth-child(4) { animation-delay: 180ms; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .top::after { display: none; }
  .anima .reveal { opacity: 1; transform: none; }
  .anima .reveal .traccia path { stroke-dashoffset: 0; }
}
