/* =============================================
   Light Masonry Gallery - Frontend Styles
   JS-positioned masonry for pixel-perfect gaps
   ============================================= */

.mpg-masonry-gallery {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    font-size: 0;
    line-height: 0;
    /* height set dynamically by JS */
}

.mpg-masonry-gallery figure.mpg-gallery-item {
    position: absolute !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    line-height: 0 !important;
    font-size: 0 !important;
    box-sizing: border-box !important;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.mpg-masonry-gallery figure.mpg-gallery-item.mpg-positioned {
    opacity: 1;
}

.mpg-masonry-gallery .mpg-gallery-item a.mpg-lightbox-trigger {
    display: block !important;
    width: 100% !important;
    text-decoration: none !important;
    line-height: 0 !important;
    font-size: 0 !important;
    cursor: zoom-in !important;
    overflow: hidden !important;
    border-radius: var(--mpg-radius, 10px) !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

.mpg-masonry-gallery .mpg-gallery-item img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    line-height: 0 !important;
    font-size: 0 !important;
    max-width: 100% !important;
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Hover Effects */
.mpg-hover-zoom:hover img { transform: scale(1.05); }
.mpg-hover-brightness:hover img { filter: brightness(1.15); }
.mpg-hover-fade:hover img { opacity: 0.85; }

/* Hidden title for SEO */
.mpg-image-title.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

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

.mpg-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2147483647;
    opacity: 0;
    transition: opacity 0.3s ease;
    isolation: isolate;
}

body.mpg-lightbox-open .et-l--header,
body.mpg-lightbox-open header.et-l,
body.mpg-lightbox-open #main-header,
body.mpg-lightbox-open #top-header,
body.mpg-lightbox-open .et-fixed-header,
body.mpg-lightbox-open .divi-fixed-header,
body.mpg-lightbox-open .et_pb_menu,
body.mpg-lightbox-open .et_mobile_nav_menu,
body.mpg-lightbox-open .et-menu-nav,
body.mpg-lightbox-open .mobile_nav,
body.mpg-lightbox-open .et_mobile_menu,
body.mpg-lightbox-open .et_pb_menu__wrap,
body.mpg-lightbox-open .et_pb_menu_inner_container,
body.mpg-lightbox-open .et_pb_section_0_tb_header,
body.mpg-lightbox-open .et_pb_row_0_tb_header {
    display: none !important;
}

body.mpg-lightbox-open #page-container,
body.mpg-lightbox-open #et-boc,
body.mpg-lightbox-open .et-db,
body.mpg-lightbox-open .et-l,
body.mpg-lightbox-open .et_builder_inner_content,
body.mpg-lightbox-open header {
    z-index: 0 !important;
}

body.mpg-lightbox-open {
    overflow: hidden !important;
    touch-action: none !important;
}

.mpg-lightbox.mpg-lightbox-active {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.mpg-lightbox-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.mpg-lightbox-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    padding: 60px 80px;
    box-sizing: border-box;
}

.mpg-lightbox-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.mpg-lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 120px);
    width: auto; height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.35s ease, transform 0.35s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.mpg-lightbox-image.mpg-image-loaded {
    opacity: 1;
    transform: scale(1);
}

.mpg-lightbox-spinner {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.mpg-lightbox-spinner.mpg-spinner-active { display: block; }

.mpg-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mpg-spin 0.7s linear infinite;
}

@keyframes mpg-spin { to { transform: rotate(360deg); } }

.mpg-lightbox-close,
.mpg-lightbox-prev,
.mpg-lightbox-next {
    position: absolute;
    z-index: 10;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 12px;
    border-radius: 50%;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    outline: none;
}

.mpg-lightbox-close:hover,
.mpg-lightbox-prev:hover,
.mpg-lightbox-next:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.mpg-lightbox-close { top: 16px; right: 16px; }
.mpg-lightbox-close svg { width: 28px; height: 28px; }
.mpg-lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.mpg-lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.mpg-lightbox-prev svg, .mpg-lightbox-next svg { width: 32px; height: 32px; }

.mpg-lightbox-counter {
    position: absolute;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
}

.mpg-lightbox-close:focus-visible,
.mpg-lightbox-prev:focus-visible,
.mpg-lightbox-next:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

@media (max-width: 768px) {
    .mpg-lightbox-content { padding: 50px 16px; }
    .mpg-lightbox-prev { left: 4px; }
    .mpg-lightbox-next { right: 4px; }
    .mpg-lightbox-prev svg, .mpg-lightbox-next svg { width: 24px; height: 24px; }
    .mpg-lightbox-close { top: 8px; right: 8px; }
    .mpg-lightbox-close svg { width: 24px; height: 24px; }
    .mpg-lightbox-image { max-height: calc(100vh - 100px); }
    .mpg-lightbox-counter { bottom: 12px; font-size: 12px; }
}

@media (hover: none) and (pointer: coarse) {
    .mpg-lightbox-close,
    .mpg-lightbox-prev,
    .mpg-lightbox-next {
        padding: 16px;
        min-width: 48px;
        min-height: 48px;
    }
}
