/* ================================================================
   WP Gallery Pro – Front-End Styles  v1.1.0
   ================================================================ */

:root {
    --wggp-radius: 4px;
    --wggp-transition: 0.3s ease;
    --wggp-caption-bg: rgba(0,0,0,0.72);
    --wggp-thumb-active: #2271b1;
}

/* ── Base ─────────────────────────────────────────────────── */
.wggp-gallery {
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.wggp-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--wggp-radius);
    background: #e8e8e8;
}

.wggp-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--wggp-transition), filter var(--wggp-transition);
    filter: var(--wggp-img-filter, none);
}

.wggp-item:hover img { transform: scale(1.04); }

/* ── Captions ─────────────────────────────────────────────── */
.wggp-caption-hover {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 10px 14px;
    background: var(--wggp-caption-bg);
    color: #fff;
    font-size: 0.875rem;
    line-height: 1.4;
    transform: translateY(100%);
    transition: transform var(--wggp-transition);
}
.wggp-item:hover .wggp-caption-hover { transform: translateY(0); }

.wggp-caption-below {
    padding: 6px 4px 10px;
    font-size: 0.85rem;
    color: #444;
    text-align: center;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: SHOWCASE  (main image + thumbnail strip)
   ════════════════════════════════════════════════════════════ */
.wggp-layout-showcase {
    display: flex;
    flex-direction: column;
    gap: var(--wggp-gap, 10px);
}

/* Main image container */
.wggp-showcase-main {
    position: relative;
    width: 100%;
    border-radius: var(--wggp-radius);
    overflow: hidden;
    background: #222;
    aspect-ratio: 16 / 9;
    cursor: pointer;
}

.wggp-showcase-main-link {
    display: block;
    width: 100%;
    height: 100%;
}

.wggp-showcase-main-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;          /* fill frame – no black bars */
    object-position: center;
    transition: opacity 0.25s ease, transform 0.4s ease;
    filter: var(--wggp-img-filter, none);
}

.wggp-showcase-main:hover .wggp-showcase-main-img {
    transform: scale(1.03);
}

.wggp-showcase-main-img.wggp-loading {
    opacity: 0.35;
}

/* Caption overlaid at bottom of main image */
.wggp-showcase-main-caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 10px 16px;
    background: var(--wggp-caption-bg);
    color: #fff;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: opacity 0.2s;
}

/* Thumbnail strip */
.wggp-showcase-thumbs {
    display: grid;
    grid-template-columns: repeat(var(--wggp-columns, 4), 1fr);
    gap: var(--wggp-gap, 10px);
}

/* Hide the lightbox hidden-anchor placeholders */
.wggp-showcase-lb-trigger { display: none !important; }

.wggp-thumb-btn {
    display: block;
    padding: 0;
    margin: 0;
    border: 3px solid transparent;
    border-radius: var(--wggp-radius);
    overflow: hidden;
    cursor: pointer;
    background: #e8e8e8;
    aspect-ratio: 1 / 1;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
}

.wggp-thumb-btn img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    transition: transform 0.25s ease, filter 0.25s ease;
    filter: var(--wggp-img-filter, none);
}

.wggp-thumb-btn:hover {
    border-color: var(--wggp-thumb-active);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}

.wggp-thumb-btn.wggp-thumb-active {
    border-color: var(--wggp-thumb-active);
    box-shadow: 0 2px 8px rgba(34,113,177,0.35);
}

.wggp-thumb-btn:focus-visible {
    outline: 2px solid var(--wggp-thumb-active);
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: GRID
   ════════════════════════════════════════════════════════════ */
.wggp-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--wggp-columns, 3), 1fr);
    gap: var(--wggp-gap, 10px);
}
.wggp-layout-grid .wggp-item { aspect-ratio: 1 / 1; }

/* ════════════════════════════════════════════════════════════
   LAYOUT: MASONRY  (CSS columns)
   ════════════════════════════════════════════════════════════ */
.wggp-layout-masonry {
    columns: var(--wggp-columns, 3);
    column-gap: var(--wggp-gap, 10px);
}
.wggp-layout-masonry .wggp-item {
    break-inside: avoid;
    margin-bottom: var(--wggp-gap, 10px);
    display: inline-block;
    width: 100%;
}
.wggp-layout-masonry .wggp-item img { height: auto; object-fit: unset; }

/* ════════════════════════════════════════════════════════════
   LAYOUT: JUSTIFIED ROW
   ════════════════════════════════════════════════════════════ */
.wggp-layout-justified {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wggp-gap, 10px);
}
.wggp-layout-justified .wggp-item {
    flex: 1 1 200px;
    height: 220px;
    min-width: 120px;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: MOSAIC / FEATURED
   ════════════════════════════════════════════════════════════ */
.wggp-layout-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--wggp-columns, 3), 1fr);
    grid-auto-rows: 220px;
    gap: var(--wggp-gap, 10px);
}
.wggp-layout-mosaic .wggp-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: SLIDER / CAROUSEL
   ════════════════════════════════════════════════════════════ */
.wggp-layout-slider {
    position: relative;
    overflow: hidden;
    border-radius: var(--wggp-radius);
}
.wggp-slider-track {
    display: flex;
    transition: transform 0.45s cubic-bezier(0.4,0,0.2,1);
    will-change: transform;
}
.wggp-layout-slider .wggp-item {
    flex: 0 0 calc(100% / var(--wggp-columns, 1));
    height: 460px;
    border-radius: 0;
}

.wggp-slider-btn {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.45);
    color: #fff;
    border: none;
    font-size: 2.2rem;
    line-height: 1;
    padding: 0 18px;
    height: 56px;
    cursor: pointer;
    z-index: 10;
    border-radius: var(--wggp-radius);
    transition: background 0.2s;
}
.wggp-slider-btn:hover { background: rgba(0,0,0,0.75); }
.wggp-slider-prev { left: 12px; }
.wggp-slider-next { right: 12px; }

.wggp-slider-dots {
    position: absolute;
    bottom: 12px;
    left: 50%; transform: translateX(-50%);
    display: flex;
    gap: 7px;
    z-index: 10;
}
.wggp-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: rgba(255,255,255,0.55);
    cursor: pointer;
    border: none;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}
.wggp-dot.wggp-dot-active { background: #fff; transform: scale(1.3); }

/* ════════════════════════════════════════════════════════════
   LIGHTBOX
   ════════════════════════════════════════════════════════════ */

/* The lightbox sits above EVERYTHING on the page.
   isolation:isolate + transform force a new stacking context
   so no child of the page can bleed on top of it. */
.wggp-lightbox {
    position: fixed;
    inset: 0;
    /* Maximum z-index to beat sticky headers, sliders, hero sections */
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
}

/* Full-screen dark overlay — rendered at z-index 0 inside the lightbox */
.wggp-lightbox-overlay {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

/* Inner wrapper sits above the overlay */
.wggp-lightbox-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Use most of the viewport, leaving room for the arrow buttons */
    width: calc(100vw - 160px);
    max-width: 1200px;
    max-height: 92vh;
}

/* The image itself */
#wggp-lightbox-img {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
    transition: opacity 0.22s ease;
}

/* Caption below the image */
#wggp-lightbox-caption {
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.9rem;
    margin-top: 14px;
    text-align: center;
    max-width: 700px;
    padding: 0 16px;
    line-height: 1.5;
}

/* ── Shared button base ─────────────────────────────────── */
.wggp-lightbox-close,
.wggp-lightbox-prev,
.wggp-lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 300;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    /* Prevent accidental text selection */
    user-select: none;
    -webkit-user-select: none;
}
.wggp-lightbox-close:hover,
.wggp-lightbox-prev:hover,
.wggp-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.32);
    border-color: rgba(255, 255, 255, 0.7);
}

/* ── Close button – top-right corner of the inner box ──── */
.wggp-lightbox-close {
    width: 42px;
    height: 42px;
    font-size: 1.4rem;
    /* Anchor to the top-right of .wggp-lightbox (not .wggp-lightbox-inner) */
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2;
}
.wggp-lightbox-close:hover { transform: scale(1.12); }

/* ── Prev / Next – anchored to the lightbox viewport edges ─ */
.wggp-lightbox-prev,
.wggp-lightbox-next {
    /* Fix them to the viewport so they are never clipped by the inner box */
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    font-size: 2rem;
    z-index: 2;
}
.wggp-lightbox-prev { left: 16px; }
.wggp-lightbox-next { right: 16px; }
.wggp-lightbox-prev:hover { transform: translateY(-50%) scale(1.1); }
.wggp-lightbox-next:hover { transform: translateY(-50%) scale(1.1); }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ════════════════════════════════════════════════════════════ */

/* Tablet – 900px */
@media (max-width: 900px) {
    /* Grid */
    .wggp-layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Masonry */
    .wggp-layout-masonry { columns: 2 !important; }

    /* Mosaic */
    .wggp-layout-mosaic {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 180px;
    }

    /* Showcase thumbnails – max 4 cols */
    .wggp-showcase-thumbs {
        grid-template-columns: repeat(min(var(--wggp-columns, 4), 4), 1fr) !important;
    }

    /* Lightbox inner narrows on tablet */
    .wggp-lightbox-inner { width: calc(100vw - 140px); }
}

/* Large phone – 600px */
@media (max-width: 600px) {
    /* Grid */
    .wggp-layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Masonry */
    .wggp-layout-masonry { columns: 2 !important; }

    /* Mosaic – collapse to simple 2-col grid */
    .wggp-layout-mosaic {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 140px;
    }
    .wggp-layout-mosaic .wggp-item:first-child {
        grid-column: span 2;
        grid-row: span 1;
    }

    /* Justified */
    .wggp-layout-justified .wggp-item {
        flex: 1 1 130px;
        height: 160px;
    }

    /* Slider */
    .wggp-layout-slider .wggp-item { height: 280px; }
    .wggp-slider-btn { font-size: 1.6rem; height: 44px; padding: 0 12px; }

    /* Showcase – 2-col thumbnails on phones */
    .wggp-showcase-thumbs {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .wggp-showcase-main { aspect-ratio: 4 / 3; }

    /* Lightbox on mobile – smaller arrows, full-width image */
    .wggp-lightbox-inner { width: calc(100vw - 100px); }
    .wggp-lightbox-prev,
    .wggp-lightbox-next { width: 42px; height: 42px; font-size: 1.5rem; }
    .wggp-lightbox-prev { left: 8px; }
    .wggp-lightbox-next { right: 8px; }
    .wggp-lightbox-close { top: 12px; right: 12px; }
    #wggp-lightbox-img { max-height: 70vh; }
}

/* Small phone – 400px */
@media (max-width: 400px) {
    /* Grid & Masonry stay 2-col */
    .wggp-layout-grid {
        grid-template-columns: repeat(1, 1fr) !important;
    }
    .wggp-layout-masonry { columns: 1 !important; }

    /* Showcase stay 2-col thumbs */
    .wggp-showcase-main { aspect-ratio: 1 / 1; }
}
