/* ═══════════════════════════════════════════════════════════
   Lightbox - Mobile-Optimized Gallery Viewer
   Full-featured lightbox with zoom, pan, and responsive design
   ═══════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   Lightbox Overlay
   ───────────────────────────────────────────────────────────── */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
    touch-action: none;
}

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

/* ─────────────────────────────────────────────────────────────
   Lightbox Container
   ───────────────────────────────────────────────────────────── */

.lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 60px);
    padding-top: clamp(60px, 8vh, 80px);
    padding-bottom: clamp(60px, 8vh, 80px);
}

/* ─────────────────────────────────────────────────────────────
   Image Wrapper - Handles zoom and pan
   ───────────────────────────────────────────────────────────── */

.lightbox-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
}

.lightbox-image-wrapper.zoomed {
    cursor: move;
}

.lightbox-image-wrapper.loading {
    cursor: wait;
}

/* ─────────────────────────────────────────────────────────────
   Image Element
   ───────────────────────────────────────────────────────────── */

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease, opacity 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}

/* Prevent image flicker on mobile */
.lightbox-image {
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
}

/* ─────────────────────────────────────────────────────────────
   Loading State
   ───────────────────────────────────────────────────────────── */

.lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: lightbox-spin 0.8s linear infinite;
    display: none;
}

.lightbox-overlay.loading .lightbox-loader {
    display: block;
}

@keyframes lightbox-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────
   Close Button
   ───────────────────────────────────────────────────────────── */

.lightbox-close {
    position: fixed;
    top: clamp(12px, 2vh, 20px);
    right: clamp(12px, 2vw, 20px);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.lightbox-close:active {
    transform: scale(0.95);
}

.lightbox-close::before,
.lightbox-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

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

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

/* ─────────────────────────────────────────────────────────────
   Zoom Controls (Desktop)
   ───────────────────────────────────────────────────────────── */

.lightbox-zoom-controls {
    position: fixed;
    bottom: clamp(16px, 3vh, 24px);
    right: clamp(16px, 3vw, 24px);
    display: none;
    gap: 8px;
    z-index: 10001;
}

@media (min-width: 769px) {
    .lightbox-zoom-controls {
        display: flex;
    }
}

.lightbox-zoom-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #fff;
    font-size: 20px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.lightbox-zoom-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.lightbox-zoom-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.lightbox-zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────
   Open Original Button
   ───────────────────────────────────────────────────────────── */

.lightbox-open-original {
    position: fixed;
    bottom: clamp(16px, 3vh, 24px);
    left: clamp(16px, 3vw, 24px);
    padding: 12px 20px;
    min-height: 44px;
    background: rgba(232, 196, 196, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 22px;
    color: #3D3D3D;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    z-index: 10001;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.lightbox-open-original:hover {
    background: rgba(232, 196, 196, 1);
    transform: translateY(-2px);
}

.lightbox-open-original:active {
    transform: translateY(0) scale(0.98);
}

.lightbox-open-original::before {
    content: '🔗';
    font-size: 16px;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .lightbox-open-original {
        font-size: 13px;
        padding: 10px 16px;
    }
}

/* ─────────────────────────────────────────────────────────────
   Zoom Level Indicator (Desktop)
   ───────────────────────────────────────────────────────────── */

.lightbox-zoom-indicator {
    position: fixed;
    top: clamp(16px, 3vh, 24px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 10001;
}

.lightbox-zoom-indicator.visible {
    opacity: 1;
}

/* Hide on mobile */
@media (max-width: 768px) {
    .lightbox-zoom-indicator {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────
   Mobile-specific: Double-tap hint
   ───────────────────────────────────────────────────────────── */

.lightbox-mobile-hint {
    position: fixed;
    bottom: clamp(70px, 12vh, 100px);
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    color: #fff;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10000;
    white-space: nowrap;
}

.lightbox-mobile-hint.visible {
    opacity: 1;
}

/* Only show on mobile */
@media (min-width: 769px) {
    .lightbox-mobile-hint {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────
   Animations
   ───────────────────────────────────────────────────────────── */

@keyframes lightboxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.lightbox-overlay.active .lightbox-image {
    animation: lightboxFadeIn 0.3s ease;
}

/* ─────────────────────────────────────────────────────────────
   Accessibility
   ───────────────────────────────────────────────────────────── */

.lightbox-overlay:focus {
    outline: none;
}

/* Keyboard navigation hint */
.lightbox-keyboard-hint {
    position: fixed;
    bottom: clamp(70px, 12vh, 100px);
    right: clamp(16px, 3vw, 24px);
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 10000;
}

.lightbox-overlay:hover .lightbox-keyboard-hint {
    opacity: 1;
}

/* Hide on mobile/touch devices */
@media (max-width: 768px), (hover: none) {
    .lightbox-keyboard-hint {
        display: none;
    }
}

/* ─────────────────────────────────────────────────────────────
   High DPI / Retina Displays
   ───────────────────────────────────────────────────────────── */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .lightbox-image {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ─────────────────────────────────────────────────────────────
   Reduced Motion Support
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .lightbox-overlay,
    .lightbox-image,
    .lightbox-close,
    .lightbox-zoom-btn,
    .lightbox-open-original {
        transition: none;
        animation: none;
    }
}

/* ─────────────────────────────────────────────────────────────
   Print Styles
   ───────────────────────────────────────────────────────────── */

@media print {
    .lightbox-overlay {
        display: none !important;
    }
}
