/* ============================================================================
   FARMACIA SANTO SPIRITO — movimento.css
   Ultimo foglio della catena: design-system → site → shop → coerenza →
   graphics → movimento.

   Tre famiglie di movimento, e una regola che vale per tutte e tre:
   si animano SOLO transform, opacity, clip-path e stroke-dashoffset, cioe'
   proprieta' che il browser gestisce senza rifare l'impaginazione.

   1. TRANSIZIONI ALLO SCORRIMENTO — le sezioni e i loro elementi entrano
   2. GRAFICHE IN CICLO — le decorazioni respirano, non stanno ferme
   3. PASSAGGIO DEL MOUSE — ogni cosa cliccabile risponde

   ⚠️ Niente qui dentro puo' nascondere del contenuto in modo permanente.
   Tutto cio' che parte da invisibile sta sotto `html.reveal-on`, che si
   accende solo se c'e' chi lo spegne (js/reveal-init.js), e l'ultimo blocco
   del file rimette tutto a posto in stampa e per chi ha chiesto meno
   movimento.
   ============================================================================ */


/* ============================================================================
   1. TRANSIZIONI ALLO SCORRIMENTO
   ============================================================================ */

/* --- La cascata: gli elementi di una stessa griglia entrano uno dopo l'altro.
       L'indice --i lo mette main.js sui figli delle griglie note, cosi' non
       serve scrivere data-delay a mano su ogni scheda. Il tetto di 9 evita
       che l'ultima scheda di un elenco lungo entri dopo un secondo. -------- */
html.reveal-on [data-cascata] {
  transition-delay: calc(min(var(--i, 0), 9) * .065s);
}

/* --- Il titolo di sezione si scopre da sotto una riga invece di sfumare.
       E' il gesto che segna il passaggio da una fascia all'altra. --------- */
html.reveal-on .section-head[data-reveal] h2,
html.reveal-on .section-head[data-reveal] .h2,
html.reveal-on .reviews-head[data-reveal] h2 {
  clip-path: inset(0 0 108% 0);
  transition: clip-path .85s var(--ease-out) .08s;
}
html.reveal-on .section-head[data-reveal].in h2,
html.reveal-on .section-head[data-reveal].in .h2,
html.reveal-on .reviews-head[data-reveal].in h2 {
  clip-path: inset(0 0 -25% 0);
}

/* --- Il filo sotto la testata di sezione si tira da sinistra --------------- */
html.reveal-on .section-head[data-reveal] { position: relative; }
html.reveal-on .section-head[data-reveal]::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: calc(var(--sp-5) * -1);
  width: clamp(44px, 6vw, 78px);
  height: 2px;
  background: var(--green-500, #81aa60);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .7s var(--ease-out) .3s;
}
html.reveal-on .section-head[data-reveal].in::after { transform: scaleX(1); }
/* la testata centrata non porta il filo: partirebbe da un bordo a caso */
html.reveal-on .section-head.center[data-reveal]::after { display: none; }

/* --- Le righe dei servizi arrivano di lato invece che dal basso: su un
       elenco lungo il movimento verticale diventa monotono. --------------- */
html.reveal-on .svc-list [data-cascata] { transform: translate3d(-18px, 10px, 0); }
html.reveal-on .svc-list [data-cascata].in { transform: none; }


/* ============================================================================
   2. GRAFICHE IN CICLO
   Cinque cicli in tutto il sito, tutti lenti e tutti su elementi decorativi.
   Nessuno gira sopra a del testo.
   ============================================================================ */

/* --- Il cerchio tratteggiato delle testate interne gira su se stesso ------- */
@keyframes decoGiro { to { transform: rotate(360deg); } }
.page-hero .page-hero-deco__ring {
  animation: decoGiro 64s linear infinite;
}

/* --- Il logo e la croce delle testate stanno FERMI (2026-10-13).
       Prima il logo «respirava» e la croce galleggiava. Gira solo il cerchio
       tratteggiato attorno, che non e' il marchio. ------------------------- */
.page-hero .page-hero-deco__mark,
.page-hero .page-hero-deco__cross { animation: none; }

/* --- Il tracciato del cuore si disegna, si ferma, esce.
       E' l'unica animazione del sito che racconta qualcosa: e' la tessera
       della telemedicina, e quello e' un elettrocardiogramma. ------------- */
@keyframes ecgTraccia {
  0%   { stroke-dashoffset: 150; }
  45%  { stroke-dashoffset: 0; }
  78%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -150; }
}
.ecg-trace {
  stroke-dasharray: 150;
  animation: ecgTraccia 4.6s var(--ease-in-out) infinite;
}
/* il cerchio attorno al tracciato pulsa a tempo, mezzo battito dopo */
@keyframes ecgCerchio {
  0%, 100% { transform: scale(1);    opacity: .9; }
  46%      { transform: scale(1.04); opacity: 1; }
}
.tile__icon .ecg-ring {
  transform-box: fill-box;
  transform-origin: center;
  animation: ecgCerchio 4.6s var(--ease-in-out) infinite;
}

/* --- La bolla fissa del contatto chiama l'occhio ogni tanto, con un'onda
       che si allarga e svanisce. Un solo anello, non un semaforo. -------- */
.wa-float::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: bollaOnda 3.8s var(--ease-out) infinite;
  pointer-events: none;
}
@keyframes bollaOnda {
  0%       { transform: scale(1);   opacity: .55; }
  70%,100% { transform: scale(1.7); opacity: 0; }
}


/* ============================================================================
   3. PASSAGGIO DEL MOUSE
   Regola di casa: si alza di 2px e l'ombra si apre. Sempre lo stesso gesto,
   cosi' il sito risponde in un modo solo e si impara al primo elemento.
   ============================================================================ */

.card, .info-card, .prod-card, .faq-item, .post-card, .blog-card, .stat {
  transition: transform var(--t) var(--ease-out),
              box-shadow var(--t) var(--ease),
              border-color var(--t) var(--ease);
}
.card:hover, .info-card:hover, .post-card:hover, .blog-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(26, 42, 26, .10);
}

/* --- Card prodotto: si alza, la foto si avvicina, la freccia parte -------- */
.prod-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 34px rgba(26, 42, 26, .13);
}
.prod-card__buy svg { transition: transform var(--t) var(--ease-out); }
.prod-card:hover .prod-card__buy svg { transform: translate(2px, -2px); }

/* --- Tessere della home: la freccia scende o esce, secondo il verso ------ */
.tile__arrow svg { transition: transform var(--t) var(--ease-out); }
.tile:hover .tile__arrow svg { transform: translateY(3px); }
.tile__media img { transition: transform var(--t-slow) var(--ease-out); }
.tile:hover .tile__media img { transform: scale(1.04); }

/* --- Navigazione: il filo cresce da sinistra, non compare tutto insieme --- */
.header nav a[data-nav] { position: relative; }
.header nav a[data-nav]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--t) var(--ease-out);
}
.header nav a[data-nav]:hover::after,
.header nav a[data-nav]:focus-visible::after { transform: scaleX(1); transform-origin: left; }
/* la pagina in cui ci si trova ha il filo gia' tirato */
.header nav a[data-nav].is-active::after,
.header nav a[data-nav][aria-current]::after { transform: scaleX(1); }

/* --- Pillole e filtri: stesso gesto, piu' piccolo ----------------------- */
.cat-pill, .filter-btn {
  transition: transform var(--t) var(--ease-out),
              background var(--t) var(--ease),
              border-color var(--t) var(--ease),
              color var(--t) var(--ease);
}
.cat-pill:hover, .filter-btn:hover { transform: translateY(-2px); }

/* --- Collegamenti del piede: scivolano di lato ------------------------- */
.footer a:not(.social a) {
  display: inline-block;
  transition: transform var(--t) var(--ease-out), color var(--t) var(--ease);
}
.footer a:not(.social a):hover { transform: translateX(3px); }

/* --- Le icone social ruotano appena ------------------------------------ */
.social a { transition: transform var(--t) var(--ease-out), background var(--t) var(--ease); }
.social a:hover { transform: translateY(-2px) rotate(-4deg); }

/* --- La freccia dei collegamenti in linea ------------------------------ */
.link-arrow:hover svg { transform: translateX(4px); }

/* --- Torna su: si alza come tutto il resto ----------------------------- */
.to-top { transition: transform var(--t) var(--ease-out), background var(--t) var(--ease), opacity .35s var(--ease); }
.to-top.show:hover { transform: translateY(-3px); }


/* ============================================================================
   3-bis. LE GRAFICHE IN CICLO SI FERMANO (2026-11-01)
   Nessuna animazione decorativa gira per sempre (WCAG 2.2.2, «Pausa, stop,
   nascondi»). Qui quelle la cui posa di partenza e' gia' quella giusta da
   ferme: tre giri e si fermano (il tracciato ECG resta disegnato, l'onda della
   bolla di WhatsApp sparisce, la linea che invita a scorrere resta ferma). Il
   cerchio tratteggiato delle testate, lento (64 s), fa un giro solo.
   Le grafiche animate (molecola, capsule, mortaio...) le ferma js/graphics.js:
   dieci secondi dopo che si vedono passano alla posa di «meno movimento».
   !important come nelle regole che sovrascrive; il blocco 4 qui sotto, scritto
   dopo, le spegne comunque del tutto.
   ============================================================================ */
.page-hero .page-hero-deco__ring { animation-iteration-count: 1; }
.ecg-trace,
.tile__icon .ecg-ring,
.wa-float::after,
.hero > .container::after { animation-iteration-count: 3 !important; }


/* ============================================================================
   4. QUANDO IL MOVIMENTO NON SI FA
   Questo blocco sta in fondo apposta: spegne anche quello che qualcuno
   aggiungesse sopra.
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .page-hero .page-hero-deco__ring,
  .page-hero .page-hero-deco__cross,
  .page-hero .page-hero-deco__mark,
  .ecg-trace,
  .tile__icon .ecg-ring,
  .wa-float::after { animation: none !important; }

  .ecg-trace { stroke-dasharray: none; }
  .wa-float::after { display: none; }

  /* Rete di sicurezza (2026-10-31): ogni grafica animata (molecola, capsule,
     battito, mortaio...) e l'invito a scorrere della home stanno fermi, anche
     quelle che in graphics.css non hanno una regola propria. */
  .gfx-svg, .gfx-svg *,
  .hero > .container::after { animation: none !important; }

  html.reveal-on .section-head[data-reveal] h2,
  html.reveal-on .section-head[data-reveal] .h2,
  html.reveal-on .reviews-head[data-reveal] h2 { clip-path: none !important; transition: none !important; }
  html.reveal-on .section-head[data-reveal]::after { transform: scaleX(1); transition: none; }
  html.reveal-on [data-cascata] { transition-delay: 0s !important; }
  html.reveal-on .svc-list [data-cascata] { transform: none !important; }

  .card:hover, .info-card:hover, .post-card:hover, .blog-card:hover,
  .prod-card:hover, .cat-pill:hover, .filter-btn:hover,
  .to-top.show:hover, .social a:hover,
  .footer a:not(.social a):hover,
  .tile:hover .tile__media img { transform: none; }
}

/* In stampa nulla puo' restare nascosto: il ritaglio dei titoli va sciolto,
   i cicli fermati. Completa il blocco @media print di design-system.css. */
@media print {
  .section-head h2, .section-head .h2, .reviews-head h2 {
    clip-path: none !important;
  }
  .section-head::after { transform: scaleX(1) !important; }
  .page-hero-deco__ring, .page-hero-deco__cross, .page-hero-deco__mark,
  .ecg-trace, .tile__icon .ecg-ring, .wa-float::after {
    animation: none !important;
  }
  .ecg-trace { stroke-dasharray: none !important; }
}


/* ============================================================================
   6. ENTRATE ALLO SCORRIMENTO PIU' DECISE (2026-10-13)
   Scorrendo fra le sezioni si deve sempre vedere un
   effetto di comparsa; prima il sito sembrava statico. Tre cose:
   - corsa piu' lunga (da 14 a 44 px) e una messa a fuoco leggera;
   - le entrate di lato tornano di lato davvero e alternano le sezioni;
   - main.js ora vela anche i blocchi che non avevano data-reveal, e li
     scopre quando sono dentro la finestra, non appena ne sfiorano il bordo.
   Con «riduci movimento», in stampa e senza JavaScript non cambia niente:
   le regole che spengono il velo stanno in design-system.css e vincono.
   ============================================================================ */
html.reveal-on [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 44px, 0);
  filter: blur(6px);
  transition: opacity .85s var(--ease-out),
              transform 1.05s cubic-bezier(.16, 1, .3, 1),
              filter .85s var(--ease-out);
  will-change: opacity, transform;
}
html.reveal-on [data-reveal="left"]  { transform: translate3d(-56px, 0, 0); }
html.reveal-on [data-reveal="right"] { transform: translate3d(56px, 0, 0); }
html.reveal-on [data-reveal="scale"] { transform: translate3d(0, 28px, 0) scale(.94); }
html.reveal-on [data-reveal].in {
  opacity: 1; transform: none; filter: none; will-change: auto;
}
/* gli elementi di una griglia entrano uno dopo l'altro, in modo percepibile */
html.reveal-on [data-cascata] { transition-delay: calc(min(var(--i, 0), 8) * 80ms); }
html.reveal-on .svc-list [data-cascata] { transform: translate3d(-36px, 14px, 0); }
html.reveal-on .svc-list [data-cascata].in { transform: none; }

/* telefono: niente entrate di lato (allargherebbero la pagina) e niente
   sfocatura, che sui telefoni lenti scatta */
@media (max-width: 860px) {
  html.reveal-on [data-reveal],
  html.reveal-on [data-reveal="left"],
  html.reveal-on [data-reveal="right"],
  html.reveal-on [data-reveal="scale"] { transform: translate3d(0, 32px, 0); filter: none; }
  html.reveal-on [data-reveal].in { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.reveal-on [data-reveal] { filter: none !important; }
  [data-cascata] { transition-delay: 0s !important; }
}
@media print {
  [data-reveal], html.reveal-on [data-reveal] { filter: none !important; }
}
