/* =============================================================================
   Bludit Gallery Plugin — Frontend Styles
   gallery.css
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Gallery wrapper & grid
   --------------------------------------------------------------------------- */

.bludit-gallery {
    width: 100%;
    box-sizing: border-box;
}

.bludit-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* ---------------------------------------------------------------------------
   Individual grid items / thumbnails
   --------------------------------------------------------------------------- */

.bludit-gallery-item {
    display: block;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-radius: 4px;
    background-color: transparent;
    text-decoration: none;
    line-height: 0;
    /* Enforce a consistent 1:1 aspect ratio */
    aspect-ratio: 1 / 1;
}

.bludit-gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.bludit-gallery-item:hover img,
.bludit-gallery-item:focus img {
    opacity: 0.75;
}

.bludit-gallery-item:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Lightbox overlay
   --------------------------------------------------------------------------- */

.bludit-lightbox {
    position: fixed;
    inset: 0;                       /* top/right/bottom/left: 0 */
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.9);
    /* Fade-in when the overlay becomes visible */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bludit-lightbox.bludit-lightbox-active {
    opacity: 1;
    visibility: visible;
}

/* Inner container that holds the image so it can be centred */
.bludit-lightbox-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

/* ---------------------------------------------------------------------------
   Lightbox image
   --------------------------------------------------------------------------- */

.bludit-lightbox-image {
    display: block;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    /* Cross-fade when the src changes (toggled via JS class) */
    opacity: 1;
    transition: opacity 0.2s ease;
}

.bludit-lightbox-image.bludit-lightbox-image--fade {
    opacity: 0;
}

/* ---------------------------------------------------------------------------
   Navigation arrows — prev / next
   --------------------------------------------------------------------------- */

.bludit-lightbox-prev,
.bludit-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Large, touch-friendly clickable area */
    width: 56px;
    height: 72px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
    /* Prevent text selection on double-click */
    -webkit-tap-highlight-color: transparent;
}

.bludit-lightbox-prev {
    left: 16px;
}

.bludit-lightbox-next {
    right: 16px;
}

.bludit-lightbox-prev:hover,
.bludit-lightbox-prev:focus,
.bludit-lightbox-next:hover,
.bludit-lightbox-next:focus {
    background-color: rgba(255, 255, 255, 0.3);
    outline: none;
}

/* Arrow glyphs via pseudo-elements (no external font/icon needed) */
.bludit-lightbox-prev::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border-left: 3px solid #ffffff;
    border-bottom: 3px solid #ffffff;
    transform: rotate(45deg) translateX(2px);
}

.bludit-lightbox-next::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border-right: 3px solid #ffffff;
    border-top: 3px solid #ffffff;
    transform: rotate(45deg) translateX(-2px);
}

/* ---------------------------------------------------------------------------
   Close button
   --------------------------------------------------------------------------- */

.bludit-lightbox-close {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.bludit-lightbox-close:hover,
.bludit-lightbox-close:focus {
    background-color: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
    outline: none;
}

/* X glyph via pseudo-elements */
.bludit-lightbox-close::before,
.bludit-lightbox-close::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background-color: #ffffff;
    border-radius: 1px;
}

.bludit-lightbox-close::before {
    transform: rotate(45deg);
}

.bludit-lightbox-close::after {
    transform: rotate(-45deg);
}

/* ---------------------------------------------------------------------------
   Counter text  (e.g. "3 / 12")
   --------------------------------------------------------------------------- */

.bludit-lightbox-counter {
    flex-shrink: 0;
    padding: 10px 0 16px;
    color: #ffffff;
    font-size: 13px;
    font-family: inherit;
    letter-spacing: 0.05em;
    text-align: center;
    opacity: 0.75;
    user-select: none;
}

/* ---------------------------------------------------------------------------
   Mobile responsive overrides
   --------------------------------------------------------------------------- */

@media (max-width: 600px) {
    .bludit-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    /* Bigger touch targets on small screens */
    .bludit-lightbox-prev,
    .bludit-lightbox-next {
        width: 48px;
        height: 64px;
        font-size: 22px;
    }

    .bludit-lightbox-prev {
        left: 6px;
    }

    .bludit-lightbox-next {
        right: 6px;
    }

    .bludit-lightbox-close {
        top: 10px;
        right: 10px;
        width: 48px;
        height: 48px;
    }

    .bludit-lightbox-image {
        max-width: 96vw;
        max-height: 80vh;
    }
}

@media (max-width: 400px) {
    .bludit-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 6px;
    }
}
