.mx-lightbox-btn__label {
    display: inline-block;
}

.mx-lightbox-btn__icon {
    display: inline-block;
    margin-left: 8px;
}
/* MX Masonry Gallery Styles */

.mx-masonry-gallery-wrapper {
    position: relative;
    width: 100%;
    --mx-gap: 10px; /* unified gutter size */
    --mx-row-height: 200px; /* default row height, can be overridden from widget */
    /* Use padding on top/left so only one side contributes per edge */
    padding-top: var(--mx-gap);
    padding-left: var(--mx-gap);
    margin: 0;
    /* Reserve space for floating lightbox button so it doesn't overlap 'View More' */
    --mx-lightbox-btn-space: 56px;
    padding-bottom: var(--mx-lightbox-btn-space);
}

.mx-masonry-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, var(--mx-row-height, 200px));
    align-items: stretch; /* ensure items fill row height */
    gap: 0; /* use padding-based gutters to avoid internal white lines on spanning items */
    width: 100%;
    margin-bottom: 20px;
}

/* Specific positioning for a 7-image masonry within 3 columns x 3 rows */
.mx-masonry-item.slot-a { /* single - row1 col1 */
    grid-column: 1;
    grid-row: 1;
}

.mx-masonry-item.slot-b { /* tall - col2 rows1-2 */
    grid-column: 2;
    grid-row: 1 / 3;
}

.mx-masonry-item.slot-c { /* single - row1 col3 */
    grid-column: 3;
    grid-row: 1;
}

.mx-masonry-item.slot-d { /* single - row2 col1 */
    grid-column: 1;
    grid-row: 2;
}

.mx-masonry-item.slot-e { /* tall - col3 rows2-3 */
    grid-column: 3;
    grid-row: 2 / 4;
}

.mx-masonry-item.slot-f { /* single - row3 col2 */
    grid-column: 2;
    grid-row: 3;
}

.mx-masonry-item.slot-g { /* single - row3 col1 */
    grid-column: 1;
    grid-row: 3;
}

.mx-masonry-item {
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 0;
    height: 100%; /* fill grid area height */
    box-sizing: border-box;
    padding: 0;
    /* Apply gutters only on right/bottom to avoid 0.5px rounding */
    border-right: var(--mx-gap) solid transparent;
    border-bottom: var(--mx-gap) solid transparent;
    position: relative; /* anchor absolutely positioned photo */
}

.mx-masonry-item:hover {
    transform: none; /* do not move container on hover */
    box-shadow: none; /* no card shadow */
}

.mx-masonry-photo {
    position: absolute;
    inset: 0; /* fill inside the padded item */
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: block;
    transition: transform 0.3s ease;
    will-change: transform;
}

.mx-masonry-item:hover .mx-masonry-photo {
    transform: scale(1.05);
}

/* Expandable Gallery */
.mx-masonry-gallery-more {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0; /* gutters handled by item borders using --mx-gap */
    grid-auto-rows: var(--mx-row-height, 200px); /* match main gallery row height */
    margin-top: 10px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.5s ease;
}

.mx-masonry-gallery-more.show {
    opacity: 1;
    transform: translateY(0);
}

.mx-masonry-item-more {
    height: var(--mx-row-height, 200px); /* inherit widget row height */
    animation: slideInUp 0.5s ease forwards;
}

.mx-masonry-item-more:nth-child(even) {
    animation-delay: 0.1s;
}

.mx-masonry-item-more:nth-child(3n) {
    animation-delay: 0.2s;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* View More Button */
.mx-view-more-wrapper {
    text-align: center;
    margin: 20px 0;
}

.mx-view-more-btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: #f8f8f8;
    color: #333333;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.mx-view-more-btn:hover {
    background-color: #333333;
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.mx-view-more-btn.expanded {
    background-color: #e0e0e0;
    color: #666666;
}

.mx-view-more-btn.expanded:hover {
    background-color: #d0d0d0;
    color: #555555;
}

/* Lightbox Button */
.mx-lightbox-btn {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
    border: none;
    border-radius: 0; /* rectangular */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1;
    transition: background-color 0.2s ease, transform 0.2s ease;
    z-index: 20; /* float above gallery and view-more */
}

.mx-lightbox-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: translateX(-50%);
}

/* Lightbox Modal */
.mx-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mx-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

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

.mx-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 6; /* above image */
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 0;
    width: 32px;
    height: 32px;
    line-height: 28px;
    font-size: 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mx-lightbox-close:hover {
    background: rgba(0,0,0,0.8);
}

.mx-lightbox-image-container {
    position: relative;
    max-width: 100%;
    max-height: 100%;
}

.mx-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}

/* Lightbox Controls */
.mx-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 6; /* above image */
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 0;
    width: 32px;
    height: 32px;
    line-height: 28px;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mx-lightbox-close:hover {
    background: rgba(0,0,0,0.8);
}

.mx-lightbox-prev,
.mx-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 15px 20px;
    transition: background-color 0.3s ease;
    border-radius: 4px;
}

.mx-lightbox-prev:hover,
.mx-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mx-lightbox-prev {
    left: -80px;
}

.mx-lightbox-next {
    right: -80px;
}

/* Lightbox Counter */
.mx-lightbox-counter {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mx-masonry-gallery {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 150px);
        gap: 8px;
    }
    
    /* Mobile layout adjustments */
    .mx-masonry-item:nth-child(1) {
        grid-column: 1 / 3;
        grid-row: 1;
    }
    
    .mx-masonry-item:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
    }
    
    .mx-masonry-item:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
    }
    
    .mx-masonry-item:nth-child(4) {
        grid-column: 1 / 3;
        grid-row: 3;
    }
    
    .mx-masonry-item:nth-child(5) {
        grid-column: 1;
        grid-row: 4;
    }
    
    .mx-masonry-item:nth-child(6) {
        grid-column: 2;
        grid-row: 4;
    }
    
    .mx-masonry-item:nth-child(7) {
        grid-column: 1 / 3;
        grid-row: 5;
    }
    
    .mx-lightbox-prev {
        left: -60px;
    }
    
    .mx-lightbox-next {
        right: -60px;
    }
}

@media (max-width: 768px) {
    /* Mobile-first approach: Override desktop styles for mobile */
    .mx-masonry-gallery-wrapper {
        /* Reset desktop padding and use mobile-friendly spacing */
        padding-top: 0;
        padding-left: 0;
        --mx-gap: 15px; /* Slightly larger gap for mobile */
        --mx-mobile-height: 250px; /* Taller images for mobile */
    }
    
    .mx-masonry-gallery {
        /* Single column layout for mobile */
        display: flex;
        flex-direction: column;
        gap: var(--mx-gap);
        grid-template-columns: none;
        grid-template-rows: none;
        margin-bottom: 20px;
    }
    
    .mx-masonry-item {
        /* Reset all grid positioning and use flex layout */
        grid-column: unset !important;
        grid-row: unset !important;
        position: relative;
        width: 100%;
        height: var(--mx-mobile-height);
        border-right: none;
        border-bottom: none;
        border-radius: 0;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .mx-masonry-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
    
    .mx-masonry-photo {
        /* Ensure photos fill the mobile container properly */
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        border-radius: 0;
    }
    
    /* Ensure all items are visible and properly spaced */
    .mx-masonry-item:nth-child(n) {
        display: block;
        opacity: 1;
        visibility: visible;
    }
    
    /* Lightbox button adjustments for mobile */
    .mx-lightbox-btn {
        bottom: 20px;
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Lightbox navigation for mobile */
    .mx-lightbox-prev,
    .mx-lightbox-next {
        top: auto;
        bottom: -40px;
        transform: none;
        font-size: 32px;
        padding: 0;
        background: transparent;
        border-radius: 0;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        border: none;
        z-index: 10;
    }
    
    .mx-lightbox-prev:hover,
    .mx-lightbox-next:hover {
        color: rgba(255, 255, 255, 0.7);
    }
    
    .mx-lightbox-prev {
        left: 15px;
    }
    
    .mx-lightbox-next {
        right: 15px;
    }
    
    .mx-lightbox-close {
        top: 5px;
        right: 5px;
        background: rgba(0, 0, 0, 0.7);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
    }
    
    /* View More button mobile styling */
    .mx-view-more-wrapper {
        margin-top: var(--mx-gap);
        text-align: center;
    }
    
    .mx-view-more-btn {
        padding: 12px 24px;
        font-size: 16px;
        border-radius: 25px;
    }
}

/* Smaller mobile devices */
@media (max-width: 480px) {
    .mx-masonry-gallery-wrapper {
        --mx-gap: 12px;
        --mx-mobile-height: 220px;
    }
    
    .mx-masonry-item {
        height: var(--mx-mobile-height);
        border-radius: 0;
    }
    
    .mx-masonry-photo {
        border-radius: 0;
    }
    
    .mx-lightbox-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Animation for modal */
.mx-lightbox-modal.show {
    animation: fadeIn 0.3s ease;
}

.mx-lightbox-modal.hide {
    animation: fadeOut 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
