/* ============================================================
   AVIS Arona — Preloader + Esperienza scroll-frame (home)
   Caricato solo sulla home (pageKey === 'home').
   ============================================================ */

:root {
  --ss-red: #e2051b;
  --ss-blue: #1d70b8;
  --ss-space: #05070d;
}

/* Blocca lo scroll mentre il preloader carica i frame */
html.ss-locked,
body.ss-locked {
  overflow: hidden !important;
  height: 100%;
  touch-action: none;
}

/* ---------------- PRELOADER ---------------- */
.ss-preloader {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 120% at 50% 30%, #ffffff 0%, #eef3fb 60%, #e3ebf7 100%);
  transition: opacity 0.8s cubic-bezier(0.7, 0, 0.3, 1),
              visibility 0.8s cubic-bezier(0.7, 0, 0.3, 1);
}
.ss-preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.ss-preloader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 0 24px;
  text-align: center;
  transform: translateY(-2%);
}

.ss-preloader__logo {
  width: clamp(96px, 16vw, 150px);
  height: auto;
  display: block;
  filter: drop-shadow(0 14px 30px rgba(226, 5, 27, 0.18));
  animation: ssLogoBreath 2.6s ease-in-out infinite;
}
@keyframes ssLogoBreath {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-5px) scale(1.035); }
}

.ss-preloader__bar {
  position: relative;
  width: min(300px, 72vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(8, 27, 56, 0.12);
  overflow: hidden;
}
.ss-preloader__fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ss-red), #ff5a44);
  transition: transform 0.25s ease-out;
}

.ss-preloader__pct {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(8, 27, 56, 0.62);
  font-weight: 600;
}
.ss-preloader__pct b { color: var(--ss-red); font-variant-numeric: tabular-nums; }

/* ---------------- SEZIONE CINEMATIC ---------------- */
.scrollstory {
  position: relative;
  width: 100%;
  height: 260vh;            /* poco scroll = molti frame: ~1.6 schermate */
  background: var(--ss-space);
}

.scrollstory__sticky {
  position: sticky;
  top: var(--header-height, 96px);
  /* Fallback per browser senza dvh: usa la var JS (--app-vh) o svh. */
  height: calc(var(--app-vh, 100svh) - var(--header-height, 96px));
  width: 100%;
  overflow: hidden;
  background: var(--ss-space);
}
/* iOS Safari moderno: dvh segue in modo fluido la toolbar dinamica,
   eliminando il "rettangolo"/banda bianca senza scatti durante lo scroll. */
@supports (height: 100dvh) {
  .scrollstory__sticky {
    height: calc(100dvh - var(--header-height, 96px));
  }
}

.scrollstory__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--ss-space);
}

/* Scrim per leggibilità testo sopra/sotto */
.scrollstory__scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg,
      rgba(0,0,0,0.45) 0%,
      rgba(0,0,0,0.05) 26%,
      rgba(0,0,0,0.05) 60%,
      rgba(0,0,0,0.62) 100%);
}

/* Blocchi testo */
.ss-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 0 6vw 9vh;
  padding-bottom: calc(9vh + env(safe-area-inset-bottom, 0px));
  color: #fff;
}

.ss-intro { will-change: opacity, transform; }

.ss-eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  margin: 0 0 1rem;
  font-weight: 600;
}

.ss-title {
  margin: 0;
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.02em;
  font-size: clamp(2rem, 6vw, 4.6rem);
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.45);
}
.ss-title .ss-light { font-weight: 300; display: block; }
.ss-title .ss-bold  { font-weight: 800; display: block; }

/* Hint scroll */
.ss-hint {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
}
.ss-hint__line {
  position: relative;
  width: 1px;
  height: 46px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.ss-hint__line::before {
  content: "";
  position: absolute;
  top: 0; left: 50%;
  width: 1px; height: 15px;
  background: #fff;
  transform: translate(-50%, -100%);
  animation: ssHintTravel 1.9s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes ssHintTravel {
  0%   { transform: translate(-50%, -100%); opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(-50%, 360%); opacity: 0; }
}

/* Blocco finale (CTA sopra la sede AVIS) */
.ss-outro {
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  will-change: opacity, transform;
}
.ss-outro .ss-eyebrow { color: #ffd2d2; }
.ss-outro__title {
  margin: 0 0 1.6rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-size: clamp(1.9rem, 5.4vw, 4rem);
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.5);
}
.ss-outro__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}
.ss-outro__note {
  margin: 1.5rem 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.82);
}

/* La sezione successiva sale dolcemente sopra il cinematic alla fine */
.scrollstory + * { position: relative; z-index: 3; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 768px) {
  .scrollstory { height: 220vh; }
  .ss-overlay { padding: 0 7vw 11vh; padding-bottom: calc(12vh + env(safe-area-inset-bottom, 0px)); }
  .ss-title { font-size: clamp(1.9rem, 8.5vw, 3.2rem); }
  .ss-outro__title { font-size: clamp(1.7rem, 7.5vw, 2.8rem); }
  .ss-outro__actions { width: 100%; flex-direction: column; align-items: stretch; }
  .ss-outro__actions .button { justify-content: center; text-align: center; }
}

/* ---------------- REDUCED MOTION ---------------- */
@media (prefers-reduced-motion: reduce) {
  .scrollstory { height: auto; }
  .scrollstory__sticky {
    position: relative;
    top: 0;
    height: min(82vh, 720px);
  }
  .ss-preloader__logo { animation: none; }
  .ss-hint__line::before { animation: none; }
  /* In reduced-motion intro e outro restano entrambi leggibili */
  .ss-intro { justify-content: flex-start; padding-top: 8vh; }
}
