/* VIAGGIO-3D (prova del 19/10/2026, non pubblicata)
   «Ogni gesto conta»: dopo «La Nostra Storia», le foto dell'azienda dentro lastre di vetro in 3D
   (Three.js) e una telecamera che ci passa attraverso mentre si scorre la pagina.
   Senza 3D (movimento ridotto, niente WebGL, errore) la sezione resta una pagina normale:
   foto e testi uno sotto l'altro, tutto visibile. Il codice è in viaggio-3d.js. */

.v3d {
  --v3d-ease: cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  background: var(--color-primary);
  color: var(--color-text-light);
  padding: clamp(4rem, 9vw, 7.5rem) 0;
}

/* ---------- Versione ferma (anche quella di partenza, prima che il 3D sia pronto) ---------- */

.v3d__gl,
.v3d__poster,
.v3d-rail {
  display: none;
}

.v3d__steps {
  width: min(1100px, calc(100% - 44px));
  margin: 0 auto;
  display: grid;
  gap: clamp(3.5rem, 7vw, 6rem);
}

.v3d-step {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: center;
}

.v3d-step:nth-child(even) .v3d-step__media {
  order: 2;
}

.v3d-step__media {
  margin: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 60px -36px rgba(0, 0, 0, 0.7);
}

.v3d-step__media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: cover;
}

.v3d-step--end {
  grid-template-columns: minmax(0, 1fr);
  text-align: center;
  justify-items: center;
}

.v3d-kicker {
  margin: 0 0 0.9rem;
  font-family: var(--font-text);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.v3d-title,
.v3d-name {
  margin: 0 0 1rem;
  font-family: var(--font-title);
  font-weight: 400;
  line-height: 1.08;
  color: var(--color-text-light);
  text-wrap: balance;
}

.v3d-title {
  font-size: clamp(2.5rem, 5vw, 4.25rem);
}

.v3d-name {
  font-size: clamp(2rem, 3.6vw, 3.1rem);
}

.v3d-name em {
  font-style: italic;
  color: var(--color-accent);
}

.v3d-text {
  margin: 0;
  max-width: 34ch;
  font-family: var(--font-text);
  font-size: clamp(1.02rem, 1.2vw, 1.15rem);
  line-height: 1.65;
  color: rgba(245, 239, 230, 0.86);
  text-wrap: pretty;
}

.v3d-step--end .v3d-text {
  margin-inline: auto;
}

.v3d-step .btn-primary {
  margin-top: 1.75rem;
}

/* il pulsante oro sul bordeaux: al passaggio diventa bordeaux, qui serve un bordo chiaro */
.v3d .btn-primary:hover {
  background-color: transparent;
  color: var(--color-accent);
}

@media (max-width: 899px) {
  .v3d-step {
    grid-template-columns: minmax(0, 1fr);
  }

  .v3d-step:nth-child(even) .v3d-step__media {
    order: 0;
  }
}

/* ---------- Versione 3D ---------- */

.v3d--live {
  height: calc(var(--v3d-units, 8) * 100svh);
  padding: 0;
}

.v3d--live .v3d__stage {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}

/* L'anello finale si gira trascinando di lato (21/10): in verticale la pagina scorre come sempre */
.v3d--live .v3d__stage {
  touch-action: pan-y;
}

@media (hover: hover) and (pointer: fine) {
  .v3d--live .v3d__stage.can-spin {
    cursor: grab;
  }

  .v3d--live .v3d__stage.is-spinning {
    cursor: grabbing;
  }

  /* sopra una foto dell'anello: si può aprire in grande con un clic */
  .v3d--live .v3d__stage.can-spin.over-photo:not(.is-spinning) {
    cursor: zoom-in;
  }
}

/* il film del calice nella finestra della foto in grande: come le foto (.lightbox-figure img) */
.v3d-lightbox .lightbox-figure video {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.v3d--live .v3d__gl {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.9s var(--v3d-ease);
}

.v3d--ready .v3d__gl {
  opacity: 1;
}

/* Mentre Three.js arriva, la prima foto è già al suo posto (mai un riquadro vuoto). */
.v3d--live .v3d__poster {
  display: block;
  position: absolute;
  top: calc(50% + 2.5vh);
  left: 39vw;
  width: 48vw;
  aspect-ratio: 3 / 2;
  transform: translateY(-50%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transition: opacity 0.6s ease-out;
}

.v3d--live .v3d__poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.v3d--ready .v3d__poster {
  opacity: 0;
  pointer-events: none;
}

.v3d--live .v3d__steps {
  position: absolute;
  inset: 0;
  width: auto;
  margin: 0;
  display: block;
  pointer-events: none;
}

.v3d--live .v3d-step {
  display: block;
  position: absolute;
  left: clamp(24px, 6vw, 104px);
  top: 50%;
  width: min(30rem, 36vw);
  /* trasparenti ma non nascoste: i lettori di schermo leggono tutte le tappe, e se la tastiera porta
     il fuoco su una tappa la pagina scorre fin lì (viaggio-3d.js) */
  opacity: 0;
  transform: translateY(calc(-50% + 18px));
  filter: blur(4px);
  /* uscita più rapida dell'entrata */
  transition: opacity 0.25s ease-out, transform 0.3s ease-out, filter 0.25s ease-out;
}

.v3d--live .v3d-step.is-on {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
  filter: blur(0);
  transition: opacity 0.6s var(--v3d-ease) 0.08s, transform 0.75s var(--v3d-ease) 0.08s,
    filter 0.6s var(--v3d-ease) 0.08s;
}

.v3d--live .v3d-step.is-past {
  transform: translateY(calc(-50% - 18px));
}

.v3d--live .v3d-step__media {
  display: none;
}

.v3d--live .v3d-step--end {
  text-align: left;
}

.v3d--live .v3d-step--end .v3d-text {
  margin-inline: 0;
}

/* Le tappe, a destra: si vede dove si è e si salta a una tappa. */
.v3d--live .v3d-rail {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: absolute;
  right: clamp(16px, 2.4vw, 36px);
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
  list-style: none;
  transition: opacity 0.4s ease-out;
}

.v3d--live .v3d-rail.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.v3d-rail button {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  min-height: 32px;
  padding: 0.25rem 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-text);
  font-size: 0.8rem; /* 12,8px: mai sotto i 12 (controllo 20/10) */
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 239, 230, 0.55);
  transition: color 0.2s ease;
}

.v3d-rail button::after {
  content: '';
  width: 18px;
  height: 1px;
  background: currentColor;
  transform-origin: right;
  transform: scaleX(0.55);
  transition: transform 0.3s var(--v3d-ease);
}

.v3d-rail button.is-on {
  color: var(--color-accent);
}

.v3d-rail button.is-on::after {
  transform: scaleX(1.6);
}

@media (hover: hover) and (pointer: fine) {
  .v3d-rail button:hover {
    color: var(--color-text-light);
  }
}

.v3d-rail button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* Telefono: la lastra in alto, il testo in basso sopra un velo scuro, sopra la barra «Prenota». */
@media (max-width: 899px) {
  .v3d--live .v3d__stage::after {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 52%;
    background: linear-gradient(to top, rgba(39, 11, 23, 0.94) 35%, rgba(39, 11, 23, 0));
    pointer-events: none;
  }

  .v3d--live .v3d__steps {
    z-index: 1;
  }

  /* l'elenco delle tappe è solo per lo schermo grande: sul telefono coprirebbe la foto */
  .v3d--live .v3d-rail {
    display: none;
  }

  .v3d--live .v3d-step {
    left: 20px;
    right: 20px;
    top: auto;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    width: auto;
    transform: translateY(18px);
  }

  .v3d--live .v3d-step.is-on {
    transform: none;
  }

  .v3d--live .v3d-step.is-past {
    transform: translateY(-18px);
  }

  .v3d--live .v3d__poster {
    top: 14svh;
    left: 8vw;
    width: 84vw;
    transform: none;
  }

  .v3d-title {
    font-size: clamp(2.2rem, 9vw, 2.8rem);
  }

  .v3d-name {
    font-size: clamp(1.9rem, 8vw, 2.4rem);
    margin-bottom: 0.6rem;
  }

  .v3d-text {
    font-size: 1rem;
  }

  .v3d-kicker {
    font-size: 0.875rem;
  }

  .v3d-step .btn-primary {
    margin-top: 1.25rem;
  }
}
