/**
 * Bloc Mosaïque
 */

.leb-mosaic {
    padding: 1rem 0;
}

.leb-mosaic__grid {
    display: grid;
    gap: var(--mosaic-gap, 1rem);
}

/* Colonnes */
.leb-mosaic--cols-2 .leb-mosaic__grid {
    grid-template-columns: repeat(2, 1fr);
}

.leb-mosaic--cols-3 .leb-mosaic__grid {
    grid-template-columns: repeat(3, 1fr);
}

.leb-mosaic--cols-4 .leb-mosaic__grid {
    grid-template-columns: repeat(4, 1fr);
}

.leb-mosaic--cols-5 .leb-mosaic__grid {
    grid-template-columns: repeat(5, 1fr);
}

/* Gaps */
.leb-mosaic--gap-small {
    --mosaic-gap: 0.5rem;
}

.leb-mosaic--gap-medium {
    --mosaic-gap: 1rem;
}

.leb-mosaic--gap-large {
    --mosaic-gap: 1.5rem;
}

.leb-mosaic--gap-none {
    --mosaic-gap: 0;
}

/* Items */
.leb-mosaic__item {
    margin: 0;
    overflow: hidden;
    border-radius: var(--wp--custom--border-radius, 4px);
}

.leb-mosaic__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 1;
    display: block;
    transition: transform 0.3s ease;
}

/* Zoom hover */
.leb-mosaic--zoom .leb-mosaic__item:hover img {
    transform: scale(1.05);
}

.leb-mosaic--zoom .leb-mosaic__item a {
    display: block;
    cursor: zoom-in;
}

/* Caption */
.leb-mosaic__caption {
    padding: 0.5rem;
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    background: #f9f9f9;
}

/* Placeholder éditeur */
.leb-mosaic__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    color: #666;
}

.leb-mosaic__placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .leb-mosaic--cols-4 .leb-mosaic__grid,
    .leb-mosaic--cols-5 .leb-mosaic__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .leb-mosaic--cols-3 .leb-mosaic__grid,
    .leb-mosaic--cols-4 .leb-mosaic__grid,
    .leb-mosaic--cols-5 .leb-mosaic__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Style Avancé - Reproduit l'esthétique du CMS LEB
   ========================================================================== */

.leb-mosaic.is-style-advanced {
    padding: 2rem 0;
}

.leb-mosaic.is-style-advanced .leb-mosaic__grid {
    gap: 1.25rem;
}

.leb-mosaic.is-style-advanced .leb-mosaic__item {
    position: relative;
    border-radius: 0;
    overflow: hidden;
    background: #f5f5f5;
}

.leb-mosaic.is-style-advanced .leb-mosaic__item img {
    border-radius: 0;
    transition: transform 0.4s ease, filter 0.4s ease;
}

.leb-mosaic.is-style-advanced .leb-mosaic__item:hover img {
    transform: scale(1.08);
}

/* Légende toujours visible avec overlay */
.leb-mosaic.is-style-advanced .leb-mosaic__caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    transform: translateY(0);
    opacity: 1;
    transition: all 0.3s ease;
}

.leb-mosaic.is-style-advanced .leb-mosaic__item:hover .leb-mosaic__caption {
    padding-bottom: 1.25rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 70%, transparent 100%);
}

/* Icône zoom au survol */
.leb-mosaic.is-style-advanced.leb-mosaic--zoom .leb-mosaic__item a::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23333'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3Cpath d='M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z'/%3E%3C/svg%3E");
    background-size: 24px;
    background-repeat: no-repeat;
    background-position: center;
}

.leb-mosaic.is-style-advanced.leb-mosaic--zoom .leb-mosaic__item:hover a::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Espacement responsive */
@media (max-width: 768px) {
    .leb-mosaic.is-style-advanced .leb-mosaic__grid {
        gap: 0.75rem;
    }

    .leb-mosaic.is-style-advanced .leb-mosaic__caption {
        font-size: 0.75rem;
        padding: 0.75rem;
    }
}

/* ==========================================================================
   Lightbox
   ========================================================================== */

.leb-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.leb-lightbox.is-open {
    visibility: visible;
    opacity: 1;
}

.leb-lightbox__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

/* Boutons */
.leb-lightbox__close,
.leb-lightbox__prev,
.leb-lightbox__next {
    z-index: 1;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.leb-lightbox__close:hover,
.leb-lightbox__prev:hover,
.leb-lightbox__next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.leb-lightbox__close:focus-visible,
.leb-lightbox__prev:focus-visible,
.leb-lightbox__next:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.leb-lightbox__close svg,
.leb-lightbox__prev svg,
.leb-lightbox__next svg {
    display: block;
}

/* Close */
.leb-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* Navigation wrapper — desktop : flèches sur les côtés */
.leb-lightbox__nav {
    display: contents;
}

.leb-lightbox__prev,
.leb-lightbox__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.leb-lightbox__prev {
    left: 16px;
}

.leb-lightbox__next {
    right: 16px;
}

/* Contenu */
.leb-lightbox__content {
    position: relative;
    z-index: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.leb-lightbox__image {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    display: block;
}

.leb-lightbox__caption {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    margin-top: 12px;
    max-width: 600px;
}

/* Compteur — desktop : en bas centré */
.leb-lightbox__counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

/* Mobile / tablette : flèches sous l'image */
@media (max-width: 1024px) {
    .leb-lightbox {
        flex-direction: column;
    }

    .leb-lightbox__content {
        flex: 1;
        justify-content: center;
        min-height: 0;
    }

    .leb-lightbox__image {
        max-width: 95vw;
        max-height: 70vh;
    }

    .leb-lightbox__nav {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 24px;
        position: relative;
        z-index: 1;
        padding: 16px 0 20px;
    }

    .leb-lightbox__prev,
    .leb-lightbox__next {
        position: static;
        transform: none;
        width: 48px;
        height: 48px;
    }

    .leb-lightbox__counter {
        position: static;
        transform: none;
    }
}
