/* =============================================================================
   STREET BARBER'S STUDIO — hero.css
   Le cinque versioni dell'hero pilotato dallo scroll.
   Ogni blocco di testo riceve --b (da 0 a 1) e --dir (1 entra, -1 esce):
   qui si decide soltanto come tradurli in movimento.
   ========================================================================== */

.hx {
  --p: 0;
  position: relative;
  height: 320vh;
  margin-top: calc(var(--head-h) * -1);
}
.hx__stage {
  position: sticky; top: 0;
  height: 100svh;
  overflow: clip; isolation: isolate;
  background: #0b0b0c;
}
.hx__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* velo: tiene leggibile il testo sopra le parti chiare del filmato */
.hx__veil {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    linear-gradient(90deg, rgba(6,6,8,.9) 0%, rgba(6,6,8,.55) 42%, transparent 72%),
    linear-gradient(180deg, rgba(6,6,8,.75), transparent 26%, transparent 64%, rgba(6,6,8,.92));
}

/* barra di caricamento dei fotogrammi, sparisce da sola */
.hx__bar {
  position: absolute; inset: auto 0 0 0; height: 2px; z-index: 5;
  background: rgba(255,255,255,.08);
  transition: opacity .5s var(--e-out) .2s;
}
.hx__bar i {
  display: block; height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: var(--gold-lt);
}
.hx.is-loaded .hx__bar { opacity: 0; }

/* ------------------------------ i blocchi di testo ----------------------- */
.hx__beats {
  position: absolute; inset: 0; z-index: 2;
  display: grid; align-content: center;
  width: var(--wrap); margin-inline: auto;
  pointer-events: none;
}
.hx__beat, .hv .hx__beat { color: #fff; }
.hx__beat .display, .hx__beat .h1, .hx__beat .h2 { color: #fff; }
.hx__beat p:not(.eyebrow):not(.kicker) { color: rgba(255,255,255,.76) !important; }
.hx__beat .kicker { color: rgba(255,255,255,.72); }
.hx__beat .eyebrow { color: var(--gold-lt); }
.hx__beat .eyebrow::before { background: var(--gold-lt); }
.hx__beat .btn--primary { background: #fff; border-color: #fff; color: var(--ink); }
.hx__beat .btn--primary:hover { background: var(--gold); border-color: var(--gold); color: #fff; }
.hx__beat .btn--ghost { color: #fff; border-color: rgba(255,255,255,.4); }
.hx__beat .btn--ghost:hover { border-color: #fff; background: rgba(255,255,255,.1); color: #fff; }
.hx__beat {
  grid-area: 1 / 1;
  display: grid; gap: clamp(12px, 1.6vw, 20px); justify-items: start;
  max-width: 640px;
  opacity: var(--b, 0);
  will-change: opacity, transform;
}
.hx__beat.is-off { visibility: hidden; }
.hx__beat > * { pointer-events: auto; }
.hx__beat .display { max-width: none; font-size: clamp(1.75rem, 3.7vw, 3.1rem); }
.hx__beat p:not(.eyebrow):not(.kicker) { color: var(--txt-dim); max-width: 42ch; }
.hx__cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }

/* scorrimento indice del filmato, in basso a destra */
.hx__count {
  position: absolute; right: clamp(16px, 3vw, 44px); bottom: clamp(18px, 3vh, 34px);
  z-index: 3;
  font: 500 .6rem/1 var(--f-mono); letter-spacing: .28em; text-transform: uppercase;
  color: var(--txt-mute);
  display: flex; align-items: center; gap: 12px;
}
.hx__count b { color: var(--gold); font-weight: 500; }
/* nelle pagine di prova la striscia in basso occupa il posto */
body:has(.lab) .hx__count, body:has(.lab) .hx__hint { bottom: 76px; }
.hx__count span {
  width: 60px; height: 1px; background: rgba(255,255,255,.16); position: relative; overflow: hidden;
}
.hx__count span::after {
  content: ""; position: absolute; inset: 0; background: var(--gold);
  transform: scaleX(var(--p)); transform-origin: 0 50%;
}

/* invito a scorrere, solo all'inizio */
.hx__hint {
  position: absolute; left: 50%; translate: -50% 0; bottom: clamp(18px, 3vh, 34px);
  z-index: 3;
  display: grid; justify-items: center; gap: 8px;
  font: 500 .58rem/1 var(--f-mono); letter-spacing: .3em; text-transform: uppercase;
  color: var(--txt-mute);
  opacity: clamp(0, calc(1 - var(--p) * 12), 1);
}
.hx__hint i {
  display: block; width: 1px; height: 34px; background: rgba(255,255,255,.2);
  position: relative; overflow: hidden;
}
.hx__hint i::after {
  content: ""; position: absolute; inset: 0; background: var(--gold);
  animation: hintRun 2.2s var(--e-in-out) infinite;
}
@keyframes hintRun { 0% { transform: translateY(-100%); } 60%, 100% { transform: translateY(100%); } }

/* ========================================================================== */
/* V1 · RACCONTO — i testi salgono ed escono verso l'alto                     */
/* ========================================================================== */
[data-hero="v1"] .hx__beat {
  transform: translateY(calc((1 - var(--b)) * var(--dir, 1) * 42px));
}

/* ========================================================================== */
/* V2 · SOBRIO — nessun movimento, solo dissolvenza                           */
/* ========================================================================== */
[data-hero="v2"] .hx__beat { transform: none; }
[data-hero="v2"] .hx__veil {
  background:
    linear-gradient(90deg, rgba(6,6,8,.92) 0%, rgba(6,6,8,.6) 46%, transparent 76%),
    linear-gradient(180deg, rgba(6,6,8,.6), transparent 30%, transparent 70%, rgba(6,6,8,.9));
}

/* ========================================================================== */
/* V3 · LAMA — il testo viene tagliato in due e le meta' si separano          */
/* ========================================================================== */
[data-hero="v3"] .hx__beat { transform: none; }
[data-hero="v3"] .cutline { position: relative; display: grid; }
[data-hero="v3"] .cutline > span {
  grid-area: 1 / 1;
  display: block;
  transition: none;
}
/* meta' alta e meta' bassa della stessa riga: si allontanano mentre esce */
[data-hero="v3"] .cutline > span:nth-child(1) {
  clip-path: inset(0 0 50% 0);
  transform: translateY(calc((1 - var(--b)) * -34px));
}
[data-hero="v3"] .cutline > span:nth-child(2) {
  clip-path: inset(50% 0 0 0);
  transform: translateY(calc((1 - var(--b)) * 34px));
}
/* filo dorato che passa nel punto del taglio */
[data-hero="v3"] .cutline::after {
  content: ""; position: absolute; left: -6%; right: -6%; top: 46%;
  height: 1px; background: var(--gold-lt);
  opacity: calc(1 - var(--b));
  transform: scaleX(calc(.2 + var(--b) * .8));
}

/* ========================================================================== */
/* V4 · RIENTRO — la scena si ritira in un riquadro e libera la colonna       */
/* ========================================================================== */
[data-hero="v4"] .hx__stage { padding: 0; }
[data-hero="v4"] .hx__frame {
  position: absolute; z-index: 0;
  inset: calc(var(--k) * 12vh) calc(var(--k) * 5vw) calc(var(--k) * 12vh) calc(var(--k) * 46vw);
  --k: clamp(0, calc((var(--p) - .5) / .34), 1);
  border-radius: calc(var(--k) * 10px);
  overflow: clip;
  box-shadow: 0 0 0 calc(var(--k) * 1px) rgba(255,255,255,.14);
}
[data-hero="v4"] .hx__canvas { position: absolute; inset: 0; }
[data-hero="v4"] .hx__veil {
  --k: clamp(0, calc((var(--p) - .5) / .34), 1);
  background:
    linear-gradient(90deg, rgba(6,6,8,calc(.9 - var(--k) * .9)) 0%, rgba(6,6,8,calc(.55 - var(--k) * .55)) 42%, transparent 72%),
    linear-gradient(180deg, rgba(6,6,8,.7), transparent 28%, transparent 66%, rgba(6,6,8,calc(.9 - var(--k) * .5)));
}
[data-hero="v4"] .hx__beat { transform: translateY(calc((1 - var(--b)) * var(--dir, 1) * 30px)); }

/* ========================================================================== */
/* V5 · SENZA SCROLL — il filmato parte da solo, i testi seguono il tempo     */
/* ========================================================================== */
.hv { position: relative; height: 100svh; margin-top: calc(var(--head-h) * -1); overflow: clip; }
.hv__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 55% 45%; }
.hv .hx__veil { z-index: 1; }
.hv__beats {
  position: absolute; inset: 0; z-index: 2;
  display: grid; align-content: center;
  width: var(--wrap); margin-inline: auto;
}
.hv .hx__beat { transform: translateY(calc((1 - var(--b)) * 26px)); }

/* ============================== responsive =============================== */
@media (max-width: 999px) {
  .hx { height: 300vh; }
  .hx__beat { max-width: none; }
  .hx__beats { align-content: end; padding-bottom: clamp(56px, 12vh, 110px); }
  .hx__veil {
    background:
      linear-gradient(180deg, rgba(6,6,8,.72), transparent 24%, rgba(6,6,8,.72) 58%, rgba(6,6,8,.96));
  }
  [data-hero="v4"] .hx__frame { inset: 0 !important; border-radius: 0; box-shadow: none; }
  .hx__count { display: none; }
}

/* ============================== movimento ridotto ======================== */
@media (prefers-reduced-motion: reduce) {
  .hx { height: auto; margin-top: 0; }
  .hx__stage { position: static; height: auto; min-height: 100svh; }
  .hx__beats { position: static; padding-block: calc(var(--head-h) + 40px) 60px; gap: 40px; }
  .hx__beat { grid-area: auto; opacity: 1 !important; transform: none !important; visibility: visible !important; }
  .hx__bar, .hx__hint, .hx__count { display: none; }
  [data-hero="v3"] .cutline > span { clip-path: none; transform: none; }
  [data-hero="v3"] .cutline > span:nth-child(2) { display: none; }
  [data-hero="v3"] .cutline::after { display: none; }
}

/* ============================== barra di scelta ========================== */
/* striscia presente solo nelle pagine di prova, per saltare da una all'altra */
.lab {
  position: fixed; inset: auto 0 0 0; z-index: 90;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  font: 500 .6rem/1 var(--f-mono); letter-spacing: .16em; text-transform: uppercase;
}
.lab a {
  padding: 9px 13px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--txt-mute);
  transition: color var(--t-fast) linear, border-color var(--t-fast) linear;
}
.lab a:hover { color: var(--ink); border-color: var(--line-2); }
.lab a.is-here { color: #14100a; background: var(--gold-lt); border-color: transparent; }
.lab b { color: var(--txt-mute); font-weight: 500; margin-right: 8px; }
@media (max-width: 620px) { .lab b { display: none; } .lab a { padding: 9px 10px; } }
