section.slider-gallery-block {
    padding: 0 16px;
    margin: 0 !important;
}

@media screen and (min-width: 998px){
    section.slider-gallery-block {
        padding: 0 32px;
    }
}

/* Background support */
section.slider-gallery-block.background-primary {
    background-color: var(--gbg-color-primary);
    color: #ffffff;
}

section.slider-gallery-block.background-grey {
    background-color: var(--gbg-color-grey);
    color: var(--gbg-color-primary);
}

section.slider-gallery-block.background-light {
    background-color: var(--gbg-color-light);
    color: var(--gbg-color-primary);
}

section.slider-gallery-block.background-primary .slider-gallery-title,
section.slider-gallery-block.background-primary .slider-slide-wrapper .slider-slide-content .slider-slide-description {
    color: var(--gbg-color-light-citron);
}

section.slider-gallery-block.background-primary .slider-dots .slider-dot.slider-dot-active {
    background-color: var(--gbg-color-light-citron);
}

section.slider-gallery-block .slider-gallery-wrapper {
    max-width: var(--gbg-breakpoint-desktop);
    margin: 48px 16px;
}

section.slider-gallery-block .slider-gallery-title {
    margin: 0 0 32px 0;
    color: var(--gbg-color-primary);
    font-size: clamp(20px, 4vw, 56px) !important;
    font-weight: 500;
    letter-spacing: -1px;
    line-height: 1.1 !important;
}

@media screen and (min-width: 998px) {
    section.slider-gallery-block .slider-gallery-wrapper {
        padding: 64px 0;
        margin: 0 auto;
    }
    section.slider-gallery-block .slider-gallery-title {
        max-width: 55%;
        text-wrap: pretty;
    }
    section.slider-gallery-block .slider-gallery-title.is-full-width {
        max-width: 100%;
    }
}

/* Slider container */
section.slider-gallery-block .slider-gallery-container {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: var(--gbg-spacing-sm);
}

@media screen and (min-width: 998px) {
    section.slider-gallery-block .slider-gallery-container {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        align-items: start;
    }
    
    section.slider-gallery-block .slider-gallery-slides {
        grid-column: 1;
        grid-row: 1;
    }
    
    section.slider-gallery-block .slider-nav-arrows {
        grid-column: 2;
        margin-top: 0;
        margin-bottom: 88px;
        align-self: stretch;
        justify-content: flex-end;
    }
    
    section.slider-gallery-block .slider-dots {
        grid-column: 1;
        grid-row: 2;
        align-self: end;
    }
}

section.slider-gallery-block .swiper {
    position: relative;
    overflow: hidden;
    list-style: none;
    padding: 0;
    z-index: 1;
    display: block;
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
}

section.slider-gallery-block .swiper-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    transition-property: transform;
    box-sizing: content-box;
}

section.slider-gallery-block .swiper-slide {
    flex-shrink: 0;
    height: 100%;
    position: relative;
    transition-property: transform;
    display: block;
    box-sizing: border-box;
}

/* Mobile: 1 slide visible - définir explicitement pour éviter le layout shift */
@media screen and (max-width: 767px) {
    section.slider-gallery-block .swiper:not(.swiper-initialized) .swiper-wrapper .swiper-slide {
        width: 100% !important;
    }
}

/* Desktop: 3 slides visibles - définir explicitement AVANT l'init Swiper */
@media screen and (min-width: 768px) {
    body:not(.block-editor-page) section.slider-gallery-block .swiper:not(.swiper-initialized) .swiper-wrapper .swiper-slide {
        width: calc((100% - 60px) / 3) !important; /* 60px = 2 gaps × 30px */
        margin-right: 30px !important;
    }

    section.slider-gallery-block .swiper:not(.swiper-initialized) .swiper-wrapper .swiper-slide:nth-child(3n) {
        margin-right: 0 !important;
    }
}

/* Styles spécifiques au bloc slider-gallery seulement */

/* Navigation arrows */
section.slider-gallery-block .slider-nav-arrows {
    display: flex;
    flex-direction: row;
    gap: var(--gbg-spacing-xs);
    justify-content: center;
    margin-top: 16px;
}

section.slider-gallery-block .slider-arrow {
    display: block;
    width: 47px;
    height: 47px;
    padding: 7px !important;
    border-radius: 9999px;
    background-color: var(--gbg-color-secondary) !important;
}

section.slider-gallery-block .slider-arrow svg {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

@media screen and (min-width: 998px) {
    section.slider-gallery-block .slider-nav-arrows {
        flex-direction: column;
        justify-content: flex-end;
    }
}

.slider-nav-arrows[data-visible="false"],
.slider-nav-arrows[data-visible=""],
.slider-nav-arrows[data-visible="0"] {
    display: none !important;
}

/* Pagination dots */
section.slider-gallery-block .slider-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

/* Cacher les dots quand data-visible est falsy */
section.slider-gallery-block .slider-dots[data-visible="false"],
section.slider-gallery-block .slider-dots[data-visible=""],
section.slider-gallery-block .slider-dots[data-visible="0"] {
    display: none !important;
}

section.slider-gallery-block .slider-dots .slider-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gbg-color-grey);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

section.slider-gallery-block .slider-dots .slider-dot.slider-dot-active {
    background: var(--gbg-color-secondary);
}

/* ============================================
   Editor
   ============================================ */

.editor-styles-wrapper section.slider-gallery-block .slider-gallery-container .slider-gallery-slides .block-editor-block-list__layout{
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 1fr;
    gap: var(--gbg-spacing-sm);
}
