/*=========================================================
 TWAL HERO — composant public

 Contextes : .tw-hero_home / .tw-hero_main / .tw-hero_secondary
 Compositions : .tw-hero_editorial / .tw-hero_side / .tw-hero_background
 Voir modules/hero/README.md pour le contrat complet.
 =========================================================*/

/*---------------------------------------------------------
 A — Variables et structure commune
 ---------------------------------------------------------*/

.tw-hero {
    --tw-hero-context-bg: var(--tw-hero_bg, #455538);
    --tw-hero-context-overline: var(--tw-hero_overline-color, #fff);
    --tw-hero-context-title: var(--tw-hero_title-color, #fff);
    --tw-hero-context-text: var(--tw-hero_text-color, #fff);

    --tw-hero-min-height: 280px;
    --tw-hero-content-max: 700px;
    --tw-hero-image-width: 58%;
    --tw-hero-image-opacity-desktop: 1;
    --tw-hero-image-opacity-mobile: 1;
    --tw-hero-image-position: center center;
    --tw-hero-overlay-color: var(--tw-hero-context-bg);
    --tw-hero-overlay-opacity: .65;
    --tw-hero-overlay-gradient-end: 65%;

    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: var(--tw-hero-min-height);
    background: var(--tw-hero-context-bg);
    color: var(--tw-hero-context-text);
}

.tw-hero_secondary {
    --tw-hero-context-bg: var(--tw-hero-secondaire_bg, var(--tw-hero_bg, #D9BC82));
    --tw-hero-context-overline: var(--tw-hero_overline-color, currentColor);
    --tw-hero-context-title: var(--tw-hero_title-color, currentColor);
    --tw-hero-context-text: var(--tw-hero_text-color, currentColor);
}

.tw-hero_inner {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    width: min(100%, var(--tw-container_max, 1280px));
    min-height: var(--tw-hero-min-height);
    margin-inline: auto;
    padding-inline: clamp(1rem, 3vw, 2rem);
}

.tw-hero_content {
    position: relative;
    z-index: 3;
    width: min(100%, var(--tw-hero-content-max));
    padding-block: clamp(2.25rem, 4vw, 3.75rem);
}

.tw-hero_home:not(.tw-hero_home-inherit) .tw-hero_content {
    padding-block: clamp(3rem, 7vw, 6.5rem);
}

.tw-hero_secondary .tw-hero_content {
    padding-block: clamp(1.25rem, 2.6vw, 2.1rem);
}


/* Emplacement réservé au complément lorsque le profil demande de le placer
 * après l'image sur mobile. Le nœud .tw-hero_extra lui-même est déplacé par
 * hero.js ; aucun contenu n'est dupliqué dans le DOM. */
.tw-hero_extra-mobile-slot {
    display: none;
}

/*---------------------------------------------------------
 B — Média et voile
 ---------------------------------------------------------*/

.tw-hero_media,
.tw-hero_visual {
    position: absolute;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.tw-hero_image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--tw-hero-image-position);
    opacity: var(--tw-hero-image-opacity-desktop);
}

.tw-hero_media::before,
.tw-hero_visual::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    pointer-events: none;
    opacity: var(--tw-hero-overlay-opacity);
}

/* Marqueur DOM historique conservé ; le voile visuel reste le ::before de
 * .tw-hero_visual afin que les CSS enfants 1.0.8.x puissent encore le neutraliser. */
.tw-hero_overlay {
    display: none;
}

.tw-hero_overlay-desktop-none .tw-hero_media::before {
    display: none;
}

.tw-hero_overlay-desktop-solid .tw-hero_media::before {
    background: var(--tw-hero-overlay-color);
}

/*---------------------------------------------------------
 C — Composition image latérale
 ---------------------------------------------------------*/

.tw-hero_side .tw-hero_media {
    inset-block: 0;
    width: var(--tw-hero-image-width);
}

.tw-hero_side.tw-hero_image-right .tw-hero_media {
    right: 0;
}

.tw-hero_side.tw-hero_image-left .tw-hero_media {
    left: 0;
}

.tw-hero_side.tw-hero_image-left .tw-hero_content {
    margin-left: auto;
}

.tw-hero_side.tw-hero_image-right .tw-hero_content {
    margin-right: auto;
}

.tw-hero_side.tw-hero_overlay-desktop-gradient.tw-hero_image-right .tw-hero_media::before {
    display: block;
    opacity: 1;
    background: linear-gradient(
        to right,
        var(--tw-hero-overlay-color) 0%,
        transparent var(--tw-hero-overlay-gradient-end)
    );
}

.tw-hero_side.tw-hero_overlay-desktop-gradient.tw-hero_image-left .tw-hero_media::before {
    display: block;
    opacity: 1;
    background: linear-gradient(
        to left,
        var(--tw-hero-overlay-color) 0%,
        transparent var(--tw-hero-overlay-gradient-end)
    );
}

/* Le texte peut légèrement chevaucher la zone de fondu sans passer sous
 * la partie lisible de l'image. */
.tw-hero_side.tw-hero_with-image .tw-hero_content {
    max-width: min(var(--tw-hero-content-max), 52vw);
}

/*---------------------------------------------------------
 D — Composition image de fond
 ---------------------------------------------------------*/

.tw-hero_background .tw-hero_media {
    inset: 0;
    width: 100%;
    height: 100%;
}

.tw-hero_background.tw-hero_overlay-desktop-gradient.tw-hero_content-left .tw-hero_media::before {
    display: block;
    opacity: 1;
    background: linear-gradient(
        to right,
        var(--tw-hero-overlay-color) 0%,
        transparent var(--tw-hero-overlay-gradient-end)
    );
}

.tw-hero_background.tw-hero_overlay-desktop-gradient.tw-hero_content-right .tw-hero_media::before {
    display: block;
    opacity: 1;
    background: linear-gradient(
        to left,
        var(--tw-hero-overlay-color) 0%,
        transparent var(--tw-hero-overlay-gradient-end)
    );
}

.tw-hero_background.tw-hero_overlay-desktop-gradient.tw-hero_content-center .tw-hero_media::before {
    display: block;
    background: var(--tw-hero-overlay-color);
}

.tw-hero_background.tw-hero_content-center .tw-hero_inner {
    width: 100%;
    max-width: none;
    justify-content: center;
}

.tw-hero_background.tw-hero_content-center .tw-hero_content {
    margin-inline: auto;
    text-align: center;
}

.tw-hero_background.tw-hero_content-center .tw-hero_accroche,
.tw-hero_background.tw-hero_content-center .tw-hero_extra {
    margin-inline: auto;
}

.tw-hero_background.tw-hero_content-center .tw-hero_components,
.tw-hero_background.tw-hero_content-center .tw-cta-group_list {
    justify-content: center;
}

.tw-hero_background.tw-hero_content-right .tw-hero_content {
    margin-left: auto;
    text-align: right;
}

.tw-hero_background.tw-hero_content-right .tw-hero_accroche,
.tw-hero_background.tw-hero_content-right .tw-hero_extra {
    margin-left: auto;
}

.tw-hero_background.tw-hero_content-right .tw-hero_components,
.tw-hero_background.tw-hero_content-right .tw-cta-group_list {
    justify-content: flex-end;
}

.tw-hero_background.tw-hero_content-v-top .tw-hero_inner {
    align-items: flex-start;
}

.tw-hero_background.tw-hero_content-v-center .tw-hero_inner {
    align-items: center;
}

.tw-hero_background.tw-hero_content-v-bottom .tw-hero_inner {
    align-items: flex-end;
}

/*---------------------------------------------------------
 E — Composition éditoriale / Hero sans image
 ---------------------------------------------------------*/

.tw-hero_editorial .tw-hero_media,
.tw-hero_without-image .tw-hero_media,
.tw-hero_without-image .tw-hero_overlay {
    display: none;
}

.tw-hero_editorial .tw-hero_content,
.tw-hero_without-image .tw-hero_content {
    max-width: var(--tw-hero-content-max);
}

/*---------------------------------------------------------
 F — Contenu éditorial
 ---------------------------------------------------------*/

.tw-hero_surtitre {
    margin: 0 0 .9rem;
    color: var(--tw-hero-context-overline);
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.tw-hero_title {
    margin: 0 0 .9rem;
    color: var(--tw-hero-context-title);
    font-size: var(--tw-hero_title-font-size, clamp(2.2rem, 4vw, 4rem));
    font-weight: var(--tw-font-title_weight, var(--tw-weight_strong, 500));
    line-height: var(--tw-font-title_line-height, 1.15);
    letter-spacing: var(--tw-font-title_letter-spacing, normal);
}

.tw-hero_secondary .tw-hero_title {
    font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.tw-hero_accroche {
    max-width: 62ch;
    margin: 0;
    color: var(--tw-hero-context-text);
    font-size: var(--tw-hero_accroche-font-size, clamp(1.08rem, 1.4vw, 1.45rem));
    font-weight: 400;
    line-height: 1.55;
}

.tw-hero_accroche span {
    color: var(--tw-color_accent);
}

.tw-hero_extra,
.tw-hero_text {
    max-width: 62ch;
    margin-top: .9rem;
    color: var(--tw-hero-context-text);
    font-size: var(--tw-hero_text-font-size, clamp(.95rem, 1.1vw, 1.08rem));
    line-height: 1.55;
}

.tw-hero_extra > :first-child {
    margin-top: 0;
}

.tw-hero_extra > :last-child {
    margin-bottom: 0;
}

.tw-hero_extra p,
.tw-hero_extra ul,
.tw-hero_extra ol {
    margin-block: .5rem;
}

/*---------------------------------------------------------
 G — Composants existants greffés dans le Hero
 ---------------------------------------------------------*/

.tw-hero_components {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .75rem 1.5rem;
    margin-top: 1.25rem;
    color: var(--tw-hero-context-text);
}

.tw-hero_components .tw-info {
    gap: .25rem;
}

.tw-hero_components .tw-info_item,
.tw-hero_components .tw-info_item a,
.tw-hero_components .tw-info_valeur {
    color: inherit;
}

.tw-hero_hours {
    min-width: min(100%, 260px);
}

.tw-hero .tw-horaire_compact {
    color: var(--tw-hero-context-text);
}

.tw-hero .tw-horaire_compact > .tw-horaire_status,
.tw-hero .tw-horaire_compact .tw-horaire_details,
.tw-hero .tw-horaire_compact .tw-horaire_row,
.tw-hero .tw-horaire_compact .tw-horaire_slots,
.tw-hero .tw-horaire_compact .tw-horaire_note {
    color: var(--tw-hero-context-text);
}

.tw-hero .tw-horaire_compact[open] > .tw-horaire_details {
    border-top-color: color-mix(in srgb, currentColor 25%, transparent);
}

.tw-hero .tw-cta-group:not(.tw-cta-group_bandeau) {
    margin-top: 1.25rem;
}

/*---------------------------------------------------------
 H — Responsive : image latérale devient texte puis image
 ---------------------------------------------------------*/

@media (max-width: 900px) {
    .tw-hero:not(.tw-hero_background) {
        min-height: 0;
    }

    .tw-hero:not(.tw-hero_background) .tw-hero_inner {
        min-height: 0;
    }

    .tw-hero_side {
        display: flex;
        flex-direction: column;
    }

    .tw-hero_side .tw-hero_inner {
        order: 1;
        width: 100%;
    }

    .tw-hero_side .tw-hero_content,
    .tw-hero_side.tw-hero_with-image .tw-hero_content {
        width: 100%;
        max-width: none;
        margin-inline: 0;
        padding-block: clamp(2rem, 7vw, 3.25rem);
    }

    .tw-hero_side .tw-hero_media,
    .tw-hero_side.tw-hero_image-left .tw-hero_media,
    .tw-hero_side.tw-hero_image-right .tw-hero_media {
        position: relative;
        inset: auto;
        order: 2;
        width: 100%;
        min-height: 280px;
        aspect-ratio: 16 / 9;
    }

    .tw-hero_side .tw-hero_image {
        min-height: 280px;
        opacity: var(--tw-hero-image-opacity-mobile);
    }

    .tw-hero_side.tw-hero_extra-mobile-after_image > .tw-hero_extra-mobile-slot {
        order: 3;
        display: block;
        width: min(100%, var(--tw-container_max, 1280px));
        margin-inline: auto;
        padding-inline: clamp(1rem, 3vw, 2rem);
    }

    .tw-hero_side.tw-hero_extra-mobile-after_image > .tw-hero_extra-mobile-slot > .tw-hero_extra {
        width: 100%;
        max-width: 62ch;
        margin-top: 0;
        padding-block: clamp(1.25rem, 5vw, 2rem);
    }

    /* Le voile responsive est explicitement contrôlé. */
    .tw-hero.tw-hero_side.tw-hero_overlay-mobile-none .tw-hero_media::before {
        display: none;
    }

    .tw-hero.tw-hero_side.tw-hero_overlay-mobile-solid .tw-hero_media::before {
        display: block;
        background: var(--tw-hero-overlay-color);
    }

    .tw-hero.tw-hero_side.tw-hero_overlay-mobile-gradient .tw-hero_media::before,
    .tw-hero.tw-hero_side.tw-hero_overlay-mobile-auto .tw-hero_media::before {
        display: block;
        opacity: 1;
        background: linear-gradient(
            to bottom,
            var(--tw-hero-overlay-color) 0%,
            transparent var(--tw-hero-overlay-gradient-end)
        );
    }

    /* Une composition image de fond reste une image de fond sur mobile. */
    .tw-hero_background .tw-hero_image {
        opacity: var(--tw-hero-image-opacity-mobile);
    }

    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-none .tw-hero_media::before {
        display: none;
    }

    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-solid .tw-hero_media::before {
        display: block;
        background: var(--tw-hero-overlay-color);
    }

    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-gradient .tw-hero_media::before {
        display: block;
        opacity: 1;
        background: linear-gradient(
            to bottom,
            var(--tw-hero-overlay-color) 0%,
            transparent var(--tw-hero-overlay-gradient-end)
        );
    }

    /* Automatique conserve le type desktop ; un dégradé devient vertical sur mobile. */
    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-auto.tw-hero_overlay-desktop-none .tw-hero_media::before {
        display: none;
    }

    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-auto.tw-hero_overlay-desktop-solid .tw-hero_media::before {
        display: block;
        background: var(--tw-hero-overlay-color);
    }

    .tw-hero.tw-hero_background.tw-hero_overlay-mobile-auto.tw-hero_overlay-desktop-gradient .tw-hero_media::before {
        display: block;
        opacity: 1;
        background: linear-gradient(
            to bottom,
            var(--tw-hero-overlay-color) 0%,
            transparent var(--tw-hero-overlay-gradient-end)
        );
    }

    /*-----------------------------------------------------
     * Hero secondaire : contrat responsive explicite.
     *
     * La classe historique .tw-hero_secondaire reste dans
     * le DOM pour la compatibilité des thèmes enfants.
     * Certaines anciennes CSS peuvent cependant lui avoir
     * appliqué une grille ou un flex horizontal. Le nouveau
     * moteur impose ici sa structure mobile : surtitre, H1,
     * accroche et complément sont empilés verticalement.
     *-----------------------------------------------------*/
    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_inner {
        display: flex;
        align-items: stretch;
        width: 100%;
        min-width: 0;
    }

    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_inner > .tw-hero_content {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-inline: 0;
        padding-block: clamp(1.25rem, 6vw, 2rem);
    }

    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_content > .tw-hero_surtitre,
    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_content > .tw-hero_title,
    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_content > .tw-hero_accroche,
    .tw-hero.tw-hero_secondary.tw-hero_secondaire .tw-hero_content > .tw-hero_extra {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .tw-hero_components {
        flex-direction: column;
    }
}

/*---------------------------------------------------------
 I — Très petits écrans
 ---------------------------------------------------------*/

@media (max-width: 480px) {
    .tw-hero_inner {
        padding-inline: 1rem;
    }

    .tw-hero_title {
        font-size: clamp(2rem, 10vw, 2.7rem);
    }

    .tw-hero_secondary .tw-hero_title {
        font-size: clamp(1.7rem, 8vw, 2.2rem);
    }
}
