/* Scrollytelling a soste (works/*-walkthrough.html). Motore in story.js, sorgenti in _build/stories/.
   La storia occupa esattamente lo schermo: mentre e' agganciata lo scroll non muove la pagina
   ma avvia il movimento di camera fino alla sosta successiva. */
:root { --story-curve: cubic-bezier(.35, 0, .15, 1); }

/* ---- Intro e chiusura, nello stile dei case study */
.story-intro { padding-top: 3rem; padding-bottom: 4rem; }
.story-intro .case-title { margin-bottom: 1.5rem; }
.story-lead { font-size: 1.15rem; line-height: 1.8; max-width: 62ch; color: var(--text-color); }
.story-how { display: flex; align-items: center; gap: 1.1rem; margin-top: 2.2rem; max-width: 62ch; font-size: .85rem;
  line-height: 1.6; color: var(--accent-color); }
.story-how::before { content: ""; flex: none; width: 1px; height: 2.6rem; background: currentColor; transform-origin: top;
  animation: story-cue 2.4s var(--story-curve) infinite; }
@keyframes story-cue { 0% { transform: scaleY(0); } 55% { transform: scaleY(1); transform-origin: top; } 56% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }
.story-outro { padding-top: 5rem; padding-bottom: 4rem; }
.story-outro h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); margin-bottom: 1.2rem; }
.story-outro p { max-width: 62ch; line-height: 1.8; }
.story-credits { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-color); font-size: .8rem;
  line-height: 1.7; color: var(--accent-color); max-width: 90ch; }
.story-links { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; margin-top: 2rem; }

/* L'intestazione del sito si ritira mentre la storia e' a schermo */
#main-header { transition: transform .5s var(--story-curve), opacity .4s ease; }
html.story-locked #main-header { transform: translateY(-100%); opacity: 0; pointer-events: none; }
html.story-locked { overflow: hidden; }

/* ---- La storia */
.scrolly { position: relative; height: 100vh; height: 100svh; background: #111; overflow: hidden; touch-action: pan-y; }
html.story-locked .scrolly { touch-action: none; }
.scrolly .layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; }
.scrolly .layer.on { opacity: 1; }
.scrolly .layer.dissolve { transition: opacity .8s ease; }
.scrolly .caption { position: absolute; left: 6vw; bottom: 10vh; max-width: 440px; color: #fff; opacity: 0; transform: translateY(14px);
  transition: opacity .6s, transform .6s; text-shadow: 0 1px 14px rgba(0,0,0,.5); pointer-events: none; z-index: 50; }
.scrolly .caption.on { opacity: 1; transform: none; transition-delay: .1s; }
.scrolly .caption .n { font-size: 11px; letter-spacing: .18em; opacity: .8; }
.scrolly .caption h2 { font: 400 clamp(28px, 3.6vw, 48px)/1.05 var(--font-serif, "Cormorant Garamond"), Georgia, serif; color: #fff;
  margin: .2em 0 .35em; text-transform: uppercase; }
.scrolly .caption p { margin: 0; font-size: 15px; line-height: 1.6; color: #fff; }
.scrolly .dots { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 12px; z-index: 60; }
.scrolly .dots button { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.85); background: transparent; cursor: pointer; }
.scrolly .dots button.on { background: #fff; }
.scrolly .hint { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); color: rgba(255,255,255,.85); font-size: 11px;
  letter-spacing: .18em; text-transform: uppercase; z-index: 60; transition: opacity .4s; }
.scrolly .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: rgba(255,255,255,.85); width: 0; z-index: 60; }
.scrolly .wait { position: absolute; right: 22px; bottom: 22px; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: story-spin .8s linear infinite; opacity: 0; z-index: 60; }
.scrolly .wait.on { opacity: 1; }
@keyframes story-spin { to { transform: rotate(360deg); } }

/* ---- Disegni sopra l'animazione, in differenza: le linee del rilievo (bianche dopo l'inversione)
   rovesciano i colori del render. Entrano a sosta raggiunta con la curva dei movimenti di camera,
   escono appena parte il gesto successivo. */
.scrolly .tavole { position: absolute; inset: 0; z-index: 45; mix-blend-mode: difference; pointer-events: none; }
.scrolly .velo { position: absolute; inset: 0; z-index: 44; pointer-events: none; opacity: 0; transition: opacity .4s ease; }
.scrolly .velo.destra { background: radial-gradient(ellipse 42% 58% at 70% 50%, rgba(0,0,0,.5), rgba(0,0,0,.25) 60%, transparent 100%); }
.scrolly .velo.alto { background: linear-gradient(to bottom, rgba(0,0,0,.5), rgba(0,0,0,.2) 45%, transparent 60%); }
.scrolly .velo.on { opacity: 1; transition: opacity 1.4s ease .2s; }
.scrolly .sovra { position: absolute; margin: 0; opacity: 0; transition: opacity .35s ease; }
.scrolly .sovra.on { opacity: 1; transition: opacity .25s ease; }
.scrolly .sovra img { display: block; width: 100%; height: auto; filter: invert(1);
  clip-path: inset(0 100% 0 0); transition: clip-path 0s linear .4s; }
.scrolly .sovra.on img { clip-path: inset(0 0 0 0); transition: clip-path 1.9s var(--story-curve) .35s; }
.scrolly .sovra.destra { right: 6vw; top: 50%; transform: translateY(-50%); width: min(46vw, 125vh); }
.scrolly .sovra.dettagli { right: 7vw; top: 50%; transform: translateY(-50%); width: min(34vw, 60vh); display: grid; gap: 4vh; }
.scrolly .sovra.dettagli.on img + img { transition-delay: .8s; }
.scrolly .sovra.banda { left: 6vw; right: 6vw; top: 7vh; }
.scrolly .sovra .tela { position: relative; }
.scrolly .sovra svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.scrolly .sovra .linea { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: var(--l) var(--l); stroke-dashoffset: var(--l); transition: stroke-dashoffset 0s .4s; }
.scrolly .sovra.on .linea { stroke-dashoffset: 0; transition: stroke-dashoffset 2.2s var(--story-curve) .9s; }
.scrolly .sovra .linea.dopo { stroke-width: 4; stroke-dasharray: 3 16; stroke-dashoffset: 0; opacity: 0; transition: opacity .3s; }
.scrolly .sovra.on .linea.dopo { opacity: .6; transition: opacity 1s ease 2.6s; }
.scrolly .sovra .punto circle { fill: #000; stroke: #fff; stroke-width: 5; }
.scrolly .sovra .punto text { font: 500 26px Inter, sans-serif; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.scrolly .sovra .punto.qui circle { fill: #fff; }
.scrolly .sovra .punto.qui text { fill: #000; }
.scrolly .sovra .punto, .scrolly .sovra .cono { opacity: 0; transition: opacity .3s; }
.scrolly .sovra.on .punto, .scrolly .sovra.on .cono { opacity: 1; transition: opacity .8s ease 2.4s; }
.scrolly .sovra .cono { fill: #fff; }
.scrolly .sovra.on .cono { opacity: .28; }

/* la nota sul disegno entra dopo la didascalia, una riga alla volta */
.scrolly .caption .nota { margin-top: 1.4em; padding-top: .9em; border-top: 1px solid transparent; max-width: 400px; transition: border-color .3s; }
.scrolly .caption.on .nota { border-top-color: rgba(255,255,255,.45); transition: border-color 1s ease 1s; }
.scrolly .caption .nota .n { display: block; }
.scrolly .caption .nota p { font-size: 13px; line-height: 1.65; opacity: .92; margin-top: .3em; }
.scrolly .caption .nota > * { opacity: 0; transform: translateY(10px); transition: opacity .3s, transform .3s; }
.scrolly .caption.on .nota > * { opacity: 1; transform: none; transition: opacity .8s ease, transform .8s var(--story-curve); }
.scrolly .caption.on .nota > :nth-child(1) { transition-delay: 1.2s; }
.scrolly .caption.on .nota > :nth-child(2) { transition-delay: 1.45s; }

/* Telefono in verticale: l'immagine intera in una fascia quadrata, le didascalie sotto, il disegno dentro la fascia */
@media (max-aspect-ratio: 4/5) {
  .scrolly .layer { inset: auto 0 auto 0; top: 12vh; height: min(100vw, 58vh); }
  .scrolly .caption { left: 6vw; right: 6vw; top: calc(12vh + min(100vw, 58vh) + 4vh); bottom: auto; max-width: none; color: #eee; text-shadow: none; }
  .scrolly .caption h2 { font-size: 30px; }
  .scrolly .caption p { font-size: 14px; }
  .scrolly .dots { right: 50%; top: 18px; transform: translateX(50%); flex-direction: row; }
  .scrolly .tavole { top: 12vh; bottom: auto; height: min(100vw, 58vh); }
  .scrolly .sovra.destra, .scrolly .sovra.dettagli { right: 5vw; left: 5vw; width: auto; top: 50%; }
  .scrolly .sovra.dettagli { gap: 2vh; left: 14vw; right: 14vw; }
  .scrolly .sovra.banda { left: 3vw; right: 3vw; top: 6%; }
  .scrolly .sovra .linea { stroke-width: 10; }
  .scrolly .caption .nota { margin-top: 1em; }
}

/* Movimento ridotto (story.js aggiunge .is-still): stesse soste, passaggi in dissolvenza,
   disegni e testi compaiono senza scorrere */
@media (prefers-reduced-motion: reduce) { .story-how::before { animation: none; } }
.scrolly.is-still .sovra img { clip-path: none; transition: none; }
.scrolly.is-still .sovra .linea { stroke-dashoffset: 0; transition: none; }
.scrolly.is-still .caption, .scrolly.is-still .caption .nota > * { transform: none; }
.scrolly.is-still .sovra.on .punto, .scrolly.is-still .sovra.on .cono, .scrolly.is-still .sovra.on .linea.dopo,
.scrolly.is-still .caption.on .nota > * { transition: opacity .4s ease; }
