/* Studio IA — section « Les 10 studios IA » en galerie 3D (assets/js/studio-ia-gallery.js).
 * Sans la classe .sg-on (mobile, écran bas, mouvement réduit, JS absent) : grille d'origine, rien ne change.
 * Avec .sg-on : section épinglée, les cartes arrivent de tous les côtés et se posent sur les murs d'une salle. */

/* Éléments de décor et de progression : invisibles hors mode 3D */
.studio-gallery .sg-floor,
.studio-gallery .sg-backwall,
.studio-gallery .sg-hud {
    display: none;
}

/* La scène pleine largeur ne doit pas être rognée par main (overflow-x: clip) */
body.home3d:has(.studio-gallery.sg-on) {
    overflow-x: clip;
}

body.home3d:has(.studio-gallery.sg-on) main {
    overflow-x: visible;
}

.studio-gallery.sg-on {
    padding: 0;
}

.studio-gallery.sg-on .sg-track {
    position: relative;
    height: 330vh;
}

.studio-gallery.sg-on .sg-stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    overflow: hidden;
}

.studio-gallery.sg-on .sg-head {
    position: absolute;
    top: 86px;
    left: 0;
    right: 0;
    z-index: 3;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
    pointer-events: none;
    transition: opacity .4s ease;
}

.studio-gallery.sg-on .sg-head h2 {
    margin: 12px 0 8px;
    font-size: clamp(1.8rem, 3.4vw, 2.8rem);
}

.studio-gallery.sg-on .sg-head .section-lead {
    margin: 0 auto;
}

.studio-gallery.sg-on .sg-viewport {
    position: absolute;
    inset: 0;
    perspective: 1000px;
    perspective-origin: 50% 46%;
}

.studio-gallery.sg-on .sg-room {
    position: absolute;
    top: 56%;
    left: 50%;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    will-change: transform;
}

.studio-gallery.sg-on .studio-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    margin: 0;
    display: block;
    transform-style: preserve-3d;
}

.studio-gallery.sg-on .studio-card {
    position: absolute;
    left: calc(var(--sg-card-w, 250px) / -2);
    top: calc(var(--sg-card-w, 250px) * -0.62);
    width: var(--sg-card-w, 250px);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform, opacity;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .55), 0 0 0 1px rgba(160, 175, 255, .12);
    transition: box-shadow .3s ease, filter .3s ease;
}

.studio-gallery.sg-on .studio-card:hover {
    filter: brightness(1.08);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6), 0 0 46px rgba(142, 114, 255, .35);
}

/* Sol de la galerie : quadrillage lumineux qui se perd dans la profondeur */
.studio-gallery.sg-on .sg-floor {
    display: block;
    position: absolute;
    left: -2600px;
    top: 0;
    width: 5200px;
    height: 7000px;
    transform-origin: 50% 0;
    background:
        radial-gradient(60% 40% at 50% 0%, rgba(142, 114, 255, .18), transparent 70%),
        linear-gradient(rgba(160, 175, 255, .09) 1px, transparent 1px) 0 0 / 100% 180px,
        linear-gradient(90deg, rgba(160, 175, 255, .09) 1px, transparent 1px) 0 0 / 180px 100%;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
    mask-image: linear-gradient(to bottom, #000 0%, transparent 85%);
    pointer-events: none;
}

/* Mur du fond : halo doux derrière les cartes du fond */
.studio-gallery.sg-on .sg-backwall {
    display: block;
    position: absolute;
    left: -1600px;
    top: -900px;
    width: 3200px;
    height: 1500px;
    background: radial-gradient(45% 45% at 50% 55%, rgba(107, 217, 232, .12), rgba(142, 114, 255, .08) 45%, transparent 75%);
    pointer-events: none;
}

.studio-gallery.sg-on .sg-hud {
    position: absolute;
    left: 50%;
    bottom: 26px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateX(-50%);
    color: var(--muted, #a9b2d0);
    font-size: .8rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.studio-gallery.sg-on .sg-bar {
    display: block;
    width: 160px;
    height: 2px;
    border-radius: 2px;
    background: rgba(160, 175, 255, .2);
    overflow: hidden;
}

.studio-gallery.sg-on .sg-bar i {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--violet, #8e72ff), var(--cyan, #6bd9e8));
    transform: scaleX(0);
    transform-origin: left;
}

/* ---------- Mobile : carrousel de cartes « image + texte en surimpression », 6 studios principaux ---------- */
.studio-gallery .sg-swipe {
    display: none;
}

@media (max-width: 899px) {
    .studio-gallery .studio-card--secondary {
        display: none;
    }

    .studio-gallery .studio-grid {
        display: flex;
        gap: 14px;
        margin: 22px -20px 0;
        padding: 4px 20px 16px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding: 0 20px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .studio-gallery .studio-grid::-webkit-scrollbar {
        display: none;
    }

    .studio-gallery .studio-card {
        flex: 0 0 min(80%, 340px);
        aspect-ratio: 4 / 5;
        scroll-snap-align: start;
        border-radius: 22px;
        transform: none;
    }

    .studio-gallery .studio-card .media {
        position: absolute;
        inset: 0;
        aspect-ratio: auto;
    }

    .studio-gallery .studio-card .media::after {
        background: linear-gradient(180deg, rgba(7, 11, 24, .15) 0%, transparent 30%, rgba(7, 11, 24, .55) 55%, rgba(7, 11, 24, .96) 100%);
    }

    .studio-gallery .studio-card .body {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
        padding: 18px 18px 20px;
    }

    .studio-gallery .studio-card h3 {
        margin-bottom: 6px;
        font-size: 1.25rem;
    }

    .studio-gallery .studio-card p {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        color: rgba(230, 235, 255, .82);
        font-size: .92rem;
        line-height: 1.5;
    }

    .studio-gallery .sg-swipe {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 4px 0 0;
        color: var(--muted, #a9b2d0);
        font-size: .82rem;
    }

    .studio-gallery .sg-swipe span {
        animation: sg-swipe 1.6s ease-in-out infinite;
    }
}

@keyframes sg-swipe {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .studio-gallery .sg-swipe span { animation: none; }
}
