/* ==========================================================================
   1. TYPOGRAPHIE ET LIENS
   ========================================================================== */
.gl-content-wrapper a, 
.gl-content-wrapper h2, 
.gl-content-wrapper h3 {
    font-family: 'Gabarito', sans-serif !important;
    font-weight: bold !important;
}

.gl-content-wrapper a, 
.gl-content-wrapper h2, 
.gl-content-wrapper h3,
.gl-content-wrapper p,{
    text-wrap: pretty
}


.gl-content-wrapper h2, 
.gl-content-wrapper h3 {
    color: #31406E !important;
}

/* ==========================================================================
   2. BOUTONS WP-BLOCK
   ========================================================================== */
.gl-content-wrapper .wp-block-button__link {
    background-color: #ec6556 !important;
    color: #ffffff !important;
    transition: all 0.3s ease !important;
    text-transform: uppercase !important;
    border-radius: 40px;
}

.gl-content-wrapper .wp-block-button__link:hover {
    background-color: #31406e !important;
    color: #ffffff !important;
}

/* ==========================================================================
   3. PHOTOS ET LÉGENDES (CAPTION)
   ========================================================================== */
.gl-content-wrapper figure:not(.gl-large-block) {
    position: relative ;
    display: flex ;
    line-height: 0 ;
    padding: 0 ;
    margin-left: auto ;
    margin-right: auto ;
    flex-direction: row ;
    justify-content:center;
}



.gl-content-wrapper figure img {
    display: block !important;
    width: 100%;
    height: auto;
    margin: 0 !important; /* On annule la marge sur l'image seule */
}

.gl-content-wrapper figcaption.wp-element-caption,
.gl-content-wrapper .wp-caption-text, figcaption {
    font-size: 12px !important;
}

.gl-content-wrapper .wp-element-caption, .gl-content-wrapper .wp-caption-text, figcaption {
    /* Positionnement : Strictement sur l'image */
    position: absolute !important;
    bottom: 0%;
    left: 50% !important;
    transform: translateX(-50%) !important;
    
    /* Dimensions */
    width: fit-content !important;
    min-width: 100%;
    max-width: 100%;
    z-index: 10;

    /* Design */
    color: #FFFFFF !important;
    font-family: 'Gabarito', sans-serif !important;
    font-size: 12px !important;
    font-weight: 400 !important;
    line-height: 1.2 !important;
    text-align: center;
    border-radius: 5px !important;
    text-shadow: none !important;
    padding: 0.6rem 1rem !important;
}

.gl-content-wrapper .wp-block-column-is-layout-flow p {
    background-color: #006D4B !important;
    color: #FFFFFF !important;
    border-radius: 20px !important;
    padding: 1em;
}

.gl-content-wrapper .wp-block-column-is-layout-flow a {
    color: #FFFFFF !important;
}

.gl-content-wrapper .wp-block-column-is-layout-flow a:hover {
    text-decoration: underline;
}

/* 1. On prépare le conteneur SEULEMENT s'il y a un figcaption */
.gl-content-wrapper .wp-block-image:has(figcaption),
.gl-content-wrapper .contenu picture:has(figcaption) {
    position: relative;
    display: inline-block; /* Ou block selon votre mise en page */
    overflow: hidden;
}

/* 2. On crée le dégradé SEULEMENT s'il y a un figcaption */
.gl-content-wrapper .wp-block-image:has(figcaption)::after,
.gl-content-wrapper .contenu picture:has(figcaption)::after,
.gl-content-wrapper figure:has(figcaption) picture::after,
.gl-content-wrapper .wp-block-image:has(figcaption) picture::after {
    content: "";
    position: absolute;
    bottom: 0; /* On part du bas */
    left: 0;
    width: 100%;
    height: 50%; /* Le dégradé n'a pas besoin de faire 100% de la hauteur */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}
/* 3. On fait remonter la légende au-dessus du dégradé */
.gl-content-wrapper .wp-block-image figcaption {
    position: relative;
    z-index: 2;
    color: white; /* Optionnel : pour que ce soit lisible sur le noir */
}

/* 1. On prépare le terrain sur picture */
.gl-content-wrapper.contenu picture {
    position: relative;
    display: inline-block; /* Pour coller à la largeur de l'image */
    line-height: 0;
    vertical-align: bottom;
}

/* 2. On s'assure que l'image ne cache pas le dégradé */
.gl-content-wrapper.contenu picture img {
    display: block;
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1; /* L'image est au niveau 1 */
}

/* 3. Le dégradé doit être au-dessus (z-index: 2) */
/* On cible picture UNIQUEMENT s'il y a un figcaption dans le parent */
figure:has(figcaption) picture::after,
.gl-content-wrapper .wp-block-image:has(figcaption) picture::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%; /* Hauteur du dégradé */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    z-index: 2; /* FORCE le passage par-dessus l'image */
    pointer-events: none;
}

/* Forcer l'affichage en ligne sur Desktop/Tablette */
.gl-content-wrapper .wp-block-gallery.has-nested-images, .gl-content-wrapper .gallery {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    overflow-x: auto; /* Ajoute un scroll horizontal si les images dépassent */
    gap: 10px; /* Espace entre les images */
}

/* Ajuster la taille des images pour qu'elles rentrent */
.gl-content-wrapper .wp-block-gallery.has-nested-images, .gl-content-wrapper.gallery figure {
    flex: 1 1 auto; /* Permet aux images de s'ajuster */
    min-width: 150px;
}

/* Mode Mobile : Retour en colonne pour la lisibilité */
@media (max-width: 767px) {
    .gl-content-wrapper .wp-block-gallery.has-nested-images, .gl-content-wrapper .gallery {
        flex-direction: row !important;
        flex-wrap: wrap;
    }
    
    .gl-content-wrapper .wp-block-gallery.has-nested-images, .gl-content-wrapper .gallery figure {
        max-width: 100% !important;
        width: 100%;
    }
}

/* --- Desktop (Valeur par défaut) --- */
.wp-block-group {
    padding: 50px;
}

/* --- Laptop (Généralement < 1200px) --- */
@media (max-width: 1200px) {
    .wp-block-group {
        padding: 40px;
    }
}

/* --- Tablette Paysage (Généralement < 1024px) --- */
@media (max-width: 1024px) {
    .wp-block-group {
        padding: 30px;
    }
}

/* --- Tablette Portrait (Généralement < 768px) --- */
@media (max-width: 768px) {
    .wp-block-group {
        padding: 20px;
    }
}

/* --- Mobile (Généralement < 480px) --- */
@media (max-width: 480px) {
    .wp-block-group {
        padding: 15px;
    }
}

/* Ciblage par attribut (Desktop par défaut) */
p[style*="font-size:24px"] {
    display: block; /* S'assure que les marges s'appliquent bien */
    margin-top: 40px;
    margin-bottom: 30px;
}

/* Laptop */
@media (max-width: 1200px) {
    p[style*="font-size:24px"] {
        margin-top: 35px;
        margin-bottom: 25px;
    }
}

/* Tablette Paysage */
@media (max-width: 1024px) {
    p[style*="font-size:24px"] {
        margin-top: 30px;
        margin-bottom: 20px;
    }
}

/* Tablette Portrait */
@media (max-width: 768px) {
    p[style*="font-size:24px"] {
        margin-top: 25px;
        margin-bottom: 15px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    p[style*="font-size:24px"] {
        margin-top: 20px;
        margin-bottom: 10px;
    }
}


/* ==========================================================================
   4. RÉGLAGES RESPONSIVE (Tailles et Espacements)
   ========================================================================== */

/* --- DESKTOP (Base) --- */
/* On applique les marges sur le conteneur figure ici */
.gl-content-wrapper h2, .wp-block-button {
    margin-top: 4.375rem;
    margin-bottom: 4.375rem;
}

.gl-content-wrapper h2 { font-size: 3.4375rem; }
.gl-content-wrapper .wp-element-caption, .gl-content-wrapper .wp-caption-text { 
    font-size: 1.25rem !important; 
    padding: 0.625rem 1.5625rem !important; 
}

/* --- PC PORTABLE (1600px) --- */
@media (max-width: 1600px) {
    .gl-content-wrapper h2, .wp-block-button {
        margin-top: 3.75rem !important;
        margin-bottom: 3.75rem !important;
    }
    .gl-content-wrapper h3 {
        margin-top: 2.5rem !important;
        margin-bottom: 2.5rem !important;
    }
    .gl-content-wrapper h2 { font-size: 3.125rem !important; }
}

/* --- TABLETTE PORTRAIT (1024px) --- */
@media (max-width: 1024px) {
    .gl-content-wrapper h2, .wp-block-button {
        margin-top: 2.5rem !important;
        margin-bottom: 2.5rem !important;
    }
    .gl-content-wrapper h3 {
        margin-top: 1.875rem !important;
        margin-bottom: 1.875rem !important;
    }
    .gl-content-wrapper h2 { font-size: 2.5rem !important; }
    .gl-content-wrapper .wp-element-caption { 
        font-size: 1.125rem !important; 
        padding: 0.5rem 1.25rem !important;
        bottom: 15px !important;
    }
}

/* --- MOBILE PORTRAIT (767px) --- */
@media (max-width: 767px) {
    .gl-content-wrapper h2, .wp-block-button {
        margin-top: 1.875rem !important;
        margin-bottom: 1.875rem !important;
    }
    .gl-content-wrapper h3 {
        margin-top: 1.25rem !important;
        margin-bottom: 1.25rem !important;
    }
    .gl-content-wrapper h2 { font-size: 1.875rem !important; }
    .gl-content-wrapper .wp-element-caption, .gl-content-wrapper .wp-caption-text { 
        font-size: 1rem !important; 
        padding: 0.4rem 0.8rem !important; 
        width: 95% !important;
        bottom: 10px !important;
    }
}

.gl-content-wrapper .wp-caption-text {
    font-size: 12px !important;
}

/* Pour l'image à droite : on ajoute de l'espace à gauche et en bas */
.gl-content-wrapper figure.alignright {
    margin-left: 25px !important;
    margin-bottom: 20px !important;
    float: right;
}

/* Pour l'image à gauche : on ajoute de l'espace à droite et en bas */
.gl-content-wrapper figure.alignleft {
    margin-right: 25px !important;
    margin-bottom: 20px !important;
    float: left;
}

/* Optionnel : S'assurer que le texte ne se colle pas sur mobile */
@media (max-width: 600px) {
    .gl-content-wrapper figure.alignright, 
    .gl-content-wrapper figure.alignleft {
        float: none;
        margin-left: 0 !important;
        margin-right: 0 !important;
        display: block;
        text-align: center;
    }
}
