/*
 * Homepage Styles (front-page.php)
 * Refactored and sorted for clarity.
 * -------------------------------------------------- */

/* --- General Section Styles --- */

.front-page-content .container {
    margin-left: auto;
    margin-right: auto;
    max-width: 1000px;
    padding-left: 20px;
    padding-right: 20px;
}

.front-page-section:not(.hero-section) {
    margin-bottom: 40px;
    margin-top: 40px;
    padding: 20px 0;
    text-align: center;
}

.front-page-section h2 {
    margin-bottom: 1em;
}

.front-page-section p {
    font-size: 1em;
    line-height: 1.7;
    margin-bottom: 2em;
    margin-left: auto;
    margin-right: auto;
    max-width: 700px;
}

@media (max-width: 450px) {
    .front-page-section h2 {
        margin-bottom: 2em;
    }
}

/* ==========================================================
   1. HERO : STYLES DE BASE (Desktop Standard)
   ========================================================== */

.hero-section {
    position: relative;
    width: 100%;
    max-width: 1500px;
    height: 100vh;
    /* min-height: 60vh;  */
    margin: 0 auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--site-color-background);
    box-sizing: border-box;
    padding-top: var(--header-height, 180px);
}


.hero-img {    
    border-radius: 0 !important;
    display: block;
    transform-origin: center center;
    will-change: transform;
}

/* Ensure the image container clips scaled images so zoom doesn't overflow */
.hero-image {
    position: relative;
    overflow: hidden;
    /* border-radius: var(--site-image-border-radius); */
}

.hero-content {
    display: flex;
    flex-direction: column;
    width: 100%; 
}

/* Mobile default overlay: when no hero content bg is set, use a subtle
   dark overlay on small screens to improve contrast for stacked text. The
   variable `--hero-content-bg-color-rgba` is emitted by PHP only when the
   background option is enabled; when omitted we fall back to this value
   on mobile. */
:root { --hero-content-bg-mobile-default: rgba(0,0,0,0); }
@media (max-width: 767px) {
    :root { --hero-content-bg-mobile-default: rgba(0,0,0,0.35); }
}
.hero-content { background-color: var(--hero-content-bg-color-rgba, var(--hero-content-bg-mobile-default)); }

/* On centre toujours horizontalement le inner */
.hero-content-inner {
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 600px; /* Largeur de lecture confortable */
}

/* Ensure all text inside the hero-content-inner follows the computed/forced hero content text color */
.hero-content-inner,
.hero-content-inner p,
.hero-content-inner .hero-philosophy,
.hero-content-inner .hero-subtitle,
.hero-content-inner li,
.hero-content-inner a {
    color: var(--hero-content-text-color, var(--site-color-text));
}

/* --- Typographie (Base) --- */
.hero-section h1 {
    color: var(--hero-title-color) !important;
    margin-bottom: 0.5em;
    font-family: var(--hero-title-font-family, var(--font-site-title));
    font-weight: var(--hero-title-weight, 700);
}
/* Note: hero H1 uses the CSS variable above; preview-specific inline JS
   writes font-family to the element when the Customizer control changes.
   Avoid !important here so inline styles from the preview script take
   precedence and the Customizer selection is visible immediately. */
.hero-section .hero-philosophy {
    color: var(--hero-content-text-color, var(--site-color-text));
    font-size: 2em;
    font-weight: var(--hero-philosophy-weight, 500);
    margin-bottom: 1em;
}

/* --- Bouton (Base) --- */
.hero-section .hero-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 0.5rem;
    background: var(--hero-button-bg-color, linear-gradient(45deg, var(--site-color-accent-primary), var(--site-color-text)));
    background-size: 200% 200%;
    border-radius: var(--site-image-border-radius);
    border: var(--hero-button-border, 1.5px solid var(--site-color-text));
    padding: 12px 25px;
    color: var(--hero-button-text-color, var(--site-color-text));
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    transition: transform 0.15s ease, background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    margin: 1em auto;
}

/* Effet léger de zoom au survol pour le bouton du hero */
.hero-section .hero-button:hover {
    transform: translateY(-2px) scale(1.03);
}




/* ==========================================================
   2. LES MODES DE DISPOSITION (Desktop)
   ========================================================== */

/* --- MODE CENTERED --- */
.hero--centered {
    display: grid; /* On utilise Grid */
    grid-template-areas: "hero-stack"; /* On définit une zone unique */
    align-items: center;
    justify-content: center;
    text-align: center;
    /* height: 100%;  */
}

/* On force l'image et le contenu à aller dans la même zone */
.hero--centered .hero-image,
.hero--centered .hero-content {
    grid-area: hero-stack; 
}

/* L'image remplit tout le fond */
.hero--centered .hero-image {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero--centered .hero-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Important pour que l'image ne soit pas déformée */
}

.hero--centered .hero-content {
    grid-area: hero-stack;
    flex-grow: 1;
    /* position: relative; */
    /* width: 100%; */
    height: auto;
    display: flex;
    flex-direction: column;
    z-index: 10;
    /* max-width: var(--hero-centered-max-width, 900px); */
    padding: 20px;
    margin-top: 0; 
}

/* --- MODE TRAVELING (PANORAMIQUE) --- */
.hero-traveling {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* L'image de fond pour Traveling (gérée via style inline dans le PHP) */
.hero-traveling .hero-slide-background {
    position: absolute;
    inset: 0;
    width: 120%; /* Plus large pour permettre le mouvement */
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
    -webkit-animation: traveling-pan var(--hero-traveling-duration, 20s) linear infinite alternate;
        animation: traveling-pan var(--hero-traveling-duration, 20s) linear infinite alternate;
    -webkit-animation-play-state: running !important;
        animation-play-state: running !important;
    will-change: transform;
    -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
}

/* --- MODE : SPLIT / TWO-COLUMN (Statique) --- */
.hero--split:not(.hero-carousel), 
.hero--two-column:not(.hero-carousel) {
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: var(--hero-split-gap, 40px);
    /* padding: 0; */
}
.hero--split:not(.hero-carousel) .hero-content, 
.hero--two-column:not(.hero-carousel) .hero-content {
    justify-content: center;
    max-width: 400px;
    padding-left: 0;
    padding-right: 0;
    /* padding: 60px 40px; */
}
.hero--split:not(.hero-carousel) .hero-image, 
.hero--two-column:not(.hero-carousel) .hero-image {
    /* flex: 1.8; */
    position: relative;
    overflow: hidden;
    /* max-width: 60%; */
}
.hero--split:not(.hero-carousel) .hero-image .hero-img, 
.hero--two-column:not(.hero-carousel) .hero-image .hero-img {
    width: 100%;
    height: 100%;    /* Remplit toute la hauteur de la colonne */
    object-fit: cover; /* Recadre l'image sans la déformer */
    border-radius: var(--site-image-border-radius);
}

/* --- MODE : CAROUSEL (Swiper) --- */
.hero-swiper {
    width: 100% !important;
    /* height: 100%; */
    position: relative;
    overflow: hidden;
    display: block !important; /* Swiper doit être un bloc pour calculer */
}

.hero-swiper .swiper-wrapper {
    display: flex !important;
    flex-direction: row !important; /* Force l'alignement horizontal des slides */
    height: 100%;
    width: 100%;
}

.hero-swiper .swiper-slide {
    flex-shrink: 0; 
    width: 100% !important;
    height: 100%;
    position: relative;
    /* Ici, on peut utiliser Flex pour le contenu interne */
    display: flex; 
}


.hero-carousel:not(.hero--two-column) .swiper-slide {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}
.hero-carousel:not(.hero--two-column) .hero-swiper {
    height: 100%;
}

/* Background element used by slides (fills slide, gets inline background-image) */
.hero-carousel:not(.hero--two-column) .hero-slide-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1; /* Derrière le texte */
}

/* Masquer les slides non-actives */
.hero-section.hero-carousel .swiper-slide:not(.swiper-slide-active) {
    opacity: 0;
    pointer-events: none; /* Rendre inactif au clic */
    visibility: hidden;
    z-index: 0 !important;
}

.hero--split.hero-carousel .hero-content, 
.hero--two-column.hero-carousel .hero-content {
    justify-content: center;
    max-width: 600px;
    padding: 60px 40px;
}
.hero--split.hero-carousel .hero-image, 
.hero--two-column.hero-carousel .hero-image {
    /* flex: 1.8; */
    position: relative;
    overflow: hidden;
    /* max-width: 60%; */
}

/* Navigation (arrows) appearance */
.hero-swiper .swiper-button-prev,
.hero-swiper .swiper-button-next {
    background: var(--swiper-navigation-bg, transparent);
    color: var(--swiper-navigation-color, var(--site-color-accent-primary));
    left: var(--swiper-navigation-sides-offset, 16px);
    position: absolute;
    /* top: calc(50% + (var(--header-height, 180px) / 2)); */
    /* transform: translateY(-50%); */
    z-index: 9;
}

.hero-swiper .swiper-button-next {
    left: auto;
    right: var(--swiper-navigation-sides-offset, 16px);
}

/* Pagination bullets */
.hero-swiper .swiper-pagination {
    bottom: var(--swiper-pagination-bottom, 16px);
    z-index: 9;
}

.hero-swiper .swiper-pagination-bullet {
    background: var(--swiper-pagination-bullet-inactive-color, rgba(255,255,255,0.5));
    margin: 0 var(--swiper-pagination-bullet-horizontal-gap, 6px);
    opacity: 1;
}

.hero-swiper .swiper-pagination-bullet-active {
    background: var(--swiper-pagination-color, var(--site-color-accent-primary));
}

/* Carousel en mode Two-Column */
.hero-carousel.hero--two-column .swiper-slide {
    flex-direction: row;
    align-items: stretch;
    /* padding: 0 10%; */
    gap: 40px;
}
.hero-carousel.hero--two-column .hero-content,
.hero-carousel.hero--two-column .hero-image {
    flex: 1;
    position: relative;
    text-align: center;
    z-index: 10;
}

/* --- INVERSION (Content First) --- */
.content-first { flex-direction: row-reverse !important; 
}

/* ==========================================================
   3. ANIMATIONS (Zoom & Traveling)
   ========================================================== */
.hero-zoom .hero-img, .hero-zoom .hero-slide-background {
    animation: hero-zoom-in var(--hero-zoom-duration, 18s) ease-in-out infinite alternate;
}
@keyframes hero-zoom-in {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

@keyframes traveling-pan {
    from { transform: translateX(0) scale(1); }
    to { transform: translateX(-10%) scale(1.1); }
}

@-webkit-keyframes traveling-pan {
    from { -webkit-transform: translateX(0) scale(1); transform: translateX(0) scale(1); }
    to { -webkit-transform: translateX(-10%) scale(1.1); transform: translateX(-10%) scale(1.1); }
}

/* Larger variant used on very wide viewports (1500px+).
   The media query switches to `traveling-pan-large` and a wider
   background; define corresponding keyframes here so the animation
   continues to run on big screens. */
@keyframes traveling-pan-large {
    from { transform: translateX(0) scale(1); }
    to   { transform: translateX(-15%) scale(1.12); }
}

@-webkit-keyframes traveling-pan-large {
    from { -webkit-transform: translateX(0) scale(1); transform: translateX(0) scale(1); }
    to   { -webkit-transform: translateX(-15%) scale(1.12); transform: translateX(-15%) scale(1.12); }
}

/* ==========================================================
   4. LE CONTENU 
   ========================================================== */
/* --- Effet de flou et fond semi-transparent pour le contenu --- */
.hero-content {
    position: relative;
    z-index: 10;   
    display: flex !important;
    flex-direction: column;
    height: auto;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

.hero-content-inner {
    margin-left: auto;
    margin-right: auto;
    /* width: 60%; */
    max-width: 100%;
    padding: 20px;
    /* transition: all 0.3s ease; */
    border-radius: var(--site-image-border-radius);
    background-color: var(--hero-content-bg-color-rgba, rgba(0,0,0,0.3));
    -webkit-backdrop-filter: blur(var(--hero-content-backdrop-filter-blur, 5px)) brightness(var(--hero-content-backdrop-filter-brightness, 100%));
    backdrop-filter: blur(var(--hero-content-backdrop-filter-blur, 5px)) brightness(var(--hero-content-backdrop-filter-brightness, 100%));
    
    /* Par défaut transparent (pour le mode Two-column) */
}

/* ACTIVATION DE L'OVERLAY : Uniquement si mode centered OU mode mobile */
.hero--centered .hero-content-inner,
.hero-traveling .hero-content-inner,
.hero-carousel:not(.hero--two-column) .hero-content-inner {
    padding: 20px;
}


/* --- Alignements (Desktop uniquement) --- */
/* On limite ces alignements aux modes où le texte survole l'image */
.hero--centered .hero-content,
.hero-traveling .hero-content {
    /* min-height: 100%; */
    /* height: 100%; */
    display: flex;
    flex-direction: column;
    text-align: center;
}

.hero-carousel:not(.hero--two-column) .hero-content {
    position: relative;
    z-index: 10; /* Devant l'image */
    flex: 1;     /* PREND TOUTE LA HAUTEUR RESTANTE */
    display: flex !important;
    flex-direction: column;
    width: 100%;
    margin-bottom: 20px ;
}

.hero--centered .hero__content--top,
.hero-carousel:not(.hero--two-column) .hero__content--top { justify-content: flex-start; }

.hero--centered .hero__content--center,
.hero-carousel:not(.hero--two-column) .hero__content--center { justify-content: center; }

/* .hero--centered .hero__content--bottom,
.hero-carousel:not(.hero--two-column) .hero__content--bottom { justify-content: flex-end; padding-bottom: 60px; } */

/* On applique le padding bottom variable UNIQUEMENT si on n'est pas en 2 colonnes */
.hero--centered .hero__content--bottom,
.hero-carousel:not(.hero--two-column) .hero__content--bottom {
    justify-content: flex-end;
    /* padding-bottom: clamp(40px, 10vh, 120px) !important; */
}

/* Cas spécial : Le carrousel 2 colonnes en Desktop doit rester centré verticalement 
   quels que soient les réglages de position du texte */
.hero-carousel.hero--two-column .swiper-slide {
    align-items: center !important; 
}

/* ==========================================================
   5. RESPONSIVE
   ========================================================== */

/* --- DESKTOP (1500px+) --- */
@media (min-width: 1500px) {
    .hero-section, .hero-carousel { height: 100vh; }
    .hero-panoramic.hero-traveling .hero-slide-background {
        -webkit-animation: traveling-pan-large var(--hero-traveling-duration, 20s) linear infinite alternate;
        animation: traveling-pan-large var(--hero-traveling-duration, 20s) linear infinite alternate;
        width: 150vw;
        position: absolute;
    }
    .hero--split:not(.hero-carousel) .hero-content, .hero--two-column:not(.hero-carousel) .hero-content {
        max-width: 700px;
    }
    .hero-section h1 { font-size: 3em;}
    .hero-section .hero-philosophy { font-size: 2.5em; }
    .hero-section .hero-button { font-size: 1.8em; }
}

@media (max-width: 1500px) {
    /* .hero-section, .hero-carousel { 
        height: auto; 
        min-height: 70vh; 
    } */
    
    .hero-swiper .swiper-button-prev::after,
    .hero-swiper .swiper-button-next::after { 
        /* height: 30px; width: 30px;  */
        /* top: 50% ; */
        font-size: xx-large;
    }
}

/* --- LAPTOP (1200px and down) --- */

    /* Portfolio tabs styles - adapted from your preferred presentation styles */
    .portfolio-tabs {
        margin: 2.5rem 0;
    }
    .portfolio-tabs .tabs-nav {
        display: flex;
        justify-content: center;
        margin-bottom: 2em;
        /* border-bottom: 2px solid var(--site-color-border-light); */
    }

    .portfolio-tabs .tab-toggle {
        padding: 10px 20px;
        cursor: pointer;
        border: none;
        background-color: transparent;
        font-size: 1.2em;
        font-family: var(--font-body);
        color: var(--site-color-text);
        position: relative;
        bottom: -2px;
        transition: color 0.3s ease, border-bottom-color 0.3s ease;
        border-bottom: 2px solid transparent;
    }

    .portfolio-tabs .tab-toggle.tab-toggle--active {
        color: var(--site-color-text);
        font-weight: 500;
        border-bottom-color: var(--site-color-accent-primary);
    }

    /* Panels are visible by default; visibility controlled by [hidden] or .active for compatibility */
    .portfolio-tabs .tabs-panel {
        display: block;
        line-height: 1.8;
    }

    /* When panels are explicitly hidden (attribute used by JS), hide them */
    .portfolio-tabs .tabs-panel[hidden] {
        display: none !important;
    }

    /* Backwards-compatible: panels with .active class are shown */
    .portfolio-tabs .tabs-panel.active {
        display: block;
    }

    /* Content inside panels */
    .portfolio-tabs .tabs-panel p,
    .portfolio-tabs .tabs-panel ul,
    .portfolio-tabs .tabs-panel ol,
    .portfolio-tabs .tabs-panel h1,
    .portfolio-tabs .tabs-panel h2,
    .portfolio-tabs .tabs-panel h3,
    .portfolio-tabs .tabs-panel h4,
    .portfolio-tabs .tabs-panel h5,
    .portfolio-tabs .tabs-panel h6,
    .portfolio-tabs .tabs-panel .wp-block-group,
    .portfolio-tabs .tabs-panel .wp-block-image,
    .portfolio-tabs .tabs-panel .wp-block-gallery,
    .portfolio-tabs .tabs-panel .wp-block-columns {
        margin-bottom: 1em;
    }

    .portfolio-tabs .tabs-panel h2 {
        margin-top: 2em;
        margin-bottom: 1em;
        color: var(--site-color-text);
    }

    .portfolio-tabs .tabs-panel .wp-block-group {
        padding: 1.5em;
    }

    .portfolio-tabs .tabs-panel ul,
    .portfolio-tabs .tabs-panel ol,
    .portfolio-tabs .tabs-panel ul.wp-block-list,
    .portfolio-tabs .tabs-panel ol.wp-block-list {
        margin-left: 2em;
        margin-bottom: 1.5em;
        line-height: 1.7;
        list-style: none !important;
        padding-left: 0;
    }

    .portfolio-tabs .tabs-panel li {
        margin-bottom: 0.8em;
        position: relative;
        padding-left: 1em;
    }

    /* @media (max-width: 640px) {
        .portfolio-tabs .tabs-nav {
            flex-wrap: wrap;
        }
        .portfolio-tabs .tab-toggle {
            flex: 1 1 48%;
            text-align: center;
        }
    } */

    
@media (max-width: 1200px) {
    /* .hero-section, .hero-carousel { 
        height: 100% !important; 
        min-height: 70vh; 
    } */
    
    .hero-section h1 { font-size: 2em; }
    
    /* Ajustement flèches carousel */
    .hero-swiper .swiper-button-prev::after,
    .hero-swiper .swiper-button-next::after { 
        /* height: 30px; width: 30px;  */
        /* top: 50% ; */
        font-size: medium;
    }
}

/* --- TABLET (768px and down) --- */
@media (max-width: 768px) {
    /* .hero-section, .hero-carousel { 
        height: 100%; 
        min-height: 70vh; 
    } */
   
    .hero--split:not(.hero-carousel), .hero--two-column:not(.hero-carousel) {
        gap: 10px;
    }
    .hero--two-column:not(.hero-carousel) .hero-content {
        padding: 40px 20px;
    }
    .hero-section h1 { font-size: 1.8em; } 
    /* .hero--two-column .hero-content h1, .hero--two-column .hero-content .hero-philosophy {
        font-size: 1.3em ;
    }    */
    
    /* Cacher navigation pour clarté */
    .hero-swiper .swiper-button-prev, .hero-swiper .swiper-button-next { display: none; }

    /* Désactiver animations lourdes */
    /* .hero-zoom .hero-img { animation: none !important; } */
}

@media (min-width: 550px) {    
 /* Desktop: when layout is two-column we hide the content overlay (no background)
    but keep the variables available so the overlay can be shown on small screens.
    This ensures two-column desktop has no overlay while mobile still shows it. */
    .hero--two-column .hero-content-inner,
    .hero--split .hero-content-inner,
    .hero-carousel.hero--two-column .hero-content-inner {
        background: transparent !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        /* padding: 0 !important; */
    }
}

/* --- MOBILE (550px and down) --- */
@media (max-width: 550px) {
    .hero-section { height: 100vh; }
    .hero-section h1 { font-size: 1.5em; }
    .hero-section .hero-philosophy { font-size: 1.3em; }
    .hero-section .hero-button { font-size: 1em; }

    /* .hero--two-column .hero-content h1, .hero--two-column .hero-content .hero-philosophy {
        font-size: 1.2em !important;
    } */
    .hero-image { order: -1; width: 100% !important; max-width: 100% !important; }
    .hero-section .hero-button { margin-top: 0.5em; }

    /* On transforme le conteneur en pile (stack) */
    .hero--two-column, 
    .hero-carousel.hero--two-column .swiper-slide {
        display: grid !important; /* Grid est plus simple pour la superposition */
        grid-template-areas: "hero-stack";
        gap: 0;
        /* height: 80vh; */
    }

    /* L'image et le contenu occupent la même zone (ils se superposent) */
    /* .hero--two-column .hero-image,
    .hero--two-column .hero-content { */
    .hero-image, .hero-content {
        grid-area: hero-stack;
        width: 100% !important;
        /* max-width: 100% !important; */
        height: 100% !important;
    }

    /* L'image passe en arrière-plan */
    .hero--two-column .hero-image {
        z-index: 1;
    }

    /* Le contenu passe devant avec son effet de flou */
    /* .hero--two-column  */
    .hero-content {
        z-index: 2;
        background: transparent !important;       
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 25px;
    }

    /* On crée un panneau unique pour TOUT le contenu */
    /* On utilise une largeur max pour ne pas recouvrir toute l'image latéralement */
    /* .hero--two-column  */
    .hero-content-inner { 
        /* If `--hero-content-bg-color-rgba` is not provided by PHP (background disabled),
           fall back to a sensible default opacity of 0.35 to keep text readable. */
        background-color: var(--hero-content-bg-color-rgba, rgba(0,0,0,0.35)) !important;
        -webkit-backdrop-filter: blur(var(--hero-content-backdrop-filter-blur, 15px)) brightness(var(--hero-content-backdrop-filter-brightness, 100%));
        backdrop-filter: blur(var(--hero-content-backdrop-filter-blur, 15px)) brightness(var(--hero-content-backdrop-filter-brightness, 100%));        
        padding: 5px;        
        max-width: 90%;        
        /* max-width: 400px; */
        text-align: center;
        box-shadow: var(--shadow-lg);
        border-radius: var(--site-image-border-radius);
        /* transition: all 0.3s ease; */
        /* overflow: hidden; */
    }
    /* Par défaut transparent (pour le mode Two-column) */


    /* On s'assure que les textes à l'intérieur n'ont plus leurs propres fonds */
    .hero--two-column .hero-content h1,
    .hero--two-column .hero-content .hero-philosophy {
        background: transparent !important;
        /* color: #ffffff !important; */
        margin-bottom: 15px;
    }

    /* On s'assure que l'image remplit bien tout le fond */
    .hero--two-column .hero-img {
        z-index: 1;
        height: 100% !important;
        object-fit: cover;
        border-radius: 0; /* Souvent mieux sur mobile de border à border */
    }
    /* Overrides d'alignement mobile */
    .hero-content.hero__content--mobile-top    { justify-content: flex-start !important; }
    .hero-content.hero__content--mobile-center { justify-content: center !important; }
    .hero-content.hero__content--mobile-bottom { justify-content: flex-end !important; }
}

@media (max-width: 430px) {
    .hero-section { height: 100vh; }
    .hero-section h1 { font-size: 1.1em; }
    .hero-section .hero-philosophy { font-size: 1em; }
    .hero-section .hero-button { font-size: 0.8em; }

    .hero--centered .hero-content-inner { padding: 5px; }
 
    .hero-carousel:not(.hero--two-column) .hero-content-inner {
        width: 90%;
        padding: 10px;
    }
}


/* --- Presentation Section --- */

.presentation-flex {
    align-items: center;
    display: flex;
    gap: 60px;
    justify-content: center;
    text-align: left;
}

.presentation-text {
    color: var(--site-color-text);
    flex: 1 1 500px;
    line-height: 2;
    max-width: 400px;
}

.presentation-text span {
    color: var(--site-color-text);
    font-size: 1.3em;
    font-weight: 300;
    letter-spacing: 1px;
}

.presentation-image {
    flex-shrink: 0;
    width: 100%;
    max-width: 350px;
}

.presentation-image img {
    display: block;
    width: 100%;
    height: auto; /* Le navigateur calcule la hauteur grâce aux attributs width/height de WP */
    border-radius: var(--site-image-border-radius);
    box-shadow: var(--shadow-sm);
    object-fit: cover;
    transition: opacity 0.3s ease-in-out;
}

.presentation-read-more-button {
    margin-top: 1.5em;
}

@media (max-width: 1200px) {   
    .presentation-flex {
        gap: 60px;
    }
}
@media (max-width: 768px) {   
    .presentation-flex {
        gap: 20px;
    }
    .presentation-image {
        max-width: 200px;
    }
}
@media (max-width: 450px) {
    .presentation-flex {
        flex-direction: column-reverse;
        gap: 20px; /* Reduce the gap for very small screens */
        justify-content: center;
        text-align: center;
    }
    .presentation-text {
        flex: 1 1 100%;
        margin: 0 auto;
        max-width: 100%;
    }
    .presentation-image {
        flex-basis: auto;
        margin: 0 auto;
        max-width: 80%;
    }
    .presentation-image img {
        max-width: 100%;
    }
}
/* --- Portfolio Gallery Section --- */

.gallery-grid-3x3 {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(3, 1fr); /* 3 colonnes de taille égale */
    margin: 0 auto;
    max-width: 900px;
}

/* Centering the last item if it's the only one in its row for 3-column layout */
.gallery-grid-3x3 .gallery-item:last-child:nth-child(3n + 1) {
    grid-column: 1 / -1; /* Span all columns */
    justify-self: center; /* Center the item within the spanned row */
    max-width: calc((100% - 2 * 15px) / 3); /* Constrain width to approximate single-column width */
}

.gallery-item {
    aspect-ratio: 1 / 1; /* Ensure squares are uniform */
    overflow: hidden;
    position: relative;
}

.gallery-item img {
    border-radius: var(--site-image-border-radius);
    display: block;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    width: 100%;
}

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

/* Simplified, CSS-only responsive gallery using Flexbox for natural centering of
   incomplete rows, with special rules (using :has) to adapt column counts for
   small image sets so we avoid undesirable left-aligned pairs.
   This approach uses pure CSS (no JS). */

:root { --gallery-gap: 15px; }

.gallery-grid-3x3 {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gallery-gap);
    justify-content: center; /* center last row when incomplete */
    align-items: start;
}

.gallery-grid-3x3 > .gallery-item {
    box-sizing: border-box;
}

/* Default: 3 columns on desktop equivalent (each item ~1/3 width) */
.gallery-grid-3x3 > .gallery-item {
    width: calc((100% - 2 * var(--gallery-gap)) / 3);
}

/* Tablet default: 2 columns */
@media (max-width: 899px) and (min-width: 600px) {
    .gallery-grid-3x3 > .gallery-item { width: calc((100% - var(--gallery-gap)) / 2); }
}

/* Mobile: single column */
@media (max-width: 599px) {
    /* Force a strict single-column layout on small viewports. Use !important to
       override other gallery/grid rules that may come from WP core or other CSS. */
    .gallery-grid-3x3 {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: var(--gallery-gap) !important;
        justify-content: center !important;
        align-items: start !important;
    }
    /* Make mobile items square to avoid excessive vertical height and crop images neatly */
    .gallery-grid-3x3 > .gallery-item {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        aspect-ratio: 1 / 1 !important; /* force square tiles on mobile */
        overflow: hidden !important;
    }
    .gallery-grid-3x3 > .gallery-item img {
        width: 100% !important;
        height: 100% !important; /* fill the square */
        object-fit: cover !important; /* crop to fit */
        display: block !important;
    }
    /* Hide extras by default on mobile (show only preview of 3 items). The 'Voir plus' button
       toggles the .expanded class to reveal the extras. */
    .gallery-grid-3x3 .gallery-item.gallery-item--extra { display: none !important; }
    .gallery-grid-3x3.expanded .gallery-item.gallery-item--extra { display: block !important; }
}

/* Exact-count rules using :has() to prefer a column layout that avoids
   awkward left-aligned pairs and centers the final singleton image. These
   selectors match containers with an exact number of children. */

/* Exactly 1 image: on tablet+desktop make it same size as 2-column layout; keep full-width on mobile */
@media (min-width: 600px) {
    .gallery-grid-3x3:has(> .gallery-item:only-child) > .gallery-item {
        width: calc((100% - var(--gallery-gap)) / 2);
    }
}
@media (max-width: 599px) {
    .gallery-grid-3x3:has(> .gallery-item:only-child) > .gallery-item { width: 100%; }
}

/* Exactly 2 images */
.gallery-grid-3x3:has(> .gallery-item:nth-child(2):nth-last-child(1)) > .gallery-item { width: calc((100% - var(--gallery-gap)) / 2); }

/* Ensure single-image container uses flex sizing and image fills width (avoid height-constrained square) */
@media (min-width: 600px) {
    .gallery-grid-3x3:has(> .gallery-item:only-child) > .gallery-item {
        flex: 0 0 calc((100% - var(--gallery-gap)) / 2);
        width: calc((100% - var(--gallery-gap)) / 2);
        max-width: calc((100% - var(--gallery-gap)) / 2);
        aspect-ratio: 1 / 1; /* keep single tile square (match two-column height) */
    }
    .gallery-grid-3x3:has(> .gallery-item:only-child) > .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
}

/* 4 or 5 images → prefer a 2-column layout (2x2 or 2x2+1) */
.gallery-grid-3x3:has(> .gallery-item:nth-child(4):nth-last-child(1)) > .gallery-item,
.gallery-grid-3x3:has(> .gallery-item:nth-child(5):nth-last-child(1)) > .gallery-item {
    width: calc((100% - var(--gallery-gap)) / 2);
}

/* 8 images → prefer 4 columns on wide screens */
@media (min-width: 900px) {
    .gallery-grid-3x3:has(> .gallery-item:nth-child(8):nth-last-child(1)) > .gallery-item { width: calc((100% - 3 * var(--gallery-gap)) / 4); }
}

/* Desktop: when there are many items default back to thirds but allow the
   flex-based centering of incomplete rows to behave naturally. */

/* Tablet breakpoint: reveal the 4th item (first extra) so the last row looks full
   even when the checkbox isn't toggled. Use a specific nth-child override so that
   the server-side 'gallery-item--extra' class can remain on items beyond the preview. */
@media (min-width: 600px) and (max-width: 899px) {
    .gallery-grid-3x3 .gallery-item:nth-child(4) {
        display: block !important;
    }
}

/* Desktop: show all items by default (no toggle needed) */
@media (min-width: 900px) {
    .gallery-grid-3x3 .gallery-item.gallery-item--extra {
        display: block;
    }
    /* Hide the toggle area on wide screens where all items are shown */
    .gallery-actions { display: none; }
}

/* Grid column adjustments driven by server-side class to avoid singletons on last row */
@media (min-width: 900px) {
    .gallery-grid-3x3.gallery-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .gallery-grid-3x3.gallery-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .gallery-grid-3x3.gallery-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* On tablet we keep 2 columns as default (existing rules), but allow a cols-4 grid to flow into 2 columns */
@media (min-width: 600px) and (max-width: 899px) {
    .gallery-grid-3x3.gallery-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Keep gallery-actions spacing consistent */
.gallery-actions { margin-top: 0.75rem; }

@media (max-width: 450px) {
    .gallery-grid-3x3 {
        grid-template-columns: 1fr; /* 1 column on mobile */
    }
    .gallery-grid-3x3 .gallery-item:last-child {
        max-width: 100% !important;
    }
}

/* When last row contains a single visible item, center it */
.gallery-grid-3x3.last-row-single .gallery-item.visible-last {
    /* Span the full row and center the image — works for 2 or 3 columns */
    grid-column: 1 / -1;
    justify-self: center;
    max-width: 50%;
}

/* Hide the 'Voir plus' button when the number of images fits the preview for the current breakpoint.
   Rules are written per breakpoint and use the server-provided classes `gallery-count-N` and
   `gallery-cols-M` to decide when there is nothing more to show. */

/* MOBILE: (<=599px) preview max = 3 images */
@media (max-width: 599px) {
    .gallery-count-1 .gallery-actions,
    .gallery-count-2 .gallery-actions,
    .gallery-count-3 .gallery-actions {
        display: none !important;
    }
}

/* TABLET: (600..899px) preview = columns(=2) * 2 rows = 4 images */
@media (min-width: 600px) and (max-width: 899px) {
    .gallery-count-1 .gallery-actions,
    .gallery-count-2 .gallery-actions,
    .gallery-count-3 .gallery-actions,
    .gallery-count-4 .gallery-actions {
        display: none !important;
    }
}

/* DESKTOP: (>=900px) preview = columns * 3 rows. We consider possible server-side column values (2,3,4).
   For each gallery-cols-N we hide the actions when the gallery-count is <= N*3 (capped at 9). */
@media (min-width: 900px) {
    /* cols = 2 => 2 * 3 = 6 */
    .gallery-cols-2 .gallery-count-1 .gallery-actions,
    .gallery-cols-2 .gallery-count-2 .gallery-actions,
    .gallery-cols-2 .gallery-count-3 .gallery-actions,
    .gallery-cols-2 .gallery-count-4 .gallery-actions,
    .gallery-cols-2 .gallery-count-5 .gallery-actions,
    .gallery-cols-2 .gallery-count-6 .gallery-actions {
        display: none !important;
    }

    /* cols = 3 => 3 * 3 = 9 */
    .gallery-cols-3 .gallery-count-1 .gallery-actions,
    .gallery-cols-3 .gallery-count-2 .gallery-actions,
    .gallery-cols-3 .gallery-count-3 .gallery-actions,
    .gallery-cols-3 .gallery-count-4 .gallery-actions,
    .gallery-cols-3 .gallery-count-5 .gallery-actions,
    .gallery-cols-3 .gallery-count-6 .gallery-actions,
    .gallery-cols-3 .gallery-count-7 .gallery-actions,
    .gallery-cols-3 .gallery-count-8 .gallery-actions,
    .gallery-cols-3 .gallery-count-9 .gallery-actions {
        display: none !important;
    }

    /* cols = 4 => 4 * 3 = 12, but cap at 9 (theme limits galleries to 9 items). Hide for 1..9 */
    .gallery-cols-4 .gallery-count-1 .gallery-actions,
    .gallery-cols-4 .gallery-count-2 .gallery-actions,
    .gallery-cols-4 .gallery-count-3 .gallery-actions,
    .gallery-cols-4 .gallery-count-4 .gallery-actions,
    .gallery-cols-4 .gallery-count-5 .gallery-actions,
    .gallery-cols-4 .gallery-count-6 .gallery-actions,
    .gallery-cols-4 .gallery-count-7 .gallery-actions,
    .gallery-cols-4 .gallery-count-8 .gallery-actions,
    .gallery-cols-4 .gallery-count-9 .gallery-actions {
        display: none !important;
    }
}

/* --- Instagram Feed Container --- */
.instagram-feed-container {
    margin: 0 auto;
    max-width: 900px; /* Align with gallery-grid-3x3 max-width */
    padding: 0;
}

/* Ensure consistent sizing for 4-image galleries on tablet and desktop.
   This forces the 2-column layout and makes extras match regular items. */
@media (min-width: 600px) {
    .gallery-grid-3x3.gallery-count-4 > .gallery-item {
        width: calc((100% - var(--gallery-gap)) / 2) !important;
        flex: 0 0 calc((100% - var(--gallery-gap)) / 2) !important;
        max-width: calc((100% - var(--gallery-gap)) / 2) !important;
        aspect-ratio: 1 / 1 !important;
    }
    .gallery-grid-3x3.gallery-count-4 > .gallery-item img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        display: block !important;
    }
}

/* Style for Instagram Feed "Load More" button */
.sbi_load_btn {
    font-family: var(--font-body) !important;
}

/* --- Services Section --- */

.services-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
}

.service-item {
    backface-visibility: hidden;
    border-radius: var(--site-image-border-radius);
    box-shadow: var(--card-shadow);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 300px;
    justify-content: flex-end;
    margin-left: auto;
    margin-right: auto;
    max-width: 300px;
    overflow: hidden;
    position: relative;
    text-decoration: none;
    transform: translateZ(0);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    will-change: transform;
}

.service-item:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-10px);
}

.service-item.no-image {
    background: linear-gradient(to top right, var(--site-color-accent-primary), var(--site-color-accent-secondary));
}

.service-item.no-image h3 {
    color: var(--service-card-title-color, var(--site-color-text));
}
    .services-grid.service-titles-centered .service-item .card-content h3,
    .services-grid.service-titles-centered .service-item h3 {
        text-align: center;
    }

/* Overlay gradient at the bottom of image cards to improve text readability */
.service-item:not(.no-image)::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 45%;
    background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0));
    z-index: 3;
    pointer-events: none;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.service-item img {
    backface-visibility: hidden;
    border-radius: var(--site-image-border-radius);
    height: 100%;
    left: 0;
    object-fit: cover;
    position: absolute;
    top: 0;
    transform: translateZ(0);
    transition: transform 0.3s ease;
    width: 100%;
    will-change: transform;
    z-index: 1;
}

.service-item:hover img {
    transform: scale(1.08) translateZ(0);
}

.service-item .overlay {
    background: linear-gradient(to top, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.3) 40%, transparent 80%);
    border-radius: var(--site-image-border-radius);
    height: 120%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: 2;
}

.service-item .card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    justify-content: flex-end;
    padding: 1.5em;
    position: relative;
    text-align: left;
    z-index: 4;
}

.service-item h3 {
    color: var(--service-card-title-color, var(--site-color-text));
    /* font-size: clamp(1.4em, 2.5vw, 2.1em); */
    font-weight: var(--service-card-title-weight, 700);
    line-height: 1.3;
    margin-bottom: 0;
    margin-top: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    /* white-space: nowrap; */
}


/* Force white title on image cards (overlay) to ensure legibility in preview and published),
   keep variable-based color for no-image (accent) cards. */
.service-item:not(.no-image) .card-content h3 {
    /* Use server-provided token for image-card titles (defaults to white).
       This lets PHP compute a different color in future if needed. */
    color: var(--service-card-image-title-color, #ffffff);
    text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.service-item span {
    display: none;
}

@media (max-width: 768px) {
    .services-grid {
        gap: 2.5em;
        grid-template-columns: 1fr;
        justify-items: center;
    }
      .service-item {
        height: 300px;
        margin: 0 auto;
        max-width: 400px;
    }
    .service-item .card-content {
        padding: 1.2em;
    }
}


/* --- Latest Posts Section --- */

.latest-posts-grid {
    display: grid;
    gap: 30px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    margin-top: 2em;
    text-align: left;
}

.latest-post-item {
    background-color: var(--site-color-background);
    border: 1px solid var(--site-color-border-dark);
    border-radius: var(--site-image-border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.latest-post-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-5px);
}

.latest-posts-grid .post-thumbnail {
    margin-bottom: 15px;
}

.post-thumbnail a {
    display: block;
}

#primary .latest-posts-grid .post-thumbnail img,
#primary.blog article.post.has-post-thumbnail .post-thumbnail img,
#primary.archive article.post.has-post-thumbnail .post-thumbnail img,
#primary.search article.post.has-post-thumbnail .post-thumbnail img,
.site-content .latest-posts-grid .post-thumbnail img,
.site-content.blog article.post.has-post-thumbnail .post-thumbnail img,
.site-content.archive article.post.has-post-thumbnail .post-thumbnail img,
.site-content.search article.post.has-post-thumbnail .post-thumbnail img {
    border-radius: var(--site-image-border-radius);
    display: block;
    height: 200px;
    object-fit: cover;
    width: 100%;
}

.latest-post-title {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 0.5em;
    margin-top: 0;
}

.latest-post-excerpt {
    flex-grow: 1;
    font-size: 0.95em;
    margin-bottom: 1em;
}

.latest-post-read-more.button {
    align-self: flex-start;
    background: none;
    border: none;
    margin-top: auto;
    padding-left: 0;
    font-weight: 400;
    text-transform: none;
    color: var(--site-color-accent-primary);
}

.latest-post-read-more.button:hover {
    color: var(--site-color-text);
    box-shadow: none;
}

@media (max-width: 360px) {
    .latest-posts-grid {
        grid-template-columns: 1fr; /* one column to avoid overflow */
        gap: 18px; /* slightly smaller gap on tiny screens */
    }
    .latest-post-item {
        padding: 12px; /* reduce internal padding to fit narrow viewports */
    }
    .front-page-content .container {
        padding-left: 12px; /* slightly reduce outer container padding */
        padding-right: 12px;
    }
}

/* --- Contact CTA Section --- */

#contact-cta {
    margin-top: 80px;
}

.contact-cta-section {
    background-color: var(--site-color-background);
    box-sizing: border-box;
    color: var(--cta-button-text-color, var(--site-color-text));
    margin: 0 auto;
    max-width: 1500px;
}

.contact-cta-section .container {
    padding-left: 20px;
    padding-right: 20px;
}

.contact-cta-section h2 {
    color: var(--cta-button-text-color, var(--site-color-text));
    margin: 20px 10px;
}

.contact-cta-section p {
    color: var(--cta-button-text-color, var(--site-color-text));
    font-weight: 600;
}

.contact-cta-section .button-secondary {
    background-color: var(--button-secondary-bg-color);
    border: 2px solid var(--button-secondary-border-color);
    color: var(--cta-button-text-color, var(--button-secondary-text-color));
    margin-top: 20px;
    margin-bottom: 20px;
}

.contact-cta-section .button-secondary:hover {
    background-color: var(--button-secondary-bg-hover-color);
    border-color: var(--button-secondary-border-hover-color);
    color: var(--button-secondary-text-hover-color);
    transform: translateY(-2px);
}

@media (min-width: 1500px) {
    .contact-cta-section {
        border-radius: var(--site-image-border-radius);
    }
}