/* ─── Méga Menu ────────────────────────────────────────────────── */

.megamenu {
    position: relative;
}

.megamenu__list {
    display: flex;
    align-items: center;
    gap: 40px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.megamenu__item {
    position: relative;
}

/* CTA « Trouver ma prestation » (ouvre le quiz) */
.megamenu__cta {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    border-radius: 32px;
    background: var(--wp--preset--color--cibc-rouge-accent, #A21C16);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--wp--preset--font-family--cabin, 'Cabin', sans-serif);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity .2s ease;
}
.megamenu__cta:hover { opacity: .9; }

/* Liens principaux */
.megamenu__trigger {
    text-decoration: none;
    color: var(--cibc-text, #333333);
    font-size: 16px;
    font-family: var(--wp--preset--font-family--cabin, 'Cabin', sans-serif);
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
}

/* Chevron sur les items avec panel */
.megamenu__trigger.has-panel::after {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--cibc-text, #333333);
    border-bottom: 1.5px solid var(--cibc-text, #333333);
    transform: rotate(45deg);
    margin-left: 7px;
    margin-bottom: 3px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.megamenu__trigger.has-panel[aria-expanded="true"]::after {
    transform: rotate(225deg);
    margin-bottom: -1px;
}

/* ─── Panel ─────────────────────────────────────────────────────── */

.megamenu__panel {
    position: absolute;
    top: calc(100% + 48px);
    left: -41%;
    background: #ffffff;
    border: 1px solid var(--cibc-rouge-light, rgba(106, 26, 22, 0.15));
    border-radius: 16px;
    padding: 56px;
    width: 1200px;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
}

/* Panneau injecté par JS sur la nav WordPress : centré dans le viewport et
   largeur plafonnée → ne déborde jamais, quelle que soit la largeur d'écran.
   Le « top » est posé en JS (sous le déclencheur) via --mm-top. */
.megamenu__panel--injected {
    position: fixed;
    left: 50%;
    top:55px;
    transform: translateX(-50%);
    width: min(1200px, calc(100vw - 32px));
    max-height: calc(100vh - var(--mm-top, 96px) - 24px);
    overflow-y: auto;
}

/* ─── Grille 2 colonnes ─────────────────────────────────────────── */

.megamenu__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.megamenu__col {
    display: flex;
    flex-direction: column;
    gap: 48px;
}

/* ─── Sections ──────────────────────────────────────────────────── */

.megamenu__section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.megamenu__section-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--cibc-text, #333333);
    margin: 0 0 4px 0;
    font-family: var(--cibc-font, 'Cabin', sans-serif);
}

.megamenu__sub-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888888;
    margin: 8px 0 4px 0;
    font-family: var(--cibc-font, 'Cabin', sans-serif);
}

/* ─── Items ─────────────────────────────────────────────────────── */

.megamenu__items {
    list-style: none;
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.megamenu__card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-decoration: none;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.megamenu__card:hover {
    background: var(--cibc-rouge-light, rgba(106, 26, 22, 0.08));
}

/* Conteneur icône */
.megamenu__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: start;
    justify-content: center;
    border-radius: 8px;
    margin-top: 2px;
}

/* SVG généré par Lucide à l'intérieur du conteneur */
.megamenu__icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--cibc-rouge, rgba(106, 26, 22, 1));
    stroke-width: 1.5;
    flex-shrink: 0;
}

.megamenu__card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--cibc-text, #333333);
    display: block;
    line-height: 1.3;
}

.megamenu__card:hover .megamenu__card-title {
    color: var(--cibc-rouge, rgba(106, 26, 22, 1));
}

.megamenu__card-desc {
    font-size: 12px;
    color: #666666;
    margin: 2px 0 0 0;
    line-height: 1.4;
}

/* ─── Responsive ────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .megamenu__panel:not(.megamenu__panel--injected) {
        left: 0 !important;
        width: 100%;
        padding: 32px;
        border-radius: 0 0 16px 16px;
        max-height: 70vh;
        overflow-y: auto;
    }
    /* Panneau injecté : moins de padding sur tablette (reste centré/fixed) */
    .megamenu__panel--injected {
        padding: 32px;
    }

    .megamenu__grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .megamenu__col {
        gap: 24px;
    }
}

/* ─── Burger custom (caché sur desktop) ─────────────────────────── */

.mobile-burger {
    display: none;
}

/* Burger dès ≤1024px : la nav horizontale (logo + 5 entrées dont
   « Entreprises/Collectivités ») ne tient plus en dessous → elle chevauchait
   le logo entre 769 et 1024px. */
@media (max-width: 1024px) {

    /* Masque le megamenu desktop et chevrons */
    .megamenu__panel--injected,
    .megamenu__chevron {
        display: none !important;
    }

    /* Masque tous les éléments natifs WordPress sur mobile */
    .wp-block-navigation__responsive-container,
    .wp-block-navigation__responsive-container-open,
    .wp-block-navigation__responsive-container-close {
        display: none !important;
    }

    /* Cache la nav WordPress sur mobile (le burger custom la remplace) */
    nav.site-header .wp-block-navigation,
    nav.wp-block-group .wp-block-navigation {
        display: none !important;
    }
    .megamenu__section-title p {
    font-weight: 600;
}


    /* ── Burger ── */
    .mobile-burger {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        margin-left: auto;
        z-index: 10;
        align-self: center;
    }

    .mobile-burger span {
        display: block;
        width: 22px;
        height: 2px;
        background: var(--cibc-text, #333);
        border-radius: 2px;
        transition: all 0.25s ease;
    }

    .mobile-burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .mobile-burger.is-open span:nth-child(2) { opacity: 0; }
    .mobile-burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* ── Overlay ── */
    .mobile-menu {
        position: fixed;
        top: 0px;
        left: 50%;
        transform: translateX(-50%);
        width: 95%;
        bottom: 0;
        background: #ffffff;
        z-index: 9999;
        border-radius: 16px 16px 0 0;
        border: 0.5px solid var(--cibc-rouge-light, rgba(106,26,22,0.15));
        overflow: hidden;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .mobile-menu[hidden] { display: none; }

    /* ── Vues (principale / sous-menu) ── */
    .mobile-menu__view {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow-y: auto;
    }

    .mobile-menu__view[hidden] { display: none; }

    /* ── Header (logo + croix / retour + croix) ── */
    .mobile-menu__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px 20px 16px;
        border-bottom: 1px solid var(--cibc-rouge-light, rgba(106,26,22,0.1));
        flex-shrink: 0;
    }

    .mobile-menu__logo {
        height: 36px;
        width: auto;
    }

    .mobile-menu__close {
        background: none;
        border: none;
        cursor: pointer;
        color: var(--cibc-text);
        padding: 4px;
        display: flex;
        margin-left: auto;
    }

    /* ── Bouton retour ── */
    .mobile-menu__back {
        display: flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 15px;
        font-weight: 600;
        font-family: var(--cibc-font, 'Cabin', sans-serif);
        color: var(--cibc-text, #333);
        padding: 0;
    }

    /* ── Liste principale ── */
    .mobile-menu__list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    /* Label catégorie (rouge, uppercase) */
    .mobile-menu__category {
        padding: 16px 20px 6px;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--cibc-rouge, rgba(106,26,22,1));
        font-family: var(--cibc-font, 'Cabin', sans-serif);
    }

    .mobile-menu__item {
        border-bottom: 1px solid var(--cibc-rouge-light, rgba(106,26,22,0.08));
    }

    .mobile-menu__trigger,
    .mobile-menu__link {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 18px 20px;
        background: none;
        border: none;
        font-size: 16px;
        font-weight: 500;
        font-family: var(--cibc-font, 'Cabin', sans-serif);
        color: var(--cibc-text, #333);
        text-decoration: none;
        cursor: pointer;
        text-align: left;
        box-sizing: border-box;
    }

    .mobile-menu__arrow {
        flex-shrink: 0;
        color: #aaa;
    }

    /* ── Sous-contenu (cartes megamenu) ── */
    .mobile-menu__sub-content {
        padding: 16px 12px;
    }

    .mobile-menu__sub-content .megamenu__grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .mobile-menu__sub-content .megamenu__col {
        gap: 16px;
    }

    .mobile-menu__sub-content .megamenu__items {
        padding: 4px 0;
    }

    .mobile-menu__sub-content.hide-section-title .megamenu__section-title {
        display: none;
    }

    .mobile-menu__sub-content .megamenu__section-title,
    .mobile-menu__sub-content .megamenu__sub-title {
        font-family: var(--cibc-font);
        font-weight: 600 !important;
        color: #888888;
        font-size: 11px;
    }

    .mobile-menu__sub-content .megamenu__card {
        padding: 10px 8px;
        font-family: var(--cibc-font, 'Cabin', sans-serif);

    }

    /* Icônes plus épaisses en mobile */
    .mobile-menu__sub-content .megamenu__icon svg {
        stroke-width: 1.5;
    }
}
