/* EL VIAJE DE LA LUZ — página con animaciones guiadas por el scroll */

:root {
    --bg: #050810;
    --surface: #101A2B;
    --ink: #EFF5FF;
    --muted: #98A8BF;
    --line: rgba(152, 168, 191, .25);
    --faint: #1A2438;
    --blue: #5078FF;
    --cyan: #65E4FF;
    --coral: #FF806B;
    --accent: var(--cyan);
    --display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.vj {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 17px/1.6 var(--display);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

[data-color="blue"] { --accent: var(--blue); }
[data-color="cyan"] { --accent: var(--cyan); }

.vj-mono {
    font-family: var(--mono);
    letter-spacing: .06em;
    font-size: .78rem;
}

/* Barra superior y capítulo actual */
.vj-top {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px clamp(16px, 4vw, 48px);
    background: linear-gradient(var(--bg), transparent);
}

.vj-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: .02em;
}

.vj-brand img {
    border-radius: 8px;
}

.vj-chapter {
    font-family: var(--mono);
    font-size: .78rem;
    letter-spacing: .06em;
    color: var(--muted);
}

.vj-chapter [data-hud-num] {
    color: var(--accent);
    transition: color .4s;
}

.vj-cta-small {
    color: var(--ink);
    text-decoration: none;
    font-size: .9rem;
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: .8rem;
    transition: border-color .3s, background .3s;
}

.vj-cta-small:hover {
    border-color: var(--accent);
}

/* Riel de progreso a la derecha */
.vj-rail {
    position: fixed;
    right: clamp(10px, 2vw, 28px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 9;
}

.vj-rail-line {
    display: block;
    width: 2px;
    height: 38vh;
    background: var(--faint);
    border-radius: 2px;
    overflow: hidden;
}

.vj-rail-fill {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--accent);
    transform-origin: top;
    transform: scaleY(var(--progress, 0));
    box-shadow: 0 0 12px var(--accent);
    transition: background .4s;
}

/* Escenas: altas por fuera, fijas por dentro */
.vj-scene {
    position: relative;
    height: var(--h, 300vh);
}

.vj-sticky {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.vj-split {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: clamp(16px, 4vw, 64px);
    padding: 80px clamp(20px, 6vw, 96px) 40px;
}

.vj-copy h2 {
    margin: 10px 0 14px;
    font-size: clamp(2rem, 4.2vw, 3.6rem);
    font-weight: 600;
    line-height: 1.02;
    letter-spacing: -.045em;
}

.vj-copy p {
    color: var(--muted);
    max-width: 30em;
    margin: 0;
}

.vj-copy strong {
    color: var(--ink);
    font-weight: 600;
}

.vj-num {
    color: var(--accent);
    margin: 0;
}

.vj-stats {
    display: grid;
    gap: 14px;
    margin: 28px 0 0;
}

.vj-stats div {
    border-left: 1px solid var(--accent);
    padding-left: 14px;
}

.vj-stats dt {
    font-family: var(--mono);
    font-size: clamp(1.3rem, 2.2vw, 1.9rem);
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.vj-stats dd {
    margin: 0;
    color: var(--muted);
    font-size: .88rem;
}

/* Lo que aparece con el scroll: el JS escribe --in (0..1) */
[data-at] {
    opacity: var(--in, 0);
    transform: translateY(calc((1 - var(--in, 0)) * 12px));
    will-change: opacity, transform;
}

.vj-art {
    width: 100%;
    max-height: 78vh;
    overflow: visible;
}

.vj-art-full {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
}

/* Portada */
.vj-hero-copy,
.vj-end-copy {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
}

.vj-end-copy::before,
.vj-hero-copy::before {
    content: "";
    position: absolute;
    inset: 18% 8%;
    z-index: -1;
    background: radial-gradient(closest-side, rgba(6, 10, 22, .92), rgba(6, 10, 22, 0));
    pointer-events: none;
}

.vj-kicker {
    color: var(--accent);
    margin: 0 0 12px;
}

.vj-title {
    margin: 0;
    font-size: clamp(3.4rem, 13vw, 11rem);
    font-weight: 700;
    line-height: .9;
    letter-spacing: -.06em;
}

.vj-hero .vj-title span {
    display: inline-block;
    opacity: 0;
    transform: translateY(12px);
    filter: blur(6px);
    animation: vj-letter .6s cubic-bezier(.16, 1, .3, 1) forwards;
    animation-delay: calc(var(--i) * 45ms + 150ms);
}

.vj-title span:nth-child(1) { --i: 0; }
.vj-title span:nth-child(2) { --i: 1; }
.vj-title span:nth-child(3) { --i: 2; }
.vj-title span:nth-child(4) { --i: 3; }
.vj-title span:nth-child(5) { --i: 4; }
.vj-title span:nth-child(6) { --i: 5; }
.vj-title span:nth-child(7) { --i: 6; }
.vj-title span:nth-child(8) { --i: 7; }
.vj-title span:nth-child(9) { --i: 8; }

.vj-title-end {
    background: linear-gradient(100deg, #FFFFFF 10%, var(--cyan) 60%, var(--blue));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    padding: 0 .08em .06em;
}

@keyframes vj-letter {
    to { opacity: 1; transform: none; filter: none; }
}

.vj-lead {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.6vw, 1.25rem);
}

.vj-scroll-hint {
    position: absolute;
    bottom: 32px;
    color: var(--muted);
    animation: vj-bob 1.6s ease-in-out infinite;
}

@keyframes vj-bob {
    50% { transform: translateY(6px); }
}

.vj-button {
    display: inline-block;
    margin-top: 28px;
    padding: 14px 28px;
    border-radius: 4px;
    border: 1px solid var(--cyan);
    background: rgba(101, 228, 255, .08);
    color: var(--ink);
    font: 500 .95rem/1 var(--mono);
    letter-spacing: .04em;
    text-decoration: none;
    box-shadow: 0 0 24px rgba(101, 228, 255, .18), inset 0 0 12px rgba(101, 228, 255, .12);
    transition: background .25s, box-shadow .25s;
}

.vj-button:hover {
    background: rgba(101, 228, 255, .18);
    box-shadow: 0 0 36px rgba(101, 228, 255, .35), inset 0 0 12px rgba(101, 228, 255, .2);
}

/* Piezas de los dibujos */
.vj-art text {
    font-family: var(--mono);
    letter-spacing: .08em;
}

.vj-glow {
    filter: drop-shadow(0 0 4px currentColor);
}

/* La señal: un mismo pulso de luz que recorre todas las escenas */
.vj-signal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 8;
    pointer-events: none;
}

@media (max-width: 860px) {
    .vj-split {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        align-content: start;
        padding-top: 76px;
        gap: 4px;
    }

    .vj-copy h2 {
        font-size: 1.9rem;
    }

    .vj-copy p {
        font-size: .95rem;
    }

    .vj-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        margin-top: 14px;
        gap: 10px;
    }

    .vj-stats dt {
        font-size: 1.15rem;
    }

    .vj-art {
        max-height: 44vh;
    }

    .vj-chapter {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .vj-hero .vj-title span { animation: none; opacity: 1; transform: none; }
    .vj-scroll-hint { animation: none; }
}
