/*
  Home — hero "Livrea '90", "Chi siamo", diario fotografico e caroselli
  (solo index.html).

  Regole:
  - si carica dopo eventi.css/contatti.css e PRIMA di design-refinements.css,
    che resta l'ultimo foglio: token (colori, font, easing), bottoni,
    wordmark e header condivisi stanno lì;
  - la hero usa classi nuove (.hero-*), così le vecchie regole .main-banner
    di main.css/eventi.css non la toccano;
  - la sequenza d'ingresso vale solo sotto html.js (classe aggiunta da uno
    script inline nel <head>) e parte quando custom.js aggiunge .is-ready:
    senza JavaScript la hero si vede completa e ferma;
  - il parallasse legge --hero-progress (scroll, 0→1) e --hero-px/--hero-py
    (puntatore, -1→1), aggiornate da custom.js; con reduced motion restano a 0.
  - si animano solo transform, opacity e clip-path.
*/

/* ---------------------------------------------
   1. Hero: struttura e livelli
--------------------------------------------- */
.hero {
  --hero-progress: 0;
  --hero-px: 0;
  --hero-py: 0;
  --intro: running;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background-color: var(--color-bg);
  color: var(--color-text);
}

/* In attesa della foto le animazioni d'ingresso restano ferme sul primo
   fotogramma; .is-ready (custom.js) le fa partire tutte insieme. */
.js .hero {
  --intro: paused;
}

.js .hero.is-ready,
.js.hero-fallback .hero {
  --intro: running;
}

/* Foto: un <img> invece del vecchio background CSS, così può muoversi in
   parallasse e conta come LCP. Il contenitore fa lo zoom d'ingresso, l'img
   il parallasse: due transform separati che non si sovrascrivono. */
.hero-media {
  position: absolute;
  inset: 0;
  z-index: -3;
  overflow: hidden;
}

.hero-media img {
  position: absolute;
  top: -6%;
  left: -3%;
  width: 106%;
  height: 112%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 42%;
  filter: saturate(0.92) contrast(1.06) brightness(0.86);
  transform: translate3d(calc(var(--hero-px) * -14px), calc(var(--hero-progress) * 20vh + var(--hero-py) * -10px), 0)
    scale(calc(1.02 + var(--hero-progress) * 0.08));
  will-change: transform;
}

/* Ombra: scura a sinistra (dove sta il testo) e in basso (dove la hero
   si fonde con la sezione successiva). */
.hero-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(11, 11, 12, 0.95) 0%, rgba(11, 11, 12, 0.82) 30%, rgba(11, 11, 12, 0.42) 62%, rgba(11, 11, 12, 0.55) 100%),
    linear-gradient(0deg, var(--color-bg) 0%, rgba(11, 11, 12, 0) 42%),
    linear-gradient(180deg, rgba(11, 11, 12, 0.72) 0%, rgba(11, 11, 12, 0) 24%);
}

/* Sipario d'avvio: un pannello carbonio che si ritira verso destra come
   una tendina, scoprendo la foto. A riposo è già ritirato (no-JS). */
.hero-shade::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--color-bg);
  clip-path: inset(0 0 0 100%);
}

/* Livrea: tre fasce verde / avorio / rosso che salgono in diagonale verso
   destra, come le grafiche sulle carene delle 125 anni '90 nella foto. */
.hero-livery {
  position: absolute;
  z-index: -1;
  right: -10vw;
  bottom: clamp(90px, 15vh, 170px);
  width: min(66vw, 1060px);
  display: flex;
  flex-direction: column;
  gap: clamp(7px, 0.9vw, 14px);
  pointer-events: none;
  transform-origin: 100% 50%;
  transform: translate3d(calc(var(--hero-px) * 22px), calc(var(--hero-progress) * -34vh + var(--hero-py) * 12px), 0) rotate(-21deg);
}

.hero-livery span {
  display: block;
  height: clamp(14px, 2.6vw, 40px);
  background: var(--color-green);
  transform-origin: left center;
  clip-path: polygon(3% 0, 100% 0, 100% 100%, 0 100%);
}

.hero-livery span:nth-child(2) {
  margin-left: 7%;
  background: var(--color-white);
}

.hero-livery span:nth-child(3) {
  margin-left: 14%;
  background: var(--color-red);
}

/* "125" gigante a contorno: il numero di gara della livrea. */
.hero-number {
  position: absolute;
  z-index: -1;
  top: 50%;
  right: -0.03em;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(190px, 36vw, 620px);
  line-height: 0.8;
  letter-spacing: -0.02em;
  /* Fondo scuro traslucido + contorno: sulla foto, piena di dettagli, il
     solo contorno sparirebbe; così il numero si legge come un'ombra. */
  color: rgba(11, 11, 12, 0.38);
  -webkit-text-stroke: 2px rgba(243, 239, 230, 0.6);
  pointer-events: none;
  user-select: none;
  transform: translate3d(calc(var(--hero-px) * 30px), calc(-58% + var(--hero-progress) * 14vh + var(--hero-py) * 18px), 0);
}

/* ---------------------------------------------
   2. Hero: contenuti
--------------------------------------------- */
.hero-inner {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: clamp(22px, 4vh, 40px);
  padding-bottom: clamp(96px, 15vh, 150px);
  transform: translate3d(0, calc(var(--hero-progress) * -12vh), 0);
  opacity: calc(1 - var(--hero-progress) * 1.5);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.hero .hero-wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(21px, 2vw, 28px);
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-white);
}

.hero-body {
  margin-top: auto;
  margin-bottom: auto;
  padding-top: clamp(40px, 8vh, 90px);
}

.hero .caption-kicker {
  display: block;
  margin: 0 0 clamp(16px, 2.4vh, 26px);
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-green-light);
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(40px, 15vw, 184px);
  line-height: 0.86;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  color: var(--color-text);
}

/* Ogni riga è una maschera: il testo sale da sotto il bordo. Il padding a
   destra lascia spazio all'inclinazione del corsivo. */
.hero-line {
  display: block;
  overflow: hidden;
  padding: 0.02em 0.14em 0.03em 0;
  margin-bottom: -0.03em;
}

.hero-line > span {
  display: inline-block;
}

/* "UN'EPOCA": prima solo il contorno, poi una copia piena in tricolore
   (::after, nascosta alle tecnologie assistive) si scopre da sinistra. */
.hero-outline {
  position: relative;
  display: inline-block;
  color: transparent;
  -webkit-text-stroke: max(1.5px, 0.012em) var(--color-text);
}

.hero-outline::after {
  content: attr(data-text);
  content: attr(data-text) / "";
  position: absolute;
  inset: 0;
  -webkit-text-stroke: 0;
  background: var(--tricolore);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  clip-path: inset(0 0 0 0);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(18px, 3vw, 40px);
  margin-top: clamp(28px, 5vh, 52px);
}

.hero .main-button-green a {
  font-size: 17px;
  padding: 19px 30px 19px 32px;
}

/* Indicatore di scroll a linea, in basso al centro. */
.hero-scroll-cue {
  position: absolute;
  left: 50%;
  bottom: clamp(26px, 5vh, 48px);
  z-index: 1;
  width: 1px;
  height: 46px;
  overflow: hidden;
  background: rgba(243, 239, 230, 0.2);
  pointer-events: none;
}

.hero-scroll-cue span {
  display: block;
  width: 100%;
  height: 40%;
  background: var(--color-text);
  animation: hero-cue 1.9s var(--ease-out-expo) infinite;
}

.hero.is-offscreen .hero-scroll-cue span {
  animation-play-state: paused;
}

/* ---------------------------------------------
   3. Hero: sequenza d'ingresso (~2,2 s)
   Ogni animazione parte ferma (--intro: paused) e riempie all'indietro,
   quindi gli elementi aspettano nello stato iniziale finché la foto è
   pronta. Le proprietà individuali translate/scale si sommano ai
   transform del parallasse invece di sostituirli.
--------------------------------------------- */
.js .hero .hero-shade::after {
  animation: hero-curtain 1200ms var(--ease-out-expo) 0ms both var(--intro);
}

.js .hero .hero-media {
  animation: hero-zoom 2200ms var(--ease-out-expo) 0ms both var(--intro);
}

.js .hero .hero-livery span {
  animation: hero-stripe 1100ms var(--ease-out-expo) 260ms both var(--intro);
}

.js .hero .hero-livery span:nth-child(2) {
  animation-delay: 350ms;
}

.js .hero .hero-livery span:nth-child(3) {
  animation-delay: 440ms;
}

.js .hero .hero-number {
  animation: hero-number 1600ms var(--ease-out-expo) 320ms both var(--intro);
}

.js .hero .hero-top {
  animation: hero-fade-down 900ms var(--ease-out-expo) 420ms both var(--intro);
}

.js .hero .caption-kicker {
  animation: hero-fade-up 900ms var(--ease-out-expo) 520ms both var(--intro);
}

.js .hero .hero-line > span {
  animation: hero-line-up 1150ms var(--ease-out-expo) 600ms both var(--intro);
}

.js .hero .hero-line:nth-child(2) > span {
  animation-delay: 720ms;
}

.js .hero .hero-outline::after {
  animation: hero-fill 1100ms var(--ease-out-expo) 1350ms both var(--intro);
}

.js .hero .hero-actions {
  animation: hero-fade-up 900ms var(--ease-out-expo) 1100ms both var(--intro);
}

@keyframes hero-curtain {
  from {
    clip-path: inset(0 0 0 0);
  }
  to {
    clip-path: inset(0 0 0 100%);
  }
}

@keyframes hero-zoom {
  from {
    transform: scale(1.18);
  }
  to {
    transform: none;
  }
}

@keyframes hero-stripe {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes hero-number {
  from {
    opacity: 0;
    translate: 9vw 0;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes hero-fade-up {
  from {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-fade-down {
  from {
    opacity: 0;
    transform: translate3d(0, -16px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes hero-line-up {
  from {
    transform: translate3d(0, 112%, 0) skewY(5deg);
  }
  to {
    transform: none;
  }
}

@keyframes hero-fill {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes hero-cue {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(260%);
  }
}

/* ---------------------------------------------
   4. Hero: tablet e telefoni
--------------------------------------------- */
@media (max-width: 991px) {
  .hero-livery {
    right: -24vw;
    width: 96vw;
    bottom: clamp(90px, 14vh, 150px);
  }

  .hero-number {
    top: 40%;
    font-size: clamp(170px, 46vw, 380px);
  }
}

@media (max-width: 575.98px) {
  .hero-shade {
    background:
      linear-gradient(90deg, rgba(11, 11, 12, 0.9) 0%, rgba(11, 11, 12, 0.6) 100%),
      linear-gradient(0deg, var(--color-bg) 0%, rgba(11, 11, 12, 0) 45%),
      linear-gradient(180deg, rgba(11, 11, 12, 0.72) 0%, rgba(11, 11, 12, 0) 24%);
  }

  .hero-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .hero-number {
    top: 34%;
    -webkit-text-stroke-width: 1px;
  }

  .hero-livery {
    bottom: 96px;
    opacity: 0.85;
  }

  .hero .main-button-green a {
    font-size: 15px;
    padding: 17px 24px 17px 26px;
  }
}

/* ---------------------------------------------
   5. Chi siamo: la frase che prima stava nella hero, in grande.
   custom.js divide il testo in parole e le "accende" mentre la sezione
   scorre (.is-scrubbing / .is-lit); senza JS o con reduced motion il
   testo è subito pieno.
--------------------------------------------- */
.chi-siamo {
  position: relative;
  padding: clamp(96px, 13vw, 200px) 0 clamp(64px, 8vw, 120px);
  background-color: var(--color-bg);
}

.chi-siamo-grid {
  display: grid;
  grid-template-columns: minmax(150px, 3fr) 9fr;
  gap: clamp(28px, 5vw, 80px);
  align-items: start;
}

.chi-siamo-label {
  position: sticky;
  top: 110px;
}

/* "Chi siamo": piccola etichetta mono accanto alla frase in grande. */
.chi-siamo .chi-siamo-label h2 {
  margin: 0;
  padding: 0;
  border: 0;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--color-text-3);
}

.chi-siamo .chi-siamo-text {
  margin: 0;
  max-width: 24ch;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: clamp(27px, 3.9vw, 60px);
  line-height: 1.14;
  letter-spacing: -0.028em;
  color: var(--color-text);
}

.chi-siamo .chi-siamo-text b {
  font-weight: 700;
  color: var(--color-green-light);
}

.chi-siamo-text.is-scrubbing .word {
  color: rgba(243, 239, 230, 0.16);
  transition: color 450ms var(--ease-standard);
}

.chi-siamo-text.is-scrubbing .word.is-lit {
  color: var(--color-text);
}

.chi-siamo-text.is-scrubbing b .word.is-lit {
  color: var(--color-green-light);
}

/* Stampa, alto contrasto e colori forzati: testo subito pieno. */
@media print, (prefers-contrast: more), (forced-colors: active) {
  .chi-siamo-text.is-scrubbing .word {
    color: inherit;
  }
}

@media (max-width: 767px) {
  .chi-siamo-grid {
    grid-template-columns: 1fr;
  }

  .chi-siamo-label {
    position: static;
  }

  .chi-siamo .chi-siamo-text {
    max-width: none;
  }
}


/* ---------------------------------------------
   6. Caroselli di foto: diario (subito dopo la hero) e Padova Moto Days 2026
   File di card 16:9 che scorrono all'infinito, in direzioni opposte.
   custom.js duplica le card (le copie sono aria-hidden e fuori dal Tab),
   regola la durata sulla lunghezza della fila e aggiunge .is-looping.
   Senza JS o con reduced motion la fila resta ferma e si scorre a mano.
--------------------------------------------- */
.diario {
  position: relative;
  padding-bottom: clamp(56px, 7vw, 104px);
  background-color: var(--color-bg);
}

/* Ordine della home: hero -> caroselli eventi -> countdown -> carosello
   2026 -> Chi siamo -> I nostri eventi. Stesso fondo e nessuna linea: il
   countdown resta isolato tra le due fasce di foto, e gli stacchi tra le
   sezioni sono solo spazio. */
.hero + .diario {
  padding-top: clamp(56px, 8vw, 110px);
}

.diario + .counter-next {
  padding-top: clamp(24px, 3vw, 44px);
}

.counter-next + .chi-siamo {
  padding-top: clamp(48px, 6vw, 96px);
}

.strip {
  --strip-gap: clamp(12px, 1.4vw, 20px);
  --strip-card: clamp(240px, 27vw, 420px);
  position: relative;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent);
}

.strip + .strip {
  margin-top: var(--strip-gap);
}

.strip-track {
  display: flex;
  width: max-content;
  margin: 0;
  padding: 0 0 0 5vw;
  list-style: none;
}

.strip-item {
  flex: none;
  width: var(--strip-card);
  margin-right: var(--strip-gap);
  scroll-snap-align: center;
}

/* Il loop sposta la fila di esattamente metà (una copia completa): per
   questo nessun padding sulla fila, solo il margine uguale su ogni card. */
.strip.is-looping {
  overflow: hidden;
  scroll-snap-type: none;
}

.strip.is-looping .strip-track {
  padding: 0;
  animation: strip-scroll var(--strip-duration, 60s) linear infinite;
}

.strip.is-looping[data-direction="right"] .strip-track {
  animation-direction: reverse;
}

/* Pausa: fuori schermo e al passaggio del mouse (solo dove esiste l'hover,
   così un tap non la blocca). Con "riduci movimento" le file stanno ferme.
   La tastiera non serve: col Tab la fila passa in modalità manuale (custom.js). */
.strip.is-offscreen .strip-track {
  animation-play-state: paused;
}

@media (hover: hover) {
  .strip.is-looping:hover .strip-track {
    animation-play-state: paused;
  }
}

@keyframes strip-scroll {
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

.strip-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  clip-path: var(--clip-card);
  background-color: var(--color-bg-2);
}

.strip-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.8) contrast(1.05);
  transition: transform 800ms var(--ease-out-expo),
    filter var(--duration-normal) var(--ease-standard);
}

.strip-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 11, 12, 0) 48%, rgba(11, 11, 12, 0.88) 100%);
  pointer-events: none;
}

.strip-card:hover img,
.strip-card:focus-visible img {
  transform: scale(1.06);
  filter: brightness(0.98) contrast(1.05);
}

/* clip-path taglia il contorno esterno: il focus si disegna all'interno. */
.strip-card:focus-visible {
  outline: 2px solid var(--color-green-light);
  outline-offset: -4px;
}

.strip-label {
  position: absolute;
  z-index: 1;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.strip-label-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(16px, 1.45vw, 22px);
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--color-text);
  transition: color var(--duration-normal) var(--ease-standard);
}

.strip-label-year {
  flex: none;
  font-family: var(--font-label);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.16em;
  color: var(--color-text-3);
}

.strip-card:hover .strip-label-name,
.strip-card:focus-visible .strip-label-name {
  color: var(--color-green-light);
}

/* Counter singolo: le foto di un evento passato sotto il countdown
   (es. la prima edizione di Padova Moto Days). */
.counter-gallery {
  position: relative;
  z-index: 1;
  margin-top: clamp(56px, 7vw, 100px);
}

.counter-gallery-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.counter-gallery-caption {
  margin: 0;
  font-family: var(--font-label);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--counter-accent-light);
}

.strip--counter {
  --strip-card: clamp(260px, 30vw, 460px);
}

/* ---------------------------------------------
   7. I nostri eventi: titolo grande in Barlow Condensed corsivo, solo
   contorno verde, e, su desktop, l'evento più recente in evidenza su due
   colonne con il testo sulla foto. La data di ogni card è in
   design-refinements.css (.evento-data).
--------------------------------------------- */
.chi-siamo + .meetings-page::before {
  content: none;
}

.eventi-head {
  margin-bottom: clamp(36px, 5vw, 64px);
}

.meetings-page .eventi-head h2 {
  margin: 0;
  padding: 0 0.1em 0 0;
  border: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(52px, 9vw, 136px);
  line-height: 0.86;
  letter-spacing: -0.005em;
  text-transform: uppercase;
  color: transparent;
  -webkit-text-stroke: max(1.5px, 0.014em) var(--color-green-light);
}

@media (min-width: 993px) {
  .eventi-grid > .evento-item-col:first-child {
    grid-column: span 2;
  }

  .eventi-grid > .evento-item-col:first-child .meeting-item .thumb {
    position: absolute;
    inset: 0;
    aspect-ratio: auto;
    height: 100%;
  }

  .eventi-grid > .evento-item-col:first-child .meeting-item .thumb::after {
    background: linear-gradient(180deg, rgba(11, 11, 12, 0.05) 25%, rgba(11, 11, 12, 0.92) 100%);
  }

  .eventi-grid > .evento-item-col:first-child .meeting-item .down-content {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    margin-top: auto;
    max-width: 640px;
    padding: 40px 44px;
    background-color: transparent;
  }

  /* The overlaid text sits above the photo link: stretch the title link
     over the text block so the whole card stays clickable. */
  .eventi-grid > .evento-item-col:first-child .meeting-item .down-content > a::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  .eventi-grid > .evento-item-col:first-child .meeting-item .down-content h3 {
    font-size: clamp(32px, 3.4vw, 48px);
    font-weight: 800;
    line-height: 0.95;
  }

  .eventi-grid > .evento-item-col:first-child .meeting-item .down-content p {
    color: var(--color-text-2);
    font-size: 15px;
    -webkit-line-clamp: 2;
  }
}

/* ---------------------------------------------
   8. Reduced motion: niente ingresso né parallasse; tutto si vede
   subito nello stato finale (i caroselli si scorrono a mano).
--------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .hero *,
  .hero *::before,
  .hero *::after,
  .hero-shade::after {
    animation: none !important;
  }

  .hero-media img,
  .hero-livery,
  .hero-number,
  .hero-inner {
    transform: none;
    opacity: 1;
  }

  .hero-livery {
    transform: rotate(-21deg);
  }

  .hero-number {
    transform: translateY(-58%);
  }

}
