/*
 * The one light object each service has, shared by its home section and its page's hero: the metallic
 * ribbon for AI Automations (full bleed, slow drift), stacked glass layers for Website Services (a
 * contained object on a quiet grid), and Connected Systems for Software Engineering (its drawing and
 * sequence are in connected-systems.css). A poster always paints first; background-motion.js swaps in the
 * video only where it is allowed.
 * Spec: Design/pivot-2026-11-24/DESIGN.md, sections 5, 7.2 and 8.1.
 */

/* ---------- The visual's frame ---------- */

.service-visual {
    position: relative;
    min-height: min(72vh, 680px);
}

/* ---------- Full bleed: to the right edge of the window, fading into the page ---------- */

.service-visual-bleed {
    position: absolute;
    inset: 0 calc(-1 * var(--page-gutter) - max(0px, (100vw - var(--content-width) - 2 * var(--page-gutter)) / 2)) 0 -8%;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 34%, #000 86%, transparent 100%), linear-gradient(0deg, transparent, #000 18%, #000 82%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(90deg, transparent 0%, #000 34%, #000 86%, transparent 100%), linear-gradient(0deg, transparent, #000 18%, #000 82%, transparent);
    mask-composite: intersect;
}

.service-visual-bleed img,
.service-visual-bleed video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* AI Automations: the metallic ribbon drifts slowly, back and forth */
.service-visual-ribbon img {
    object-position: 60% 40%;
    animation: ribbon-drift 26s var(--ease-in-out) infinite alternate;
}

@keyframes ribbon-drift {
    from {
        transform: scale(1.02) translate3d(0, 0, 0);
    }

    to {
        transform: scale(1.08) translate3d(-1.5%, -1%, 0);
    }
}

/* ---------- Contained object: a square stage on a faint grid, with a soft glow ---------- */

.service-visual-stage {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: var(--radius-large);
    background:
        radial-gradient(closest-side, rgba(98, 210, 255, 0.10), transparent 70%),
        linear-gradient(var(--color-line) 1px, transparent 1px) 0 0 / 48px 48px,
        linear-gradient(90deg, var(--color-line) 1px, transparent 1px) 0 0 / 48px 48px;
    -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 60%, transparent 100%);
}

.service-visual-stage .service-visual-poster-swap {
    position: relative;
    width: min(78%, 560px);
    aspect-ratio: 1 / 1;
}

/* The video's black becomes the page */
.service-visual-stage img,
.service-visual-stage video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    mix-blend-mode: screen;
}

/* ---------- Poster first, then the video fades in over it once it is actually playing ---------- */

.service-visual-poster-swap video {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out);
}

.service-visual-poster-swap video.is-playing {
    opacity: 1;
}

/* ---------- Tablet and phone: the visual becomes a band at the full window width ---------- */

@media (max-width: 1023px) {
    .service-visual {
        min-height: 0;
        aspect-ratio: 16 / 10;
        margin: 0 calc(-1 * var(--page-gutter));
    }

    .service-visual-bleed {
        inset: 0;
        -webkit-mask-image: linear-gradient(0deg, transparent 0%, #000 24%, #000 85%, transparent 100%);
        -webkit-mask-composite: source-over;
        mask-image: linear-gradient(0deg, transparent 0%, #000 24%, #000 85%, transparent 100%);
        mask-composite: add;
    }

    /* Website Services keeps its square object, centred */
    .service-visual-contained {
        width: 100%;
        max-width: 420px;
        max-height: 420px;
        aspect-ratio: 1 / 1;
        margin: 0 auto;
    }

    .service-visual-stage .service-visual-poster-swap {
        width: 86%;
    }
}

/* ---------- Reduced motion: every visual is its still picture ---------- */

@media (prefers-reduced-motion: reduce) {
    .service-visual-ribbon img {
        animation: none;
        transform: scale(1.02);
    }

    .service-visual-poster-swap video {
        display: none;
    }
}
