/* ============================================================
   HERO · AST3C
   Composición: fondo → atmósfera (canvas) → AST3C → pirámides
   (canvas, con nubes) → contorno glass → contenido (aparece con scroll).
   Solo usa los tokens de styles.css y variaciones derivadas.
   ============================================================ */

:root {
    /* Variaciones derivadas de --accent-purple / --accent-cyan / --bg-primary */
    --hero-purple-glow: rgba(176, 38, 255, 0.45);
    --hero-purple-soft: rgba(176, 38, 255, 0.16);
    --hero-cyan-soft: rgba(0, 240, 255, 0.10);
    --hero-purple-tint: #e2c9ff;   /* --accent-purple + blanco */
    --hero-cyan-tint: #b3f9ff;     /* --accent-cyan + blanco */
    --hero-gutter: clamp(1rem, 4vw, 2rem);
    --hero-wm-size: min(clamp(4rem, 22vw, 19rem), 32vh);
}

@supports (height: 100svh) {
    :root {
        --hero-wm-size: min(clamp(4rem, 22vw, 19rem), 32svh);
    }
}

/* ---------- Contenedor ---------- */
.hero {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    padding: 0;
    overflow: hidden;
    overflow: clip;
    isolation: isolate;
}

/* ---------- Capa 1 · Fondo ---------- */
.hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 55% 45% at 50% 46%, var(--hero-purple-soft), transparent 70%),
        radial-gradient(ellipse 38% 32% at 18% 22%, var(--hero-cyan-soft), transparent 72%),
        radial-gradient(ellipse 42% 36% at 84% 70%, rgba(176, 38, 255, 0.10), transparent 72%);
}

/* Retícula técnica muy tenue */
.hero-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 64px 64px;
    background-position: center center;
    -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 50%, #000 15%, transparent 75%);
            mask-image: radial-gradient(ellipse 65% 55% at 50% 50%, #000 15%, transparent 75%);
}

/* ---------- Canvas ---------- */
.hero-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.hero-canvas--atmo {
    z-index: 1;
}

.hero-canvas--scene {
    z-index: 3;
}

/* Textura de líneas: da a las nubes un acabado "digital" */
.hero-scanlines {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, rgba(10, 10, 10, 0.16) 0 1px, transparent 1px 3px);
    -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 85%);
            mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, #000 30%, transparent 85%);
}

/* ---------- Capa 3 · AST3C ---------- */
/* La primera pantalla NO crea stacking context: así el <h1> (z 2), el canvas
   de pirámides (z 3) y el contorno (z 4) se intercalan correctamente. */
.hero-intro {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100svh;
    min-height: 460px;
}

.hero-wordmark {
    position: absolute;
    left: 0;
    right: 0;
    /* --hero-wm-top lo calcula el JS; el valor por defecto sirve sin JS */
    top: var(--hero-wm-top, calc(5.5rem + 10vh));
    margin: 0;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: var(--hero-wm-size);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.035em;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    transform-origin: 50% 62%;
    will-change: transform, opacity;
}

.hero-wordmark { z-index: 2; }
.hero-wordmark--ghost { z-index: 4; }

.hero-wordmark__text {
    display: inline-block;
    color: #ffffff;
    padding: 0 0.04em;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .hero-wordmark__text {
        background:
            linear-gradient(105deg, transparent 42%, rgba(179, 249, 255, 0.95) 50%, transparent 58%) no-repeat,
            linear-gradient(180deg, #ffffff 0%, #ffffff 40%, var(--hero-purple-tint) 76%, var(--hero-cyan-tint) 100%);
        background-size: 250% 100%, 100% 100%;
        background-position: 160% 0, 0 0;
        -webkit-background-clip: text;
                background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    /* Destello de luz que recorre AST3C cada pocos segundos */
    [data-hero-wordmark] .hero-wordmark__text {
        animation: hero-wm-sheen 7s cubic-bezier(0.45, 0, 0.25, 1) 2.2s infinite;
    }
}

@keyframes hero-wm-sheen {
    0% { background-position: 160% 0, 0 0; }
    28%, 100% { background-position: -60% 0, 0 0; }
}

[data-hero-wordmark] .hero-wordmark__text {
    filter:
        drop-shadow(0 0 0.06em rgba(255, 255, 255, 0.35))
        drop-shadow(0 0 0.22em var(--hero-purple-glow));
}

/* Contorno fino por encima de las pirámides: mantiene AST3C legible */
.hero-wordmark--ghost .hero-wordmark__text {
    background: none;
    color: transparent;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 1px rgba(179, 249, 255, 0.42);
    filter: none;
}

/* ---------- Capa 6 · Contenido ---------- */
.hero-content {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: calc(680px + 2 * var(--hero-gutter));
    margin: 0 auto;
    padding:
        clamp(1rem, 4vh, 2.5rem)
        max(var(--hero-gutter), env(safe-area-inset-right, 0px))
        calc(clamp(5rem, 16vh, 9rem) + env(safe-area-inset-bottom, 0px))
        max(var(--hero-gutter), env(safe-area-inset-left, 0px));
    text-align: center;
}

.hero-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(0.78rem, 1.4vw, 0.95rem);
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--hero-cyan-tint);
}

.hero-subtitle::before,
.hero-subtitle::after {
    content: '';
    width: clamp(1.25rem, 4vw, 2.75rem);
    height: 1px;
    flex: none;
    background: linear-gradient(90deg, transparent, var(--accent-cyan));
}

.hero-subtitle::after {
    background: linear-gradient(90deg, var(--accent-purple), transparent);
}

.hero-description {
    max-width: 600px;
    margin: 1rem auto 2rem;
    color: var(--text-secondary);
    font-size: clamp(0.95rem, 1.25vw, 1.06rem);
    line-height: 1.75;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.875rem;
}

/* CTA (estilo original conservado y refinado) */
.cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 2.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
    border-radius: 0;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    isolation: isolate; /* el barrido ::before queda sobre el fondo del botón */
}

.cta-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: var(--accent-gradient);
    transition: var(--transition);
    z-index: -1;
}

.cta-button:hover,
.cta-button:focus-visible {
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.2);
}

.cta-button:hover::before,
.cta-button:focus-visible::before {
    left: 0;
}

.cta-button:focus-visible {
    outline: 2px solid var(--accent-cyan);
    outline-offset: 3px;
}

.cta-button svg {
    transition: var(--transition);
}

.cta-button:hover svg {
    transform: translateX(5px);
}

.cta-button--ghost {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.14);
    -webkit-backdrop-filter: blur(8px);
            backdrop-filter: blur(8px);
}

/* ---------- Indicador de scroll ---------- */
.hero-scroll-hint {
    position: absolute;
    left: 50%;
    bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
    z-index: 5;
    transform: translateX(-50%);
    pointer-events: none;
}

.hero-scroll-hint__inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    opacity: 0;
    animation: hero-hint-in 0.9s ease 1.7s forwards;
}

.hero-scroll-hint__label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.32em;
    text-indent: 0.32em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.hero-scroll-hint__line {
    position: relative;
    display: block;
    width: 1px;
    height: 40px;
    overflow: hidden;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.25));
}

.hero-scroll-hint__line i {
    position: absolute;
    left: 0;
    top: -40%;
    width: 1px;
    height: 40%;
    background: linear-gradient(180deg, transparent, var(--accent-cyan));
    animation: hero-scroll-hint 2.4s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes hero-scroll-hint {
    0% { top: -40%; }
    70%, 100% { top: 100%; }
}

@keyframes hero-hint-in {
    to { opacity: 1; }
}

/* Transición suave hacia la siguiente sección */
.hero::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 18%;
    z-index: 4;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, var(--bg-primary));
}

/* ---------- Estado inicial con JS (evita parpadeo antes de la intro) ----------
   Si el JS no llega a ejecutarse, la animación de seguridad muestra todo. */
.js .hero:not(.hero--live) .hero-wordmark,
.js .hero:not(.hero--live) .hero-bg {
    opacity: 0;
    animation: hero-failsafe 0.6s ease 2.5s forwards;
}

@keyframes hero-failsafe {
    to { opacity: 1; }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .hero-bg::before {
        background-size: 44px 44px;
    }
}

@media (max-width: 639px) {
    :root {
        --hero-wm-size: min(25vw, 27vh);
    }
    @supports (height: 100svh) {
        :root {
            --hero-wm-size: min(25vw, 27svh);
        }
    }
    .hero-subtitle {
        letter-spacing: 0.2em;
        gap: 0.6rem;
    }
    .hero-description {
        margin: 0.85rem auto 1.6rem;
        line-height: 1.7;
    }
    .hero-actions {
        flex-direction: column;
        align-items: stretch;
        max-width: 340px;
        margin: 0 auto;
    }
    .cta-button {
        padding: 0.95rem 1.5rem;
        font-size: 0.95rem;
    }
}

@media (max-width: 400px) {
    .hero-subtitle {
        font-size: 0.72rem;
        letter-spacing: 0.16em;
        text-wrap: balance;
    }
    .hero-subtitle::before,
    .hero-subtitle::after {
        display: none;
    }
}

@media (max-width: 360px) {
    .hero-description {
        font-size: 0.92rem;
    }
}

/* Teléfonos en horizontal / pantallas muy bajas */
@media (max-height: 560px) and (orientation: landscape) {
    :root {
        --hero-wm-size: min(15vw, 34vh);
    }
    @supports (height: 100svh) {
        :root {
            --hero-wm-size: min(15vw, 34svh);
        }
    }
    .hero-description {
        margin: 0.6rem auto 1.1rem;
    }
}

@media (max-height: 520px) {
    .hero-scroll-hint__label {
        display: none;
    }
}

/* Ultrawide: la composición crece con moderación, sin estirarse */
@media (min-width: 1800px) {
    :root {
        --hero-wm-size: min(20rem, 32vh);
    }
    @supports (height: 100svh) {
        :root {
            --hero-wm-size: min(20rem, 32svh);
        }
    }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
    [data-hero-wordmark] .hero-wordmark__text {
        animation: none;
    }
    .hero-scroll-hint__inner {
        animation: none;
        opacity: 1;
    }
    .hero-scroll-hint__line i {
        animation: none;
        top: 30%;
    }
    .cta-button,
    .cta-button::before,
    .cta-button svg {
        transition: none;
    }
}
