/* ---------------------------------------------------------------
   Hero 3D — La Boutique del Sorriso
   Mappa blueprint a tutto schermo, sempre interamente visibile.
--------------------------------------------------------------- */

#hero3d {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  background: #F7F6F2; /* un solo colore: niente che distragga dalla sede */
  overflow: hidden;
  isolation: isolate;
}

/* Raggi di luce che attraversano la scena (come adidas arena) */
.hero3d-rays {
  position: absolute;
  inset: -20% -10%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.4s ease 0.6s;
  background:
    linear-gradient(115deg, transparent 0 22%, rgba(255, 255, 255, 0.55) 26%, transparent 34%),
    linear-gradient(115deg, transparent 0 40%, rgba(255, 255, 255, 0.4) 43%, transparent 49%),
    linear-gradient(115deg, transparent 0 63%, rgba(255, 255, 255, 0.5) 66%, transparent 73%);
  mix-blend-mode: soft-light;
  animation: rays 14s ease-in-out infinite alternate;
}
#hero3d.is-loaded .hero3d-rays { opacity: 1; }
@keyframes rays {
  from { transform: translateX(-4%); }
  to { transform: translateX(4%); }
}
.hero3d-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(130% 95% at 50% 50%, transparent 60%, rgba(16, 40, 58, 0.07) 100%);
}

#hero3d-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 1200ms ease;
  cursor: grab;
}
#hero3d-canvas:active { cursor: grabbing; }
#hero3d-canvas.is-visible { opacity: 1; }
/* Anteprima della mappa (immagine leggera) mentre il 3D carica: poi sfuma */
.hero3d-poster {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #F7F6F2 url('/assets/images/hero-poster-desktop.webp') center / cover no-repeat;
  transition: opacity 1400ms ease;
  pointer-events: none;
}
@media (max-aspect-ratio: 1/1) {
  .hero3d-poster { background-image: url('/assets/images/hero-poster-mobile.webp'); }
}
#hero3d.is-loaded .hero3d-poster { opacity: 0; }
#hero3d-canvas canvas { display: block; touch-action: pan-y; }

/* ---------------------------------------------------------------
   Pin: etichetta + asta + punto (il punto sta ESATTAMENTE sul luogo)
--------------------------------------------------------------- */
#hero3d-hotspots, #hero3d-landmarks {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
#hero3d-landmarks { z-index: 3; opacity: 0; transition: opacity 1.4s ease; }
#hero3d-landmarks.is-visible { opacity: 1; }

.hero3d-pin {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  text-decoration: none;
  transform: translate3d(-9999px, -9999px, 0);
  will-change: transform;
  transition: opacity 250ms ease;
  pointer-events: auto;
}
.hero3d-pin > * {
  position: absolute;
  /* l'asta cambia lunghezza per evitare sovrapposizioni */
  left: 0;
  opacity: 0;
  transition: opacity 500ms ease var(--d, 0ms), transform 700ms cubic-bezier(0.22, 1, 0.36, 1) var(--d, 0ms);
}
#hero3d-hotspots.is-visible .hero3d-pin > * { opacity: 1; }

.hero3d-pin__dot {
  top: -6px;
  left: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #009EE3;
  box-shadow: 0 0 0 4px rgba(0, 158, 227, 0.18);
}
.hero3d-pin__dot::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 158, 227, 0.55);
  animation: hero3d-pulse 2.4s ease-out infinite;
}
@keyframes hero3d-pulse {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}
.hero3d-pin__stem {
  bottom: 4px;
  left: -0.5px;
  width: 1px;
  height: var(--stem, 34px);
  background: linear-gradient(to top, #009EE3, rgba(0, 158, 227, 0.2));
  transform-origin: bottom;
  transform: scaleY(0);
}
#hero3d-hotspots.is-visible .hero3d-pin__stem { transform: scaleY(1); }
.hero3d-pin__label {
  bottom: calc(var(--stem, 34px) + 4px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border-radius: 999px;
  background: rgba(253, 252, 250, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 158, 227, 0.3);
  white-space: nowrap;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #10283A;
  transform: translate(-50%, 10px);
  transition-property: opacity, transform, background, color;
  box-shadow: 0 10px 30px rgba(16, 40, 58, 0.08);
}
#hero3d-hotspots.is-visible .hero3d-pin__label { transform: translate(-50%, 0); }
.hero3d-pin__label i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #009EE3;
}
.hero3d-pin__label b {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #009EE3;
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.hero3d-pin:hover .hero3d-pin__label { background: #10283A; color: #fff; border-color: #10283A; }
.hero3d-pin:hover .hero3d-pin__label i { color: #7fd0f3; }
.hero3d-pin:hover { z-index: 2; }

/* Etichette di paesaggio (Monte Berico, centro storico…) */
.hero3d-landmark {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform: translate3d(-9999px, -9999px, 0);
  will-change: transform;
}
.hero3d-landmark span {
  position: absolute;
  bottom: 22px;
  left: 0;
  transform: translateX(-50%);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(16, 40, 58, 0.55);
  white-space: nowrap;
}
.hero3d-landmark i {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 18px;
  background: rgba(16, 40, 58, 0.3);
}

/* ---------------------------------------------------------------
   UI in basso: tab delle zone, suggerimento drag, invito allo scroll
--------------------------------------------------------------- */
.hero3d-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
  padding: 0 var(--gutter, 24px) 24px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s ease 1.6s, transform 1.2s cubic-bezier(0.22, 1, 0.36, 1) 1.6s;
}
#hero3d.is-loaded .hero3d-ui { opacity: 1; transform: none; }
.hero3d-ui > * { pointer-events: auto; }

#hero3d-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid rgba(16, 40, 58, 0.14);
  border-radius: 14px;
  background: rgba(253, 252, 250, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 4px;
  width: fit-content;
}
.hero3d-tab {
  border: 0;
  background: transparent;
  padding: 9px 14px;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5B6B78;
  cursor: pointer;
  transition: background 300ms ease, color 300ms ease;
}
.hero3d-tab:hover { color: #10283A; }
.hero3d-tab.is-active { background: #10283A; color: #fff; }

#hero3d-drag-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #10283A;
  opacity: 0;
  transition: opacity 600ms ease;
  pointer-events: none;
}
#hero3d-drag-hint.is-visible { opacity: 1; }
#hero3d-drag-hint svg { width: 64px; height: 28px; color: #009EE3; }
#hero3d-drag-hint .hand { animation: hand 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes hand {
  0%, 100% { transform: translateX(-9px); }
  50% { transform: translateX(9px); }
}

.hero3d-scroll {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #10283A;
}
.hero3d-scroll span:last-child {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #009EE3;
  color: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hero3d-scroll svg { width: 18px; height: 18px; animation: arrow 1.8s cubic-bezier(0.65, 0, 0.35, 1) infinite; }
@keyframes arrow {
  0% { transform: translateY(-140%); }
  50% { transform: translateY(0); }
  100% { transform: translateY(140%); }
}

/* Info in alto a sinistra sotto la nav */
.hero3d-meta {
  position: absolute;
  top: 92px;
  left: var(--gutter, 24px);
  z-index: 5;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(16, 40, 58, 0.55);
  line-height: 1.9;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease 2s;
}
.hero3d-meta b { color: #009EE3; font-weight: 800; }
.hero3d-meta a { color: inherit; text-decoration: none; pointer-events: auto; transition: color 0.2s; }
.hero3d-meta a:hover { color: #009EE3; }
.hero3d-landmark--link span { pointer-events: auto; cursor: pointer; transition: color 0.2s; }
.hero3d-landmark--link:hover span { color: #009EE3; }
#hero3d.is-loaded .hero3d-meta { opacity: 1; }

/* ---------------------------------------------------------------
   Loader con contatore
--------------------------------------------------------------- */
#hero3d-loader {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 100px var(--gutter, 24px) 28px;
  background: rgba(247, 246, 242, 0.55);
  transition: opacity 900ms ease 200ms, visibility 0s 1.2s;
}
#hero3d-loader.is-done { opacity: 0; visibility: hidden; }
.hero3d-loader__center {
  align-self: center;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  color: #10283A;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hero3d-loader__center svg { width: 58px; height: 58px; color: #009EE3; }
.hero3d-loader__center svg path {
  stroke-dasharray: 260;
  stroke-dashoffset: 260;
  animation: draw 2.2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes draw {
  0% { stroke-dashoffset: 260; }
  55% { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -260; }
}
.hero3d-loader__bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}
.hero3d-loader__track {
  flex: 1;
  height: 1px;
  background: rgba(16, 40, 58, 0.14);
  margin-bottom: 18px;
  overflow: hidden;
}
#hero3d-bar {
  display: block;
  height: 100%;
  background: #009EE3;
  transform-origin: left;
  transform: scaleX(0);
}
#hero3d-count {
  font-size: clamp(72px, 14vw, 200px);
  line-height: 0.8;
  font-weight: 500;
  letter-spacing: -0.06em;
  color: #10283A;
  font-variant-numeric: tabular-nums;
}

.hero3d-error { font-size: 13px; color: #b4005f; margin: auto; }

#hero3d-calibrate-readout {
  display: none;
  position: absolute;
  left: 16px;
  bottom: 90px;
  z-index: 9;
  font-family: monospace;
  font-size: 12px;
  background: #10283A;
  color: #009EE3;
  padding: 8px 12px;
  border-radius: 8px;
}

@media (max-width: 760px) {
  .hero3d-ui { grid-template-columns: 1fr auto; padding-bottom: 16px; }
  #hero3d-tabs { grid-column: 1 / -1; order: 3; display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 100%; }
  .hero3d-tab { white-space: nowrap; padding: 9px 8px; font-size: 10px; text-align: center; }
  #hero3d-drag-hint { justify-self: start; }
  .hero3d-scroll > span:first-child { display: none; }
  .hero3d-scroll span:last-child { width: 44px; height: 44px; }
  .hero3d-pin__label { font-size: 11px; padding: 5px 6px 5px 10px; gap: 6px; }
  .hero3d-pin__label b { width: 18px; height: 18px; font-size: 10px; }
  .hero3d-meta { top: 72px; font-size: 9px; }
  .hero3d-landmark span { font-size: 8px; }
}

/* ---------------------------------------------------------------
   Fallback senza WebGL: solo link
--------------------------------------------------------------- */
#hero3d.hero3d--fallback { height: auto; min-height: 0; padding-top: 90px; }
#hero3d.hero3d--fallback #hero3d-hotspots { position: static; pointer-events: auto; }
.hero3d-fallback-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 28px 20px;
}
.hero3d-fallback-link {
  font-size: 14px;
  font-weight: 600;
  color: #10283A;
  background: #fff;
  border: 1px solid rgba(0, 158, 227, 0.35);
  padding: 10px 18px;
  border-radius: 999px;
  text-decoration: none;
}
