/* Galerie : les vignettes doivent revenir à la ligne et rester dans la carte */
article.card .card-body,
article.card .gallery-thumbnails {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
}


/* Toujours 2 photos par ligne */
article.card .gallery-thumbnails {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

article.card .gallery-thumbnail {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: 115px;
    object-fit: cover;
    border-radius: 8px;
}


@media (min-width: 768px) {
    article.card .gallery-thumbnails {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (min-width: 1200px) {
    article.card .gallery-thumbnails {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (max-width: 576px) {
    article.card .gallery-thumbnail { height: 125px; }
}

/* Fenêtre photo isolée des classes Bootstrap */
.photo-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.85);
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    overflow: auto;
}
.photo-modal .modal-container { position: relative; }
.photo-modal-image {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
    background: #000;
}
/* Gallery Grid Layout */
.gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 20px;
            max-width: 1000px;
            margin: 30px auto;
}

.photo-card {
            background: #fff;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
}

.photo-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 12px rgba(0,0,0,0.15);
}

.photo-card img {
            width: 100%;
            height: 160px;
            object-fit: cover;
            display: block;
}

.photo-card-info {
            padding: 12px;
}

.photo-card-info h4 {
    margin: 0 0 5px 0;
    font-size: 16px;
    color: #333;
}

.photo-card-info p {
    margin: 0;
    font-size: 12px;
    color: #777;
}

/* Centered Modal Overlay using Flexbox */
.photo-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
            
    /* Center children horizontally and vertically */
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    overflow: auto;
}

/* Modal Container */
.modal-container {
    position: relative;
    background-color: #fff;
    border-radius: 8px.    max-width: 850px;
    width: 100%;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Maximized Photo Area */
.photo-modal-image {
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
    background-color: #000;
    display: block;
}

/* Compact Information Area */
.modal-details {
    padding: 12px 18px;
    background: #fff;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.modal-info-text {
    flex-grow: 1;
    min-width: 0; /* Prevents text overflow issues in flex layout */
}

.modal-info-text h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-info-text p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #555;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.modal-meta {
    font-size: 12px;
    color: #777;
}

.modal-meta .author {
    font-weight: bold;
    color: #007bff;
}

/* Download Button */
.download-btn {
    display: inline-block;
    padding: 8px 14px;
    background-color: #28a745;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    transition: background-color 0.2s;
}

.download-btn:hover {
    background-color: #218838;
}

/* Close Button */
.close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    line-height: 1;
}

.close:hover {
    color: #ccc;
}

/* Responsive */
@media (max-width: 600px) {
    .modal-details {
        flex-direction: column;
        align-items: flex-start;
    }
    .download-btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    .modal-info-text h3, 
    .modal-info-text p {
        white-space: normal; /* allow wrapping on small screens */
    }
}

/* -------------------------------------------------------------------------- */


/* Centrage automatique de la modale */
        .modal {
            display: none; /* Masqué par défaut */
            position: fixed;
            z-index: 1050;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.8); /* Fond sombre plus opaque pour un meilleur focus */
            align-items: center;
            justify-content: center;
        }

        /* Conteneur élargi pour occuper quasi tout l'écran */
        .modal-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 0.5rem;
            max-width: 85vw;  /* Occupe 90% de la largeur de l'écran */
            max-height: 85vh; /* Occupe 90% de la hauteur de l'écran */
            display: flex;
            flex-direction: column;
            position: relative;
            box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.5);
            overflow: hidden;
        }

        /* Image agrandie au maximum de l'écran sans déformation */
        .model-img {
            max-width: 100%;
            max-height: 70vh;  /* L'image prend jusqu'à 75% de la hauteur de l'écran */
            width: auto;
            height: auto;
            object-fit: contain; /* Conserve les proportions d'origine */
            display: block;
            margin: 0 auto 15px auto;
            border-radius: 0.25rem;
        }

        /* Détails sous l'image */
        .modal-details {
            overflow-y: auto; /* Permet de scroller le texte si nécessaire */
            max-height: 15vh;
        }

        /* Bouton de fermeture */
        .close {
            position: absolute;
            top: 10px;
            right: 15px;
            font-size: 2rem;
            font-weight: bold;
            cursor: pointer;
            color: #000;
            z-index: 10;
        }
        
        .close:hover {
            color: #dc3545;
        }

/* -------------------------------------------------------------------- */
/* Style personnalisé pour uniformiser les miniatures et les rendre interactives */

.gallery-card {
    overflow: hidden;
    border-radius: 0.375rem;
    background-color: #fff;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important;
}

.thumbnail-img {
    width: 100%;
    height: 100px; /* Hauteur fixe pour que toutes les miniatures soient alignées */
    object-fit: cover; /* Empêche la déformation de l'image */
    transition: transform 0.3s ease;
}

.gallery-card:hover .thumbnail-img {
    transform: scale(1.05);
}
