/* BIMQTY — transizioni cinematiche allo scroll (stessi capitoli e slogan del video promozionale).
   Le variabili --p (avanzamento del capitolo), --e (entrata) e --x (uscita) le scrive js/cinema.js. */

:root {
  --ease-cine: cubic-bezier(0.2, 0.7, 0.2, 1);
  --story-bg: #0b1626;
}

/* ---------- Header ---------- */

.hero { position: relative; overflow: hidden; --hs: 0; }

.hero::after {                    /* griglia di progetto, come nel promo */
  content: "";
  position: absolute;
  inset: -20% -10% 0;
  background:
    linear-gradient(rgba(80, 150, 255, 0.07) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(90deg, rgba(80, 150, 255, 0.07) 1px, transparent 1px) 0 0 / 64px 64px;
  mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
  transform: perspective(900px) rotateX(58deg) translateY(calc(var(--hs) * 140px));
  transform-origin: 50% 100%;
  pointer-events: none;
  opacity: 0.9;
}

.hero .wrap { position: relative; z-index: 1; }

.hero h1 { font-size: clamp(2.3rem, 3.6vw, 3.5rem); text-wrap: balance; }
.hero-logo-card { width: 170px; height: 170px; padding: 24px; }

/* tra tablet e desktop piccolo: niente logo grande (c'e' gia' nella barra), piu' spazio a testo e video */
@media (max-width: 1180px) and (min-width: 861px) {
  .hero-logo-card { display: none; }
  .hero-video { flex-basis: 46%; }
}

.hero-tagline {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #8fc1ff;
}

/* il testo dell'header resta sempre nitido e pieno: solo un leggero spostamento (niente su telefono) */
.hero-content {
  transform: translate3d(0, calc(var(--hs) * -40px), 0);
}

.hero-video {
  transform: translate3d(0, calc(var(--hs) * -40px), 0) scale(calc(1 + var(--hs) * 0.08));
}

.hero-logo-card {
  transform: translate3d(0, calc(var(--hs) * -40px), 0) scale(calc(1 - var(--hs) * 0.12));
  opacity: calc(1 - var(--hs) * 0.9);
}

/* entrata dell'header al caricamento */
.cine-ready .hero .eyebrow,
.cine-ready .hero h1,
.cine-ready .hero-tagline,
.cine-ready .hero p.lead,
.cine-ready .hero-cta,
.cine-ready .hero-meta,
.cine-ready .hero-video,
.cine-ready .hero-logo-card { animation: cine-in 1.2s var(--ease-cine) both; }
.cine-ready .hero-logo-card { animation-delay: 0.05s; }
.cine-ready .hero .eyebrow { animation-delay: 0.15s; }
.cine-ready .hero h1 { animation-delay: 0.25s; }
.cine-ready .hero-video { animation-delay: 0.45s; }
.cine-ready .hero-tagline { animation-delay: 0.55s; }
.cine-ready .hero p.lead { animation-delay: 0.65s; }
.cine-ready .hero-cta { animation-delay: 0.75s; }
.cine-ready .hero-meta { animation-delay: 0.85s; }

@keyframes cine-in {
  from { opacity: 0; translate: 0 34px; filter: blur(10px); }
  to   { opacity: 1; translate: 0 0;    filter: blur(0); }
}

/* ---------- Capitoli ---------- */

.story {
  position: relative;
  padding: 0;
  color: #fff;
  background:
    radial-gradient(900px 520px at 80% 30%, rgba(47, 134, 255, 0.16), transparent 65%),
    linear-gradient(180deg, #142640 0, var(--story-bg) 600px);
}

.story::after {                   /* passaggio morbido verso le sezioni chiare */
  content: "";
  display: block;
  height: 28vh;
  background: linear-gradient(180deg, var(--story-bg), #ffffff);
}

.chapter {
  --p: 0; --e: 0; --x: 0;
  position: relative;
  height: 170vh;
}
.chapter-long { height: 300vh; }
.chapter-end { height: 150vh; }

.ch-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 24px 24px;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 56px;
  overflow: hidden;
}

.chapter:nth-child(even) .ch-text { order: 2; }

.ch-text {
  transform: translate3d(0, calc(var(--x) * -70px), 0);
  opacity: calc(1 - var(--x));
  filter: blur(calc(var(--x) * 8px));
}

.ch-num {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: #6fb2ff;
  opacity: var(--e);
}

.story h2 {
  margin: 0;
  font-size: clamp(2.2rem, 4.6vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.story .blue { color: #4b9bff; }
.story p { text-align: left; }
.story .ch-closing p { text-align: center; }

.ch-sub {
  margin: 14px 0 0;
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  color: rgba(255, 255, 255, 0.82);
}
.ch-sub.blue { color: #8fc1ff; }

/* scritta che sale lettera per lettera (come le scritte del promo) */
.kin .w { display: inline-block; white-space: nowrap; }
.kin .ch { display: inline-block; }
.kin .ch {
  --lp: clamp(0, calc(var(--e) * 1.8 - var(--i) * 0.8), 1);
  transform: translate3d(0, calc((1 - var(--lp)) * 0.6em), calc((1 - var(--lp)) * -120px)) rotateX(calc((1 - var(--lp)) * 70deg));
  opacity: var(--lp);
  filter: blur(calc((1 - var(--lp)) * 10px));
}
.kin { perspective: 600px; }

.ch-list {
  list-style: none;
  margin: 28px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.ch-list li {
  --lp: clamp(0, calc((var(--p) - 0.16 - var(--k) * 0.07) * 9), 1);
  position: relative;
  padding: 10px 14px 10px 40px;
  border-radius: 10px;
  background: rgba(47, 134, 255, 0.08);
  border: 1px solid rgba(111, 178, 255, 0.22);
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  transform: translate3d(calc((1 - var(--lp)) * -28px), 0, 0);
  opacity: var(--lp);
  filter: blur(calc((1 - var(--lp)) * 6px));
}
.ch-list li::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border-radius: 3px;
  background: linear-gradient(135deg, #2f86ff, #8fc1ff);
  box-shadow: 0 0 12px rgba(47, 134, 255, 0.7);
}

/* immagine del capitolo: arriva dal fondo ruotata e sfocata, poi si allontana */
.ch-visual {
  position: relative;
  transform:
    perspective(1600px)
    translate3d(0, calc((1 - var(--e)) * 80px - var(--x) * 60px), calc((1 - var(--e)) * -380px + var(--x) * -220px))
    rotateY(calc((1 - var(--e)) * -20deg + var(--x) * 14deg))
    rotateX(calc((1 - var(--e)) * 8deg));
  opacity: calc(var(--e) - var(--x));
  filter: blur(calc((1 - var(--e)) * 14px + var(--x) * 10px));
  will-change: transform, opacity, filter;
}
.chapter:nth-child(even) .ch-visual {
  transform:
    perspective(1600px)
    translate3d(0, calc((1 - var(--e)) * 80px - var(--x) * 60px), calc((1 - var(--e)) * -380px + var(--x) * -220px))
    rotateY(calc((1 - var(--e)) * 20deg - var(--x) * 14deg))
    rotateX(calc((1 - var(--e)) * 8deg));
}

.ch-visual img, .ch-visual canvas { display: block; width: 100%; height: auto; }

.ch-visual.panel img {
  border-radius: 12px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(111, 178, 255, 0.25);
  transform: scale(calc(0.96 + var(--p) * 0.06));
  transform-origin: 50% 40%;
}

.ch-visual.stack { padding: 0 0 18% 0; }
.ch-visual.stack .ch-back {
  position: absolute;
  right: -6%;
  bottom: 0;
  width: 62%;
  opacity: 0.92;
  transform: translate3d(calc((1 - var(--p)) * 60px), 0, 0) scale(0.98);
}

.ch-visual.holo img,
.ch-visual.holo canvas { filter: drop-shadow(0 0 30px rgba(47, 134, 255, 0.35)); }

.ch-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.ch-scan {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #8fc1ff, transparent);
  box-shadow: 0 0 22px 6px rgba(47, 134, 255, 0.55);
  opacity: 0;
}

/* 04 · Migrazione: i due modelli collegati da un fascio di luce, come nel video promozionale.
   Il modello aggiornato e il collegamento arrivano con lo scroll (--p); il punto luminoso corre dal v1 all'aggiornato. */
.ch-visual.mig { display: grid; gap: 22px; }
.mig-models { display: grid; grid-template-columns: 1fr minmax(48px, 0.55fr) 1fr; align-items: center; }
.mig-model { margin: 0; text-align: center; }
.ch-visual.mig .mig-model img { width: 100%; height: auto; filter: drop-shadow(0 0 26px rgba(47, 134, 255, 0.4)); }
.mig-model figcaption {
  margin-top: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #8fc1ff;
}
.mig-v2 {
  --mv: clamp(0, calc((var(--p) - 0.06) * 6), 1);
  opacity: var(--mv);
  filter: blur(calc((1 - var(--mv)) * 6px));
  transform: translate3d(calc((1 - var(--mv)) * 26px), 0, 0);
}
.mig-link { position: relative; height: 26px; opacity: clamp(0, calc((var(--p) - 0.12) * 6), 1); }
.mig-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(143, 195, 255, 0), #8fc3ff, rgba(143, 195, 255, 0));
  box-shadow: 0 0 18px 4px rgba(47, 134, 255, 0.55);
}
.mig-dot {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #eaf3ff;
  box-shadow: 0 0 18px 7px rgba(143, 195, 255, 0.9);
  animation: mig-travel 1.3s linear infinite;
}
.mig-dot-2 { animation-delay: -0.65s; }
@keyframes mig-travel {
  0% { left: 0; opacity: 0; }
  20%, 80% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}
.ch-visual.mig .mig-report {
  --mr: clamp(0, calc((var(--p) - 0.5) * 6), 1);
  border-radius: 12px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(111, 178, 255, 0.25);
  opacity: var(--mr);
  transform: translate3d(0, calc((1 - var(--mr)) * 26px), 0) scale(calc(0.96 + var(--mr) * 0.04));
}

.ch-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid rgba(111, 178, 255, 0.5);
  background: rgba(47, 134, 255, 0.18);
  opacity: 0.35;
  transition: opacity 0.4s, transform 0.4s var(--ease-cine), box-shadow 0.4s;
}
.chip.on { opacity: 1; transform: scale(1.06); box-shadow: 0 0 24px rgba(47, 134, 255, 0.35); }
.chip-green { background: rgba(40, 180, 90, 0.25); border-color: #5fe08e; }
.chip-red { background: rgba(200, 40, 40, 0.25); border-color: #ff7b7b; }

.ch-date, .ch-amount .ch-euro {
  display: block;
  margin-top: 22px;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #8fc1ff;
  text-shadow: 0 0 30px rgba(47, 134, 255, 0.5);
}
.ch-amount small {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

/* chiusura */
.chapter-end .ch-stage { grid-template-columns: 1fr; justify-items: center; text-align: center; }
.ch-closing {
  transform: scale(calc(0.82 + var(--e) * 0.18));
  opacity: var(--e);
  filter: blur(calc((1 - var(--e)) * 12px));
}
.ch-logo { width: clamp(120px, 16vw, 200px); margin: 0 auto 10px; display: block; }
.ch-brand { font-size: clamp(3.4rem, 10vw, 7.5rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.ch-wordmark { display: block; width: clamp(240px, 46vw, 560px); height: auto; margin: 0 auto; }
.ch-motto { margin: 14px 0 0; font-size: clamp(1.2rem, 2.4vw, 1.9rem); color: rgba(255, 255, 255, 0.9); }
.ch-kicker {
  margin: 22px 0 0;
  font-size: 0.95rem;
  line-height: 1.7;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8fc1ff;
  opacity: clamp(0, calc((var(--p) - 0.35) * 5), 1);
}

/* a entrata completata il testo torna testo "normale": niente trasformazioni ne' filtri,
   che su telefono (specie iPhone) lo lasciano leggermente sfocato */
.chapter.settled .kin .ch,
.chapter.settled .ch-text { transform: none; filter: none; opacity: 1; }

/* pagina che non scorre da sola (es. dentro un riquadro alto quanto il contenuto): tutto fermo e leggibile */
.cine-static .chapter { height: auto; --p: 1; --e: 1; --x: 0; }
.cine-static .ch-stage { position: static; height: auto; padding: 72px 24px; }
.cine-static .ch-visual, .cine-static .ch-text, .cine-static .ch-closing, .cine-static .kin .ch,
.cine-static .ch-list li, .cine-static .ch-visual.panel img { transform: none; filter: none; opacity: 1; }
.cine-static .ch-layer { display: none; }

/* ---------- Comparsa delle altre sezioni ---------- */

.cine-ready .reveal {
  opacity: 0;
  translate: 0 46px;
  scale: 0.98;
  filter: blur(8px);
  transition: opacity 1s var(--ease-cine), translate 1.1s var(--ease-cine), scale 1.1s var(--ease-cine), filter 1s var(--ease-cine);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.cine-ready .reveal.in { opacity: 1; translate: 0 0; scale: 1; filter: blur(0); }

/* ---------- Schermi stretti ---------- */

@media (max-width: 860px) {
  .chapter { height: 160vh; }
  .chapter-long { height: 260vh; }
  .ch-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: center;
    gap: 22px;
    padding: 76px 20px 20px;
  }
  .chapter:nth-child(even) .ch-text { order: 0; }
  .ch-visual { max-height: 42svh; display: flex; justify-content: center; }
  .ch-visual img, .ch-visual canvas { width: auto; max-width: 100%; max-height: 42svh; }
  .ch-visual.stack { padding: 0; }
  .ch-visual.stack .ch-back { display: none; }
  .ch-visual.mig { display: block; }
  .ch-visual.mig .mig-model img { width: 100%; max-height: 30svh; object-fit: contain; }
  .ch-visual.mig .mig-report { display: none; }
  .ch-list { margin-top: 16px; gap: 6px; }
  .ch-list li { font-size: 0.88rem; padding: 7px 12px 7px 34px; }
  .ch-list li::before { left: 12px; width: 10px; height: 10px; margin-top: -5px; }
  .ch-chips { margin-top: 14px; }
  .ch-date, .ch-amount .ch-euro { margin-top: 12px; }
  .hero-video, .hero-content { transform: none; }
  /* su telefono il testo si muove solo in 2D e non si sfoca mai */
  .kin .ch { transform: translate3d(0, calc((1 - var(--lp)) * 0.4em), 0); filter: none; }
  .kin { perspective: none; }
  .ch-text, .ch-list li { filter: none; }
  .hero-logo-card { width: 120px; height: 120px; padding: 18px; transform: none; opacity: 1; }
}

@media (max-height: 700px) and (max-width: 860px) {
  .ch-list li:nth-child(n+3) { display: none; }
}

/* ---------- Riduci movimento: tutto fermo e leggibile ---------- */

@media (prefers-reduced-motion: reduce) {
  .hero-content, .hero-video, .hero-logo-card, .hero::after { transform: none !important; opacity: 1 !important; filter: none !important; }
  .chapter, .chapter-long, .chapter-end { height: auto; --p: 1 !important; --e: 1 !important; --x: 0 !important; }
  .ch-stage { position: static; height: auto; min-height: 0; padding: 72px 24px; }
  .ch-visual, .ch-text, .ch-closing, .kin .ch, .ch-list li, .ch-visual.panel img, .ch-visual.stack .ch-back {
    transform: none !important; filter: none !important; opacity: 1 !important;
  }
  .ch-layer { display: none; }
  .ch-kicker { opacity: 1; }
  .mig-dot { animation: none; left: 50%; opacity: 1; }
  .mig-dot-2 { display: none; }
  .cine-ready .reveal { opacity: 1; translate: none; scale: none; filter: none; transition: none; }
  .cine-ready .hero * { animation: none !important; }
}
