/* ============================================================
   MEGA MENU – Praz-de-Lys Sommand
   Fichier : /css/mega-menu.css  (dossier css/ à créer à la racine du thème)
   Chargé via inc/mega-menu-acf.php
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --mm-topbar-bg  : transparent;
    --mm-topbar-text: #1a3a5c;
    --mm-topbar-h   : 40px;
    --mm-main-h     : 116px;
    --mm-gold       : #C4922A;
    --mm-gold-hover : #a87a22;
    --mm-text       : #1a1a1a;
    --mm-radius     : 0px;
    --mm-ease       : 0.22s ease;
    --mm-px         : clamp(16px, 2.5vw, 32px);
}

/* ── Masquer l'ancien header (Header-top / Header-bottom / Menu burger) ────── */
.Header-top,
.Header-bottom,
.Menu {
    display: none !important;
}

/* ── Shell du header ───────────────────────────────────────────────────────── */
.Header {
    position  : relative !important;
    z-index   : 1000 !important;
    background: #FFF !important;
    display   : block !important;
    padding   : 0 !important;
    transition: background 0.3s ease, box-shadow 0.3s ease !important;
}

/* Accueil : header en overlay sur le hero */
.Header.home {
    position: absolute !important;
    top     : 0 !important;
    left    : 0 !important;
    right   : 0 !important;
    background: transparent !important;
}

/* Au scroll (accueil ET pages secondaires) : la barre de menu devient fixe, la topbar disparaît */
.Header.is-scrolled {
    position  : fixed !important;
    top       : 0 !important;
    left      : 0 !important;
    right     : 0 !important;
    background: #fff !important;
    box-shadow: 0 2px 16px rgba(0,0,0,.1) !important;
}
.Header.is-scrolled .Header-topbar {
    display: none !important;
}

/* Pages secondaires : fond blanc fixe sur la topbar et la barre de menu */
.Header:not(.home) .Header-topbar,
.Header:not(.home) .Header-main {
    background: #fff !important;
}

/* ── Override agressif du logo (thème : position:absolute z-index:99 etc.) ── */
.Header-logo,
.Header-main .Header-logo,
.Header.home .Header-logo {
    position        : relative !important;
    top             : auto !important;
    left            : auto !important;
    width           : auto !important;
    height          : auto !important;
    z-index         : auto !important;
    background-color: transparent !important;
    border-radius   : 0 !important;
    padding         : 0 !important;
    margin          : 0 !important;
    transform       : none !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════════════════════════════════════ */
.Header-topbar {
    background : var(--mm-topbar-bg);
    height     : var(--mm-topbar-h);
    display    : flex;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.Header-topbar--inner {
    display    : flex;
    align-items: center;
    justify-content: flex-end;
    width      : 100%;
    max-width  : 150rem;
    margin     : 0 auto;
    padding    : 0 var(--mm-px);
    box-sizing : border-box;
}

.Header-topbar--item,
.Header-topbar--search {
    display    : inline-flex;
    align-items: center;
    gap        : 5px;
    padding    : 0 12px;
    font-size  : 14px;
    font-weight: 700;
    color      : var(--mm-topbar-text);
    text-decoration: none;
    background : none;
    border     : none;
    cursor     : pointer;
    font-family: inherit;
    white-space: nowrap;
    transition : opacity var(--mm-ease);
}

.Header-topbar--item:hover,
.Header-topbar--search:hover { opacity: 0.65; }

.Header-topbar--fav-counter {
    font-size  : 11px;
    font-weight: 700;
}

.Header-topbar--sep {
    color        : var(--mm-gold);
    user-select  : none;
    pointer-events: none;
    padding      : 0 2px;
}

.Header-topbar--language { padding-left: 8px; }

/* Menu mobile déployé : masquer uniquement le sélecteur de langue de la topbar (remplacé par celui du menu déployé) */
body.mobile-menu-open .Header-topbar--language {
    display: none !important;
}

/* Neutraliser le style natif du sélecteur de langue WPML dans la topbar */
.Header-topbar--language select,
.Header-topbar--language .wpml-ls,
.Header-topbar--language .wpml-ls-statics-shortcode_actions,
.Header-topbar--language input,
.Header-topbar--language .wpml-ls-legacy-dropdown-click a,
.Header-topbar--language #wpml-ls-submenu-click-default {
    background  : transparent !important;
    border      : none !important;
    color       : var(--mm-topbar-text) !important;
    font-size   : 14px !important;
    height      : auto !important;
    width       : auto !important;
    box-shadow  : none !important;
    outline     : none !important;
    z-index: 99999;
}

/* ════════════════════════════════════════════════════════════════════════════
   MAIN BAR
   ════════════════════════════════════════════════════════════════════════════ */
.Header-main {
    display    : flex;
    align-items: center;
    height     : var(--mm-main-h);
    padding    : 0 var(--mm-px);
    background : none;
    gap        : 16px;
    position   : relative;
    z-index    : 101;
    max-width  : 150rem;
    margin-left : auto;
    margin-right: auto;
    box-sizing : border-box;
}

/* Logo */
.Header-main .Header-logo {
    display    : flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 8px;
}
.Header-main .Header-logo img {
    height: 110px;
    width : auto;
    transition: height var(--mm-ease);
}

/* Au scroll : le logo rétrécit pour tenir dans la barre fixée */
.Header.is-scrolled .Header-main .Header-logo img {
    height: 90px;
    padding: 10px 5px;
}

/* ════════════════════════════════════════════════════════════════════════════
   MEGANAV
   ════════════════════════════════════════════════════════════════════════════ */
.MegaNav { flex: 1; }

.MegaNav-list {
    display    : flex;
    align-items: center;
    justify-content: end;
    list-style : none;
    margin     : 0;
    padding    : 0;
}

.MegaNav-trigger {
    display    : inline-flex;
    align-items: center;
    gap        : 7px;
    padding    : 0 20px;
    height     : var(--mm-main-h);
    font-size  : 18px;
    font-weight: 600;
    color      : var(--mm-text);
    background : none;
    border     : none;
    border-bottom: 3px solid transparent;
    cursor     : pointer;
    font-family: inherit;
    white-space: nowrap;
    transition : color var(--mm-ease), border-color var(--mm-ease);
}

.MegaNav-trigger:hover,
.MegaNav-item.is-active .MegaNav-trigger {
    color       : var(--mm-gold);
    border-color: var(--mm-gold);
}

.MegaNav-chevron {
    flex-shrink: 0;
    opacity    : 0.55;
    transition : transform var(--mm-ease);
}
.MegaNav-item.is-active .MegaNav-chevron {
    transform: rotate(180deg);
}

/* ── CTA Webcam ─────────────────────────────────────────────────────────── */
.Header-webcam {
    display        : inline-flex;
    align-items    : center;
    gap            : 8px;
    padding        : 6px 16px;
    background     : var(--mm-gold);
    color          : #000;
    text-decoration: none;
    border-radius  : 6px;
    font-size      : 18px;
    font-weight    : 700;
    white-space    : nowrap;
    flex-shrink    : 0;
    transition     : background var(--mm-ease);
}
.Header-webcam:hover { background: var(--mm-gold-hover); }

/* ── Utils compacts (mobile/tablette) : infos pistes, agenda, webcam ──────── */
.Header-mobileUtils {
    display        : none;
    align-items    : center;
    justify-content: center;
    gap            : 22px;
    flex           : 1;
}
.Header-mobileUtils--item {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    gap            : 4px;
    color          : var(--mm-text);
    text-decoration: none;
    font-size      : 11px;
    font-weight    : 600;
    white-space    : nowrap;
    transition     : color var(--mm-ease);
}
.Header-mobileUtils--item:hover { color: var(--mm-gold); }

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

.Header-burger.__megaBurger span {
    display   : block;
    width     : 24px;
    height    : 2px;
    background: var(--mm-text);
    transition: transform var(--mm-ease), opacity var(--mm-ease);
    border-radius: 2px;
}
.Header-burger:after, .Header-burger:before {
    content: none;
}


/* ════════════════════════════════════════════════════════════════════════════
   MEGA PANELS
   ════════════════════════════════════════════════════════════════════════════ */
.MegaPanels {
    position: absolute;
    left    : 0;
    right   : 0;
    top     : 100%;
    z-index : 1000;
}

/* Overlay sombre derrière le panel */
.MegaPanels-overlay {
    position      : fixed;
    inset         : 0;
    top           : calc(var(--mm-topbar-h) + var(--mm-main-h));
    background    : rgba(0, 0, 0, .32);
    opacity       : 0;
    pointer-events: none;
    transition    : opacity var(--mm-ease);
    z-index       : -1;
}
.MegaPanels-overlay.is-visible {
    opacity       : 1;
    pointer-events: all;
}

/* Panel */
.MegaPanel {
    display   : none;
    background: #fff;
    padding   : 20px 0;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .14);
}
.MegaPanel.is-open {
    display  : block !important;
    animation: mmPanelIn var(--mm-ease);
}

@keyframes mmPanelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Grille de cartes ───────────────────────────────────────────────────── */
.MegaPanel-grid {
    display              : grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows       : 225px; /* demi-unité : carte normale = span 2, demi-carte = span 1 */
    gap                  : 10px;
    max-width            : 150rem;
    margin               : 0 auto;
    padding              : 0 var(--mm-px);
    box-sizing           : border-box;
}

/* ════════════════════════════════════════════════════════════════════════════
   MEGA CARD
   ════════════════════════════════════════════════════════════════════════════ */
.MegaCard {
    position         : relative;
    display          : flex;
    flex-direction   : column;
    justify-content  : flex-end;
    border-radius    : var(--mm-radius);
    overflow         : hidden;
    text-decoration  : none;
    background-color : #c8d4de;
    background-size  : cover;
    background-position: center;
    transition       : transform var(--mm-ease);
    cursor           : pointer;
    grid-row         : span 2; /* carte normale = 2 demi-unités */
}

/* Dégradé de base */
.MegaCard::before {
    content   : '';
    position  : absolute;
    inset     : 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, .68) 0%,
        rgba(0, 0, 0, .06) 55%,
        transparent 100%
    );
    transition: background var(--mm-ease);
    z-index   : 0;
}

.MegaCard:hover { transform: scale(1.018); }

.MegaCard:hover::before {
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, .75) 0%,
        rgba(0, 0, 0, .15) 60%,
        transparent 100%
    );
}

.MegaCard-inner {
    position       : absolute;
    inset          : 0;
    display        : flex;
    flex-direction : column;
    justify-content: flex-end;
    text-decoration: none;
    z-index        : 1;
}

/* Label (titre + flèche) */
.MegaCard-label {
    position       : relative;
    z-index        : 1;
    display        : flex;
    justify-content: space-between;
    align-items    : flex-end;
    padding        : 14px;
    gap            : 8px;
}

.MegaCard-title {
    font-size  : 20px;
    font-weight: 600;
    color      : #fff;
    line-height: 1.25;
}

.MegaCard-arrow {
    height: 24px;
}

/* ── Demi-carte ────────────────────────────────────────────────────────── */
/*
   Principe : la grille utilise des rangées de 110px (demi-unité).
   - Carte normale : grid-row: span 2  → 220px
   - Demi-carte    : grid-row: span 1  → 110px (2 s'empilent dans 1 colonne)
*/
.MegaCard--half {
    grid-row: span 1 !important;
}

/* ── Sous-liens niveau 3 (overlay au survol) ───────────────────────────── */
.MegaCard.has-sublinks .MegaCard-sublinks {
    position     : absolute;
    inset        : 0;
    background   : rgba(0, 0, 0, .5);
    border-radius: var(--mm-radius);
    padding      : 20px;
    display      : flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity      : 0;
    transition   : opacity var(--mm-ease);
    z-index      : 2;
}

.MegaCard.has-sublinks:hover .MegaCard-sublinks { opacity: 1; }

.MegaCard-sublinks--header {
    display    : flex;
    align-items: center;
    gap        : 6px;
    font-size  : 20px;
    font-weight: 600;
    color      : #fff;
    margin-bottom: 14px;
}

.MegaCard-sublinks ul {
    list-style: none;
    margin    : 0;
    padding   : 0;
    display   : flex;
    flex-direction: column;
    gap       : 4px;
}

.MegaCard-sublinks ul a {
    font-size      : 18px;
    color          : rgba(255, 255, 255, .82);
    text-decoration: underline;
    transition     : color var(--mm-ease);
}
.MegaCard-sublinks ul a:hover { color: #fff; }

/* ════════════════════════════════════════════════════════════════════════════
   MOBILE MENU
   ════════════════════════════════════════════════════════════════════════════ */
.MobileMenu {
    position  : fixed;
    inset     : 0;
    z-index   : 2000;
    background: #fff;
    transform : translateX(100%);
    transition: transform 0.3s ease;
    display   : flex;
    flex-direction: column;
}
.MobileMenu.is-open { transform: translateX(0); }

.MobileMenu-header {
    display        : flex;
    align-items    : center;
    justify-content: space-between;
    padding        : 16px 20px;
    border-bottom  : 1px solid #eee;
    flex-shrink    : 0;
}
.MobileMenu-header img { height: 54px; width: auto; }

.MobileMenu-close {
    display    : flex;
    align-items: center;
    background : none;
    border     : none;
    cursor     : pointer;
    padding    : 8px;
    color      : var(--mm-text);
}

.MobileMenu-body {
    flex      : 1;
    overflow-y: auto;
}

/* Bouton webcam toujours visible, collé en bas de l'écran */
.MobileMenu-footer {
    flex-shrink   : 0;
    padding       : 16px 20px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    border-top    : 1px solid #eee;
    background    : #fff;
}

/* Accordéon */
.MobileMenu-accordion { border-bottom: 1px solid #eee; }

.MobileMenu-accordion--trigger {
    display        : flex;
    justify-content: space-between;
    align-items    : center;
    width          : 100%;
    padding        : 16px 20px;
    font-size      : 16px;
    font-weight    : 600;
    color          : var(--mm-text);
    background     : none;
    border         : none;
    cursor         : pointer;
    text-align     : left;
    font-family    : inherit;
}
.MobileMenu-accordion--chevron {
    flex-shrink: 0;
    opacity    : 0.6;
    transition : transform var(--mm-ease);
}
.MobileMenu-accordion.is-open .MobileMenu-accordion--chevron {
    transform: rotate(180deg);
}

.MobileMenu-accordion--panel {
    display: none;
    padding: 0 20px 16px;
    gap    : 12px;
}
.MobileMenu-accordion.is-open .MobileMenu-accordion--panel {
    display       : flex;
    flex-direction: column;
}

.MobileMenu-accordion--panel a {
    font-size      : 14px;
    color          : #444;
    text-decoration: none;
    padding        : 4px 0;
}
.MobileMenu-accordion--panel a:hover { color: var(--mm-gold); }

/* Liens utilitaires en bas */
.MobileMenu-utils {
    padding        : 24px 20px;
    display        : flex;
    flex-direction : column;
    gap            : 24px;
    margin-top     : 8px;
}

/* Infos pistes / Agenda / Favoris : côte à côte, picto au-dessus du libellé */
.MobileMenu-utils--row {
    display        : flex;
    align-items    : flex-start;
    justify-content: space-around;
    gap            : 8px;
}
.MobileMenu-utils--item {
    display        : flex;
    flex-direction : column;
    align-items    : center;
    gap            : 6px;
    color          : var(--mm-text);
    text-decoration: none;
    font-size      : 12px;
    font-weight    : 600;
    text-align     : center;
    position       : relative;
}
.MobileMenu-utils--item:hover { color: var(--mm-gold); }
.MobileMenu-utils--item .Header-topbar--fav-counter {
    position  : absolute;
    top       : -4px;
    right     : -10px;
    color     : var(--mm-gold);
}

/* Sélecteur de langue sous la rangée infos pistes / agenda / favoris */
.MobileMenu-language {
    display        : flex;
    justify-content: center;
    padding-top    : 20px;
    margin-top     : 4px;
    border-top     : 1px solid #eee;
}
.MobileMenu-language .wpml-ls,
.MobileMenu-language ul {
    display        : flex !important;
    align-items    : center;
    justify-content: center;
    flex-wrap      : wrap;
    gap            : 16px;
    list-style     : none;
    margin         : 0;
    padding        : 0;
}
.MobileMenu-language li,
.MobileMenu-language .wpml-ls-item {
    display: flex;
}

/* Skin "dropdown" WPML : fond blanc + flèche noire */
.MobileMenu-language select {
    -webkit-appearance: none;
    appearance        : none;
    border            : 1px solid #ddd;
    border-radius     : 8px;
    padding           : 8px 32px 8px 14px;
    font-size         : 13px;
    font-weight       : 600;
    background-color  : #fff;
    color             : var(--mm-text);
    background-image  : url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23000' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
    background-repeat : no-repeat;
    background-position: right 12px center;
}

/* Webcam : bouton pleine largeur, bien visible */
.MobileMenu-utils--webcam {
    display        : flex;
    align-items    : center;
    justify-content: center;
    gap            : 10px;
    width          : 100%;
    padding        : 16px 20px;
    background     : var(--mm-gold);
    color          : #000;
    border-radius  : 10px;
    font-weight    : 700 !important;
    font-size      : 16px;
    text-decoration: none;
    box-sizing     : border-box;
    box-shadow     : 0 4px 14px rgba(196, 146, 42, .35);
    transition     : background var(--mm-ease), transform var(--mm-ease);
}
.MobileMenu-utils--webcam:hover {
    background: var(--mm-gold-hover);
    transform : translateY(-1px);
}
.MobileMenu-utils--webcam:active { transform: translateY(0); }

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    /* Cacher nav desktop, afficher burger */
    .MegaNav,
    .Header-webcam {
        display: none;
    }

    .Header-burger.__megaBurger {
        display: flex !important;
    }

    /* Topbar remplacée par la barre d'utils compacte (infos pistes, agenda, webcam) */
    .Header-topbar { display: none !important; }
    .Header-mobileUtils { display: flex; }
}

@media (max-width: 768px) {
    .Header-main {
        height : 64px;
        padding: 0 16px;
    }

    .Header-main .Header-logo img,
    .Header.is-scrolled .Header-main .Header-logo img {
        height : 54px;
        padding: 5px 0;
    }

    /* Grille 2 colonnes sur petits écrans (si panels ouverts sur tablet) */
    .MegaPanel-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows       : 160px;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   OVERRIDES THÈME EXISTANT – corrections de conflits
   ════════════════════════════════════════════════════════════════════════════ */

.Header,
.Header *:not(.MegaPanels-overlay) {
    pointer-events: auto !important;
}

.MegaPanels-overlay {
    pointer-events: none !important;
}

.MegaPanels-overlay.is-visible {
    pointer-events: all !important;
}

/* Header-main : s'assurer que flex fonctionne sans interférence */
.Header-main {
    display     : flex !important;
    flex-wrap   : nowrap !important;
    align-items : center !important;
}

/* S'assurer que MegaNav et ses enfants ne sont pas cachés par le thème */
.MegaNav,
.MegaNav-list,
.MegaNav-item,
.MegaNav-trigger {
    visibility: visible !important;
    opacity   : 1 !important;
}

/* MegaPanels : position relative au Header (qui est sticky) */
.Header {
    overflow: visible !important;  /* sinon les panels sont coupés */
}

/* Panels : s'assurer qu'ils passent au-dessus du contenu page */
.MegaPanel.is-open {
    position: relative;
    z-index : 999 !important;
}

/* Overlay : passer au-dessus du contenu mais sous le header */
.MegaPanels-overlay.is-visible {
    z-index: 998 !important;
}

/* Corriger la topbar si le thème lui applique display:none par défaut (desktop uniquement : sur mobile elle est remplacée par .Header-mobileUtils) */
@media (min-width: 1025px) {
    .Header-topbar {
        display: flex !important;
    }
}

/* Bouton burger : visible uniquement sur mobile via le media query */
@media (min-width: 1025px) {
    .Header-burger.__megaBurger { display: none !important; }
    .MobileMenu                 { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════════════════
   MEGA SEARCH
   ════════════════════════════════════════════════════════════════════════════ */
.MegaSearch {
    position  : absolute;
    left      : 0;
    right     : 0;
    top       : 100%;
    background: #fff;
    padding   : 24px var(--mm-px);
    box-shadow: 0 12px 36px rgba(0,0,0,.12);
    display   : none;
    z-index   : 200;
    animation : mmPanelIn var(--mm-ease);
}
.MegaSearch.is-open { display: block; }

.MegaSearch-form {
    display    : flex;
    align-items: center;
    gap        : 16px;
    max-width  : 860px;
    margin     : 0 auto;
    border-bottom: 2px solid var(--mm-gold);
    padding-bottom: 4px;
}

.MegaSearch-input {
    flex       : 1;
    border     : none;
    outline    : none;
    font-size  : 22px;
    padding    : 10px 0;
    background : transparent;
    color      : var(--mm-text);
    font-family: inherit;
}
.MegaSearch-input::placeholder { color: #aaa; font-weight: 300; }

.MegaSearch-submit {
    background : none;
    border     : none;
    cursor     : pointer;
    color      : var(--mm-gold);
    display    : flex;
    align-items: center;
    padding    : 8px;
    flex-shrink: 0;
    transition : opacity var(--mm-ease);
}
.MegaSearch-submit:hover { opacity: 0.7; }

.MegaSearch-close {
    background : none;
    border     : none;
    cursor     : pointer;
    color      : #888;
    display    : flex;
    align-items: center;
    padding    : 8px;
    flex-shrink: 0;
    transition : color var(--mm-ease);
}
.MegaSearch-close:hover { color: var(--mm-text); }

/* ── Fix sublinks : masquer le label de la carte au survol ─────────────── */
.MegaCard-label { transition: opacity var(--mm-ease); }

.MegaCard.has-sublinks:hover .MegaCard-label {
    opacity       : 0;
    pointer-events: none;
}

/* ── Sublinks header : titre à gauche, flèche à droite ────────────────── */
.MegaCard-sublinks--header {
    display        : flex !important;
    justify-content: space-between !important;
    align-items    : center !important;
    gap            : 8px;
}
