/* ILV Mixed Media Gallery */

/* ── Grid layout ── */
.ilv-mmg {
    --ilv-mmg-cols: 3;
    --ilv-mmg-gap: 6px;
    display: grid;
    gap: var(--ilv-mmg-gap);
    width: 100%;
}

/* Mosaic / masonry: CSS columns for varied heights */
.ilv-mmg-layout-masonry {
    display: block;
    column-count: var(--ilv-mmg-cols);
    column-gap: var(--ilv-mmg-gap);
}

.ilv-mmg-layout-masonry .ilv-mmg-item {
    break-inside: avoid;
    margin-bottom: var(--ilv-mmg-gap);
}

/* Uniform grid */
.ilv-mmg-layout-grid {
    grid-template-columns: repeat(var(--ilv-mmg-cols), 1fr);
}

.ilv-mmg-layout-grid .ilv-mmg-item {
    aspect-ratio: var(--ilv-mmg-ratio, 4/3);
}

/* ── Gallery item ── */
.ilv-mmg-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--ilv-mmg-radius, 2px);
    cursor: pointer;
    background: #1a1a1a;
}

.ilv-mmg-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ilv-mmg-item:hover img,
.ilv-mmg-item:hover .ilv-mmg-inline-video {
    transform: scale(1.04);
}

/* Inline video for autoplay mode */
.ilv-mmg-inline-video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* No-thumb fallback */
.ilv-mmg-no-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: #666;
    background: #222;
}

/* Play button overlay for videos */
.ilv-mmg-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 52px;
    height: 52px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    pointer-events: none;
    transition: background 0.2s, transform 0.2s;
}

.ilv-mmg-item:hover .ilv-mmg-play {
    background: rgba(0, 0, 0, 0.75);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Caption overlay */
.ilv-mmg-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 10px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    pointer-events: none;
}

/* ── Lightbox ── */
.ilv-mmg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.ilv-mmg-lightbox.ilv-mmg-lb-open {
    opacity: 1;
    visibility: visible;
}

.ilv-mmg-lb-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ilv-mmg-lb-content img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
}

.ilv-mmg-lb-content video {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 4px;
    outline: none;
}

.ilv-mmg-lb-content iframe {
    width: 80vw;
    height: 45vw;
    max-width: 960px;
    max-height: 540px;
    border: 0;
    border-radius: 4px;
}

/* Lightbox close */
.ilv-mmg-lb-close {
    position: absolute;
    top: 16px;
    right: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ilv-mmg-lb-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Lightbox nav arrows */
.ilv-mmg-lb-prev,
.ilv-mmg-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ilv-mmg-lb-prev { left: 16px; }
.ilv-mmg-lb-next { right: 16px; }

.ilv-mmg-lb-prev:hover,
.ilv-mmg-lb-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Lightbox caption */
.ilv-mmg-lb-caption {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    text-align: center;
    max-width: 80%;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
}

.ilv-mmg-lb-caption:empty {
    display: none;
}

/* Counter */
.ilv-mmg-lb-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .ilv-mmg-layout-masonry {
        column-count: var(--ilv-mmg-cols-tablet, 3) !important;
    }
    .ilv-mmg-layout-grid {
        grid-template-columns: repeat(var(--ilv-mmg-cols-tablet, 3), 1fr) !important;
    }

    .ilv-mmg-lb-content iframe {
        width: 92vw;
        height: 52vw;
    }
}

@media (max-width: 767px) {
    .ilv-mmg-layout-masonry {
        column-count: var(--ilv-mmg-cols-mobile, 2) !important;
    }
    .ilv-mmg-layout-grid {
        grid-template-columns: repeat(var(--ilv-mmg-cols-mobile, 2), 1fr) !important;
    }

    .ilv-mmg-lb-prev,
    .ilv-mmg-lb-next {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .ilv-mmg-lb-prev { left: 8px; }
    .ilv-mmg-lb-next { right: 8px; }
}
