/* ==========================================================================
   ALI Conferences – Lightbox Gallery
   Usage: [ali_lightbox_gallery images="url1.jpg,url2.jpg" cols="3" gap="10"]
   ========================================================================== */

/* ── Gallery grid ─────────────────────────────────────────────────────────── */

.ali-lightbox-gallery {
    --ali-lb-cols: 3;       /* overridden per instace via inline style */n
    --ali-lb-gap: 10px;

    display: grid;
    grid-template-columns: repeat(var(--ali-lb-cols), 1fr);
    gap: var(--ali-lb-gap);
    margin: 20px 0;
}

/* ── Thumbnail tile ───────────────────────────────────────────────────────── */

.ali-lb-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background-color: #e8e8e8;
    /* Force a consistent height via aspect-ratio */
    aspect-ratio: 1 / 1;
    border-radius: 4px;
}

.ali-lb-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.35s ease, filter 0.35s ease;
    /* Prevent image dragging during swipe */
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.ali-lb-item:hover img,
.ali-lb-item:focus-within img {
    transform: scale(1.06);
    filter: brightness(0.75);
}

/* ── Zoom icon hover overlay ──────────────────────────────────────────────── */

.ali-lb-overlay-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ali-lb-overlay-icon svg {
    width: 40px;
    height: 40px;
    color: #ffffff;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.55));
}

.ali-lb-item:hover .ali-lb-overlay-icon,
.ali-lb-item:focus-within .ali-lb-overlay-icon {
    opacity: 1;
}

/* ── Accessibility: keyboard focus ring on thumbnails ─────────────────────── */

.ali-lb-item:focus-visible {
    outline: 3px solid #8dc73f;
    outline-offset: 2px;
}

/* ── Lightbox overlay ─────────────────────────────────────────────────────── */

.ali-lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Overlay receives keyboard events */
    outline: none;
}

.ali-lb-overlay.ali-lb-active {
    opacity: 1;
    visibility: visible;
}

/* Prevent body scroll while lightbox is open */
body.ali-lb-scroll-lock {
    overflow: hidden;
}

/* ── Lightbox content wrapper ─────────────────────────────────────────────── */

.ali-lb-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 90vh;
    /* Click on padding area closes the lightbox */
    padding: 0 60px;
    box-sizing: border-box;
}

/* ── Lightbox image ───────────────────────────────────────────────────────── */

.ali-lb-img {
    display: block;
    max-width: 100%;
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 3px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    transition: opacity 0.2s ease;
    -webkit-user-drag: none;
    user-drag: none;
}

.ali-lb-img.ali-lb-loading {
    opacity: 0.25;
}

/* ── Close button ─────────────────────────────────────────────────────────── */

.ali-lb-close {
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 100001;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.35);
    color: #ffffff;
    font-size: 30px;
    line-height: 1;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    padding: 0;
}

.ali-lb-close:hover,
.ali-lb-close:focus-visible {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.8);
    outline: none;
}

/* ── Prev / Next navigation buttons ──────────────────────────────────────── */

.ali-lb-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100001;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.35);
    color: #ffffff;
    font-size: 42px;
    line-height: 1;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    padding: 0 0 4px 0; /* optical alignment for › ‹ */
    user-select: none;
}

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

.ali-lb-nav:hover,
.ali-lb-nav:focus-visible {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.8);
    outline: none;
}

/* ── Counter label ────────────────────────────────────────────────────────── */

.ali-lb-counter {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.75);
    font-family: sans-serif;
    font-size: 14px;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.35);
    padding: 4px 14px;
    border-radius: 20px;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Carousel layout ─────────────────────────────────────────────────────── */
/*    Usage: [ali_lightbox_carousel images="..." aspect_ratio="16:9" autoplay="4000"] */

.ali-lightbox-carousel {
    position: relative;
    margin: 20px 0;
    user-select: none;
}

.ali-lbc-viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background-color: #111;
    aspect-ratio: var(--ali-lbc-ratio, 16 / 9);
}

/* ── Slides ───────────────────────────────────────────────────────────────── */

.ali-lbc-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.45s ease, visibility 0.45s ease;
    cursor: pointer;
}

.ali-lbc-slide.ali-lbc-active {
    opacity: 1;
    visibility: visible;
}

.ali-lbc-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.ali-lbc-slide:hover img,
.ali-lbc-slide:focus-within img {
    filter: brightness(0.8);
    transition: filter 0.35s ease;
}

/* Reuse the same zoom-icon overlay class from the gallery */
.ali-lbc-slide .ali-lb-overlay-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.ali-lbc-slide:hover .ali-lb-overlay-icon,
.ali-lbc-slide:focus-within .ali-lb-overlay-icon {
    opacity: 1;
}

.ali-lbc-slide:focus-visible {
    outline: 3px solid #8dc73f;
    outline-offset: -3px;
}

/* ── Carousel prev / next buttons ─────────────────────────────────────────── */

.ali-lbc-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: #ffffff;
    font-size: 42px;
    line-height: 1;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease;
    padding: 0 0 4px 0;
    user-select: none;
}

.ali-lbc-prev { left:  12px; }
.ali-lbc-next { right: 12px; }

.ali-lbc-btn:hover,
.ali-lbc-btn:focus-visible {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
    outline: none;
}

/* ── Dot indicators ───────────────────────────────────────────────────────── */

.ali-lbc-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

.ali-lbc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #ccc;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.ali-lbc-dot.ali-lbc-dot-active {
    background-color: #8dc73f;
    transform: scale(1.3);
}

.ali-lbc-dot:hover,
.ali-lbc-dot:focus-visible {
    background-color: #8dc73f;
    outline: none;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
    .ali-lbc-btn {
        width: 38px;
        height: 38px;
        font-size: 28px;
    }
    .ali-lbc-prev { left:  6px; }
    .ali-lbc-next { right: 6px; }
}

/* ── Collage layout variant ───────────────────────────────────────────────── */
/*    Usage: [ali_lightbox_gallery images="..." layout="collage"]             */

.ali-lightbox-gallery.ali-lb-collage {
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 200px;
    grid-auto-flow: dense;
}

/* Override the fixed square aspect ratio so grid rows control height */
.ali-lb-collage .ali-lb-item {
    aspect-ratio: unset;
}

/* Every 1st item in a group of 4 → large feature tile (2 cols × 2 rows) */
.ali-lb-collage .ali-lb-item:nth-child(4n + 1) {
    grid-column: span 2;
    grid-row: span 2;
}

/* Every 3rd item in a group of 4 → tall tile (1 col × 2 rows) */
.ali-lb-collage .ali-lb-item:nth-child(4n + 3) {
    grid-row: span 2;
}

/* ── Responsive breakpoints ───────────────────────────────────────────────── */

/* Tablet: collapse collage to a simple 2-col uniform grid */
@media (max-width: 900px) {
    .ali-lightbox-gallery {
        grid-template-columns: repeat(
            min(var(--ali-lb-cols), 3),
            1fr
        );
    }

    .ali-lightbox-gallery.ali-lb-collage {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 180px;
    }

    .ali-lb-collage .ali-lb-item:nth-child(4n + 1),
    .ali-lb-collage .ali-lb-item:nth-child(4n + 3) {
        grid-column: span 1;
        grid-row: span 1;
    }

    /* Re-apply a simpler collage on tablet: every other item is tall */
    .ali-lb-collage .ali-lb-item:nth-child(3n + 1) {
        grid-row: span 2;
    }
}

/* Large phone: cap at 2 columns */
@media (max-width: 600px) {
    .ali-lightbox-gallery {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Reset all collage spans to uniform tiles on small phones */
    .ali-lb-collage .ali-lb-item:nth-child(n) {
        grid-column: span 1;
        grid-row: span 1;
    }

    .ali-lb-content {
        padding: 0 48px;
    }

    .ali-lb-prev { left: 6px;  }
    .ali-lb-next { right: 6px; }

    .ali-lb-nav {
        width: 40px;
        height: 40px;
        font-size: 32px;
    }
}

/* Small phone: single column, compact nav */
@media (max-width: 380px) {
    .ali-lightbox-gallery {
        grid-template-columns: 1fr;
    }
}
