/* === 3D VISUALIZER — carosello 8 capi + scrub su scroll === */

.vis {
  padding: 0; background: #fdfdfd; position: relative; overflow: clip;
}

/* Header */
.vis-header {
  text-align: center;
  padding: clamp(3.5rem,7vw,7rem) 1.5rem 0;
  position: relative; z-index: 2;
}
.vis-header .section-label { color: var(--cuoio); }
.vis-header .section-title { color: var(--terra); }

/* Scroll runway — drives the scrub */
.vis-runway { height: 400vh; position: relative; }

/* Pinned stage — parte sotto il nav fisso (80px) per non finirci sotto */
.vis-pinned {
  position: sticky; top: 80px;
  height: calc(100vh - 80px);
  height: calc(100svh - 80px);   /* altezza garantita anche con le barre del browser */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  overflow: hidden;
}

/* --- Stage --- */
.vis-stage {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.vis-frame-img {
  height: 100%; width: auto; max-width: 92vw;
  object-fit: contain; display: block;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}

/* Loading indicator */
.vis-loading {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 46px; height: 1px; background: rgba(42,29,19,.1);
  opacity: 0; transition: opacity .3s ease; overflow: hidden;
}
.vis-loading.on { opacity: 1; }
.vis-loading span {
  position: absolute; inset: 0; width: 40%;
  background: var(--oro); animation: visLoad 1.1s ease-in-out infinite;
}
@keyframes visLoad { 0%{transform:translateX(-100%)} 100%{transform:translateX(250%)} }

/* --- Progress bar --- */
.vis-progress {
  width: min(280px, 62vw); height: 2px; margin-top: .7rem;
  flex-shrink: 0;
  background: rgba(42,29,19,.12); border-radius: 1px; overflow: hidden;
}
.vis-progress-fill { height: 100%; width: 0%; background: var(--oro); }

/* --- Scroll hint — fluttuante, non occupa spazio nel flusso --- */
.vis-hint {
  position: absolute; bottom: 96px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  font-family: var(--sans); font-size: .55rem; letter-spacing: .2em;
  text-transform: uppercase; color: rgba(42,29,19,.35);
  transition: opacity .4s ease; pointer-events: none; z-index: 3;
}
.vis-hint-line {
  width: 1px; height: 20px;
  background: linear-gradient(to bottom, rgba(42,29,19,.35), transparent);
  animation: scrollBounce 2s ease infinite;
}

/* --- Dock: carosello + bottone esci --- */
.vis-dock {
  position: relative;
  display: flex; flex-direction: row; align-items: center; justify-content: center;
  margin-top: .5rem; width: 100%; flex-shrink: 0;
  transition: opacity .4s ease;
}
.vis-dock.dim { opacity: .55; }

.vis-carousel-wrap {
  order: 2;
  display: flex; align-items: center; gap: .5rem;
  max-width: min(720px, 76vw);
}

.vis-carousel {
  display: flex; gap: .6rem;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding: 4px 2px;
}
.vis-carousel::-webkit-scrollbar { display: none; }

.vis-thumb {
  flex: 0 0 56px; height: 68px; scroll-snap-align: center;
  background: #fff; border: 1px solid rgba(42,29,19,.12);
  border-radius: 2px; cursor: pointer; padding: 0;
  position: relative; overflow: hidden;
  transition: border-color .35s ease, transform .35s ease, box-shadow .35s ease;
}
.vis-thumb img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  opacity: .55; transition: opacity .35s ease;
}
.vis-thumb:hover img { opacity: .85; }
.vis-thumb.active {
  border-color: var(--oro);
  box-shadow: 0 2px 14px rgba(196,154,108,.28);
}
.vis-thumb.active img { opacity: 1; }

.vis-arrow {
  display: none;
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid rgba(42,29,19,.18); background: transparent;
  color: var(--terra2); font-family: var(--sans); font-size: 1rem; line-height: 1;
  align-items: center; justify-content: center;
  cursor: pointer; transition: all .3s ease;
}
.vis-arrow:hover { border-color: var(--oro); color: var(--oro); }

.vis-carousel-wrap.scrollable .vis-arrow { display: flex; }

/* --- Exit button --- */
.vis-exit {
  position: absolute; right: max(2rem, 4vw); top: 50%; transform: translateY(-50%);
  font-family: var(--sans); font-size: .52rem; letter-spacing: .18em;
  text-transform: uppercase; color: rgba(42,29,19,.4);
  background: transparent; border: 1px solid rgba(42,29,19,.15);
  padding: .6rem 1.5rem; border-radius: 2px; cursor: pointer;
  transition: all .45s ease;
}
.vis-exit:hover { color: var(--terra); border-color: rgba(42,29,19,.4); }
.vis-exit.ready {
  color: var(--avorio); background: var(--cuoio); border-color: var(--cuoio);
}
.vis-exit.ready:hover { background: var(--terra); border-color: var(--terra); color: var(--avorio); }

/* === RESPONSIVE === */

/* Tablet e portatili stretti: a destra il bottone esci coprirebbe le ultime
   miniature, quindi scende sotto il carosello */
@media (max-width: 1079px) {
  .vis-dock { flex-wrap: wrap; gap: .5rem .8rem; }
  .vis-carousel-wrap { order: 1; flex: 0 0 100%; justify-content: center; }
  .vis-exit { position: static; transform: none; order: 2; }
  .vis-hint { bottom: 132px; }
}

/* Mobile */
@media (max-width: 768px) {
  .vis-runway { height: 340vh; }
  .vis-pinned { padding-bottom: 1.4rem; }
  .vis-progress { margin-top: .5rem; }
  .vis-hint { bottom: 128px; font-size: .5rem; }
  .vis-arrow { display: none; }
  .vis-dock { gap: .45rem .8rem; margin-top: .4rem; }
  .vis-carousel-wrap { max-width: 100%; }

  /* Tutte e 8 le miniature visibili: si dividono la larghezza dello schermo */
  .vis-carousel { gap: 3px; padding: 3px 6px; overflow-x: visible; width: 100%; }
  .vis-thumb { flex: 1 1 0; min-width: 0; height: 58px; }

  .vis-exit { font-size: .48rem; padding: .55rem 1.2rem; }
}

/* Schermi molto stretti: recupero spazio per il tap */
@media (max-width: 360px) {
  .vis-carousel { gap: 2px; padding: 3px 4px; }
}
