/* ============================================================
   Cosmic parallax hero — Horizon Advisory
   Port a CSS/JS plano del componente CosmicParallaxBg, con
   animación ligada al scroll (assets/js/cosmic.js fija --p: 0→1).
     p=0  solo "HORIZON ADVISORY" bajo el arco
     p=1  el título sube sobre el arco y la descripción aparece debajo
   ============================================================ */

:root {
  --animation-iteration: infinite;
  --hero-h: 100vh;
  --apex: 18vw;                 /* vértice del arco sobre el borde inferior (p=0) */
  --rise: 27vh;                 /* cuánto sube la Tierra durante el scroll */
  --gap: clamp(22px, 5vh, 56px);
  --title-h: calc(clamp(30px, 6.2vw, 92px) * 1.1);
  --scroll-track: 1.1;          /* recorrido extra de scroll, en alturas de pantalla */
}
@supports (height: 100svh) { :root { --hero-h: 100svh; } }
@media (max-width: 700px) {
  :root {
    --apex: 34vh;
    --rise: 30vh;
    --title-h: calc(clamp(30px, 11vw, 56px) * 2.2);
  }
}

/* ── Pista de scroll + escenario fijo ──────────────────────── */
.hero {
  --p: 0;                                              /* progreso total del scroll (lo fija cosmic.js) */
  --pt: clamp(0, calc(var(--p) / .55), 1);            /* fase 1: sube título y Tierra */
  display: block;
  position: relative;
  min-height: 0;
  height: calc(var(--hero-h) * (1 + var(--scroll-track)));
  overflow: visible;            /* overflow:hidden rompería position:sticky */
  background: #02050f;
}
.hero__stage {
  position: sticky;
  top: 0;
  height: var(--hero-h);
  overflow: hidden;
}

/* ── Escena ────────────────────────────────────────────────── */
.cosmic {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--hero-h);
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 100%, #14226b 0%, #0a1240 38%, #040919 100%);
}
.cosmic::after {              /* fundido a negro al pie de la escena */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 14vh;
  z-index: 4;
  background: linear-gradient(to bottom, rgba(2,5,15,0), #02050f);
}

/* Estrellas (parallax por velocidad) */
.cosmic__stars {
  position: absolute;
  top: 0; left: 0;
  background: transparent;
  border-radius: 50%;
  will-change: transform;
  box-shadow: var(--shadow, none);
}
.cosmic__stars::after {
  content: '';
  position: absolute;
  top: 2000px; left: 0;
  width: inherit; height: inherit;
  border-radius: 50%;
  box-shadow: var(--shadow, none);
}
.cosmic__stars--s { width: 1px; height: 1px; animation: animStar 90s linear var(--animation-iteration); opacity: .55; }
.cosmic__stars--m { width: 2px; height: 2px; animation: animStar 140s linear var(--animation-iteration); opacity: .75; }
.cosmic__stars--l { width: 3px; height: 3px; animation: animStar 200s linear var(--animation-iteration); }

/* Horizonte y Tierra (la Tierra sube con --p) */
.cosmic__horizon {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34%;
  z-index: 1;
  background: linear-gradient(to top, rgba(147,165,255,.20), rgba(147,165,255,0) 100%);
}
.cosmic__glow {
  position: absolute;
  left: 50%; bottom: 0;
  width: 120%; height: 100%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 100%, rgba(147,165,255,.55) 0%, rgba(45,63,191,.25) 35%, transparent 70%);
}
.cosmic__earth {
  position: absolute;
  left: 50%;
  bottom: calc(var(--apex) + var(--pt) * var(--rise) - 140vw);
  width: 140vw; height: 140vw;
  transform: translateX(-50%);
  z-index: 2;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 0%, #0b1650 0%, #060d2c 28%, #02050f 70%);
  box-shadow:
    0 -2px 6px rgba(190,205,255,.9),
    0 -10px 40px rgba(147,165,255,.55),
    0 -40px 120px rgba(45,63,191,.55),
    inset 0 18px 60px rgba(147,165,255,.28);
  will-change: bottom;
}

/* ── Título: nace bajo el arco y sube por encima al hacer scroll ── */
.cosmic__title {
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--hero-h) - var(--apex) + var(--gap));
  z-index: 3;
  text-align: center;
  font-weight: 700;
  font-size: clamp(30px, 6.2vw, 92px);
  line-height: 1.05;
  letter-spacing: .14em;
  padding-left: .14em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 40px rgba(147,165,255,.55), 0 0 90px rgba(45,63,191,.55);
  opacity: 0;
  transform: translateY(calc(var(--pt) * -1 * (var(--rise) + var(--title-h) + 2 * var(--gap))));
  animation: cosmicFade .9s .1s var(--ease-out) forwards;
  will-change: transform;
}
.cosmic__title span { display: inline-block; }
@keyframes cosmicFade { to { opacity: 1; } }

/* ── Descripción: aparece bajo el arco, elemento a elemento ── */
.hero__stage .hero__bottom {
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--hero-h) - var(--apex) - var(--rise) + var(--gap));
  z-index: 4;
  width: auto;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  text-align: center;
}
.hero__stage .hero__eyebrow,
.hero__stage .hero__title,
.hero__stage p.hero__subtitle,
.hero__stage .hero__ctas {
  animation: none;
  --r: clamp(0, calc((var(--p) - var(--s)) * 5), 1);   /* fase 2: entra la descripción */
  opacity: var(--r);
  transform: translateY(calc((1 - var(--r)) * 28px));
}
.hero__stage .hero__eyebrow { --s: .55; display: inline-flex; justify-content: center; }
.hero__stage .hero__title   { --s: .63; max-width: none; margin-inline: auto; }
.hero__stage p.hero__subtitle { --s: .71; margin-inline: auto; }
.hero__stage .hero__ctas    { --s: .79; justify-content: center; }

p.hero__subtitle { color: rgba(255,255,255,.88); text-shadow: 0 1px 18px rgba(4,9,25,.9), 0 0 6px rgba(4,9,25,.8); }
.hero__stage .hero__title, .hero__stage .hero__eyebrow { text-shadow: 0 2px 22px rgba(4,9,25,.85); }

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes animStar { from { transform: translateY(0); } to { transform: translateY(-2000px); } }

/* ── Móvil: título en dos líneas ───────────────────────────── */
@media (max-width: 700px) {
  .cosmic__title { font-size: clamp(30px, 11vw, 56px); letter-spacing: .12em; padding-left: .12em; }
  .cosmic__title span { display: block; }
  .hero__stage .hero__eyebrow::before { display: none; }
  .hero__stage .hero__eyebrow { text-align: center; }
}

/* ── Accesibilidad: sin movimiento → estado final fijo ─────── */
@media (prefers-reduced-motion: reduce) {
  :root { --scroll-track: 0; }
  .hero { --p: 1; }
  .cosmic__stars { animation: none !important; }
}
