/**
 * ACF Packery Gallery - Styles
 * Chemin: css/acf-masonry-gallery.css
 * 
 * Utilise Packery pour le layout en grille
 */

/* Reset box-sizing */
* { 
    box-sizing: border-box; 
}

/* Container principal */
.acf-masonry-gallery-wrapper {
    width: 100%;
}

.acf-masonry-grid {
    max-width: 100%;
    margin: 0 auto;
}

/* Clearfix pour le container */
.acf-masonry-grid:after {
    content: '';
    display: block;
    clear: both;
}

/* Grid sizer et items - Configuration de base */
.acf-masonry-grid-sizer,
.acf-masonry-grid-item {
    width: 25%; /* 4 colonnes par défaut */
}

/* Configuration des items */
.acf-masonry-grid-item {
    float: left;
    padding: 5px;
    position: relative;
}

/* Liens des images */
.acf-masonry-grid-item a {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 5px;
}

/* Images */
.acf-masonry-grid-item img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 5px;
    transition: transform 0.3s ease;
}

/* Overlay zoom au survol */
.acf-masonry-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 5px;
}

.acf-masonry-grid-item a:hover .acf-masonry-overlay {
    opacity: 1;
}

.acf-masonry-grid-item a:hover img {
    transform: scale(1.05);
}

/* Icône de zoom */
.acf-masonry-zoom-icon {
    width: 48px;
    height: 48px;
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Légendes d'images */
.acf-masonry-caption {
    padding: 8px;
    font-size: 14px;
    color: #666;
    font-style: italic;
    text-align: center;
}

/* ---- Variations de taille ---- */

/* Double largeur */
.acf-masonry-grid-item--width2 { 
    width: 50%; 
}

/* Double hauteur */
.acf-masonry-grid-item--height2 img { 
    height: 400px; 
    object-fit: cover;
}

/* ---- Bouton "Charger plus" ---- */

.acf-masonry-load-more-container {
    text-align: center;
    margin: 30px 0;
}

.acf-masonry-load-more-btn {
    background: #279ca7;
    border: 1px solid #279ca7;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.acf-masonry-load-more-btn:hover {
    transform: translateY(-2px);
    background: rgb(0,0,0,0);
    color: #279ca7;
    border: 1px solid #279ca7;
}

.acf-masonry-load-more-btn:active {
    transform: translateY(0);
}

.acf-masonry-load-more-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.load-more-count {
    font-size: 14px;
    opacity: 0.9;
}

/* Loader spinner */
.acf-masonry-loader {
    text-align: center;
    padding: 20px;
}

.acf-masonry-loader .spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 4px solid rgba(39, 156, 167, 0.2);
    border-top-color: #279ca7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- Responsive Design ---- */

/* Tablettes (768px et moins) */
@media (max-width: 768px) {
    .acf-masonry-grid-sizer,
    .acf-masonry-grid-item {
        width: 50%; /* 2 colonnes */
    }
    
    .acf-masonry-grid-item--width2 { 
        width: 100%; /* Pleine largeur */
    }

    .acf-masonry-grid-item--height2 img { 
        height: 150px; /* Réduction de la hauteur */
    }

    .acf-masonry-zoom-icon {
        width: 40px;
        height: 40px;
    }

    .acf-masonry-load-more-btn {
        padding: 12px 30px;
        font-size: 14px;
    }
}

/* Mobiles (480px et moins) */
@media (max-width: 480px) {
    .acf-masonry-grid-sizer,
    .acf-masonry-grid-item,
    .acf-masonry-grid-item--width2 {
        width: 100%; /* 1 colonne */
    }

    .acf-masonry-grid-item {
        padding: 3px; /* Réduction du padding */
    }

    .acf-masonry-grid-item--height2 img { 
        height: auto; /* Hauteur automatique sur mobile */
    }

    .acf-masonry-caption {
        font-size: 12px;
        padding: 5px;
    }

    .acf-masonry-zoom-icon {
        width: 36px;
        height: 36px;
    }

    .acf-masonry-load-more-btn {
        width: 100%;
        padding: 12px 20px;
    }

    .load-more-count {
        display: block;
        margin-top: 5px;
    }
}

/* ---- Animations de chargement ---- */

/* État initial (avant Masonry) */
.acf-masonry-grid-item {
    opacity: 0;
    animation: fadeInItem 0.5s ease forwards;
}

/* Animation de fade in progressive */
@keyframes fadeInItem {
    to {
        opacity: 1;
    }
}

/* Délai progressif pour chaque item */
.acf-masonry-grid-item:nth-child(1) { animation-delay: 0.1s; }
.acf-masonry-grid-item:nth-child(2) { animation-delay: 0.15s; }
.acf-masonry-grid-item:nth-child(3) { animation-delay: 0.2s; }
.acf-masonry-grid-item:nth-child(4) { animation-delay: 0.25s; }
.acf-masonry-grid-item:nth-child(5) { animation-delay: 0.3s; }
.acf-masonry-grid-item:nth-child(n+6) { animation-delay: 0.35s; }

/* ---- Personnalisation GLightbox ---- */

/* Vous pouvez surcharger les styles de GLightbox ici si nécessaire */
.glightbox-clean .gslide-description {
    background: rgba(0, 0, 0, 0.75);
}

/* ---- Options de personnalisation ---- */

/* Pour modifier le nombre de colonnes, ajustez ces valeurs :
   - 3 colonnes : width: 33.333%;
   - 5 colonnes : width: 20%;
   - 6 colonnes : width: 16.666%;
*/

/* Pour modifier l'espacement entre images :
   Ajustez le padding dans .acf-masonry-grid-item
*/

/* Pour modifier l'arrondi des images :
   Ajustez le border-radius dans .acf-masonry-grid-item img et .acf-masonry-grid-item a
*/