/* ============================= */
/* FAUNA MOROCCO - UNIVERSAL LIGHTBOX SYSTEM WITH SWIPE SUPPORT */
/* Based on species-account.css design - clean and minimal */
/* ============================= */

/* Images cliquables pour lightbox */
[data-lightbox] {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

[data-lightbox]:hover {
    opacity: 0.9;
}

/* ============================= */
/* LIGHTBOX OVERLAY */
/* ============================= */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0c0c0c; /* Noir moins agressif */
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    
    /* NEW: Touch optimizations */
    touch-action: pan-y pinch-zoom; /* Allow vertical scrolling and pinch zoom */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

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

/* ============================= */
/* LIGHTBOX CONTENT CONTAINER */
/* ============================= */

.lightbox-content {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    
    /* NEW: Ensure smooth touch interactions */
    touch-action: pan-y pinch-zoom;
}

/* ============================= */
/* MAIN LIGHTBOX IMAGE */
/* ============================= */

.lightbox-image {
    max-width: 90vw;
    max-height: calc(100vh - 80px);
    object-fit: contain;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    
    /* NEW: Smooth transitions for swipe */
    transition: opacity 0.2s ease;
}

/* ============================= */
/* CLOSE BUTTON */
/* ============================= */

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #e0e0e0; /* Gris clair, moins éblouissant */
    font-size: 2rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    z-index: 10001;
    
    /* NEW: Better touch target */
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    opacity: 0.7;
}

/* ============================= */
/* BOTTOM BAR */
/* ============================= */

.lightbox-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: #0c0c0c;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
    
    /* NEW: Prevent touch interference */
    touch-action: none;
}

/* ============================= */
/* CAPTION */
/* ============================= */

.lightbox-caption {
    color: #e0e0e0; /* Gris clair */
    font-size: 1.1rem;
    line-height: 1.4;
    flex: 1;
    margin-right: 20px;
    /* NOUVEAU : Permettre le retour à la ligne */
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: visible;
}

/* ============================= */
/* RIGHT CONTROLS (DESKTOP) */
/* ============================= */

.lightbox-right-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Compteur desktop */
.lightbox-counter-desktop {
    color: #e0e0e0; /* Gris clair */
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Conteneur des flèches côte à côte desktop */
.lightbox-nav-container-desktop {
    display: flex;
    gap: 15px;
}

/* ============================= */
/* NAVIGATION ARROWS */
/* ============================= */

.lightbox-nav {
    background: none;
    border: none;
    color: #e0e0e0; /* Gris clair */
    font-size: 1.5rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
    
    /* NEW: Better touch targets */
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-nav:hover {
    opacity: 0.7;
}

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

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

/* ============================= */
/* MOBILE CONTROLS */
/* ============================= */

/* Contrôles mobiles en haut - cachés par défaut */
.lightbox-mobile-top-controls {
    display: none;
}

/* ============================= */
/* SINGLE IMAGE HANDLING */
/* ============================= */

/* Hide navigation when only one image */
.lightbox-single .lightbox-nav-container,
.lightbox-single .lightbox-nav-container-desktop,
.lightbox-single .lightbox-counter,
.lightbox-single .lightbox-counter-desktop {
    display: none;
}

/* ============================= */
/* SWIPE VISUAL FEEDBACK */
/* ============================= */

/* NEW: Add subtle visual feedback for swipe areas */
@media (max-width: 768px) {
    .lightbox-content::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 30%;
        height: 100%;
        z-index: 1;
        pointer-events: none;
        background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, transparent 100%);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .lightbox-content::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 30%;
        height: 100%;
        z-index: 1;
        pointer-events: none;
        background: linear-gradient(270deg, rgba(255,255,255,0.03) 0%, transparent 100%);
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    /* Show swipe areas briefly when lightbox opens */
    .lightbox-overlay.active .lightbox-content::before,
    .lightbox-overlay.active .lightbox-content::after {
        animation: swipeHint 2s ease-out;
    }
}

@keyframes swipeHint {
    0% { opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

/* ============================= */
/* RESPONSIVE DESIGN */
/* ============================= */

@media (max-width: 768px) {
    .lightbox-image {
        max-width: 95vw;
        max-height: calc(100vh - 140px); /* Espace pour contrôles haut et bas */
    }
    
    .lightbox-close {
        top: 15px;
        right: 15px;
        font-size: 1.8rem;
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }
    
    /* Afficher les contrôles mobiles */
    .lightbox-mobile-top-controls {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 10002;
        touch-action: none;
    }
    
    /* Flèches en haut à gauche */
    .lightbox-mobile-top-controls .lightbox-nav-container {
        position: absolute;
        top: 20px;
        left: 20px;
        display: flex;
        gap: 15px;
    }
    
    /* Compteur en haut au centre */
    .lightbox-mobile-top-controls .lightbox-counter {
        position: absolute;
        top: 20px;
        left: 50%;
        transform: translateX(-50%);
        color: #e0e0e0;
        font-size: 1rem;
        font-weight: 500;
        white-space: nowrap;
    }
    
    /* Cacher les contrôles desktop sur mobile */
    .lightbox-right-controls {
        display: none;
    }
    
    /* Barre du bas uniquement pour la légende */
    .lightbox-caption {
        font-size: 1rem;
        text-align: center;
        margin: 0;
        flex: none;
        /* NOUVEAU : Gestion du texte long sur mobile */
        white-space: normal;
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
        padding: 0 10px; /* Évite que le texte touche les bords */
    }
    
    /* Augmenter la hauteur de la barre si nécessaire */
    .lightbox-bottom-bar {
        height: auto; /* Hauteur dynamique */
        min-height: 80px; /* Hauteur minimum */
        padding: 15px 20px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .lightbox-nav {
        font-size: 1.4rem;
        padding: 10px;
        min-width: 40px;
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .lightbox-image {
        max-height: calc(100vh - 120px);
    }
    
    .lightbox-close {
        top: 12px;
        right: 12px;
        font-size: 1.6rem;
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .lightbox-mobile-top-controls .lightbox-nav-container {
        top: 15px;
        left: 15px;
        gap: 12px;
    }
    
    .lightbox-mobile-top-controls .lightbox-counter {
        top: 15px;
        font-size: 0.9rem;
    }
    
    .lightbox-caption {
        font-size: 0.9rem;
        padding: 0 5px;
        line-height: 1.3;
    }
    
    .lightbox-bottom-bar {
        min-height: 70px;
        padding: 10px 15px;
    }
    
    .lightbox-nav {
        font-size: 1.2rem;
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }
}

/* ============================= */
/* ACCESSIBILITY IMPROVEMENTS */
/* ============================= */

/* High contrast mode support */
@media (prefers-contrast: high) {
    .lightbox-overlay {
        background: #000;
    }
    
    .lightbox-caption,
    .lightbox-counter,
    .lightbox-counter-desktop {
        background: #000;
        border: 1px solid #fff;
        padding: 8px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .lightbox-overlay,
    .lightbox-image,
    .lightbox-nav {
        transition: none;
    }
    
    @keyframes swipeHint {
        from { opacity: 0; }
        to { opacity: 0; }
    }
}