/* =========================================
   MEGA MENU FULL WIDTH PROPRE ET COMPACT
   ========================================= */

:root {
    --hp-mega-top: 140px;
    --hp-mega-side-gap: 20px;
    --hp-mega-col-width: 320px; /* colonnes plus larges */
}

/* parent */
#primary-menu > li.hp-mega-menu {
    position: static !important;
}

/* panneau principal */
#primary-menu > li.hp-mega-menu > .hp-mega-menu-panel {
    position: fixed;
    top: var(--hp-mega-top);
    left: var(--hp-mega-side-gap);
    right: var(--hp-mega-side-gap);
    z-index: 99999;

    width: auto;
    max-width: none;
    box-sizing: border-box;
    margin: 0;
    padding: 20px 18px;

    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);

    max-height: calc(100vh - var(--hp-mega-top) - 20px);
    overflow-y: auto;
    overflow-x: visible;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}

/* ouverture */
#primary-menu > li.hp-mega-menu:hover > .hp-mega-menu-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

/* affichage en colonnes verticales :
   on remplit d'abord vers le bas, puis colonne suivante */
.hp-mega-menu-grid {
    column-width: var(--hp-mega-col-width);
    column-gap: 18px;
}

/* bloc catégorie */
.hp-mega-menu-col {
    position: relative;
    display: inline-block;
    vertical-align: top;
    width: 100%;
    box-sizing: border-box;

    margin: 0 0 12px;
    padding: 0;

    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;

    box-shadow: none;
}

/* lien parent */
.hp-mega-menu-parent {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;

    width: 100%;
    min-width: 0;
    box-sizing: border-box;

    padding: 10px 12px;
    border-radius: 10px;

    text-decoration: none;
    color: #222;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;

    transition: background .18s ease, color .18s ease;
}

.hp-mega-menu-parent:hover {
    background: rgba(0, 0, 0, 0.045);
    color: #000;
}

.hp-mega-menu-parent-label {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* flèche */
.hp-mega-arrow {
    flex: 0 0 auto;
    font-size: 15px;
    line-height: 1;
    opacity: 0.7;
    margin-top: 2px;
}

/* sous-menu popup */
.hp-mega-submenu {
    position: absolute;
    top: 0;
    left: calc(100% - 4px);
    z-index: 100000;

    width: 420px;
    min-width: 420px;
    max-width: min(520px, calc(100vw - 80px));
    max-height: 65vh;
    overflow-y: auto;
    overflow-x: hidden;

    margin: 0;
    padding: 16px 20px;
    list-style: none;

    background: #fff;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.15);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(8px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

body .header-social-wrap .header-social-item::after {
    display:none;
}

/* ouverture sous-menu */
.hp-mega-menu-col:hover > .hp-mega-submenu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
}

.hp-mega-submenu li {
    margin: 0 0 6px;
}

.hp-mega-submenu li:last-child {
    margin-bottom: 0;
}

.hp-mega-submenu a {
    display: block;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.35;
    padding: 4px 0;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.hp-mega-submenu a:hover {
    text-decoration: underline;
}

/* les derniers blocs ouvrent à gauche */
.hp-mega-menu-col:nth-last-child(-n+5) > .hp-mega-submenu {
    left: auto;
    right: calc(100% - 4px);
    transform: translateX(-8px);
}

.hp-mega-menu-col:nth-last-child(-n+5):hover > .hp-mega-submenu {
    transform: translateX(0);
}

/* scrollbars */
#primary-menu > li.hp-mega-menu > .hp-mega-menu-panel::-webkit-scrollbar,
.hp-mega-submenu::-webkit-scrollbar {
    width: 8px;
}

#primary-menu > li.hp-mega-menu > .hp-mega-menu-panel::-webkit-scrollbar-thumb,
.hp-mega-submenu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
}

#primary-menu > li.hp-mega-menu > .hp-mega-menu-panel::-webkit-scrollbar-track,
.hp-mega-submenu::-webkit-scrollbar-track {
    background: transparent;
}

/* très grands écrans */
@media (min-width: 1600px) {
    :root {
        --hp-mega-col-width: 340px;
    }
}

/* écrans intermédiaires */
@media (max-width: 1280px) {
    :root {
        --hp-mega-side-gap: 15px;
        --hp-mega-col-width: 280px;
    }

    #primary-menu > li.hp-mega-menu > .hp-mega-menu-panel {
        padding: 16px 14px;
    }
}

/* tablette / mobile */
@media (max-width: 991px) {
    #primary-menu > li.hp-mega-menu {
        position: relative !important;
    }

    #primary-menu > li.hp-mega-menu > .hp-mega-menu-panel {
        position: static;
        top: auto;
        left: auto;
        right: auto;
        width: 100%;
        max-height: none;
        overflow: visible;

        padding: 10px 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        display: none;
    }

    #primary-menu > li.hp-mega-menu:hover > .hp-mega-menu-panel {
        display: block;
    }

    .hp-mega-menu-grid {
        column-width: auto;
        column-count: 1;
        column-gap: 0;
    }

    .hp-mega-menu-col {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
    }

    .hp-mega-menu-col:first-child {
        border-top: none;
    }

    .hp-mega-menu-parent {
        padding: 12px 15px;
        border-radius: 0;
    }

    .hp-mega-submenu,
    .hp-mega-menu-col:nth-last-child(-n+5) > .hp-mega-submenu {
        position: static;
        left: auto;
        right: auto;
        min-width: 100%;
        max-width: 100%;
        max-height: none;
        overflow: visible;

        margin: 0;
        padding: 0 0 12px 24px;
        border-radius: 0;
        box-shadow: none;
        background: transparent;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        display: none;
    }

    .hp-mega-menu-col:hover > .hp-mega-submenu {
        display: block;
    }
}

/* empêcher le thème de couper */
.site-main-header-wrap,
.site-header-row-container,
.site-header-row-container-inner,
.site-main-header-inner-wrap,
.site-header-section,
.site-header-item,
.main-navigation,
.primary-menu-container,
#site-navigation,
#primary-menu,
#primary-menu > li,
#primary-menu > li.hp-mega-menu {
    overflow: visible !important;
}

/* =========================================
   LANGUAGE SWITCHER POLYLANG
   ========================================= */

.hp-lang-switcher {
    display: flex;
    align-items: center;
}

.hp-lang-switcher ul {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hp-lang-switcher li {
    margin: 0;
    padding: 0;
    list-style: none;
}

.hp-lang-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    line-height: 1;
}

.hp-lang-switcher img {
    display: block;
    width: 18px;
    height: auto;
    border-radius: 2px;
}