.sonder-widget-title {
    margin-bottom: 20px;
    text-align: center;
}

.sonder-image-container {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.sonder-image-grid {
    display: grid;
    /* Columns handled by widget settings */
}

/* Masonry Layout fallback for simple CSS */
.layout-masonry {
    display: block;
    column-count: 3;
    column-gap: 20px;
}

.layout-masonry .sonder-gallery-item {
    break-inside: avoid;
    margin-bottom: 20px;
}

/* Horizontal Scroll Layout */
.layout-scroll {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px; /* space for scrollbar */
}

.layout-scroll .sonder-gallery-item {
    flex: 0 0 80%; /* Show 80% of image on mobile */
    scroll-snap-align: center;
    margin-right: 15px;
}

.sonder-gallery-item {
    width: 100%;
    cursor: pointer; /* Indicate clickability */
    position: relative;
    padding-bottom: 5px; /* Touch target padding */
}

.sonder-gallery-item img {
    width: 100%;
    /* height is handled by inline style for grid layout */
    display: block;
    object-fit: cover;
    transition: all 0.3s ease;
}

/* Popup Styles */
.sonder-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px; /* Safe space on mobile */
}

.sonder-popup-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.sonder-popup-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh; /* Prevent overflow on small screens */
    overflow-y: auto; /* Scrollable content */
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.sonder-popup-overlay.is-visible .sonder-popup-content {
    transform: scale(1);
}

.sonder-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 32px; /* Larger touch target */
    line-height: 1;
    cursor: pointer;
    color: #333;
    padding: 5px;
    z-index: 10;
}

.sonder-popup-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 24px;
    font-family: inherit; /* Use global font */
    padding-right: 30px; /* Space for close button */
}

.sonder-popup-description {
    font-size: 16px;
    line-height: 1.6;
    color: #555;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .layout-masonry {
        column-count: 2;
    }
    .layout-scroll .sonder-gallery-item {
        flex: 0 0 60%;
    }
}

@media (max-width: 767px) {
    .layout-masonry {
        column-count: 1;
    }
    .layout-scroll .sonder-gallery-item {
        flex: 0 0 85%;
    }
    .sonder-popup-content {
        padding: 20px;
        width: 95%;
    }
    .sonder-popup-title {
        font-size: 20px;
    }
}
