/* =============================================================
 * IAC Mega Menu
 * ============================================================= */




/* #region Top bar (Desktop)
 * ============================================================= */

.iac-mega-menu {
    background-color: #fff;
    border-bottom: 2px solid var(--iac-brand-light-grey);
    position: relative;
    z-index: 100;
}

.iac-mega-menu *,
.iac-mega-menu *::before,
.iac-mega-menu *::after {
    box-sizing: border-box;
    font-family: 'Open Sans', Helvetica, Arial, Lucida, sans-serif;
}

/* Top-level list */
.iac-mega-menu > ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
    min-height: var(--iac-menu-height);
}

/* Top-level items */
.iac-mega-top-item {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 0 1ex;
}

.iac-mega-top-item > .iac-mega-item-link {
    font-weight: 600;
    text-transform: uppercase;
    color: var(--iac-brand-anthracite-grey);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
}

.iac-mega-top-item > .iac-mega-item-link:hover,
.iac-mega-top-item.is-open > .iac-mega-item-link {
    text-decoration: underline;
    text-decoration-color: var(--iac-brand-blue);
    text-underline-offset: 8px;
}

/* #endregion */


/* #region Mega panel (dropdown)
 * ============================================================= */

.iac-mega-panel {
    display: none;
    position: fixed;
    top: var(--iac-mega-panel-top);
    left: 0;
    right: 0;
    z-index: 1000;
    list-style: none !important;
    margin: 0;
    padding: 20px !important;
    background-color: #fff;
    border-top: 2px solid var(--iac-brand-light-grey);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 1.5rem 2rem;
    justify-content: center;
    min-height: 275px;
    max-height: 275px;
    overflow-y: auto;
}

/* Bridge element — prevents hover gap between top item and panel */
.iac-mega-panel::before {
    content: "";
    display: block;
    position: absolute;
    top: -1rem;
    left: 0;
    right: 0;
    height: 1rem;
    background: transparent;
}

/* Show panel on hover or when JS adds .is-open */
.iac-mega-top-item:hover > .iac-mega-panel,
.iac-mega-top-item.is-open > .iac-mega-panel {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: center;
    justify-content: flex-start;
}

/* #endregion */


/* #region Category groups (level 1 inside panel)
 * ============================================================= */

.iac-mega-group {
    list-style: none !important;
    min-width: 180px;
}

.iac-mega-group > .iac-mega-item-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--iac-brand-light-blue);
    text-transform: uppercase;
    text-decoration: none;
    margin-bottom: 0.5rem;
    cursor: default;
}

/* Color badges */
.iac-mega-badge {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    border-radius: 2px;
    flex-shrink: 0;
}

.iac-bg-orange .iac-mega-badge  { background-color: var(--iac-brand-red-orange); }
.iac-bg-blue .iac-mega-badge    { background-color: var(--iac-brand-light-blue); }
.iac-bg-purple .iac-mega-badge  { background-color: var(--iac-brand-purple); }
.iac-bg-green .iac-mega-badge   { background-color: var(--iac-brand-green); }
.iac-bg-yellow .iac-mega-badge  { background-color: var(--iac-brand-yellow); }

/* #endregion */


/* #region Product links (level 2)
 * ============================================================= */

.iac-mega-group-links {
    list-style: none !important;
    margin: 0;
    padding: 0;
    padding-inline-start: 1.2em;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.iac-mega-link {
    list-style: none !important;
}

.iac-mega-group:not([class*="iac-bg-"]) > .iac-mega-group-links {
    padding-inline-start: 0;
}

.iac-mega-link > .iac-mega-item-link {
    color: var(--iac-brand-blue);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 400;
    padding: 0.15rem 0;
    display: block;
}

.iac-mega-link > .iac-mega-item-link:hover {
    text-decoration: underline;
}

/* #endregion */


/* #region Mobile menu
 * ============================================================= */

/* Hide hamburger + toggles on desktop */
@media (min-width: 981px) {
    .iac-mega-hamburger,
    .iac-mega-toggle {
        display: none;
    }
}

@media (max-width: 980px) {

    /* --- Layout --- */
    .iac-mega-menu > ul {
        display: none;
        flex-direction: column;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .iac-mega-menu.is-mobile-open > ul {
        display: flex;
        position: fixed;
        top: var(--iac-mega-panel-top);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        background: #fff;
        overflow-y: auto;
        padding: 0;
    }

    body.iac-mega-mobile-open {
        overflow: hidden;
    }

    /* --- Hamburger button --- */
    .iac-mega-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem 1rem;
        background: none;
        border: none;
        font-size: 1.8rem;
        color: var(--iac-brand-anthracite-grey);
        cursor: pointer;
        position: absolute;
        right: 0.5rem;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Hamburger icon (three bars) */
    .iac-mega-hamburger::before {
        content: "\2630"; /* trigram / hamburger */
    }

    /* X icon when open */
    .iac-mega-menu.is-mobile-open .iac-mega-hamburger::before {
        content: "\2715"; /* multiplication sign / X */
    }

    /* --- Top-level items --- */
    .iac-mega-top-item {
        flex-grow: 0;
        justify-content: flex-start;
        border-bottom: 1px solid var(--iac-brand-light-grey);
        padding: 0;
    }

    .iac-mega-top-item > .iac-mega-item-link {
        flex-grow: 1;
        text-align: left;
        padding: 0.75rem;
        font-size: 1rem;
        display: flex;
        align-items: center;
        gap: 0.75ch;
    }

    /* Hamburger menu icon before top-level placeholder items */
    .iac-mega-top-item--has-panel > .iac-mega-item-link::before {
        content: "\2630"; /* three bars */
        font-size: 0.9em;
        color: var(--iac-brand-blue);
    }

    /* External link icon for items with real URLs */
    .iac-mega-top-item:not(.iac-mega-top-item--has-panel) > a.iac-mega-item-link::before {
        content: "\2197"; /* north-east arrow */
        font-size: 0.9em;
        color: var(--iac-brand-blue);
    }

    /* --- Accordion toggle button --- */
    .iac-mega-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 3rem;
        background: none;
        border: none;
        font-size: 1.2rem;
        color: var(--iac-brand-blue);
        cursor: pointer;
        flex-shrink: 0;
        margin-left: auto;
    }

    .iac-mega-toggle::after {
        content: "\25BE"; /* down triangle */
    }

    .iac-mega-top-item.is-open > .iac-mega-toggle::after {
        content: "\25B4"; /* up triangle */
        color: var(--iac-brand-light-blue);
    }

    /* --- Panel becomes inline accordion --- */
    .iac-mega-panel {
        position: static;
        box-shadow: none;
        border-top: none;
        padding: 0 0 0.5rem 1rem;
        gap: 0.25rem;
    }

    .iac-mega-panel::before {
        display: none;
    }

    /* Disable hover on mobile */
    .iac-mega-top-item:hover > .iac-mega-panel {
        display: none;
    }

    .iac-mega-top-item.is-open > .iac-mega-panel {
        display: flex;
        flex-direction: column;
    }

    /* --- Category groups in mobile --- */
    .iac-mega-group {
        min-width: unset;
        border-bottom: 1px solid var(--iac-brand-light-grey);
        padding: 0.4rem 0;
    }

    .iac-mega-group:last-child {
        border-bottom: none;
    }

    .iac-mega-group > .iac-mega-item-link {
        font-size: 0.95rem;
        padding: 0.4rem 0.5rem;
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    /* External link icon for category items with real URLs */
    .iac-mega-group > a.iac-mega-item-link::before {
        content: "\2197"; /* north-east arrow */
        font-size: 0.85em;
        color: var(--iac-brand-blue);
        order: -1;
    }

    /* --- Product links in mobile --- */
    .iac-mega-group-links {
        padding-inline-start: 2rem;
        gap: 0;
    }

    .iac-mega-link > .iac-mega-item-link {
        padding: 0.35rem 0.5rem;
        font-size: 0.9rem;
    }
}

/* #endregion */


/* #region Language switcher
 * ============================================================= */

/* Hide all language switcher items on desktop */
.iac-mega-top-item.menu-item-object-language_switcher {
    display: none !important;
}

@media (max-width: 980px) {
    /* Show current language at bottom of mobile menu */
    .iac-mega-top-item.menu-item-object-language_switcher {
        display: flex !important;
    }

    .iac-mega-top-item.menu-item-object-language_switcher.current-language-menu-item {
        margin-top: auto;
        border-top: 2px solid var(--iac-brand-blue);
        background-color: var(--iac-brand-light-grey);
    }

    /* Checkmark for current language */
    .iac-mega-top-item.menu-item-object-language_switcher.current-language-menu-item > .iac-mega-item-link::after {
        content: "\2713"; /* checkmark */
        margin-left: auto;
        color: var(--iac-brand-blue);
        font-size: 1.2em;
    }
}

/* #endregion */
