/* ==========================================================================
   HERO V3 — "The Evolution of Systems"
   Canvas + image sequence (90 frames WebP). Sin <video> en runtime.
   Namespace .heroV3 para no colisionar con el HERO anterior.

   Regla de degradación: el HERO es estático y completo por defecto.
   Solo cuando hero-sequence.js confirma que puede dibujar añade
   .heroV3--live, que activa la altura de scroll y el revelado por capas.
   ========================================================================== */

.heroV3 {
  --hv-obsidian: #080a0c;
  --hv-graphite: #15191d;
  --hv-titanium: #aeb5ba;
  --hv-champagne: #c8ad83;
  --hv-ivory: #f2f0eb;
  --hv-muted: #858b90;
  --hv-font-display: "Manrope", "Inter", system-ui, sans-serif;
  --hv-font-body: "Inter", system-ui, sans-serif;
  --hv-font-mono: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  --hv-ease: cubic-bezier(0.16, 1, 0.3, 1);

  position: relative;
  background: var(--hv-obsidian);
  color: var(--hv-ivory);
  --p: 1;
}

.heroV3--live {
  height: 320vh;
}

.heroV3__sticky {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

.heroV3--live .heroV3__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-height: 0;
}

/* ---------- Capa visual -------------------------------------------------- */

.heroV3__canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: none;
  width: 100%;
  height: 100%;
  background: var(--hv-obsidian);
}

.heroV3--live .heroV3__canvas {
  display: block;
}

.heroV3__poster-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  opacity: 1;
  transition: opacity 700ms var(--hv-ease);
  pointer-events: none;
}

.heroV3__poster-wrap.is-hidden {
  opacity: 0;
}

.heroV3__poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scrim declarado: garantiza contraste del texto sobre la zona oscura. */
.heroV3__scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 85% at 74% 26%, rgba(8, 10, 12, 0) 0%, rgba(8, 10, 12, 0.3) 52%, rgba(8, 10, 12, 0.82) 100%),
    linear-gradient(180deg, rgba(8, 10, 12, 0.62) 0%, rgba(8, 10, 12, 0.12) 38%, rgba(8, 10, 12, 0.92) 100%),
    linear-gradient(90deg, rgba(8, 10, 12, 0.88) 0%, rgba(8, 10, 12, 0.55) 38%, rgba(8, 10, 12, 0) 68%);
}

/* ---------- Contenido ---------------------------------------------------- */

.heroV3__inner {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  height: 100%;
  min-height: inherit;
  padding-block: clamp(5.5rem, 10vh, 8rem) clamp(4rem, 8vh, 6rem);
}

.heroV3__content {
  max-width: 46rem;
}

.heroV3__eyebrow {
  margin: 0 0 clamp(1rem, 2vh, 1.75rem);
  font-family: var(--hv-font-mono);
  font-size: clamp(0.6875rem, 0.9vw, 0.8125rem);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--hv-champagne);
}

/* Jerarquia: el titular es el protagonista absoluto. Crece antes que el resto
   y mantiene una proporcion de ~5x sobre el texto y ~6x sobre los botones. */
.heroV3__title {
  margin: 0;
  font-family: var(--hv-font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 5.9vw, 4.5rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.heroV3__line {
  display: block;
  opacity: 1;
  transform: none;
}

/* C.1 / C.9 — Revelado CONTINUO y REVERSIBLE.
   Cada palabra y cada bloque recibe --e (0 → 1) desde hero-sequence.js con el
   MISMO progreso que mueve la secuencia de fondo. No hay transiciones de
   entrada: el valor se recalcula en cada frame de scroll, de modo que el HERO
   se despliega al bajar y se repliega al subir, al mismo ritmo que la imagen.
   El estado inicial solo existe cuando el canvas esta vivo (.heroV3--live);
   sin JS o con movimiento reducido el titular se lee completo. */
.heroV3--live .heroV3__line .heroV3__word {
  display: inline-block;
  opacity: var(--e, 1);
  transform: translate3d(0, calc((1 - var(--e, 1)) * 18px), 0);
  filter: blur(calc((1 - var(--e, 1)) * 6px));
}

/* El blur se retira en cuanto la linea queda asentada: solo las palabras en
   vuelo pagan el costo del filtro. */
.heroV3--live .heroV3__line.is-in .heroV3__word {
  filter: none;
}

/* Bloques que no son palabras: eyebrow, descripcion y CTA. */
.heroV3--live .heroV3__eyebrow,
.heroV3--live .heroV3__desc {
  opacity: var(--e, 1);
  transform: translate3d(0, calc((1 - var(--e, 1)) * 14px), 0);
}

/* El contenedor del CTA se desplaza y se asienta; la opacidad la llevan los
   botones, de modo que no existen en el primer frame. */
.heroV3--live .heroV3__cta {
  transform: translate3d(0, calc((1 - var(--e, 1)) * 14px), 0) scale(calc(0.97 + 0.03 * var(--e, 1)));
}

/* Un CTA a medio revelar no captura el puntero. */
.heroV3--live .heroV3__cta:not(.is-in) {
  pointer-events: none;
}

.heroV3--live .heroV3__cta .heroV3__btn {
  opacity: var(--e, 1);
}

.heroV3--live .heroV3__cta .heroV3__btn:hover {
  transform: translateY(-1px);
}

.heroV3--live .heroV3__cta .heroV3__btn:active {
  transform: translateY(0);
}

.heroV3__line--accent {
  color: var(--hv-champagne);
}

/* C.1 — Descompresión ligada al scroll: el bloque de contenido nace 5 % más
   compacto y se expande hasta su tamaño natural conforme avanza la película de
   fondo (--hero-decomp, 0 → 1). Solo transform: los espacios entre titular,
   texto y botones se abren ante el visitante sin provocar layout. */
.heroV3--live .heroV3__content {
  transform-origin: left bottom;
  transform: scale(calc(0.94 + 0.06 * var(--hero-decomp, 1)));
}

.heroV3__desc {
  margin: clamp(1.5rem, 2.6vh, 2.25rem) 0 0;
  max-width: 40rem;
  font-family: var(--hv-font-body);
  font-size: clamp(0.875rem, 0.95vw, 1rem);
  line-height: 1.6;
  text-wrap: pretty;
  color: var(--hv-titanium);
}

.heroV3__desc strong {
  display: block;
  margin-bottom: 0.35em;
  font-weight: 500;
  color: var(--hv-ivory);
}

.heroV3__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: clamp(1.75rem, 3.2vh, 2.75rem);
}

/* Botones propios del HERO (no dependen del sistema .btn global). La escala
   tipográfica del HERO es jerárquica: titular grande, texto medio y botones un
   punto por debajo del texto. */
.heroV3__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.7rem 1.2rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--hv-font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition:
    background-color 260ms var(--hv-ease),
    border-color 260ms var(--hv-ease),
    color 260ms var(--hv-ease),
    transform 260ms var(--hv-ease);
}

.heroV3__btn .icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  transition: transform 260ms var(--hv-ease);
}

.heroV3__btn--primary {
  background: var(--hv-champagne);
  color: var(--hv-obsidian);
}

.heroV3__btn--primary:hover {
  background: #d8bd93;
  transform: translateY(-1px);
}

.heroV3__btn--primary:hover .icon {
  transform: translateX(2px);
}

.heroV3__btn--ghost {
  border-color: rgba(174, 181, 186, 0.32);
  color: var(--hv-ivory);
  background: rgba(8, 10, 12, 0.28);
  backdrop-filter: blur(6px);
}

.heroV3__btn--ghost:hover {
  border-color: rgba(200, 173, 131, 0.55);
  color: var(--hv-champagne);
  transform: translateY(-1px);
}

.heroV3__btn:focus-visible {
  outline: 2px solid var(--hv-champagne);
  outline-offset: 3px;
}

/* ---------- Progreso ----------------------------------------------------- */

.heroV3__progress {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 4;
  display: none;
  height: 2px;
  background: rgba(242, 240, 235, 0.08);
}

.heroV3--live .heroV3__progress {
  display: block;
}

.heroV3__progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--hv-champagne);
  transform-origin: left center;
}

/* ---------- Cabecera ----------------------------------------------------- */

/* El HERO V3 ya no tiene intro de video: la cabecera no debe esconderse al
   cargar. Estas reglas neutralizan el estado de apertura del HERO anterior
   (que dependia de --hero-progress y de hero-3d.js). */
html.js .page-home .site-header,
html.hero-intro-only .page-home .site-header {
  opacity: 1;
  pointer-events: auto;
}

/* La franja de la cabecera sobre el HERO usa la paleta V3, no el azul previo. */
.page-home .site-header,
.page-home .site-header.is-scrolled {
  background: rgba(8, 10, 12, 0.55);
  border-bottom-color: rgba(174, 181, 186, 0.12);
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
}

.page-home .site-header.is-scrolled {
  background: rgba(8, 10, 12, 0.82);
}

/* ---------- Responsive --------------------------------------------------- */

@media (max-width: 1024px) {
  .heroV3__content {
    max-width: 38rem;
  }
}

/* Tablet (768–1100): el alto del HERO manda. El bloque se separa en proporcion
   al tamaño disponible (vh, no px fijos), se centra con un sesgo hacia arriba
   para que el titular se lea alto y el aire se reparte ENTRE los elementos en
   lugar de quedar amontonado. El limite superior llega a 1100 px para cubrir
   iPad 10.2", Air y Pro, incluida su orientacion apaisada. */
@media (min-width: 768px) and (max-width: 1100px) {
  .heroV3__inner {
    padding-block: clamp(4rem, 7.5vh, 6rem) clamp(6rem, 12vh, 9rem);
  }

  .heroV3__eyebrow {
    margin-bottom: clamp(2.125rem, 4.3vh, 3.25rem);
  }

  .heroV3__desc {
    margin-top: clamp(3rem, 6.2vh, 5rem);
  }

  .heroV3__cta {
    margin-top: clamp(3.625rem, 7vh, 5.5rem);
  }
}

@media (max-width: 767px) {
  .heroV3--live {
    height: 280vh;
  }

  /* C.1.4 — Ritmo vertical movil: el HERO ocupa 100svh, asi que el bloque
     (eyebrow + titular + descripcion + botones) se centra con un sesgo hacia
     arriba —el titular sube y se lee antes— y las separaciones se calculan en
     vh, en proporcion al alto real del HERO: en un telefono alto hay mas aire,
     en uno bajo se comprime, sin amontonar ni dejar un hueco muerto arriba. */
  .heroV3__sticky,
  .heroV3--live .heroV3__sticky {
    min-height: 100svh;
  }

  .heroV3__eyebrow {
    margin: 0;
    font-size: 0.625rem;
    letter-spacing: 0.16em;
  }

  .heroV3__inner {
    align-items: stretch;
    padding-block: clamp(3.5rem, 7vh, 5.5rem) clamp(5rem, 12vh, 8rem);
  }

  .heroV3__content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(1.4375rem, 4.1vh, 2.375rem);
    width: 100%;
    max-width: none;
  }

  /* Jerarquia movil: el titular manda, la descripcion baja un escalon y los
     botones quedan claramente por debajo. Antes los dos botones ocupaban todo
     el ancho (dos barras de 48 px) y competian con el titular. */
  .heroV3__title {
    font-size: clamp(2.1875rem, 9.3vw, 2.5rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
  }

  .heroV3__desc {
    margin: 0;
    max-width: none;
    font-size: 0.78125rem;
    line-height: 1.5;
  }

  .heroV3__desc strong {
    margin-bottom: 0.3em;
  }

  .heroV3__cta {
    margin: 0;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .heroV3__btn {
    flex: 0 0 auto;
    min-height: 2.75rem;
    padding: 0.6rem 1.05rem;
    font-size: 0.75rem;
  }

  .heroV3__btn .icon {
    width: 0.9rem;
    height: 0.9rem;
  }

  .heroV3__scrim {
    background:
      linear-gradient(180deg, rgba(8, 10, 12, 0.7) 0%, rgba(8, 10, 12, 0.15) 30%, rgba(8, 10, 12, 0.94) 78%, rgba(8, 10, 12, 0.98) 100%);
  }
}

/* El aviso de cookies (fijo abajo) no debe tapar los botones del HERO.
   Mientras está visible, el contenido reserva su altura + aire. */
@media (max-width: 767px) {
  body:has(.cookie-note:not([hidden])) .heroV3__inner {
    padding-block-end: clamp(8.5rem, 19vh, 10.5rem);
  }
}

/* Pantallas bajas (iPhone SE y similares): el HERO se comprime para que
   titular, descripción y botones respiren sin recortes. El gap entre bloques
   se mantiene visible: se gana espacio con tipografia, padding y botones, no
   pegando los bloques. El padding superior nunca baja del alto de la cabecera
   para que el eyebrow no quede por detras de ella. */
@media (max-width: 767px) and (max-height: 720px) {
  .heroV3__inner {
    padding-block: 4.25rem clamp(4rem, 11vh, 6.5rem);
  }

  .heroV3__content {
    gap: clamp(1.0625rem, 3.4vh, 1.75rem);
  }

  .heroV3__title {
    font-size: clamp(1.75rem, 8.8vw, 2.375rem);
  }

  .heroV3__desc {
    font-size: 0.75rem;
    line-height: 1.5;
  }

  .heroV3__btn {
    min-height: 2.75rem;
  }

  body:has(.cookie-note:not([hidden])) .heroV3__inner {
    padding-block-end: 7rem;
  }
}

/* Pantallas muy bajas (320×568 y similares): el aire extra se recorta solo en
   este caso para que el eyebrow no quede por detrás de la cabecera. */
@media (max-width: 767px) and (max-height: 600px) {
  .heroV3__content {
    gap: clamp(0.9375rem, 2.9vh, 1.25rem);
  }
}

@media (max-height: 620px) and (min-width: 768px) {
  .heroV3__title {
    font-size: clamp(2rem, 4.4vw, 3rem);
  }

  .heroV3__desc {
    margin-top: 0.75rem;
  }

  .heroV3__cta {
    margin-top: 1rem;
  }
}

/* ---------- Movimiento reducido ------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .heroV3,
  .heroV3--live {
    height: auto;
  }

  .heroV3__sticky,
  .heroV3--live .heroV3__sticky {
    position: relative;
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
  }

  .heroV3__canvas,
  .heroV3--live .heroV3__canvas,
  .heroV3__progress,
  .heroV3--live .heroV3__progress {
    display: none;
  }

  .heroV3__poster-wrap {
    transition: none;
  }

  .heroV3--live .heroV3__line,
  .heroV3--live .heroV3__line .heroV3__word {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  .heroV3--live .heroV3__eyebrow,
  .heroV3--live .heroV3__desc,
  .heroV3--live .heroV3__cta,
  .heroV3--live .heroV3__cta .heroV3__btn {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
