/* ============================================================
   wp-gallery-block — Frontend Styles
   ============================================================ */

:root {
    --wpgb-gap: 4px;
    --wpgb-radius: 6px;
    --wpgb-overlay-bg: rgba(0, 0, 0, 0.55);
    --wpgb-accent: #1877f2;
}

.wp-gallery-block {
    width: 100%;
    max-width: 680px;
    margin: 16px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===========================
   Items communs
   =========================== */
.wpgb-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #e9ebee;
    border-radius: var(--wpgb-radius);
}

.wpgb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.wpgb-item:hover img {
    transform: scale(1.05);
}

.wpgb-overlay {
    position: absolute;
    inset: 0;
    background: var(--wpgb-overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: clamp(22px, 5vw, 36px);
    font-weight: 700;
    letter-spacing: -1px;
    border-radius: var(--wpgb-radius);
    transition: background 0.2s;
}

.wpgb-item:hover .wpgb-overlay {
    background: rgba(0,0,0,0.65);
}

/* ===========================
   Grille uniforme
   =========================== */
.wpgb-grid-layout {
    display: grid;
    grid-template-columns: repeat(var(--wpgb-columns, 3), 1fr);
    gap: var(--wpgb-gap);
}

.wpgb-grid-layout .wpgb-item {
    aspect-ratio: 1;
}

/* ===========================
   Layout Facebook
   (1 à 5 images)
   =========================== */
.wpgb-facebook-layout {
    display: grid;
    gap: var(--wpgb-gap);
    border-radius: var(--wpgb-radius);
    overflow: hidden;
}

/* 1 image */
.wpgb-facebook-layout.wpgb-count-1 {
    grid-template-columns: 1fr;
}
.wpgb-facebook-layout.wpgb-count-1 .wpgb-item {
    aspect-ratio: 16/9;
    border-radius: var(--wpgb-radius);
}

/* 2 images */
.wpgb-facebook-layout.wpgb-count-2 {
    grid-template-columns: 1fr 1fr;
}
.wpgb-facebook-layout.wpgb-count-2 .wpgb-item {
    aspect-ratio: 1;
}

/* 3 images */
.wpgb-facebook-layout.wpgb-count-3 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}
.wpgb-facebook-layout.wpgb-count-3 .wpgb-item:nth-child(1) {
    grid-row: 1 / 3;
    aspect-ratio: unset;
    min-height: 300px;
}
.wpgb-facebook-layout.wpgb-count-3 .wpgb-item:nth-child(2),
.wpgb-facebook-layout.wpgb-count-3 .wpgb-item:nth-child(3) {
    aspect-ratio: 1.2;
}

/* 4 images */
.wpgb-facebook-layout.wpgb-count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
}
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(1) {
    grid-column: 1 / 3;
    aspect-ratio: 16/7;
}
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(2),
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(3),
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(4) {
    aspect-ratio: 1;
}
/* 3 colonnes pour la 2e rangée */
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(2) ~ .wpgb-item {
    grid-column: auto;
}
.wpgb-facebook-layout.wpgb-count-4 {
    grid-template-columns: 1fr 1fr 1fr;
}
.wpgb-facebook-layout.wpgb-count-4 .wpgb-item:nth-child(1) {
    grid-column: 1 / 4;
}

/* 5 images */
.wpgb-facebook-layout.wpgb-count-5 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto;
}
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(1),
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(2) {
    grid-column: span 1;
    aspect-ratio: 1.2;
}
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(1) {
    grid-column: 1 / 3;
    aspect-ratio: 16/9;
}
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(2) {
    aspect-ratio: unset;
    min-height: 180px;
}
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(3),
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(4),
.wpgb-facebook-layout.wpgb-count-5 .wpgb-item:nth-child(5) {
    aspect-ratio: 1;
}

/* ===========================
   Lightbox Slider
   =========================== */
.wpgb-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.wpgb-lightbox.active {
    display: flex;
}

.wpgb-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(6px);
}

.wpgb-lightbox-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 960px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Slides */
.wpgb-slides {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    background: #111;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpgb-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    animation: wpgbFadeIn 0.3s ease;
    width: 100%;
}

.wpgb-slide.active {
    display: flex;
}

@keyframes wpgbFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

.wpgb-slide img {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.wpgb-caption {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    margin: 8px 0 0;
    text-align: center;
    max-width: 80%;
}

/* Boutons nav */
.wpgb-close,
.wpgb-prev,
.wpgb-next {
    position: absolute;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
    font-size: 22px;
    line-height: 1;
}

.wpgb-close:hover,
.wpgb-prev:hover,
.wpgb-next:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

.wpgb-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.wpgb-prev,
.wpgb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    font-size: 28px;
}

.wpgb-prev { left: 8px; }
.wpgb-next { right: 8px; }

.wpgb-prev:hover { transform: translateY(-50%) scale(1.1); }
.wpgb-next:hover { transform: translateY(-50%) scale(1.1); }

/* Compteur */
.wpgb-counter {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    margin-top: 12px;
    letter-spacing: 0.5px;
}

/* Miniatures */
.wpgb-thumbnails {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    overflow-x: auto;
    max-width: 100%;
    padding-bottom: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.wpgb-thumb {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.5;
    border: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
}

.wpgb-thumb:hover {
    opacity: 0.85;
}

.wpgb-thumb.active {
    opacity: 1;
    border-color: var(--wpgb-accent);
}

.wpgb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* No scroll on body when lightbox open */
body.wpgb-no-scroll {
    overflow: hidden;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 600px) {
    .wpgb-prev { left: 4px; }
    .wpgb-next { right: 4px; }

    .wpgb-prev,
    .wpgb-next {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }

    .wpgb-facebook-layout.wpgb-count-3 .wpgb-item:nth-child(1) {
        min-height: 200px;
    }

    .wpgb-thumb {
        width: 40px;
        height: 40px;
    }
}
