.emig-wrap {
    width: 100%;
    --emig-mixed-base: 230px;
}

.emig-gallery {
    column-count: 3;
    column-gap: 16px;
}

.emig-item {
    display: block;
    width: 100%;
    margin-bottom: 16px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    overflow: hidden;
    text-decoration: none;
}

.emig-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* True masonry: preserve natural/original image ratio. */
.emig-mode-original .emig-item img {
    height: auto !important;
    object-fit: contain;
    aspect-ratio: auto;
}

/* Equal grid mode for product-style galleries. */
.emig-mode-grid .emig-item img {
    height: auto;
    object-fit: cover;
}

/* Pinterest-style mode: creates visible masonry variation even if source images are all same ratio. */
.emig-mode-mixed .emig-item img {
    height: var(--emig-mixed-base);
    object-fit: cover;
}

.emig-mode-mixed .emig-item:nth-child(6n + 1) img,
.emig-mode-mixed .emig-item:nth-child(6n + 4) img {
    height: calc(var(--emig-mixed-base) * 1.28);
}

.emig-mode-mixed .emig-item:nth-child(6n + 2) img,
.emig-mode-mixed .emig-item:nth-child(6n + 6) img {
    height: calc(var(--emig-mixed-base) * 0.86);
}

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

.emig-actions {
    text-align: center;
    margin-top: 20px;
}

.emig-load-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: 0;
    border-radius: 6px;
    background: #111827;
    color: #ffffff;
    cursor: pointer;
    font-size: 15px;
    line-height: 1.2;
}

.emig-load-more:hover,
.emig-load-more:focus {
    background: #374151;
    color: #ffffff;
}

.emig-load-more[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.emig-status {
    text-align: center;
    margin-top: 18px;
    color: #6b7280;
    font-size: 14px;
}


/* Lightbox with caption at bottom */
.emig-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.emig-lightbox-open {
    display: flex;
}

.emig-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
}

.emig-lightbox-inner {
    position: relative;
    z-index: 1;
    max-width: min(1100px, 96vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.emig-lightbox-image {
    max-width: 100%;
    max-height: calc(92vh - 72px);
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 6px;
}

.emig-lightbox-caption {
    width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
    padding: 12px 16px;
    text-align: center;
    color: #ffffff;
    font-size: 15px;
    line-height: 1.5;
    background: rgba(0, 0, 0, 0.52);
    border-radius: 6px;
}

.emig-lightbox-close {
    position: absolute;
    top: -18px;
    right: -18px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: #ffffff;
    color: #111111;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emig-lightbox-active {
    overflow: hidden;
}

@media (max-width: 767px) {
    .emig-lightbox {
        padding: 14px;
    }

    .emig-lightbox-close {
        top: 8px;
        right: 8px;
    }

    .emig-lightbox-image {
        max-height: calc(92vh - 90px);
    }
}
