/**
 * WS Booster - Galerie Parallax Decalee (pattern bento portrait + parallax Sher)
 *
 * Structure :
 * - .ws-gp           : section relative, min-height = 350vh (budget scroll)
 * - .ws-gp__layout   : STICKY top:0 height:100vh overflow:hidden
 *                      grid 2 cols [1fr (intro)  1.3fr (galerie)] align-items:center
 * - .ws-gp__heading  : col gauche, statique, centree verticalement (intro)
 * - .ws-gp__gallery  : col droite, contient les 2 sub-cols parallax (1fr 1fr)
 * - .ws-gp__col--down: sub-col gauche, items qui descendent au scroll (translateY)
 * - .ws-gp__col--up  : sub-col droite, items qui montent au scroll (translateY)
 *
 * Layout = bento portrait (proven works). Parallax = pattern Sher Agency.
 */

.ws-gp {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    /* PAS de min-height. v3.35 (stack copie de Sticky Timeline) : la
     * hauteur de .ws-gp vient NATURELLEMENT de ses 2 enfants reels :
     * .ws-gp__sticky (100vh) + .ws-gp__runway ({distance}vh). Comme ce
     * sont de vrais elements avec des hauteurs reelles, .ws-gp fait
     * toujours 100vh+distance => le sticky a TOUJOURS son budget de
     * scroll, impossible a ecraser (le bug v3.32 du min-height ecrase
     * a 400px ne peut plus se produire). */
}

/* ===== PANNEAU STICKY : c'est lui qui se fige (CSS pur) =====
 * Pattern Sticky Timeline. position:sticky reste colle a top:0 tant
 * qu'on scrolle dans .ws-gp. Le runway frere fournit le budget. */
.ws-gp__sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

/* ===== RUNWAY : vrai element frere = budget de scroll du sticky =====
 * Hauteur posee inline par le PHP (= {distance}vh). Tant qu'on le
 * scrolle, le panneau sticky reste fige. Equivalent des etapes 70vh
 * de Sticky Timeline. Vide, invisible, juste de l'espace de scroll. */
.ws-gp__runway {
    width: 100%;
    pointer-events: none;
}

/* ========================================================================
 * FIX CRITIQUE — transition: none sur les elements animes par GSAP
 * ========================================================================
 * Cause racine du bug "widget qui lag/saute au scroll" (documente par
 * l'equipe GSAP) : Elementor applique des `transition: all .3s` globales
 * sur enormement d'elements. Quand GSAP pose un `transform` en temps reel
 * (pin + scrub), le `transition` CSS fait que chaque frame est ANIMEE sur
 * 0.3s au lieu d'etre instantanee => le transform GSAP et le CSS transition
 * se battent => decalage, saut, lag visible.
 *
 * Solution : forcer transition:none sur TOUS les elements que GSAP touche
 * (layout pinned + les 2 cols translatees). GSAP gere lui-meme le lissage
 * via scrub, pas besoin de transition CSS.
 *
 * Ref : https://gsap.com/community/forums/ (multiple threads Elementor).
 */
.ws-gp__layout,
.ws-gp__col,
.ws-gp .pin-spacer {
    transition: none !important;
    -webkit-transition: none !important;
}


/* ===== LAYOUT : grid 2 cols (intro | galerie), remplit le panneau sticky =====
 * height:100% du .ws-gp__sticky (100vh). grid-template-rows:100% pour que
 * la row ne prenne pas la hauteur intrinseque des cols parallax.
 * PAS de position ici : c'est .ws-gp__sticky (parent) qui se fige.
 */
.ws-gp__layout {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    grid-template-rows: 100%;
    gap: 48px;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    overflow: hidden;
    padding: 32px 24px;
    box-sizing: border-box;
}

/* ===== COLONNE GAUCHE : intro (titre + sous-titre + CTAs) =====
 * Forcer height:100% du slot grid + justify-content:center pour garantir
 * que le contenu reste vertical-centre dans la fenetre 100vh sticky,
 * meme si align-items du grid est override quelque part.
 */
.ws-gp__heading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 20px 10px;
    box-sizing: border-box;
    height: 100%;
    align-self: stretch;
}

.ws-gp__title {
    margin: 0;
    font-size: clamp(28px, 3.5vw, 56px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: #0f172a;
}

.ws-gp__title-highlight {
    color: #3b82f6;
    font-style: italic;
}

.ws-gp__subtitle {
    margin: 0;
    font-size: clamp(14px, 1.1vw, 17px);
    line-height: 1.55;
    color: #475569;
    max-width: 420px;
}

.ws-gp__ctas {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    margin-top: 8px;
}

.ws-gp__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: transform 0.25s ease, background-color 0.25s ease, color 0.25s ease;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.ws-gp__cta--primary {
    background-color: #0f172a;
    color: #ffffff;
}
.ws-gp__cta--primary:hover {
    transform: translateY(-2px);
}

.ws-gp__cta--secondary {
    background-color: transparent;
    color: #0f172a;
    border-color: #0f172a;
}
.ws-gp__cta--secondary:hover {
    background-color: #0f172a;
    color: #ffffff;
}

/* ===== COLONNE DROITE : galerie (2 sub-cols parallax) ===== */
.ws-gp__gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    height: 100%;
    align-self: stretch;
    /* overflow hidden ICI (sur gallery) en plus de layout : les cols ont
     * des transforms via GSAP qui les translatent verticalement de -666px+.
     * Quand layout est en position:fixed (pin actif), la chaine de clipping
     * stacking-context peut etre cassee si gallery est en overflow:visible.
     * Double clipping (gallery + layout) garantit que les cols translatees
     * ne debordent JAMAIS visuellement au-dessus/dessous du widget. */
    overflow: hidden;
}

/* Galerie a 3 colonnes : active uniquement si le Groupe 3 contient des items
 * (classe posee par le PHP / content_template). Sinon on reste a 2 colonnes. */
.ws-gp__gallery--3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.ws-gp__col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-self: start;
    will-change: transform;
}

/* Decalage initial pour effet "decale" entre les sub-cols */
.ws-gp__col--up {
    margin-top: -80px;
}
.ws-gp__col--3 {
    margin-top: -40px;
}

/* ===== ITEMS ===== */
.ws-gp__item {
    display: block;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    position: relative;
    aspect-ratio: 4 / 3;
    max-height: 320px;
    background-color: #1e293b;
    flex-shrink: 0;
}

a.ws-gp__item {
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
a.ws-gp__item:hover {
    transform: translateY(-4px);
}

/* === Item type IMAGE === */
.ws-gp__item--image img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    display: block;
}

.ws-gp__item-overlay {
    position: absolute;
    inset: auto 0 0 0;
    padding: 16px 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
    color: #ffffff;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.ws-gp__item-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    flex: 1;
}

.ws-gp__item-btn {
    display: inline-block;
    padding: 6px 14px;
    background-color: #ffffff;
    color: #0f172a;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* === Item type LOGO === */
.ws-gp__item--logo {
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.ws-gp__item--logo img {
    width: 60% !important;
    height: auto !important;
    max-width: 200px !important;
    max-height: 80px !important;
    object-fit: contain !important;
    filter: brightness(0) invert(1);
}

/* === Item type CARD === */
.ws-gp__item--card {
    aspect-ratio: 4 / 3;
    max-height: 320px;
    padding: 28px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #ffffff;
    text-align: left;
}

.ws-gp__card-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.ws-gp__card-text {
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0.85;
}

.ws-gp__card-btn {
    display: inline-block;
    align-self: flex-start;
    padding: 10px 20px;
    background: #ffffff;
    color: #0f172a;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
}

/* ===== PLACEHOLDERS (quand pas d'image) ===== */
.ws-gp__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
    padding: 16px;
    box-sizing: border-box;
}

.ws-gp__placeholder span {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.ws-gp__placeholder svg {
    width: 40px !important;
    height: 40px !important;
    max-width: none !important;
    max-height: none !important;
}

.ws-gp__placeholder--logo {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    position: relative;
    inset: auto;
}

/* ===== MOBILE : 1 colonne empilee, pas de sticky, pas de parallax ===== */
@media (max-width: 768px) {
    .ws-gp {
        min-height: auto !important;
        height: auto !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    /* Mobile : pas de sticky, pas de runway. Tout en flux normal empile. */
    .ws-gp__sticky {
        position: static !important;
        top: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    .ws-gp__runway {
        display: none !important;
    }

    .ws-gp__layout {
        position: static !important;
        top: auto !important;
        height: auto !important;
        max-width: 100% !important;
        width: 100% !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 24px !important;
        overflow: visible !important;
        padding: 32px 16px !important;
        margin: 0 !important;
        align-items: stretch !important;
    }

    .ws-gp__heading {
        padding: 0;
        text-align: center;
        align-items: center;
    }

    .ws-gp__subtitle {
        margin-left: auto;
        margin-right: auto;
    }

    .ws-gp__ctas {
        align-items: center;
    }

    .ws-gp__gallery,
    .ws-gp__gallery--3col {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        height: auto !important;
    }

    .ws-gp__col {
        position: static !important;
        top: auto !important;
        transform: none !important;
        translate: none !important;
        margin-top: 0 !important;
        height: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        will-change: auto !important;
    }

    .ws-gp__item {
        max-height: 320px !important;
    }
}

/* ===== A11Y ===== */
@media (prefers-reduced-motion: reduce) {
    .ws-gp__col {
        transform: none !important;
        transition: none !important;
    }
}
