/* =========================================
   RÉINITIALISATION ET STYLES DE BASE
========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f4f9;
    color: #333;
}

header {
    text-align: center;
    padding: 2rem;
    background-color: #2c3e50;
    color: #ecf0f1;
    margin-bottom: 2rem;
}

/* =========================================
   GRILLE DE LA GALERIE
========================================= */
.gallery-container {
    display: grid;
    /* Crée des colonnes qui s'adaptent automatiquement avec une largeur minimale de 250px */
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 0 20px;
    max-width: 80%;
    margin: auto;
    margin-bottom: 40px;
}

.gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 250px;
    background-color: #000; /* Fond noir pendant le chargement */
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.gallery-item img, 
.gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Empêche la déformation du média */
    display: block;
    transition: opacity 0.3s ease;
}

/* Icône de lecture pour différencier les vidéos des images */
.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* =========================================
   FENÊTRE MODALE (LIGHTBOX)
========================================= */
.modal {
    display: none; /* Cachée par défaut, gérée par JS */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Fond noir presque opaque */
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 85%;
    max-height: 85%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content img, 
.modal-content video {
    width: 100%;
    height: 100%;
    max-height: 85vh;
    object-fit: contain; /* Affiche le média entier sans le rogner */
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

/* =========================================
   BOUTONS DE NAVIGATION MODALE
========================================= */
.close-btn {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 1002;
}

.close-btn:hover {
    color: #e74c3c;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 50px;
    font-weight: bold;
    cursor: pointer;
    padding: 16px;
    user-select: none;
    transition: color 0.3s;
    z-index: 1001;
}

.nav-btn:hover {
    color: #fff;
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

/* =========================================
   RESPONSIVE (TÉLÉPHONES PORTABLES)
========================================= */
@media screen and (max-width: 768px) {
    /* Rend les flèches plus petites et plus proches des bords */
    .nav-btn {
        font-size: 35px;
        padding: 10px;
    }
    .prev-btn { 
        left: 5px; 
    }
    .next-btn { 
        right: 5px; 
    }
    
    /* Repositionne la croix de fermeture */
    .close-btn {
        top: 10px;
        right: 20px;
        font-size: 35px;
    }
    
    /* Agrandit légèrement le contenu pour exploiter l'écran */
    .modal-content {
        max-width: 95%;
    }
}