/* =========================================================================
   Capabilities — animated pass over the base cards in theme.css / fx.css.
   Everything that moves is transform or opacity on its own layer, so the
   compositor carries it; capabilities.js only adds pointer tilt/spotlight
   and pauses the section while it is off screen.
   ========================================================================= */

.vs-caps {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.vs-caps > .vs-container {
    position: relative;
    z-index: 1;
}

/* --- Backdrop: faint grid floor + glow --------------------------------------- */
.vs-caps-floor {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 62%;
    z-index: 0;
    pointer-events: none;
    perspective: 520px;
    perspective-origin: 50% 0%;
    -webkit-mask-image: linear-gradient(to top, #000 15%, transparent 92%);
    mask-image: linear-gradient(to top, #000 15%, transparent 92%);
}

/* One cell (56px) of travel loops seamlessly, so the drift never jumps. */
.vs-caps-plane {
    position: absolute;
    left: -50%;
    width: 200%;
    top: 0;
    height: 180%;
    transform-origin: 50% 0%;
    transform: rotateX(64deg);
}

.vs-caps-plane::before {
    content: "";
    position: absolute;
    inset: -56px 0 0;
    animation: vs-caps-drift 3.2s linear infinite;
    will-change: transform;
    background-image:
        linear-gradient(rgba(10, 99, 246, 0.10) 1px, transparent 1px),
        linear-gradient(90deg, rgba(10, 99, 246, 0.08) 1px, transparent 1px);
    background-size: 56px 56px;
}

@keyframes vs-caps-drift {
    to { transform: translate3d(0, 56px, 0); }
}

.vs-caps-glow {
    position: absolute;
    top: -10%;
    left: 50%;
    width: min(900px, 120vw);
    height: 520px;
    z-index: 0;
    transform: translateX(-50%);
    pointer-events: none;
    background: radial-gradient(closest-side, rgba(10, 99, 246, 0.10), rgba(25, 194, 255, 0.06) 55%, transparent);
}

/* --- Cards -------------------------------------------------------------- */
.vs-caps .vs-cap-grid {
    perspective: 1200px;
}

.vs-caps .vs-cap-card {
    --rgb: 10, 99, 246;
    --rx: 0deg;
    --ry: 0deg;
    --lift: 0px;
    --mx: 50%;
    --my: 0%;
    display: flex;
    flex-direction: column;
    /* Solid glass instead of a backdrop blur: the floor moves behind these
       cards, and a blur would be recomputed on every frame of it. */
    background: var(--vs-glass-bg-strong);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transform: rotateX(var(--rx)) rotateY(var(--ry)) translate3d(0, var(--lift), 0);
    transition: transform 0.6s var(--vs-ease), border-color 0.4s var(--vs-ease), background-color 0.4s var(--vs-ease), box-shadow 0.4s var(--vs-ease);
    will-change: transform;
}

.vs-caps .vs-cap-card:nth-child(3n + 2) { --rgb: 8, 79, 197; }
.vs-caps .vs-cap-card:nth-child(3n) { --rgb: 25, 194, 255; }

.vs-caps .vs-cap-card:hover {
    --lift: -8px;
    box-shadow: var(--vs-shadow-hover), 0 0 40px rgba(var(--rgb), 0.12);
}

/* While the pointer drives the tilt, follow it closely. */
.vs-caps .vs-cap-card.is-tilting {
    transition-duration: 0.15s, 0.4s, 0.4s, 0.4s;
}

/* Arrival: rise and un-tilt in 3D, one card after another. */
.vs-caps .vs-cap-card.is-visible {
    animation: vs-cap-in 0.9s var(--vs-ease) calc(var(--i, 0) * 90ms) backwards;
}

@keyframes vs-cap-in {
    from {
        opacity: 0;
        transform: rotateX(24deg) translate3d(0, 56px, -60px) scale(0.96);
    }
}

/* Spotlight that follows the pointer across the surface. */
.vs-caps .vs-cap-card::before {
    background: radial-gradient(380px circle at var(--mx) var(--my), rgba(var(--rgb), 0.22), transparent 62%);
}

/* --- Border beam (hover) ------------------------------------------------- */
.vs-cap-ring {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    border-radius: inherit;
    padding: 1.5px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.45s var(--vs-ease);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.vs-cap-ring::before {
    content: "";
    position: absolute;
    inset: -75%;
    background: conic-gradient(from 0deg, transparent 0 58%, rgba(var(--rgb), 0.9) 76%, #fff 82%, rgba(25, 194, 255, 0.85) 88%, transparent 94%);
    animation: vs-cap-spin 3.4s linear infinite paused;
}

.vs-caps .vs-cap-card:hover .vs-cap-ring,
.vs-caps .vs-cap-card:focus-within .vs-cap-ring {
    opacity: 1;
}

.vs-caps .vs-cap-card:hover .vs-cap-ring::before {
    animation-play-state: running;
}

@keyframes vs-cap-spin {
    to { transform: rotate(360deg); }
}

/* --- Scan line on arrival ---------------------------------------------- */
.vs-cap-scan {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(var(--rgb), 0.16) 48%, rgba(255, 255, 255, 0.7) 50%, transparent 52%);
    transform: translate3d(0, -100%, 0);
}

.vs-caps .vs-cap-card.is-visible .vs-cap-scan {
    animation: vs-cap-scan 1.3s cubic-bezier(0.4, 0, 0.2, 1) calc(var(--i, 0) * 90ms + 0.45s) both;
}

@keyframes vs-cap-scan {
    0% { opacity: 0; transform: translate3d(0, -100%, 0); }
    15% { opacity: 1; }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate3d(0, 100%, 0); }
}

/* --- Card content ------------------------------------------------------ */
.vs-cap-top {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.vs-caps .vs-cap-icon {
    transition: transform 0.5s var(--vs-ease);
}

.vs-caps .vs-cap-card:hover .vs-cap-icon {
    transform: scale(1.06);
}

/* Orbit ring round the icon, with a satellite dot. */
.vs-cap-orbit {
    position: absolute;
    inset: -9px;
    border: 1px dashed rgba(10, 99, 246, 0.35);
    border-radius: 50%;
    animation: vs-cap-spin 14s linear infinite;
    pointer-events: none;
}

.vs-cap-orbit::after {
    content: "";
    position: absolute;
    top: -3px;
    left: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-radius: 50%;
    background: var(--vs-brand);
    box-shadow: 0 0 10px 2px rgba(var(--rgb), 0.6);
}

.vs-cap-num {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--vs-brand-600);
    padding: 4px 10px;
    border: 1px solid rgba(var(--rgb), 0.3);
    border-radius: 999px;
    background: rgba(var(--rgb), 0.08);
    transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

.vs-caps .vs-cap-card:hover .vs-cap-num {
    color: var(--vs-brand-600);
    border-color: rgba(var(--rgb), 0.7);
    background: rgba(var(--rgb), 0.16);
}

.vs-cap-tags {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: auto 0 0;
    padding: 22px 0 0;
    list-style: none;
}

.vs-cap-tags li {
    padding: 5px 11px;
    border: 1px solid var(--vs-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--vs-ink-soft);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    transition: border-color 0.3s ease, color 0.3s ease;
}

.vs-caps .vs-cap-card:hover .vs-cap-tags li {
    border-color: rgba(var(--rgb), 0.45);
    color: var(--vs-ink);
}

.vs-caps .vs-cap-card.is-visible .vs-cap-tags li {
    animation: vs-cap-tag 0.5s var(--vs-ease) calc(var(--i, 0) * 90ms + 0.55s + var(--t, 0) * 70ms) backwards;
}

@keyframes vs-cap-tag {
    from { opacity: 0; transform: translate3d(0, 8px, 0); }
}

/* Off screen, everything holds still. */
.vs-caps.is-off *,
.vs-caps.is-off *::before,
.vs-caps.is-off *::after {
    animation-play-state: paused !important;
}

@media (max-width: 767px) {
    .vs-caps-floor { height: 40%; }
    .vs-caps-plane::before { animation-duration: 4.5s; }
}

@media (prefers-reduced-motion: reduce) {
    .vs-caps *,
    .vs-caps *::before,
    .vs-caps *::after {
        animation: none !important;
    }
    .vs-caps .vs-cap-card { transition: border-color 0.3s ease, background-color 0.3s ease; transform: none; }
}
