/* Gallery Section Styles */
#gallery {
    background: linear-gradient(135deg, #212529 0%, #1a1d20 100%);
    position: relative;
    overflow: hidden;
    padding: 40px 0;
}

.gallery-grid-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease-out forwards;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(2, 200px);
    gap: 15px;
    margin: 2rem 0;
    width: 100%;
}

/* Nouveau layout 4 colonnes avec 7 images */
.gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: auto;
    grid-auto-flow: dense;
    gap: 6px;
    margin: 2rem 0;
    width: 100%;
}

.gallery .overflow-hidden-item {
    min-height: 200px;
}

.gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery .overflow-hidden-item:has(img.four-grid-cells) {
    grid-row: span 2 / auto;
    grid-column: span 2 / auto;
}

.gallery .overflow-hidden-item:has(img.wide-image) {
    grid-column: span 2 / auto;
}

/* Fallback pour les navigateurs qui ne supportent pas :has() */
.gallery .overflow-hidden-item:nth-child(1) {
    grid-row: span 2 / auto;
    grid-column: span 2 / auto;
}

.gallery .overflow-hidden-item:nth-child(2),
.gallery .overflow-hidden-item:nth-child(4) {
    grid-column: span 2 / auto;
}

.w-layout-grid {
    display: grid;
    grid-auto-columns: 1fr;
    grid-column-gap: 16px;
    grid-row-gap: 16px;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
}

/* Layout asymétrique spécifique Webflow */
.w-layout-grid .overflow-hidden-item:nth-child(1) {
    grid-column: 1 / 3;  /* Prend 2 colonnes */
    grid-row: 1 / 2;
}

.w-layout-grid .overflow-hidden-item:nth-child(2) {
    grid-column: 3 / 4;  /* 1 colonne */
    grid-row: 1 / 2;
}

.w-layout-grid .overflow-hidden-item:nth-child(3) {
    grid-column: 4 / 5;  /* 1 colonne */
    grid-row: 1 / 2;
}

.w-layout-grid .overflow-hidden-item:nth-child(4) {
    grid-column: 5 / 6;  /* 1 colonne */
    grid-row: 1 / 2;
}

.w-layout-grid .overflow-hidden-item:nth-child(5) {
    grid-column: 6 / 7;  /* 1 colonne */
    grid-row: 1 / 2;
}

.w-layout-grid .overflow-hidden-item:nth-child(6) {
    grid-column: 1 / 3;  /* Prend 2 colonnes */
    grid-row: 2 / 3;
}

.gallery-grid-more {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: 200px;
    gap: 15px;
    margin: 2rem 0;
    width: 100%;
}

/* Disposition exacte comme sur Webflow - ligne 1 */
.gallery-item-1 {
    grid-column: 1 / 3;  /* Large - 2 colonnes */
    grid-row: 1 / 2;
}

.gallery-item-2 {
    grid-column: 3 / 4;  /* Normal - 1 colonne */
    grid-row: 1 / 2;
}

.gallery-item-3 {
    grid-column: 4 / 5;  /* Normal - 1 colonne */
    grid-row: 1 / 2;
}

.gallery-item-4 {
    grid-column: 5 / 6;  /* Normal - 1 colonne */
    grid-row: 1 / 2;
}

.gallery-item-5 {
    grid-column: 6 / 7;  /* Normal - 1 colonne */
    grid-row: 1 / 2;
}

/* Ligne 2 */
.gallery-item-6 {
    grid-column: 1 / 3;  /* Large - 2 colonnes */
    grid-row: 2 / 3;
}

/* Grille supplémentaire - 3 images en ligne */
.gallery-item-more-1 {
    grid-column: 1 / 3;  /* Large - 2 colonnes */
    grid-row: 1 / 2;
}

.gallery-item-more-2 {
    grid-column: 3 / 5;  /* Large - 2 colonnes */
    grid-row: 1 / 2;
}

.gallery-item-more-3 {
    grid-column: 5 / 7;  /* Large - 2 colonnes */
    grid-row: 1 / 2;
}

@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(3, 250px);
    }

    .gallery {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .gallery .overflow-hidden-item:nth-child(1) {
        grid-row: span 2 / auto;
        grid-column: span 2 / auto;
    }

    .gallery .overflow-hidden-item:nth-child(2),
    .gallery .overflow-hidden-item:nth-child(4) {
        grid-column: span 1 / auto;
    }

    .gallery-item-1 {
        grid-column: 1 / 3;
        grid-row: 1 / 2;
    }

    .gallery-item-2 {
        grid-column: 3 / 4;
        grid-row: 1 / 2;
    }

    .gallery-item-3 {
        grid-column: 4 / 5;
        grid-row: 1 / 2;
    }

    .gallery-item-4 {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }

    .gallery-item-5 {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
    }

    .gallery-item-6 {
        grid-column: 3 / 5;
        grid-row: 2 / 3;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 200px);
        gap: 1rem;
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .gallery .overflow-hidden-item:nth-child(1) {
        grid-row: span 2 / auto;
        grid-column: span 1 / auto;
    }

    .gallery .overflow-hidden-item:nth-child(2),
    .gallery .overflow-hidden-item:nth-child(4) {
        grid-column: span 1 / auto;
    }

    .gallery-grid-more {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: 200px;
        gap: 1rem;
    }

    .gallery-item-1 {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }

    .gallery-item-2 {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
    }

    .gallery-item-3 {
        grid-column: 1 / 2;
        grid-row: 2 / 3;
    }

    .gallery-item-4 {
        grid-column: 2 / 3;
        grid-row: 2 / 3;
    }

    .gallery-item-5 {
        grid-column: 1 / 2;
        grid-row: 3 / 4;
    }

    .gallery-item-6 {
        grid-column: 2 / 3;
        grid-row: 3 / 4;
    }

    .gallery-item-more-1 {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }

    .gallery-item-more-2 {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
    }

    .gallery-item-more-3 {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
    }
}

.overflow-hidden-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(2, 131, 93, 0.05);
    border: 1px solid rgba(2, 131, 93, 0.1);
    transition: all 0.4s ease;
    width: 100%;
    height: 100%;
    min-height: 200px;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.overflow-hidden-item:nth-child(1) { animation-delay: 0.1s; }
.overflow-hidden-item:nth-child(2) { animation-delay: 0.2s; }
.overflow-hidden-item:nth-child(3) { animation-delay: 0.3s; }
.overflow-hidden-item:nth-child(4) { animation-delay: 0.4s; }
.overflow-hidden-item:nth-child(5) { animation-delay: 0.5s; }
.overflow-hidden-item:nth-child(6) { animation-delay: 0.6s; }

/* Layout répétitif automatique - Pattern de 7 images qui se répète */
.gallery .overflow-hidden-item:nth-child(7n+1) { /* 1er, 8ème, 15ème... */
    grid-row: span 2 / auto;
    grid-column: span 2 / auto;
}

.gallery .overflow-hidden-item:nth-child(7n+2), /* 2ème, 9ème, 16ème... */
.gallery .overflow-hidden-item:nth-child(7n+4) { /* 4ème, 11ème, 18ème... */
    grid-column: span 2 / auto;
}

/* Les autres positions (3, 5, 6, 7 de chaque cycle) gardent la taille normale */

.gallery-lightbox {
    display: block;
    position: relative;
    text-decoration: none;
    color: inherit;
}

.gallery-grid-lightbox {
    display: block;
    position: relative;
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
}

.w-inline-block {
    display: inline-block;
}

.w-lightbox {
    background: #000;
    cursor: pointer;
}

.gallery-grid-lightbox-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.gallery-image-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.4s ease;
    transform: scale(1);
}

.gallery-news-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.4s ease;
    transform: scale(1);
}

.gallery-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(2, 131, 93, 0.8);
    opacity: 0;
    transition: all 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.hover-block {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 60px;
    height: 60px;
    margin: auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 2rem;
    color: #fff;
    opacity: 0 !important;
    transition: all 0.15s ease;
}

.gallery-hover-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
}

.gallery-hover-icon i {
    font-size: 1.5rem;
    color: #fff;
}

/* Hover Effects */
.overflow-hidden-item:hover {
    transform: translateY(-8px);
    border-color: rgba(2, 131, 93, 0.3);
    box-shadow: 0 15px 40px rgba(2, 131, 93, 0.2);
}

.overflow-hidden-item:hover .gallery-image {
    transform: scale(1.05);
}

.overflow-hidden-item:hover .gallery-news-image {
    transform: scale(1.05);
}

.overflow-hidden-item:hover .gallery-hover-overlay {
    opacity: 1;
}

.overflow-hidden-item:hover .hover-block {
    opacity: 1 !important;
}

.overflow-hidden-item:hover .gallery-hover-icon {
    transform: scale(1);
    opacity: 1;
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Load More Button */
.load-more-section {
    margin: 30px 0;
    text-align: center;
}

.load-more-btn {
    background: transparent;
    color: #02835d;
    border: 2px solid #02835d;
    padding: 12px 30px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.load-more-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(2, 131, 93, 0.2), transparent);
    transition: left 0.5s ease;
}

.load-more-btn:hover {
    background: #02835d;
    color: #fff;
    border-color: #02835d;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(2, 131, 93, 0.3);
}

.load-more-btn:hover:before {
    left: 100%;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Gallery Placeholder */
.gallery-placeholder {
    padding: 4rem 2rem;
    text-align: center;
    background: rgba(2, 131, 93, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(2, 131, 93, 0.1);
}

.gallery-placeholder i {
    color: #02835d;
    opacity: 0.7;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 992px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 576px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gallery-placeholder {
        padding: 2rem 1rem;
    }

    .overflow-hidden-item:hover {
        transform: translateY(-4px);
    }
}

/* Lightbox Integration */
.gallery-lightbox:focus {
    outline: none;
}

/* Section Title Animation */
.text-reveal-mask {
    overflow: hidden;
}

.reveal-text {
    opacity: 0;
    transform: translateY(20px);
    animation: revealText 0.8s ease-out 0.3s forwards;
}

@keyframes revealText {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid Layout Variations */
.gallery-grid.masonry {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-auto-rows: 250px;
    gap: 2rem;
}

.gallery-grid.masonry .overflow-hidden-item:nth-child(3n) {
    grid-row: span 2;
}

.gallery-grid.masonry .overflow-hidden-item:nth-child(5n) {
    grid-column: span 2;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gallery-placeholder {
        background: rgba(2, 131, 93, 0.1);
        border-color: rgba(2, 131, 93, 0.2);
    }
}

/* Instagram Section */
.instagram-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Instagram Loading */
.instagram-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: white;
}

.instagram-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

.instagram-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    transition: all 0.3s ease;
}

.instagram-container:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Grille Instagram avec vrais posts */
.instagram-posts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 1.5rem;
    max-width: 800px;
    margin: 0 auto 1.5rem auto;
}

/* Responsive pour mobile */
@media (max-width: 768px) {
    .instagram-posts-grid {
        grid-template-columns: 1fr;
        max-width: 380px;
        gap: 1rem;
    }

    .instagram-post-wrapper {
        min-height: 200px;
        max-height: 200px;
    }

    .instagram-post-wrapper iframe {
        height: 200px !important;
    }
}

.instagram-post-wrapper {
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
    min-height: 220px;
    max-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.instagram-post-wrapper:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
}

/* Réinitialisation des styles pour les posts embed */
.instagram-post-wrapper .instagram-media {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 200px !important;
    border-radius: 12px !important;
    transition: all 0.3s ease !important;
    overflow: hidden !important;
    height: 220px !important;
}

.instagram-post-wrapper iframe {
    border-radius: 12px !important;
    overflow: hidden !important;
    height: 220px !important;
    width: 100% !important;
}

/* Instagram Posts dynamiques */
.instagram-post-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.instagram-post-image-container {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    border-radius: 12px;
}

.instagram-post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.instagram-post-wrapper:hover .instagram-post-image {
    transform: scale(1.05);
}

.instagram-post-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.instagram-post-wrapper:hover .instagram-post-overlay {
    opacity: 1;
}

.instagram-post-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.instagram-post-info i {
    color: #E4405F;
}

.instagram-post-date {
    font-size: 0.8rem;
    opacity: 0.8;
}

.instagram-post-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    opacity: 0.9;
}

.instagram-post-stats span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.instagram-post-caption {
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0.9;
}

.instagram-header i {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.instagram-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.instagram-post {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.instagram-post:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.instagram-post-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    position: relative;
}

.instagram-post-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
}

.instagram-post:hover .instagram-post-image::before {
    opacity: 0.1;
}

.instagram-cta .btn {
    background: linear-gradient(135deg, #833ab4 0%, #fd1d1d 50%, #fcb045 100%);
    border: none;
    border-radius: 50px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.instagram-cta .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(131, 58, 180, 0.4);
}

/* Fallback pour les posts Instagram qui ne se chargent pas */
.instagram-post-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.instagram-post-placeholder {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.instagram-post-placeholder:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.instagram-post-placeholder i {
    color: #833ab4;
    margin-bottom: 1rem;
}

.instagram-post-placeholder p {
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* Responsive Instagram */
@media (max-width: 768px) {
    .instagram-container {
        padding: 2rem 1.5rem;
    }

    .instagram-posts-grid {
        grid-template-columns: repeat(1, 1fr);
        gap: 1rem;
        max-width: 400px;
    }

    .instagram-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .instagram-section {
        margin-top: 2rem;
        padding-top: 2rem;
    }

    .instagram-container {
        padding: 1.5rem 1rem;
    }

    .instagram-posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .instagram-grid {
        gap: 0.5rem;
    }
}
