/* Evin 4 · VIVO-SCENE (16/11, pacchetto «2 · Racconto»). Si carica dopo wow.css. Il DOM lo prepara vivo-scene.js.
 * Regole: solo transform (translate/rotate/scale) e opacity animati, niente filter né blur, niente bianco che lampeggia,
 * niente pulsazioni continue. Tutto ciò che si muove allo scroll sta sotto html.vs-scorre:not(.fermo) e dentro
 * @supports (animation-timeline): con html.fermo, reduced-motion o un browser senza scroll-driven, tutto è intero e fermo.
 * Non tocca .cap-finestra, .cap-palco, .wow-* né lo z-index/position delle section. */

/* ═══ 1 · TITOLI CHE SI COMPONGONO ═══ */
.vs-titolo .vs-p { display: inline-block; white-space: nowrap; }
.vs-titolo .vs-l { display: inline-block; }
.vs-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* l'h1 delle pagine interne è già sullo schermo all'apertura: si compone una volta, come titolo di testa del film */
html.js:not(.fermo) .vs-titolo.vs-h1 .vs-l { animation: vs-compone .8s cubic-bezier(.2, .7, .1, 1) both; animation-delay: calc(.12s + var(--i) / var(--n) * .6s); }

@supports (animation-timeline: view()) {
  /* un'unica linea del tempo per titolo (non una per lettera): costa poco anche con 50 lettere */
  html.vs-scorre:not(.fermo) .vs-titolo:not(.vs-h1) { view-timeline: --vs-t block; contain: layout style; animation: none !important; }
  html.vs-scorre:not(.fermo) .vs-titolo:not(.vs-h1) .vs-l { animation: vs-compone linear both; animation-timeline: --vs-t;
    animation-range: entry calc(var(--i) / var(--n) * 30%) entry calc(65% + var(--i) / var(--n) * 35%); }
}
@keyframes vs-compone { from { opacity: 0; translate: .08em .6em; } to { opacity: 1; translate: 0 0; } }

/* numeri dei capitoli a rullo (01-05), come un contachilometri */
.vs-num { display: inline-block; }
.vs-rullo-cont { display: inline-flex; vertical-align: top; }
.vs-cifra { display: inline-block; height: 1.2em; line-height: 1.2em; overflow: hidden; }
.vs-rullo { display: flex; flex-direction: column; translate: 0 calc(var(--n) * -1.2em); }
.vs-rullo > span { display: block; height: 1.2em; }
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-rullo:not(.vs-fermo) { animation: vs-rullo steps(var(--n), end) both; animation-timeline: --apre; animation-range: entry 62% entry 98%; }
  html.vs-scorre:not(.fermo) .cap-primo .vs-rullo:not(.vs-fermo) { animation-range: contain 14% contain 36%; }
  @media (max-width: 1100px) and (orientation: portrait) {
    html.vs-scorre:not(.fermo) .vs-rullo:not(.vs-fermo) { animation-range: entry 45% entry 80%; }
  }
}
@keyframes vs-rullo { from { translate: 0 0; } to { translate: 0 calc(var(--n) * -1.2em); } }

/* ═══ 2 · OLI ═══ */
/* il livello: da 1 a 1000 litri, una tacca per formato; si riempie con lo scroll */
.vs-livello { display: flex; align-items: center; gap: 14px; max-width: 440px; margin: 26px auto 0; font-size: 12px; font-weight: 700;
  letter-spacing: .12em; color: #8A5F27; font-variant-numeric: tabular-nums; }
.vs-liv-tubo { position: relative; flex: 1; height: 6px; border-radius: 99px; background: rgba(212,159,93,.2); }
.vs-liv-pieno { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #E2AC62, #D49F5D 60%, #B9853F); transform-origin: left center; }
.vs-liv-tacca { position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; border-radius: 1px; background: rgba(138,95,39,.5); }
.vs-liv-da, .vs-liv-a { flex: none; white-space: nowrap; }
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-liv-pieno { animation: vs-riempi-x linear both; animation-timeline: view(); animation-range: entry 70% cover 62%; }
}
@keyframes vs-riempi-x { from { scale: 0 1; } to { scale: 1 1; } }

@supports (animation-timeline: view()) {
  /* home (02): le nove schede arrivano dalla profondità; resta la linea del tempo della sezione di wow.css (--sez) */
  html.vs-scorre:not(.fermo) .cap-oli { perspective: 1000px; }
  html.vs-scorre:not(.fermo) .cap-oli > li { animation-name: vs-scaffale; transform-origin: 50% 100%; }
  /* pagina oli-motore: stessa entrata, una scheda alla volta, la colonna di sinistra un istante prima */
  html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale { perspective: 1000px; }
  html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale > li { transform: none !important; transition: none !important; transform-origin: 50% 100%;
    animation: vs-scaffale linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale > li:nth-child(3n+2) { animation-range: entry 6% entry 66%; }
  html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale > li:nth-child(3n) { animation-range: entry 12% entry 72%; }
  @media (max-width: 860px) {
    html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale > li:nth-child(n) { animation-range: entry 0% entry 60%; }
    html.vs-scorre:not(.fermo) .pagina-oli-motore .vs-scaffale > li:nth-child(2n) { animation-range: entry 8% entry 68%; }
  }
}
@keyframes vs-scaffale { from { opacity: .2; rotate: x 14deg; translate: 0 40px; } to { opacity: 1; rotate: x 0deg; translate: 0 0; } }

/* col mouse: la scheda s'inclina (max 6°) e una luce oro tenue (10%) segue il puntatore; mai bianca */
@media (hover: hover) and (pointer: fine) {
  html:not(.fermo) .vs-inclina { position: relative; transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .3s; }
  html:not(.fermo) .vs-inclina.vs-sopra { transform: perspective(900px) rotateX(var(--vx, 0deg)) rotateY(var(--vy, 0deg)) translateY(-6px);
    transition: transform .14s linear, box-shadow .3s; }
  html:not(.fermo) .vs-inclina::after { content: ""; position: absolute; left: 0; top: 0; width: 360px; height: 360px; margin: -180px 0 0 -180px;
    border-radius: 50%; pointer-events: none; opacity: 0; translate: var(--mx, 50%) var(--my, 30%); transition: opacity .35s;
    background: radial-gradient(closest-side, rgba(226,172,98,.10), rgba(226,172,98,.06) 45%, rgba(226,172,98,0)); }
  html:not(.fermo) .vs-inclina.vs-sopra::after { opacity: 1; }
}
/* al tocco: si abbassa appena e torna su a molla */
@media (hover: none) {
  html:not(.fermo) .oli-scheda { transition: scale .5s cubic-bezier(.3, 1.7, .5, 1); }
  html:not(.fermo) .oli-scheda:active { scale: .97; transition-duration: .12s; }
}

/* ═══ 3 · CISTERNE ═══ */
.vs-icona-posto { position: relative; }
html.vs .vs-passi .vs-icona-posto > img { opacity: 0 !important; }
.vs-icona { position: absolute; inset: 0; margin: auto; width: 30px; height: 30px; overflow: visible; fill: none; stroke: #B9853F;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.accensioni .vs-icona { stroke: #E2AC62; width: 28px; height: 28px; }
.vs-icona path { stroke-dasharray: 1; stroke-dashoffset: 0; }
@media (max-width: 860px) {
  .vs-passi.cap-elenco-3 .cap-icona { display: grid; width: 44px; height: 44px; }
  .vs-passi.cap-elenco-3 .vs-icona { width: 24px; height: 24px; }
}
/* la firma: una sola curva morbida sotto il terzo passo */
.vs-firma { display: block; width: min(300px, calc(33.3% - 40px)); height: 30px; margin: 10px 2% 0 auto; overflow: visible; }
.vs-firma path { fill: none; stroke: #D49F5D; stroke-width: 2.2; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 0; }
.accensioni + .vs-firma { width: min(260px, 70%); margin: 14px 0 0 64px; }
@media (max-width: 860px) { .vs-firma, .accensioni + .vs-firma { width: 62%; margin: 10px auto 0; } }
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-passi { view-timeline: --vs-passi block; }
  html.vs-scorre:not(.fermo) .vs-passi .vs-icona path { animation: vs-traccia linear both; animation-timeline: --vs-passi;
    animation-range: entry calc(25% + var(--k) * 14%) cover calc(38% + var(--k) * 9%); }
  html.vs-scorre:not(.fermo) .vs-firma { view-timeline: --vs-firma block; }
  html.vs-scorre:not(.fermo) .vs-firma path { animation: vs-traccia linear both; animation-timeline: --vs-firma; animation-range: entry 60% cover 58%; }
}
@keyframes vs-traccia { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* la cisterna (orizzontale, come quella vera): sagoma a tratto oro, il verde sale con lo scroll, onda in superficie */
.vs-cisterna { position: relative; width: 190px; height: 112px; margin: 0 auto 16px; }
.vs-cis-corpo { position: absolute; left: 0; right: 0; top: 14px; height: 66px; border: 2px solid #D49F5D; border-radius: 36px; overflow: hidden;
  background: rgba(212,159,93,.07); isolation: isolate; }
.vs-cis-liquido { position: absolute; inset: 0; background: #1E574C; translate: 0 18%; }
.vs-cis-onda { position: absolute; left: 0; top: -7px; width: 200%; height: 8px; }
.vs-cis-onda svg { display: block; width: 100%; height: 100%; fill: #1E574C; }
html:not(.fermo) .vs-cis-onda { animation: vs-onda 8s linear infinite paused; }
html:not(.fermo) .vs-va .vs-cis-onda { animation-play-state: running; }
.vs-cis-fascia { position: absolute; left: 30%; top: 0; bottom: 0; width: 16%; border-left: 1.5px solid rgba(212,159,93,.85); border-right: 1.5px solid rgba(212,159,93,.85); z-index: 1; }
.vs-cis-tappo { position: absolute; top: 3px; left: 62%; width: 22px; height: 13px; border: 2px solid #D49F5D; border-bottom: 0; border-radius: 7px 7px 0 0; }
.vs-cis-gambe i { position: absolute; top: 79px; width: 2px; height: 20px; background: #D49F5D; border-radius: 1px; }
.vs-cis-gambe i:first-child { left: 22%; } .vs-cis-gambe i:last-child { right: 22%; }
.vs-cis-gambe::after { content: ""; position: absolute; left: 10%; right: 10%; top: 99px; height: 2px; border-radius: 2px; background: rgba(212,159,93,.55); }
@media (min-width: 1100px) {
  .vs-con-cisterna { position: relative; }
  .vs-con-cisterna > .vs-cisterna { position: absolute; right: clamp(24px, 3.4vw, 60px); top: clamp(26px, 3vw, 46px); margin: 0; width: clamp(140px, 12vw, 180px); }
}
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-con-cisterna { view-timeline: --vs-cis block; }
  html.vs-scorre:not(.fermo) .vs-cis-liquido { animation: vs-riempi linear both; animation-timeline: --vs-cis; animation-range: entry 22% entry 92%; }
}
@keyframes vs-riempi { from { translate: 0 100%; } to { translate: 0 18%; } }
@keyframes vs-onda { from { translate: 0 0; } to { translate: -50% 0; } }

/* ═══ 4 · BUSINESS CARD: una carta sola che si gira ═══ */
.vs-carta { display: none; }
html.vs:not(.fermo) .vs-carta { display: block; position: relative; width: min(440px, 84%); margin: 44px auto 0; perspective: 1400px; }
html.vs:not(.fermo) .vs-con-carta .cap-carte .cap-carta-faccia { display: none; }
html.vs:not(.fermo) .vs-con-carta .cap-carte { margin-top: 40px; }
.vs-carta::after { content: ""; position: absolute; left: 12%; right: 12%; top: calc(100% - 16px); height: 34px; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(56,42,20,.3), rgba(56,42,20,0)); }
.vs-carta-tilt { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.vs-carta-giro { position: relative; aspect-ratio: 1.586; transform-style: preserve-3d; }
.vs-faccia { position: absolute; inset: 0; border-radius: 18px; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 30px 50px -30px rgba(10,40,32,.75), 0 0 0 1px rgba(212,159,93,.3); }
.vs-retro { transform: rotateY(180deg); }
.vs-faccia .cap-carta-faccia { width: 100%; height: 100%; margin: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none !important; transform: none !important; }
.vs-carta .cap-carta-faccia::after { display: none !important; animation: none !important; }
.vs-carta .cap-carta-faccia span { font-size: clamp(13px, 1.3vw, 18px); }
/* la lamina a caldo: un gradiente oro tenue e FISSO (mai impulsi) che scorre con l'inclinazione */
.vs-lamina { position: absolute; inset: -10% -45%; pointer-events: none; translate: var(--lx, 0%) 0; transition: translate .5s cubic-bezier(.2, .8, .2, 1);
  background: linear-gradient(105deg, rgba(226,172,98,0) 36%, rgba(226,172,98,.17) 50%, rgba(226,172,98,0) 64%); }
.vs-carta-invito { margin-top: 20px; text-align: center; font-size: 12px; font-weight: 650; letter-spacing: .2em; text-transform: uppercase; color: #8A5F27;
  transition: opacity .4s; }
.vs-giro-scroll .vs-carta-invito { display: none; }
.vs-toccata .vs-carta-invito { opacity: 0; }
/* telefono e tablet: si gira al tocco, a molla */
.vs-giro-tocco { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.vs-giro-tocco .vs-carta-giro { transition: rotate .6s cubic-bezier(.3, 1.35, .5, 1); }
.vs-girata .vs-carta-giro { rotate: y 180deg; }
html.vs:not(.fermo) .vs-con-carta .cap-carta > :not(.cap-carta-faccia) { transition: opacity .45s; }
html.vs:not(.fermo) .vs-carta-tocco .cap-carta:not(.vs-scelta) > :not(.cap-carta-faccia) { opacity: .84; }
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-con-carta { timeline-scope: --vs-carta; }
  html.vs-scorre:not(.fermo) .vs-carta { view-timeline: --vs-carta block; }
  /* PC: la carta si gira con lo scroll; a metà sezione mostra il retro «A credito» */
  html.vs-scorre:not(.fermo) .vs-giro-scroll .vs-carta-giro { animation: vs-gira linear both; animation-timeline: --vs-carta; animation-range: cover 30% cover 52%; }
  html.vs-scorre:not(.fermo) .vs-carta-scroll .cap-carta:not(.cap-carta-oro) > :not(.cap-carta-faccia) { animation: vs-spegni linear both; animation-timeline: --vs-carta; animation-range: cover 30% cover 52%; }
  html.vs-scorre:not(.fermo) .vs-carta-scroll .cap-carta-oro > :not(.cap-carta-faccia) { animation: vs-accendi linear both; animation-timeline: --vs-carta; animation-range: cover 30% cover 52%; }
}
@keyframes vs-gira { from { rotate: y 0deg; } to { rotate: y 180deg; } }
@keyframes vs-spegni { from { opacity: 1; } to { opacity: .84; } }
@keyframes vs-accendi { from { opacity: .84; } to { opacity: 1; } }

/* ═══ 5 · DISTRIBUTORE: tieni premuto per fare il pieno ═══ */
.vs-pieno { --pieno: 0; display: grid; grid-template-columns: auto 60px 1fr; align-items: center; gap: 20px 28px; max-width: 780px; margin: 44px auto 0;
  padding: 26px 30px; border-radius: 26px; background: #062A22; color: #F3EADB; text-align: left;
  box-shadow: 0 34px 60px -40px rgba(6,42,34,.8), inset 0 0 0 1px rgba(212,159,93,.28); }
.vs-pieno-display { display: flex; flex-direction: column; gap: 8px; }
.vs-pieno-etichetta { font-size: 12px; font-weight: 650; letter-spacing: .3em; text-transform: uppercase; color: rgba(243,234,219,.72); }
.vs-pieno-litri { min-width: 6ch; padding: 10px 16px; border-radius: 12px; background: rgba(0,0,0,.28); box-shadow: inset 0 0 0 1px rgba(226,172,98,.24);
  color: #E2AC62; font-size: 44px; font-weight: 300; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.vs-pieno-serbatoio { position: relative; width: 60px; height: 104px; border-radius: 14px; border: 2px solid rgba(226,172,98,.7); overflow: hidden;
  background: rgba(243,234,219,.04); isolation: isolate; }
.vs-pieno-livello { position: absolute; inset: 0; background: linear-gradient(180deg, #E2AC62, #C98B3E); translate: 0 calc((1 - var(--pieno)) * 100%); }
.vs-pieno-onda { position: absolute; left: 0; top: -6px; width: 200%; height: 7px; }
.vs-pieno-onda svg { display: block; width: 100%; height: 100%; fill: #E2AC62; }
html:not(.fermo) .vs-pieno-onda { animation: vs-onda 1.1s linear infinite paused; }
html:not(.fermo) .vs-eroga .vs-pieno-onda { animation-play-state: running; }
.vs-pieno-btn { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 74px; padding: 14px 26px; border: 0; border-radius: 999px;
  background: linear-gradient(180deg, #E2AC62, #D49F5D); color: #062A22; font: inherit; font-size: 17px; font-weight: 700; line-height: 1.2; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  box-shadow: 0 16px 30px -18px rgba(226,172,98,.8); transition: scale .35s cubic-bezier(.3, 1.6, .5, 1); }
.vs-pieno-btn svg { flex: none; width: 34px; height: 34px; fill: none; stroke: #062A22; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.vs-pieno-btn:focus-visible { outline: 3px solid #E2AC62; outline-offset: 4px; }
.vs-eroga .vs-pieno-btn { scale: .96; transition-duration: .15s; }
.vs-pieno-fatto { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px; min-height: 1.6em; margin: 0;
  font-weight: 600; color: #F3EADB; opacity: 0; visibility: hidden; translate: 0 8px; transition: opacity .4s, translate .4s, visibility 0s .4s; }
.vs-fatto .vs-pieno-fatto { opacity: 1; visibility: visible; translate: 0 0; transition: opacity .4s, translate .4s, visibility 0s; }
.vs-pieno .vs-pieno-fatto .link-freccia { color: #E2AC62; }
.vs-fermo .vs-pieno-btn { display: none; }
.vs-fermo { grid-template-columns: auto 60px; justify-content: center; }
.servizi + .vs-pieno { width: min(780px, calc(100% - 40px)); margin-top: 56px; }
@media (max-width: 700px) {
  .vs-pieno { grid-template-columns: 1fr 52px; gap: 16px 18px; padding: 20px; border-radius: 22px; margin-top: 30px; }
  .vs-pieno-litri { font-size: 38px; }
  .vs-pieno-serbatoio { width: 52px; height: 92px; }
  .vs-pieno-btn { grid-column: 1 / -1; min-height: 66px; font-size: 16px; }
  .vs-pieno:not(.vs-fatto):not(.vs-fermo) .vs-pieno-fatto { display: none; }
}

/* ═══ 6 · DOVE SIAMO: la mappa che si raccoglie ═══ */
.vs-mappa .mappa-svg { position: relative; z-index: 1; }
.vs-mappa-strato { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.vs-mappa .mappa-punti circle { transform: none !important; transition: none !important; opacity: 1 !important; }
/* le onde che pulsavano attorno alla sede si fermano: un anello solo, fermo e tenue */
.vs-mappa .mappa-anello { animation: none !important; transform: none !important; opacity: .3 !important; }
.vs-mappa .mappa-anello-2 { display: none; }
.vs-mappa .mappa-centro { opacity: 0; }
.vs-spilla-corpo { fill: #D49F5D; stroke: #8A5F27; stroke-width: 1.2; }
.vs-spilla-foro { fill: #FBF7EF; }
.vs-zona-giro { fill: none; stroke: #C98B3E; stroke-width: 1.6; stroke-dasharray: 4 5; stroke-linecap: round; opacity: .85; }
.vs-zona-traccia { fill: none; stroke: #fff; stroke-width: 8; stroke-dasharray: 1; stroke-dashoffset: 0; }
@supports (animation-timeline: view()) {
  html.vs-scorre:not(.fermo) .vs-mappa .mappa-disegno { view-timeline: --vs-mappa block; }
  html.vs-scorre:not(.fermo) .vs-mappa-strato { animation: vs-raccogli linear both; animation-timeline: --vs-mappa;
    animation-range: entry calc(2% + var(--k) * 2%) cover calc(32% + var(--k) * 1.2%); }
  html.vs-scorre:not(.fermo) .vs-spilla { animation: vs-spilla linear both; animation-timeline: --vs-mappa; animation-range: cover 30% cover 40%; }
  html.vs-scorre:not(.fermo) .vs-zona-traccia { animation: vs-traccia linear both; animation-timeline: --vs-mappa; animation-range: cover 34% cover 48%; }
}
@keyframes vs-raccogli { from { translate: var(--dx) var(--dy); opacity: 0; } 35% { opacity: .5; } to { translate: 0 0; opacity: 1; } }
@keyframes vs-spilla { from { translate: 0 -24px; opacity: 0; } 55% { opacity: 1; } to { translate: 0 0; opacity: 1; } }

/* 16/11 unione: sul telefono il primo capitolo mostra subito «01» (la sua scena è già aperta all'arrivo) */
@media (max-width: 1100px) and (orientation: portrait) { html.vs-scorre:not(.fermo) .cap-primo .vs-rullo { animation: none; } }
