/* Screen-reader-only utility */
.wppro-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Root */
section.wppro-gallery {
    width: 100%;
}

/* Grid layout */
section.wppro-gallery > .wppro-gallery__grid {
    display: grid !important;
    gap: 0.75rem !important;

    --wppro-gallery-columns-desktop: 3;
    --wppro-gallery-columns-tablet: 2;
    --wppro-gallery-columns-mobile: 1;
    --wppro-gallery-thumb-fit: cover;

    grid-template-columns: repeat(var(--wppro-gallery-columns-desktop), minmax(0, 1fr)) !important;
}

/* Tablet */
@media (max-width: 991px) {
    section.wppro-gallery > .wppro-gallery__grid {
        grid-template-columns: repeat(var(--wppro-gallery-columns-tablet), minmax(0, 1fr)) !important;
    }
}

/* Mobile */
@media (max-width: 767px) {
    section.wppro-gallery > .wppro-gallery__grid {
        grid-template-columns: repeat(var(--wppro-gallery-columns-mobile), minmax(0, 1fr)) !important;
    }
}

section.wppro-gallery .wppro-gallery__item {
    position: relative !important;
}

/* Reset theme button junk */
section.wppro-gallery .wppro-gallery__thumb {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer;
}

/* Inner wrapper
   - width: full column, optionally capped by max-width
   - height: natural, optionally capped by max-height (with cropping)
*/
section.wppro-gallery .wppro-gallery__thumb-inner {
    position: relative !important;
    display: block !important; /* critical: override theme's inline */
    width: 100% !important;
    max-width: var(--wppro-gallery-thumb-max-width, 100%) !important;
    margin: 0 auto !important;
    height: auto !important;
    max-height: var(--wppro-gallery-thumb-max-height, none) !important;
    overflow: hidden !important;
    background: #f5f5f5;
    line-height: 0;
}

/* Image fills width; height auto. If container has max-height,
   extra image height is cropped (overflow hidden). */
section.wppro-gallery .wppro-gallery__thumb-image {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    object-fit: var(--wppro-gallery-thumb-fit, cover) !important;
    border: 0 !important;
    margin: 0 !important;
}

/* Lightbox overlay */
section.wppro-gallery .wppro-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

/* Hide lightbox when aria-hidden="true" */
section.wppro-gallery .wppro-gallery__lightbox[aria-hidden="true"] {
    display: none !important;
}

section.wppro-gallery .wppro-gallery__lightbox-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

section.wppro-gallery .wppro-gallery__lightbox-figure {
    margin: 0;
    max-width: 100%;
    max-height: 100%;
}

section.wppro-gallery .wppro-gallery__lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 80vh;
    margin: 0 auto;
}

section.wppro-gallery .wppro-gallery__lightbox-caption {
    margin-top: 0.5rem;
    text-align: center;
    color: #f1f1f1;
    font-size: 0.875rem;
}

/* Controls */
section.wppro-gallery .wppro-gallery__lightbox-close,
section.wppro-gallery .wppro-gallery__lightbox-prev,
section.wppro-gallery .wppro-gallery__lightbox-next {
    border: 0 !important;
    padding: 0.5rem 0.75rem !important;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

/* Close button fixed in top-right of viewport */
section.wppro-gallery .wppro-gallery__lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
}

/* Prev/Next centered vertically on sides of inner area */
section.wppro-gallery .wppro-gallery__lightbox-prev,
section.wppro-gallery .wppro-gallery__lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

section.wppro-gallery .wppro-gallery__lightbox-prev {
    left: 0.5rem;
}

section.wppro-gallery .wppro-gallery__lightbox-next {
    right: 0.5rem;
}

/* Prevent background scroll when any gallery is open */
body.wppro-gallery-open {
    overflow: hidden;
}
