/* ==========================================================================
   EMC MOBILE MENU v2 — Menu mobile & tablette (≤ 992px), conforme à la maquette Figma
   À COLLER TOUT À LA FIN de style.css (mêmes règles de chemin que le reste du fichier :
   les url('../images/...') des icônes sont les mêmes que celles du menu desktop).
   Le desktop (≥ 993px) n'est pas modifié : tout est isolé dans le media query
   et dans des classes préfixées "emc-".
   ========================================================================== */

:root {
    --emc-navy: #120060;
    --emc-pink: #EA2D94;
    --emc-line: rgba(18, 0, 96, .55);
    --emc-ease: cubic-bezier(.25, .46, .45, .94);
    --emc-pad: 20px;
}

/* Hors mobile/tablette : rien n'est affiché */
#site-header-top .emc-pills,
#emc-mobile-menu {
    display: none;
}

@media (max-width: 992px) {

    /* ---------- 1. HEADER (état initial Figma) : logo à gauche, 3 pastilles à droite ---------- */

    /* On masque les 2 menus desktop. .header-inner-menu1 reste dans le DOM
       (il contient le bouton fixe "Formulaires" de certaines pages). */
    #site-header-top .header-inner-menu1 > .site-navigation,
    #site-header-top .header-inner > .site-navigation {
        display: none !important;
    }
    #site-header-top .header-inner-menu1 {
        padding: 0 !important;
        min-height: 0;
    }

    #site-header-top .header-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        justify-content: space-between;
        box-sizing: border-box;
        min-height: 90px;
        padding: 0 var(--emc-pad) !important;
        padding-bottom: 10px !important;
    }

    /* Logo collé à gauche (avant : boîte de 65 % avec texte aligné à droite) */
    #site-header-top .site-branding {
        width: auto !important;
        max-width: none !important;
        flex: 0 1 auto;
        margin: 0;
        padding: 0 !important;
    }
    #site-header-top .site-logo {
        height: auto;
    }
    #site-header-top .site-logo .custom-logo-link {
        display: flex;
        align-items: center;
        padding: 0 !important;
        text-align: left;
    }
    #site-header-top .site-logo img {
        display: block;
        width: auto !important;
        height: 48px !important;
        max-width: 100% !important;
        margin: 0 !important;
    }

    [type="button"]:focus {
        outline: none !important;
    }

    /* Champ de recherche des articles : sous la barre, pleine largeur */
    #site-header-top .search-post {
        display: none;
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        margin: 0 0 12px !important;
    }

    /* ---------- 2. LES 3 PASTILLES : [langue] [téléphone] [burger / croix] — 56 × 38 ---------- */
    #site-header-top .emc-pills {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-left: auto;
    }
    #emc-mobile-menu .emc-pills {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    :is(#site-header-top, #emc-mobile-menu) .emc-pill {
        -webkit-appearance: none;
        appearance: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-direction: row;
        box-sizing: border-box;
        width: 57px;
        min-width: 57px;
        height: 38px;
        margin: 0;
        padding: 0;
        border: 1px solid var(--emc-pink);
        border-radius: 19px;
        background: #fff;
        color: var(--emc-pink);
        font-size: 0;
        line-height: 1;
        text-decoration: none !important;
        cursor: pointer;
        box-shadow: none;
        transition: background-color .3s var(--emc-ease), color .3s var(--emc-ease);
        -webkit-tap-highlight-color: transparent;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-pill:active {
        background: var(--emc-pink);
        color: #fff;
    }
    @media (hover: hover) and (pointer: fine) {
        :is(#site-header-top, #emc-mobile-menu) .emc-pill:hover {
            background: var(--emc-pink);
            color: #fff;
        }
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-pill:focus-visible {
        outline: 2px solid var(--emc-navy);
        outline-offset: 2px;
    }

    /* Burger : 2 traits roses ( = ) */
    :is(#site-header-top, #emc-mobile-menu) .emc-pill--burger {
        flex-direction: column;
        gap: 5px;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-pill--burger span {
        display: block;
        width: 27px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
    }

    /* Drapeau rond de la langue active */
    :is(#site-header-top, #emc-mobile-menu) .emc-flag {
        display: block;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        object-fit: cover;
    }

    /* Liste des autres langues (s'ouvre au clic sur la pastille de langue) */
    :is(#site-header-top, #emc-mobile-menu) .emc-lang {
        position: relative;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-lang-list {
        position: absolute;
        top: calc(100% + 3px);
        left: 0;
        z-index: 60;
        width: 56px;
        min-width: 56px;
        height: 38px;
        margin: 0;
        padding: 6px;
        list-style: none;
        border: 1px solid rgba(234, 45, 148,1);
        border-radius: 19px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(18, 0, 96, .15);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-6px);
        transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-lang.is-open .emc-lang-list {
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: opacity .25s ease, transform .25s ease, visibility 0s;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-lang-list li {
        margin: 1px 0 0 10px;
        padding: 0;
        list-style: none;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-lang-list a {
        display: flex;
        align-items: center;
        padding: 0px;
        border-radius: 10px;
        color: var(--emc-navy);
        font-size: 15px;
        font-weight: 500;
        line-height: 20px;
        text-decoration: none !important;
    }
    :is(#site-header-top, #emc-mobile-menu) .emc-lang-list a:active {
        background: #fdeaf4;
    }

    /* ---------- 3. PAGE DE MENU (état ouvert Figma) : plein écran blanc ---------- */
    html.emc-menu-open {
        overflow: hidden;
    }

    #emc-mobile-menu {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 0;
        z-index: 99999;
        overflow: hidden;
        background: #fff;
        color: var(--emc-navy);
        font-family: "Inter Tight", sans-serif;
        /* Animation d'ouverture : fondu + légère descente */
        opacity: 0;
        transform: translateY(-12px);
        visibility: hidden;
        transition: opacity .35s ease, transform .35s var(--emc-ease), visibility 0s linear .35s;
    }
    html.emc-menu-open #emc-mobile-menu {
        opacity: 1;
        transform: none;
        visibility: visible;
        transition: opacity .35s ease, transform .35s var(--emc-ease), visibility 0s;
    }
    .admin-bar #emc-mobile-menu {
        top: 46px;
    }

    /* Resets : isole le panneau du CSS global du thème (button, li, a, ul...) */
    #emc-mobile-menu *,
    #emc-mobile-menu *::before,
    #emc-mobile-menu *::after {
        box-sizing: border-box;
    }
    #emc-mobile-menu ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }
    #emc-mobile-menu li {
        margin: 0;
        padding: 0;
        border: 0;
        list-style: none;
    }
    #emc-mobile-menu a {
        color: inherit;
        text-decoration: none !important;
        -webkit-tap-highlight-color: transparent;
    }

    /* Barre du haut : même position que le header (logo + pastilles, croix à la place du burger) */
    #emc-mobile-menu .emc-m-head {
        flex: 0 0 auto;
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        height: 90px;
        padding: 0 var(--emc-pad);
        background: #fff;
        padding-bottom: 10px !important;
    }
    #emc-mobile-menu .emc-m-logo,
    #emc-mobile-menu .emc-m-logo a {
        display: flex;
        align-items: center;
        color: var(--emc-navy);
        font-size: 20px;
        font-weight: 700;
    }
    #emc-mobile-menu .emc-m-logo img {
        display: block;
        width: auto !important;
        height: 48px !important;
        max-width: none !important;
        margin: 0 !important;
    }

    /* Corps scrollable */
    #emc-mobile-menu .emc-m-body {
        flex: 1 1 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding: 24px var(--emc-pad) calc(40px + env(safe-area-inset-bottom, 0px));
    }

    /* Apparition en cascade des entrées */
    #emc-mobile-menu .emc-m-nav .emc-m-item {
        opacity: 0;
        transform: translateY(12px);
        transition: opacity .35s ease, transform .35s ease;
    }
    html.emc-menu-open #emc-mobile-menu .emc-m-nav .emc-m-item {
        opacity: 1;
        transform: none;
        transition-delay: calc(var(--i, 0) * 40ms + 120ms);
    }

    /* ---------- 4. MENU PRINCIPAL : lignes à accordéon ---------- */
    #emc-mobile-menu .emc-m-nav--main .emc-m-item {
        margin-bottom: 10px;
    }
    #emc-mobile-menu .emc-m-nav--main .emc-m-link {
        -webkit-appearance: none;
        appearance: none;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 18px;
        width: 100%;
        min-height: 43px;
        margin: 0;
        padding: 0 20px 0 13px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        box-shadow: none;
        color: var(--emc-navy);
        font-family: "Inter Tight", sans-serif;
        font-size: 17px;
        font-weight: 600;
        line-height: 22px;
        text-align: left;
        white-space: normal;
        cursor: pointer;
        transition: background-color .3s ease, color .3s ease;
        -webkit-tap-highlight-color: transparent;
    }
    /* Ligne ouverte : bandeau bleu marine, texte et icône blancs */
    #emc-mobile-menu .emc-m-nav--main .emc-m-item.is-expanded > .emc-m-link {
        background: var(--emc-navy);
        color: #fff;
        font-weight: 700;
        text-transform: uppercase;
    }

    /* Icônes (mêmes SVG que le menu desktop) */
    #emc-mobile-menu .emc-m-ico {
        flex: 0 0 24px;
        width: 16px;
        height: 16px;
        background: center / contain no-repeat;
    }
    #emc-mobile-menu .emc-m-ico--data        { background-image: url('../images/data-eminence.svg'); }
    #emc-mobile-menu .emc-m-ico--strategie   { background-image: url('../images/strategy-eminence.svg'); }
    #emc-mobile-menu .emc-m-ico--acquisition { background-image: url('../images/acquisition-eminence.svg'); }
    #emc-mobile-menu .emc-m-ico--web         { background-image: url('../images/web-eminence.svg'); }
    #emc-mobile-menu .emc-m-ico--crm         { background-image: url('../images/crm-eminence.svg'); }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-ico--data        { background-image: url('../images/data-white-eminence.svg'); }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-ico--strategie   { background-image: url('../images/strategy-white-eminence.svg'); }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-ico--acquisition { background-image: url('../images/acquisition-white-eminence.svg'); }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-ico--web         { background-image: url('../images/web-white-eminence.svg'); }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-ico--crm         { background-image: url('../images/crm-white-eminence.svg'); }

    /* Flèche ">" à droite des lignes qui ont un sous-menu (comme Ressources) : pivote en "v" à l'ouverture */
    #emc-mobile-menu .emc-m-chev {
        flex: 0 0 auto;
        width: 7px;
        height: 7px;
        margin: 0 3px 0 auto;
        border: 0;
        border-top: 1.5px solid currentColor;
        border-right: 1.5px solid currentColor;
        transform: rotate(45deg);
        transition: transform .3s var(--emc-ease);
    }
    #emc-mobile-menu .is-expanded > .emc-m-link .emc-m-chev {
        transform: rotate(135deg);
    }

    /* ---------- 5. SOUS-MENU : bloc bleu marine arrondi, s'ouvre avec une animation de hauteur ---------- */
    #emc-mobile-menu .emc-m-acc {
        display: grid;
        grid-template-rows: 0fr;
        visibility: hidden;
        transition: grid-template-rows .4s var(--emc-ease), visibility 0s linear .4s;
    }
    #emc-mobile-menu .emc-m-acc.is-open {
        grid-template-rows: 1fr;
        visibility: visible;
        transition: grid-template-rows .4s var(--emc-ease), visibility 0s;
    }
    #emc-mobile-menu .emc-m-acc-inner {
        min-height: 0;
        overflow: hidden;
    }
    #emc-mobile-menu .emc-m-sub-wrap {
        padding-top: 10px;
        opacity: 0;
        transform: translateY(-6px);
        transition: opacity .3s ease, transform .3s ease;
    }
    #emc-mobile-menu .emc-m-acc.is-open .emc-m-sub-wrap {
        opacity: 1;
        transform: none;
        transition-delay: .08s;
    }
    #emc-mobile-menu .emc-m-nav--main .emc-m-sub {
        padding: 22px 21px 12px;
        border-radius: 8px;
        background: var(--emc-navy);
        color: #fff;
    }

    /* Titres de colonne : Data Analytics / Data Marketing */
    #emc-mobile-menu .emc-m-group-title {
        display: block;
        padding: 0 0 24px;
        color: inherit;
        font-size: 20px;
        font-weight: 700;
        line-height: normal;
    }
    #emc-mobile-menu .emc-m-group + .emc-m-group {
        margin-top: 42px;
    }
    #emc-mobile-menu .emc-m-hidden {
        display: none;
    }

    /* Liens avec ">" à droite */
    #emc-mobile-menu .emc-m-sublink {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 47px;
        padding: 0 7px 0 0;
        color: #fff;
        font-size: 15px;
        font-weight: 500;
        line-height: 20px;
        transition: opacity .2s;
    }
    #emc-mobile-menu .emc-m-sublink:active {
        opacity: .65;
    }
    #emc-mobile-menu .emc-m-leaf.is-current > .emc-m-sublink {
        font-weight: 700;
        text-decoration: underline !important;
    }
    #emc-mobile-menu .emc-m-group ~ .emc-m-group .emc-m-sublink {
        min-height: 43px;
        padding: 0 14px 0 7px;
    }
    #emc-mobile-menu .emc-m-arrow {
        flex: 0 0 auto;
        width: 7px;
        height: 7px;
        border-top: 1.75px solid currentColor;
        border-right: 1.75px solid currentColor;
        transform: rotate(45deg);
    }

    /* ---------- 6. MENU SECONDAIRE : texte simple sous un trait ---------- */
    #emc-mobile-menu .emc-m-nav--top {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--emc-line);
    }
    #emc-mobile-menu .emc-m-nav--top .emc-m-link {
        -webkit-appearance: none;
        appearance: none;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0;
        width: 100%;
        min-height: 43px;
        margin: 0;
        padding: 0 6px 0 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        color: var(--emc-navy);
        font-family: "Inter Tight", sans-serif;
        font-size: 17px;
        font-weight: 500;
        line-height: 22px;
        text-align: left;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    /* ">" qui pivote en "v" quand le sous-menu est ouvert */
    #emc-mobile-menu .emc-m-nav--top .emc-m-chev {
        width: 7px;
        height: 7px;
        margin: 0 3px 0 auto;
        border: 0;
        border-top: 1.5px solid currentColor;
        border-right: 1.5px solid currentColor;
        transform: rotate(45deg);
        transition: transform .3s var(--emc-ease);
    }
    #emc-mobile-menu .emc-m-nav--top .is-expanded > .emc-m-link .emc-m-chev {
        transform: rotate(135deg);
    }
    #emc-mobile-menu .emc-m-nav--top .emc-m-sub {
        padding: 0 0 6px 14px;
        color: var(--emc-navy);
    }
    #emc-mobile-menu .emc-m-nav--top .emc-m-sublink {
        min-height: 40px;
        padding: 0;
        color: var(--emc-navy);
        font-size: 16px;
        font-weight: 400;
    }
    #emc-mobile-menu .emc-m-nav--top .emc-m-arrow {
        display: none;
    }

    /* ---------- 7. TABLETTE (≥ 768px) ---------- */
    @media (min-width: 768px) {
        :root { --emc-pad: 30px; }
    }
    @media (min-width: 783px) {
        .admin-bar #emc-mobile-menu { top: 32px; }
    }

    /* ---------- 8. Accessibilité : animations réduites ---------- */
    @media (prefers-reduced-motion: reduce) {
        #emc-mobile-menu,
        #emc-mobile-menu .emc-m-acc,
        #emc-mobile-menu .emc-m-sub-wrap,
        #emc-mobile-menu .emc-m-nav .emc-m-item,
        :is(#site-header-top, #emc-mobile-menu) .emc-lang-list {
            transition-duration: .01ms !important;
            transition-delay: 0s !important;
        }
        #emc-mobile-menu .emc-m-nav .emc-m-item {
            opacity: 1;
            transform: none;
        }
    }
}
