/* ============================================================
   PRIMARY NAV — WordPress outputs: ul#primary-menu.menu
   ============================================================ */
#primary-menu-wrap {
    flex: 1;
}

#primary-menu {
    align-items: center;
    justify-content: space-between;
    list-style: none;
    display: flex;
    font-family: var(--wp--preset--font-family--raleway);
    gap: 0;
    grid-template-columns: repeat(4, 1fr) 90px repeat(4, 1fr);
    justify-items: center;
    padding: 0;

    @media (min-width: 1024px) {
        display: grid;
    }

    /* space for the centered logo */
    > :nth-child(5) {
        grid-column-start: 6;
    }
}

.yhb-nav-menu {
    width: 100%;
}

/* Top-level items */
#primary-menu > li > a {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0;
    font-size: .875rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: none;
    color: var(--wp--preset--color--midnight);
    text-decoration: none;
    white-space: nowrap;
    transition: color .2s;
    position: relative;
}

#primary-menu > li > a::before {
    content: '';
    position: absolute;
    bottom: 18px;
    left: 18px;
    right: 18px;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transition: transform .2s;
}

#primary-menu > li > a:hover,
#primary-menu > li.menu-open > a {
    color: var(--wp--preset--color--navy);
}

#primary-menu > li > a:hover::before,
#primary-menu > li.menu-open > a::before {
    transform: scaleX(1);
}

@media (min-width: 1024px) {
    #primary-menu > li.menu-item-has-children > a::after {
        background: url(../../../assets/images/chevron-down.svg) center center no-repeat;
        background-size: contain;
        content: "";
        display: inline-block;
        height: 1em;
        width: 1em;
        margin-left: 5px;
        transition: transform .2s ease;
        vertical-align: baseline;
    }

    #primary-menu > li.menu-open.menu-item-has-children > a::after {
        transform: rotateX(180deg);
    }
}

/* ============================================================
   MEGA MENU PANEL
   ============================================================ */
.mega-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--wp--preset--color--navy);
    z-index: 999;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
}

li.menu-open > .mega-menu {
    display: flex;
}

.mega-menu__inner {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    min-height: 220px;
}

/* LEFT PANEL */
.mega-menu__left {
    flex: 0 0 260px;
    background: var(--wp--preset--color--navy);
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mega-menu__title {
    font-family: var(--wp--preset--font-family--inter);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.mega-menu__desc {
    font-size: .83rem;
    color: rgba(255,255,255,.55);
    line-height: 1.6;
    margin-bottom: 20px;
}

.mega-menu__see-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--wp--preset--color--lime);
    font-size: .83rem;
    font-weight: 700;
    text-decoration: none;
    transition: gap .2s;
}
.mega-menu__see-all:hover { gap: 12px; }
.mega-menu__see-all svg { width: 18px; height: 18px; flex-shrink: 0; }

/* RIGHT PANEL */
.mega-menu__right {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

/* TAB ROW (2nd level items become tabs) */
.mega-tabs {
    display: flex;
    font-family: var(--wp--preset--font-family--inter);
    font-size: var(--wp--preset--font-size--large);
    list-style: none;
    padding: 0;
}

.mega-tabs li {}

.mega-tabs li a,
.mega-tabs li button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 18px 28px;
    font-size: var(--wp--preset--font-size--medium);
    font-weight: 600;
    color: var(--wp--preset--color--lime);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    transition: color .2s;
    white-space: nowrap;
}
/*
.mega-tabs li a::after,
.mega-tabs li button::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 0; right: 0;
    height: 3px;
    background: var(--wp--preset--color--lime);
    transform: scaleX(0);
    transition: transform .2s;
}
*/
.mega-tabs li.tab-active a,
.mega-tabs li.tab-active button,
.mega-tabs li a:hover,
.mega-tabs li button:hover {
    background: var(--wp--preset--color--midnight);
}
/*
.mega-tabs li.tab-active a::after,
.mega-tabs li.tab-active button::after {
    transform: scaleX(1);
}
*/
.mega-tabs .chevron {
    /*width: 1em;*/
    transition: transform .2s;
}
.mega-tabs li.tab-active .chevron {
    transform: rotate(90deg);
    opacity: 1;
}

/* TAB PANELS */
.mega-tab-panels {
    background: var(--wp--preset--color--midnight);
    flex: 1;
    position: relative;
    padding: 28px 32px;
}

.mega-tab-panel {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 24px;
    animation: fadeIn .18s ease;
}

.mega-tab-panel.panel-active {
    display: grid;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* FLAT (no tabs) layout — for 2-level menus */
.mega-tab-panels.no-tabs {
    padding: 28px 32px;
}
.mega-tab-panels.no-tabs .mega-flat-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 24px;
}

/* Menu items inside panels */
.mega-item {
    display: block;
    padding: 9px 0;
    color: rgba(255,255,255,1);
    font-size: .875rem;
    text-decoration: none;
    transition: color .15s, padding-left .15s;
}

.mega-item:hover {
    color: var(--wp--preset--color--lime);
    padding-left: 6px;
}

.mega-item.current-menu-item {
    color: var(--wp--preset--color--lime);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Close button */
.mega-close {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(255,255,255,.08);
    border: none;
    color: rgba(255,255,255,.5);
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: background .2s, color .2s;
    display: flex; align-items: center; justify-content: center;
}
.mega-close:hover { background: rgba(255,255,255,.18); color: #fff; }

/* Non-mega dropdown (simple items) */
.simple-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    background: var(--wp--preset--color--midnight);
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    border-top: 3px solid var(--wp--preset--color--teal);
    list-style: none;
    z-index: 999;
}
#primary-menu > li.menu-open > .simple-dropdown { display: block; }
.simple-dropdown li a {
    display: block;
    padding: 11px 20px;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
    transition: background .15s, color .15s;
}
.simple-dropdown li a:hover { background: rgba(255,255,255,.07); color: #fff; }

/* Overlay to close on outside click */
.mega-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
}
.mega-overlay.active { display: block; }

/* Demo page chrome */
.demo-body { padding: 80px 40px; }
.demo-body h2 { font-size: 1.5rem; color: #333; margin-bottom: 12px; }
.demo-body p  { color: #666; line-height: 1.7; }

/* ============================================================
   HAMBURGER BUTTON — hidden on desktop
   ============================================================ */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle__bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--wp--preset--color--midnight);
    border-radius: 2px;
    transform-origin: center;
    transition: transform .25s, opacity .2s, width .2s;
}
/* Animate to X when open */
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
    opacity: 0;
    width: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   MOBILE STYLES  ≤ 1023px
   ============================================================ */
@media (min-width: 1024px) {
    .mob-toggle,
    .mob-drawer {
        display: none;
    }
}

@media (max-width: 1023px) {

    /* Show hamburger */
    .nav-toggle { display: flex; }

    /* Stack header */
    .header-inner {
        flex-wrap: wrap;
        padding: 0 16px;
        position: relative;
    }
    .site-logo { padding: 12px 0; }

    .yhb-nav-menu__panel {
        box-sizing: border-box;
        left: 0;
        position: absolute;
        top: 100%;
        width: 100%;
    }

    /* Full-width nav drawer */
    #primary-menu-wrap {
        flex: 0 0 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height .35s ease;
        background: var(--wp--preset--color--midnight);
        width: 100%;
    }
    #primary-menu-wrap.mobile-open {
        max-height: 100dvh;
        overflow-y: auto;
    }

    /* ── Top-level list: vertical stack ── */
    #primary-menu {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 0 24px;
    }

    /* Each top-level item is a row with optional toggle button */
    #primary-menu > li {
        display: flex;
        flex-wrap: wrap;
        border-bottom: 1px solid rgba(255,255,255,.07);
    }

    #primary-menu > li > a {
        flex: 1;
        height: auto;
        padding: 14px 20px;
        font-size: 1rem;
        color: #fff;
        white-space: normal;
    }

    #primary-menu > li > a:hover,
    #primary-menu > li.menu-open > a {
        color: var(--wp--preset--color--lime);
    }

    /* Remove desktop underline indicator */
    #primary-menu > li > a::before { display: none; }

    /* Accordion toggle button injected by JS */
    .mob-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 48px;
        flex-shrink: 0;
        background: none;
        border: none;
        border-left: 1px solid rgba(255,255,255,.07);
        cursor: pointer;
        color: rgba(255,255,255,.5);
        transition: color .2s, background .2s;
        padding: 0;
    }
    .mob-toggle:hover { background: rgba(255,255,255,.05); color: #fff; }
    .mob-toggle[aria-expanded="true"] { color: var(--wp--preset--color--lime); }

    .mob-toggle__icon {
        display: block;
        width: 10px;
        height: 10px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform .25s;
        margin-top: -4px; /* optical centre */
    }
    .mob-toggle[aria-expanded="true"] .mob-toggle__icon {
        transform: rotate(-135deg);
        margin-top: 4px;
    }

    /* ── Accordion drawer ── */
    .mob-drawer {
        flex: 0 0 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height .3s ease;
        background: var(--wp--preset--color--navy);
    }
    .mob-drawer.mob-open {
        max-height: 9999px; /* tall enough for any content */
    }

    /* ── Left panel info at top of drawer ── */
    .mob-header {
        padding: 20px 20px 16px;
        border-bottom: 1px solid rgba(255,255,255,.08);
    }
    .mob-header__title {
        font-size: 1.1rem;
        font-weight: 800;
        color: #fff;
        letter-spacing: .04em;
        text-transform: uppercase;
        margin-bottom: 6px;
    }
    .mob-header__desc {
        font-size: .8rem;
        color: rgba(255,255,255,.5);
        line-height: 1.55;
        margin-bottom: 10px;
    }
    .mob-header__see-all {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        color: var(--wp--preset--color--lime);
        font-size: .8rem;
        font-weight: 700;
        text-decoration: none;
    }
    .mob-header__see-all svg { width: 16px; height: 16px; flex-shrink: 0; }

    /* ── Level-2 accordion groups ── */
    .mob-group {
        border-bottom: 1px solid rgba(255,255,255,.06);
    }

    .mob-group__header {
        display: flex;
        align-items: stretch;
    }

    .mob-group__link {
        flex: 1;
        padding: 13px 20px 13px 28px;
        font-size: .9rem;
        font-weight: 600;
        color: rgba(255,255,255,.75);
        text-decoration: none;
        transition: color .15s;
    }
    .mob-group__link:hover { color: #fff; }

    /* Toggle for groups that have children */
    .mob-group__toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        flex-shrink: 0;
        background: none;
        border: none;
        border-left: 1px solid rgba(255,255,255,.06);
        cursor: pointer;
        color: rgba(255,255,255,.4);
        transition: color .2s;
    }
    .mob-group__toggle:hover { color: #fff; }
    .mob-group__toggle[aria-expanded="true"] { color: var(--wp--preset--color--lime); }

    .mob-group__icon {
        display: block;
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        transition: transform .2s;
        margin-top: -3px;
    }
    .mob-group__toggle[aria-expanded="true"] .mob-group__icon {
        transform: rotate(-135deg);
        margin-top: 3px;
    }

    /* ── Level-3 items list ── */
    .mob-children {
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
        background: rgba(0,0,0,.15);
    }
    .mob-children.mob-open { max-height: 9999px; }

    .mob-child-link {
        display: block;
        padding: 10px 20px 10px 40px;
        font-size: .85rem;
        color: rgba(255,255,255,.6);
        text-decoration: none;
        border-bottom: 1px solid rgba(255,255,255,.04);
        transition: color .15s, padding-left .15s;
    }
    .mob-child-link:hover { color: #fff; padding-left: 46px; }
    .mob-child-link.current-menu-item {
        color: var(--wp--preset--color--lime);
    }

    /* ── Hide desktop-only elements on mobile ── */
    .mega-menu,
    .mega-overlay { display: none !important; }

    /* Suppress desktop active-underline state */
    #primary-menu > li.menu-open > a::after { transform: scaleX(0); }
}