/* «Il filo» con acquarello — home (scena che si disegna scorrendo) e segni dei servizi nelle pagine interne.
   Le macchie sono in img/filo/. Script: js/filo.js. */

/* --- Apertura: i tre servizi si disegnano da soli appena si arriva --- */
.hero-servizi { display: flex; flex-wrap: wrap; gap: clamp(14px, 2.4vw, 30px); margin-top: 36px; padding-top: 26px; border-top: 1px solid var(--border); }
.hero-servizio { display: flex; flex-direction: column; align-items: center; gap: 6px; text-decoration: none; color: var(--fg); font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.hero-servizio svg { width: clamp(64px, 8vw, 92px); height: auto; overflow: visible; }
.hero-servizio path { fill: none; stroke: currentColor; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: filo-disegna 1.5s cubic-bezier(.6, 0, .3, 1) forwards; }
.hero-servizio:nth-child(1) path { animation-delay: .35s; }
.hero-servizio:nth-child(2) path { animation-delay: 1.15s; }
.hero-servizio:nth-child(3) path { animation-delay: 1.95s; }
.hero-servizio span { opacity: 0; animation: filo-appare .6s ease forwards; }
.hero-servizio:nth-child(1) span { animation-delay: 1.3s; }
.hero-servizio:nth-child(2) span { animation-delay: 2.1s; }
.hero-servizio:nth-child(3) span { animation-delay: 2.9s; }
.hero-servizio:hover { color: color-mix(in oklch, var(--fg) 70%, #C9A348); }
@keyframes filo-disegna { to { stroke-dashoffset: 0; } }
@keyframes filo-appare { to { opacity: 1; } }

/* --- La scena: resta ferma mentre si scorre, il filo avanza --- */
.filo { display: none; }
.filo.is-live { display: block; position: relative; height: 520vh; background: var(--bg); }
.filo.is-live ~ .porte, .filo.is-live ~ .infermiera-band { display: none; }
.filo-scena { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.filo-scena > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.filo-tratto { fill: none; stroke: var(--fg); stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.filo-punta { fill: var(--fg); }
.filo-alone { fill: rgba(201, 163, 72, .28); }

.filo-tappe { position: absolute; z-index: 2; top: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 82%, transparent); border: 1px solid var(--border); backdrop-filter: blur(6px); white-space: nowrap; }
.filo-tappe button { all: unset; cursor: pointer; padding: 7px 14px; border-radius: 999px; font: 600 13px/1 var(--font-body); color: var(--fg-soft); transition: background .4s ease, color .4s ease; }
.filo-tappe button.is-on { background: var(--ink); color: var(--ink-contrast); }
.filo-tappe button:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.filo-testo { position: absolute; z-index: 1; left: 57%; top: 50%; width: min(440px, 37vw); transform: translateY(calc(-50% + 18px)); opacity: 0; pointer-events: none; transition: opacity .6s ease, transform .6s ease; }
.filo-testo.is-on { opacity: 1; transform: translateY(-50%); pointer-events: auto; }
.filo-testo h3 { font-size: clamp(28px, 3.4vw, 44px); margin: 12px 0 14px; }
.filo-testo .filo-frase { font-family: var(--font-display); font-style: italic; font-size: clamp(18px, 1.7vw, 22px); color: var(--fg-soft); margin: 0 0 18px; }
.filo-testo p { margin: 0 0 10px; }
.filo-testo .porta-link { margin-top: 14px; }
.filo-testo .infermiera-nota { font-size: 13px; color: var(--fg-soft); }
.filo-chip { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; padding: 0; list-style: none; }
.filo-chip li { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--rep-accent); font-size: 13.5px; font-weight: 600; }
.filo-chip li small { font-weight: 400; color: var(--fg-soft); font-size: 12.5px; }

.filo-scorri { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--fg-soft); transition: opacity .5s ease; }

@media (max-width: 860px) {
  .filo-testo { left: var(--gutter); right: var(--gutter); width: auto; top: auto; bottom: 34px; transform: translateY(18px); }
  .filo-testo.is-on { transform: none; }
  .filo-testo h3 { font-size: 26px; margin: 8px 0 8px; }
  .filo-testo .filo-frase { font-size: 17px; margin-bottom: 10px; }
  .filo-testo p { font-size: 15px; }
  .filo-tappe { top: 12px; }
  .filo-tappe button { padding: 7px 10px; font-size: 12px; }
  .filo-scorri { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-servizio path { animation: none; stroke-dashoffset: 0; }
  .hero-servizio span { animation: none; opacity: 1; }
}

/* --- Acquarello dietro i tre disegni dell'apertura e dietro il segno delle pagine interne --- */
.hero-servizio, .pagina-segno { position: relative; }
.hero-servizio svg, .hero-servizio span, .pagina-segno svg { position: relative; }
.hero-servizio::before, .pagina-segno::before {
  content: ""; position: absolute; left: 50%; top: -22%; width: 150%; aspect-ratio: 1; transform: translateX(-50%) scale(.6);
  background: center / contain no-repeat; mix-blend-mode: multiply; pointer-events: none; opacity: 0;
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent); mask-image: radial-gradient(closest-side, #000 55%, transparent);
  animation: filo-sboccia 1.6s cubic-bezier(.3, 0, .2, 1) forwards;
}
.hero-servizio:nth-child(1)::before, .rep-doula .pagina-segno::before { background-image: url(../img/filo/acquarello-doula.webp); --forza: .9; animation-delay: .9s; }
.hero-servizio:nth-child(2)::before, .rep-casa .pagina-segno::before { background-image: url(../img/filo/acquarello-casa.webp); --forza: 1; animation-delay: 1.7s; }
.hero-servizio:nth-child(3)::before, .rep-inf-a .pagina-segno::before { background-image: url(../img/filo/acquarello-infermiera.webp); --forza: .7; animation-delay: 2.5s; }
@keyframes filo-sboccia { to { opacity: var(--forza, 1); transform: translateX(-50%) scale(1); } }

/* --- Pagine dei servizi: il disegno del servizio sopra il titolo, e una macchia leggera dietro la foto --- */
.pagina-segno { display: block; width: clamp(72px, 8vw, 96px); margin: 0 0 18px 6px; }
.pagina-segno svg { display: block; width: 100%; height: auto; overflow: visible; }
.pagina-segno path { fill: none; stroke: var(--fg); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: filo-disegna 1.6s cubic-bezier(.6, 0, .3, 1) .3s forwards; }
.pagina-segno::before { animation-delay: .9s !important; }
.pagina-hero::after {
  content: ""; position: absolute; z-index: -1; right: -6%; top: 50%; width: min(820px, 64vw); aspect-ratio: 1; transform: translateY(-50%);
  background: center / contain no-repeat; mix-blend-mode: multiply; opacity: .5; pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent); mask-image: radial-gradient(closest-side, #000 60%, transparent);
}
.rep-doula .pagina-hero::after { background-image: url(../img/filo/acquarello-doula.webp); }
.rep-casa .pagina-hero::after { background-image: url(../img/filo/acquarello-casa.webp); }
.rep-inf-a .pagina-hero::after { background-image: url(../img/filo/acquarello-infermiera.webp); opacity: .38; }
@media (max-width: 860px) { .pagina-hero::after { right: 50%; top: auto; bottom: -4%; width: 118vw; transform: translateX(50%); } }
@media (prefers-reduced-motion: reduce) {
  .hero-servizio::before, .pagina-segno::before { animation: none; opacity: var(--forza, 1); transform: translateX(-50%); }
  .pagina-segno path { animation: none; stroke-dashoffset: 0; }
}

/* --- Chi sono e Domande: pagine senza un colore loro. Chi sono prende l'oro della home dietro la foto,
       Domande i tre colori dei servizi, accostati, sul lato destro. Ferme, nessuna animazione. --- */
.hero-acq::after, .hero-acq-tre::after {
  content: ""; position: absolute; z-index: -1; top: 50%; aspect-ratio: 1; transform: translateY(-50%);
  background-repeat: no-repeat; mix-blend-mode: multiply; pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent); mask-image: radial-gradient(closest-side, #000 60%, transparent);
}
.hero-acq::after { right: -6%; width: min(820px, 64vw); background: url(../img/filo/acquarello-doula.webp) center / contain no-repeat; opacity: .5; }
.hero-acq-tre::after {
  right: -2%; width: min(560px, 46vw); opacity: .5; background-blend-mode: multiply;
  background-image: url(../img/filo/acquarello-doula.webp), url(../img/filo/acquarello-casa.webp), url(../img/filo/acquarello-infermiera.webp);
  background-size: 62%, 62%, 58%; background-position: 8% 30%, 92% 34%, 50% 92%;
}
@media (max-width: 860px) {
  .hero-acq::after { right: 50%; top: auto; bottom: -4%; width: 118vw; transform: translateX(50%); }
  .hero-acq-tre::after { right: -30%; top: 62%; width: 90vw; opacity: .35; }
}

/* --- I tre disegni dell'apertura, al passaggio del mouse (o con il tasto Tab).
       A riposo la macchia è chiara; quando ci si passa sopra il colore si carica e si allarga come acqua
       sulla carta, il filo si ridisegna, sotto il nome compare un tratto del colore del servizio e gli
       altri due si fanno da parte. La classe .is-pronto la mette js/filo.js a entrata finita. --- */
.hero-servizio:nth-child(1) { --tinta: #C9A348; --giro: -14deg; }
.hero-servizio:nth-child(2) { --tinta: #7F8A74; --giro: 9deg; }
.hero-servizio:nth-child(3) { --tinta: #B07A68; --giro: -10deg; }
.hero-servizi.is-pronto .hero-servizio { transition: opacity .5s ease, transform .6s cubic-bezier(.2, .7, .2, 1); }
.hero-servizi.is-pronto .hero-servizio:hover, .hero-servizi.is-pronto .hero-servizio:focus-visible { color: var(--fg); transform: translateY(-4px); }
.hero-servizi.is-pronto:has(.hero-servizio:hover) .hero-servizio:not(:hover) { opacity: .5; }
.hero-servizi.is-pronto .hero-servizio::before {
  animation: none; opacity: calc(var(--forza, 1) * .55); transform: translateX(-50%) scale(.92);
  transition: opacity .7s ease, transform 1.4s cubic-bezier(.16, .8, .2, 1);
}
.hero-servizi.is-pronto .hero-servizio:hover::before, .hero-servizi.is-pronto .hero-servizio:focus-visible::before {
  opacity: 1; transform: translateX(-50%) scale(1.28) rotate(var(--giro));
}
.hero-servizi.is-pronto .hero-servizio path { animation: none; stroke-dashoffset: 0; }
.hero-servizi.is-pronto .hero-servizio:hover path, .hero-servizi.is-pronto .hero-servizio:focus-visible path { animation: filo-ripassa 1.1s cubic-bezier(.6, 0, .3, 1); }
@keyframes filo-ripassa { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.hero-servizi.is-pronto .hero-servizio span { animation: none; opacity: 1; padding-bottom: 5px; background: linear-gradient(var(--tinta), var(--tinta)) left bottom / 0 2px no-repeat; transition: background-size .5s cubic-bezier(.6, 0, .3, 1); }
.hero-servizi.is-pronto .hero-servizio:hover span, .hero-servizi.is-pronto .hero-servizio:focus-visible span { background-size: 100% 2px; }
@media (prefers-reduced-motion: reduce) {
  .hero-servizi.is-pronto .hero-servizio, .hero-servizi.is-pronto .hero-servizio::before { transition: opacity .3s ease; }
  .hero-servizi.is-pronto .hero-servizio:hover, .hero-servizi.is-pronto .hero-servizio:focus-visible { transform: none; }
  .hero-servizi.is-pronto .hero-servizio:hover::before, .hero-servizi.is-pronto .hero-servizio:focus-visible::before { transform: translateX(-50%) scale(.92); }
  .hero-servizi.is-pronto .hero-servizio:hover path, .hero-servizi.is-pronto .hero-servizio:focus-visible path { animation: none; }
}

/* --- Acquarello anche nelle sezioni interne (11/11): una macchia per sezione, nel colore della pagina
       (oro dove non c'è un reparto, salvia in Casa, terracotta in Infermiera). Ferma, nessuna animazione.
       Sta sul fondo della sezione, sotto il testo. Lato e altezza si alternano così due sezioni vicine
       non sono uguali. Intensità: --acq-o. Grandezza: --acq-l. --- */
:root { --acq: url(../img/filo/acquarello-doula.webp); }
.rep-casa { --acq: url(../img/filo/acquarello-casa.webp); }
.rep-inf-a { --acq: url(../img/filo/acquarello-infermiera.webp); --acq-f: .8; }
main > section:not(.hero, .pagina-hero, .filo, .porte, .infermiera-band) { position: relative; isolation: isolate; }
main > section:not(.hero, .pagina-hero, .filo, .porte, .infermiera-band)::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--acq) var(--acq-x, calc(100% + 150px)) var(--acq-y, 30%) / var(--acq-l, clamp(320px, 44vw, 600px)) auto no-repeat;
  -webkit-mask: radial-gradient(closest-side, #000 55%, transparent) var(--acq-x, calc(100% + 150px)) var(--acq-y, 30%) / var(--acq-l, clamp(320px, 44vw, 600px)) var(--acq-l, clamp(320px, 44vw, 600px)) no-repeat;
          mask: radial-gradient(closest-side, #000 55%, transparent) var(--acq-x, calc(100% + 150px)) var(--acq-y, 30%) / var(--acq-l, clamp(320px, 44vw, 600px)) var(--acq-l, clamp(320px, 44vw, 600px)) no-repeat;
  mix-blend-mode: multiply; opacity: calc(var(--acq-o, .4) * var(--acq-f, 1));
}
/* alternanza: le sezioni pari a sinistra in basso, le dispari a destra in alto */
main > section:nth-of-type(even) { --acq-x: -150px; --acq-y: 78%; }
/* fasce con la frase al centro: macchia piccola dietro la frase */
main > section.citazione, main > section.riconosci { --acq-x: 50%; --acq-y: 50%; --acq-l: clamp(280px, 34vw, 440px); --acq-o: .5; }
/* modulo contatti: più leggera, a destra, lontano dai campi */
main > section.contatti { --acq-x: calc(100% + 120px); --acq-y: 60%; --acq-o: .32; }
@media (max-width: 760px) {
  main > section:not(.citazione, .riconosci) { --acq-o: .3; }
}
@media print { main > section::after { display: none; } }
