/* Image Lightbox Plugin */

/* ========================================
   Zoom cursor on clickable images
   ======================================== */
.prose img:not(.gallery-item img):not(.no-lightbox) {
    cursor: zoom-in;
}

/* ========================================
   Lightbox Overlay
   ======================================== */
.image-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, var(--il-bg-opacity, 0.92));
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 0.75rem;
    padding: 2rem;
    cursor: zoom-out;
}

.image-lightbox.active {
    display: flex;
    animation: il-fade-in 0.2s ease;
}

@keyframes il-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Lightbox Image
   ======================================== */
.image-lightbox__img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--fb-radius-md, 0.375rem);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    cursor: default;
    user-select: none;
    transform-origin: center center;
    transition: transform 0.15s ease;
}

/* Remove transform transition while dragging to avoid lag */
.image-lightbox.is-dragging .image-lightbox__img {
    transition: none;
}

/* ========================================
   Caption (from alt text)
   ======================================== */
.image-lightbox__caption {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    font-family: var(--fb-font-system, system-ui, sans-serif);
    text-align: center;
    max-width: 60ch;
}

.image-lightbox__caption:empty {
    display: none;
}

/* ========================================
   Toolbar (zoom controls + close)
   ======================================== */
.image-lightbox__toolbar {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    z-index: 1;
}

.image-lightbox__btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    color: #fff;
    font-size: 1.125rem;
    cursor: pointer;
    transition: background 0.15s ease;
    padding: 0;
    line-height: 1;
}

.image-lightbox__btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.image-lightbox__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.image-lightbox__btn--close {
    font-size: 1.25rem;
}

.image-lightbox__zoom-level {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    font-family: var(--fb-font-system, system-ui, sans-serif);
    min-width: 3ch;
    text-align: center;
    user-select: none;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .image-lightbox {
        padding: 1rem;
    }

    .image-lightbox__img {
        max-width: 95vw;
        max-height: 75vh;
    }

    .image-lightbox__toolbar {
        top: 0.75rem;
        right: 0.75rem;
    }

    .image-lightbox__btn {
        width: 36px;
        height: 36px;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .image-lightbox.active {
        animation: none;
    }

    .image-lightbox__img {
        transition: none;
    }
}
