/* ============================================================
   CPE Gallery Styles
   Desktop: CSS Grid with dynamic 50/25% layout
   Mobile:  Touch slider / carousel
   ============================================================ */

.cpe-gallery {
    position: relative;
    width: 100%;
}

/* ── Desktop Grid ───────────────────────────────────────────── */
.cpe-gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr; /* 4 equal cols; items span multiple */
    grid-auto-rows: 300px;
    gap: 8px;
    width: 100%;
}

/* First item (main) = 50% width = 2 out of 4 columns */
.cpe-gallery-grid-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 6px;
    background: #111;
    grid-column: span 1;
}

.cpe-gallery-grid-item.cpe-gallery-main {
    grid-column: span 2;
    grid-row: span 2;
}

.cpe-gallery-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.cpe-gallery-grid-item:hover img {
    transform: scale(1.05);
    opacity: 0.85;
}

/* Overlay zoom icon */
.cpe-gallery-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(0,0,0,0.25);
}

.cpe-gallery-grid-item:hover .cpe-gallery-overlay {
    opacity: 1;
}

.cpe-gallery-zoom {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    color: #333;
    transition: transform 0.2s ease;
}

.cpe-gallery-zoom svg {
    width: 22px;
    height: 22px;
}

.cpe-gallery-zoom:hover {
    transform: scale(1.1);
}

/* Mobile slider: hidden on desktop */
.cpe-gallery-slider {
    display: none;
}

/* ── Lightbox ───────────────────────────────────────────────── */
.cpe-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

.cpe-lightbox.cpe-lightbox-open {
    display: flex;
}

.cpe-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.cpe-lightbox-inner {
    position: relative;
    z-index: 1;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpe-lightbox-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cpe-lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    box-shadow: 0 10px 60px rgba(0,0,0,0.5);
}

.cpe-lightbox-close,
.cpe-lightbox-prev,
.cpe-lightbox-next {
    position: absolute;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s ease;
    z-index: 2;
    line-height: 1;
}

.cpe-lightbox-close:hover,
.cpe-lightbox-prev:hover,
.cpe-lightbox-next:hover {
    background: rgba(255,255,255,0.35);
}

.cpe-lightbox-close {
    top: -52px;
    right: 0;
}

.cpe-lightbox-prev {
    left: -60px;
    top: 50%;
    transform: translateY(-50%);
}

.cpe-lightbox-next {
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Mobile slider ──────────────────────────────────────────── */
@media (max-width: 767px) {
    .cpe-gallery-grid {
        display: none;
    }

    .cpe-gallery-slider {
        display: block;
        position: relative;
        overflow: hidden;
        border-radius: 8px;
        touch-action: pan-y;
        width: 100%;
    }

    .cpe-slider-track {
        display: flex;
        transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
        will-change: transform;
    }

    .cpe-slide {
        flex: 0 0 100%;
        width: 100%;
        max-width: 100%;
        position: relative;
        overflow: hidden;
        cursor: pointer;
    }

    .cpe-slide img {
        width: 100%;
        height: 260px;
        object-fit: cover;
        display: block;
    }

    .cpe-slider-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,0,0,0.5);
        border: none;
        color: #fff;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 18px;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.2s;
    }

    .cpe-slider-btn:hover {
        background: rgba(0,0,0,0.75);
    }

    .cpe-slider-prev { left: 10px; }
    .cpe-slider-next { right: 10px; }

    .cpe-slider-dots {
        display: flex;
        justify-content: center;
        gap: 6px;
        padding: 10px 0 4px;
    }

    .cpe-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ccc;
        cursor: pointer;
        transition: background 0.2s, transform 0.2s;
    }

    .cpe-dot-active {
        background: var(--e-global-color-primary, #6EC1E4);
        transform: scale(1.3);
    }

    /* lightbox nav on mobile */
    .cpe-lightbox-prev { left: 4px; }
    .cpe-lightbox-next { right: 4px; }
}
