/**
 * Lightbox — fullscreen image viewer with zoom and pan.
 */

.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.92);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
    overflow: hidden;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.lightbox-overlay.open {
    display: flex;
    opacity: 1;
}

/* X close button (top-right) */
.lightbox-x {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    z-index: 1002;
    transition: color 0.15s;
}

.lightbox-x:hover {
    color: #fff;
}

/* Title above image */
.lightbox-title {
    color: var(--color-text, #eee);
    font-family: var(--font-heading, var(--font-body, system-ui, sans-serif));
    font-size: 1.3rem;
    font-weight: 600;
    padding: 0.75rem 0 0.5rem;
    flex-shrink: 0;
    z-index: 1001;
    text-align: center;
}

/* Image container */
.lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    overflow: visible;
}

.lightbox-img {
    max-width: min(90vw, 100%);
    max-height: 74vh;
    width: auto;
    height: auto;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    transform-origin: center center;
    user-select: none;
    will-change: transform;
    -webkit-touch-callout: none;
}

.lightbox-img.loaded {
    opacity: 1;
}

/* Cursor states for zoom/pan */
.lightbox-overlay.lightbox-panning,
.lightbox-overlay.lightbox-panning .lightbox-img {
    cursor: grabbing !important;
}

/* Loading spinner */
.lightbox-spinner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: lb-spin 0.7s linear infinite;
}

.lightbox-spinner.hidden {
    display: none;
}

@keyframes lb-spin {
    to { transform: rotate(360deg); }
}

/* Image counter */
.lightbox-counter {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    padding-bottom: 0.25rem;
    flex-shrink: 0;
    z-index: 1001;
}

.lightbox-counter.hidden {
    display: none;
}

/* Button bar under the image */
.lightbox-btnbar {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 0 1.25rem;
    flex-shrink: 0;
    z-index: 1001;
}

.lightbox-btn {
    font-family: var(--font-body, system-ui, sans-serif);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.7rem 2rem;
    border: 2px solid var(--color-primary, #00ff73);
    border-radius: var(--radius, 6px);
    background: transparent;
    color: var(--color-primary, #00ff73);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
    user-select: none;
}

.lightbox-btn:hover:not(:disabled) {
    background: var(--color-primary, #00ff73);
    color: var(--color-bg, #000);
    box-shadow: 0 0 15px var(--color-primary-dim, rgba(0, 255, 115, 0.3));
}

.lightbox-btn:disabled {
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.2);
    cursor: default;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .lightbox-img {
        max-width: 96vw;
        max-height: 60vh;
    }

    .lightbox-title {
        font-size: 1.1rem;
        padding: 0.5rem 0 0.25rem;
    }

    .lightbox-btnbar {
        gap: 0.5rem;
        padding: 0.5rem 0.5rem 1rem;
        flex-wrap: wrap;
    }

    .lightbox-btn {
        font-size: 0.85rem;
        padding: 0.75rem 1.25rem;
        min-height: 44px;
    }

    .lightbox-x {
        font-size: 1.75rem;
        padding: 0.5rem 0.75rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
