/* =========================================================================
   Hero opening sequence: every live project flies once through a 3D tunnel
   toward the viewer, then the hero copy takes over. Only transform and
   opacity animate, so the whole flight runs on the compositor.

   Shown only while <html> carries .vs-intro-on (set inline by the hero
   partial, removed by hero-intro.js); without it none of this renders.
   ========================================================================= */

.vs-intro {
    --far: -1700px;
    --near: 500px;
    position: absolute;
    /* The hero runs taller than the screen; the tunnel centres on what is seen. */
    inset: 0 0 auto;
    height: 100vh;
    height: 100svh;
    z-index: 3;
    display: none;
    overflow: hidden;
    pointer-events: none;
    perspective: 1200px;
    transition: opacity 0.55s var(--vs-ease, ease);
}

.vs-intro-on .vs-intro,
.vs-intro.is-done {
    display: block;
}

.vs-intro.is-done {
    opacity: 0;
}

.vs-intro-space {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
}

/* --- Cards ------------------------------------------------------------- */
.vs-intro-card {
    position: absolute;
    left: 50%;
    top: 50%;
    width: clamp(160px, 17vw, 260px);
    aspect-ratio: 16 / 10;
    border-radius: 16px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 45%, #0c0c0a));
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.14);
    opacity: 0;
    will-change: transform, opacity;
    animation: vs-intro-fly 1.8s cubic-bezier(0.3, 0.1, 0.6, 1) var(--delay, 0s) both;
}

.vs-intro-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* No banner: the logo sits on the project's brand colour instead. */
.vs-intro-card.is-logo img {
    object-fit: contain;
    padding: 14% 22% 24%;
}

.vs-intro-name {
    position: absolute;
    inset: auto 0 0;
    padding: 22px 12px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82), transparent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes vs-intro-fly {
    0% {
        opacity: 0;
        transform: translate3d(calc(-50% + var(--x)), calc(-50% + var(--y)), var(--far)) rotateZ(var(--rz));
    }
    18%,
    82% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate3d(calc(-50% + var(--x)), calc(-50% + var(--y)), var(--near)) rotateZ(var(--rz));
    }
}

/* --- Centre caption ---------------------------------------------------- */
.vs-intro-caption {
    position: absolute;
    left: 50%;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    z-index: 1; /* the message stays readable; the cards pass behind it */
    width: min(92vw, 980px);
    text-align: center;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.88);
    will-change: transform, opacity;
    animation: vs-intro-caption var(--intro-total, 3s) cubic-bezier(0.3, 0.1, 0.6, 1) both;
}

/* Held on its first frame until hero-intro.js says the page has settled, so
   the flight never starts while the browser is still busy loading. */
.vs-intro:not(.is-playing) .vs-intro-card,
.vs-intro:not(.is-playing) .vs-intro-caption {
    animation-play-state: paused;
}

.vs-intro-kicker {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.vs-intro-title {
    font-size: clamp(2rem, 5.4vw, 4.4rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
    color: #fff;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}

/* Static gradient (no pan): this layer is scaled, and a panning
   background would repaint it every frame. */
.vs-intro-grad {
    background: linear-gradient(100deg, var(--vs-brand-300, #43b3ea), var(--vs-violet, #7b61ff) 55%, var(--vs-magenta, #d16bff));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow: none;
}

@keyframes vs-intro-caption {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.88); }
    14% { opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

/* --- Skip -------------------------------------------------------------- */
.vs-intro-skip {
    position: absolute;
    left: 50%;
    bottom: 32px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    background: rgba(12, 12, 10, 0.55);
    color: rgba(255, 255, 255, 0.85);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s ease, color 0.2s ease;
}

.vs-intro-skip:hover,
.vs-intro-skip:focus-visible {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

/* --- Hand-off: hold the hero copy back while the intro plays ------------
   Outranks [data-reveal].is-visible, so once .vs-intro-on goes the copy
   plays its usual staggered reveal. */
.vs-intro-on .vs-hero [data-reveal] {
    opacity: 0;
    transform: translateY(26px);
}

.vs-intro-on .vs-hero .vs-scroll-cue {
    opacity: 0;
}

.vs-hero .vs-scroll-cue {
    transition: opacity 0.6s var(--vs-ease, ease) 0.5s;
}

@media (max-width: 767px) {
    .vs-intro {
        --far: -1200px;
        --near: 350px;
        perspective: 900px;
    }

    .vs-intro-card {
        width: clamp(120px, 36vw, 180px);
        border-radius: 12px;
    }

    .vs-intro-name {
        font-size: 0.62rem;
        letter-spacing: 0.12em;
    }
}
