/* ========================================
   MetalPlus Gallery — Frontend Styles v1.1
   ======================================== */

.mpg-gallery {
    --mpg-columns: 3;
    --mpg-gap: 10px;
    --mpg-radius: 8px;
    --mpg-ratio: 1/1;
    --mpg-slides-per-view: 1;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.mpg-gallery *, .mpg-gallery *::before, .mpg-gallery *::after {
    box-sizing: border-box;
}

/* ========================================
   FILTER BUTTONS
   ======================================== */
.mpg-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
}

.mpg-filter-btn {
    padding: 8px 20px;
    border: 2px solid #d1d5db;
    border-radius: 30px;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.mpg-filter-btn:hover {
    border-color: #2c449c;
    color: #2c449c;
    background: #f0f3ff;
}

.mpg-filter-btn.active {
    background: #2c449c;
    border-color: #2c449c;
    color: #fff;
}

@media (max-width: 480px) {
    .mpg-filters {
        gap: 6px;
    }
    .mpg-filter-btn {
        padding: 6px 14px;
        font-size: 13px;
    }
}

/* ========================================
   GRID LAYOUT
   ======================================== */
.mpg-grid-wrap {
    display: grid;
    grid-template-columns: repeat(var(--mpg-columns), 1fr);
    gap: var(--mpg-gap);
}

@media (max-width: 768px) {
    .mpg-grid-wrap {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .mpg-grid-wrap {
        grid-template-columns: 1fr;
    }
}

/* Grid items */
.mpg-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--mpg-radius);
    cursor: pointer;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Filter animation */
.mpg-item.mpg-hidden {
    opacity: 0;
    transform: scale(0.8);
    position: absolute;
    pointer-events: none;
    width: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.mpg-item.mpg-visible {
    opacity: 1;
    transform: scale(1);
}

.mpg-item-inner {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: var(--mpg-radius);
}

.mpg-grid-wrap .mpg-item-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    display: block;
    transition: transform 0.4s ease;
}

/* Quand le ratio est "auto", on laisse l'image à sa hauteur naturelle */
.mpg-gallery[style*="--mpg-ratio:auto"] .mpg-grid-wrap .mpg-item-inner {
    height: auto;
}

.mpg-gallery[style*="--mpg-ratio:auto"] .mpg-grid-wrap .mpg-item-inner img {
    height: auto;
    aspect-ratio: auto;
    object-fit: fill;
}

/* Pour les ratios fixes, on applique l'aspect-ratio sur le conteneur */
.mpg-grid-wrap .mpg-item-inner {
    aspect-ratio: var(--mpg-ratio);
}

/* Hover effects */
.mpg-hover-zoom .mpg-item:hover .mpg-item-inner img {
    transform: scale(1.08);
}

.mpg-hover-fade .mpg-item:hover .mpg-item-inner img {
    opacity: 0.8;
}

/* Overlay */
.mpg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: var(--mpg-radius);
    color: #fff;
}

.mpg-item:hover .mpg-overlay {
    opacity: 1;
}

/* Caption */
.mpg-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 14px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    border-radius: 0 0 var(--mpg-radius) var(--mpg-radius);
}

/* ========================================
   CAROUSEL LAYOUT (Multi-slide support)
   ======================================== */
.mpg-layout-carousel {
    position: relative;
}

.mpg-carousel-viewport {
    overflow: hidden;
    border-radius: var(--mpg-radius);
    width: 100%;
}

.mpg-carousel-track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    gap: var(--mpg-gap);
    width: 100%;
}

.mpg-slide {
    flex: 0 0 calc((100% - (var(--mpg-gap) * (var(--mpg-slides-per-view) - 1))) / var(--mpg-slides-per-view));
    min-width: 0;
    overflow: hidden;
}

.mpg-slide .mpg-item-inner {
    border-radius: var(--mpg-radius);
    aspect-ratio: 4/3;
    overflow: hidden;
    position: relative;
}

.mpg-slide .mpg-item-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    display: block;
}

.mpg-slide .mpg-overlay {
    border-radius: var(--mpg-radius);
}

/* Responsive carousel: reduce slides on smaller screens */
@media (max-width: 768px) {
    .mpg-slide {
        flex: 0 0 calc((100% - (var(--mpg-gap) * (min(var(--mpg-slides-per-view), 2) - 1))) / min(var(--mpg-slides-per-view), 2));
    }
}

@media (max-width: 480px) {
    .mpg-slide {
        flex: 0 0 100%;
    }
}

/* Arrows */
.mpg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #1d2327;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    padding: 0;
}

.mpg-arrow:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transform: translateY(-50%) scale(1.05);
}

.mpg-arrow-prev {
    left: 12px;
}

.mpg-arrow-next {
    right: 12px;
}

/* Dots */
.mpg-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 16px 0;
}

.mpg-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #c3c4c7;
    cursor: pointer;
    padding: 0;
    transition: all 0.3s ease;
}

.mpg-dot:hover {
    background: #787c82;
}

.mpg-dot.active {
    background: #2c449c;
    transform: scale(1.2);
}

/* ========================================
   LIGHTBOX
   ======================================== */
.mpg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mpg-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.mpg-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mpg-lightbox-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.mpg-lightbox.active .mpg-lightbox-content img {
    transform: scale(1);
}

.mpg-lightbox-caption {
    position: absolute;
    bottom: -40px;
    left: 0;
    right: 0;
    text-align: center;
    color: #e0e0e0;
    font-size: 14px;
}

.mpg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 44px;
    text-align: center;
    padding: 0;
    transition: background 0.2s;
    z-index: 10;
}

.mpg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mpg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
    z-index: 10;
}

.mpg-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.25);
}

.mpg-lightbox-prev {
    left: 20px;
}

.mpg-lightbox-next {
    right: 20px;
}

.mpg-lightbox-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    z-index: 10;
}

@media (max-width: 768px) {
    .mpg-arrow {
        width: 36px;
        height: 36px;
    }
    .mpg-arrow-prev { left: 8px; }
    .mpg-arrow-next { right: 8px; }
    .mpg-lightbox-nav {
        width: 40px;
        height: 40px;
    }
    .mpg-lightbox-prev { left: 10px; }
    .mpg-lightbox-next { right: 10px; }
    .mpg-lightbox-content img {
        max-width: 95vw;
        max-height: 80vh;
    }
}
