/**
 * ACBAR site navigation — standalone (no Menuzord)
 * Breakpoint: 1024px (mobile drawer below, horizontal menu at/above)
 */

/* Neutralize legacy theme rules that targeted old Menuzord header layout */
#header .header-nav {
    position: relative;
    text-align: start;
}

#header .header-nav .header-nav-absolute-wrapper {
    position: static !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    margin: 0 !important;
}

:root {
    --acbar-nav-green: #27883b;
    --acbar-nav-green-light: #e8f5e9;
    --acbar-nav-text: #212931;
    --acbar-nav-muted: #666;
    --acbar-nav-border: #e8e8e8;
    --acbar-nav-bar-z: 2;
    --acbar-nav-drawer-z: 1100;
    --acbar-nav-backdrop-z: 1090;
    --acbar-site-header-height: 120px;
    --acbar-nav-logo-h: 72px;
    --acbar-nav-bar-pad-y: 10px;
    --acbar-nav-bar-pad-x: clamp(12px, 2.5vw, 40px);
    --acbar-nav-transition: 0.28s ease;
}

/* Sticky: only the white nav bar (header-top scrolls away above it) */
.acbar-nav-sticky {
    position: sticky;
    top: 0;
    z-index: var(--acbar-nav-bar-z);
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.acbar-nav {
    width: 100%;
    font-family: inherit;
}

.acbar-nav__bar {
    position: relative;
    width: 100%;
    background: #fff;
}

.acbar-nav__inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: calc(var(--acbar-nav-logo-h) + var(--acbar-nav-bar-pad-y) * 2);
    padding: var(--acbar-nav-bar-pad-y) var(--acbar-nav-bar-pad-x);
    max-width: 100%;
    box-sizing: border-box;
}

/* Logo */
.acbar-nav__brand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    max-width: min(340px, calc(100% - 56px));
    margin: 0;
    line-height: 0;
    text-decoration: none;
    float: none;
}

.acbar-nav__brand img {
    display: block;
    max-height: var(--acbar-nav-logo-h);
    width: auto;
    max-width: 100%;
    height: auto;
}

/* Hamburger */
.acbar-nav__toggle {
    flex: 0 0 auto;
    margin: 0;
    margin-inline-start: auto; /* pushes to end of mobile bar (right LTR / left RTL) */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--acbar-nav-border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.acbar-nav__toggle:focus-visible {
    outline: 2px solid var(--acbar-nav-green);
    outline-offset: 2px;
}

.acbar-nav__toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--acbar-nav-text);
    border-radius: 1px;
    transition:
        transform var(--acbar-nav-transition),
        opacity var(--acbar-nav-transition);
}

.acbar-nav.is-open .acbar-nav__toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.acbar-nav.is-open .acbar-nav__toggle-bar:nth-child(2) {
    opacity: 0;
}

.acbar-nav.is-open .acbar-nav__toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.acbar-nav__toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Backdrop (mobile) */
.acbar-nav__backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--acbar-nav-backdrop-z);
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity var(--acbar-nav-transition);
    pointer-events: none;
}

.acbar-nav__backdrop.is-visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

/* Panel — mobile drawer */
.acbar-nav__panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: var(--acbar-nav-drawer-z);
    width: min(100%, 340px);
    max-width: 100vw;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    background: #fff;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translate3d(100%, 0, 0);
    transition: transform var(--acbar-nav-transition);
    visibility: hidden;
}

[dir="rtl"] .acbar-nav__panel {
    right: auto;
    left: 0;
    transform: translate3d(-100%, 0, 0);
}

.acbar-nav.is-open .acbar-nav__panel {
    transform: translate3d(0, 0, 0);
    visibility: visible;
}

.acbar-nav__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px var(--acbar-nav-bar-pad-x);
    border-bottom: 1px solid var(--acbar-nav-border);
}

.acbar-nav__panel-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--acbar-nav-muted);
}

.acbar-nav__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--acbar-nav-text);
    font-size: 22px;
    cursor: pointer;
}

.acbar-nav__close:focus-visible {
    outline: 2px solid var(--acbar-nav-green);
    outline-offset: 2px;
}

.acbar-nav__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.acbar-nav__item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid var(--acbar-nav-border);
}

.acbar-nav__row {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.acbar-nav__link {
    flex: 1 1 auto;
    display: block;
    padding: 14px var(--acbar-nav-bar-pad-x);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--acbar-nav-text);
    text-decoration: none;
    text-align: start;
    background: #fff;
    border: none;
    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.acbar-nav__link:hover,
.acbar-nav__link:focus {
    color: var(--acbar-nav-green);
    text-decoration: none;
}

.acbar-nav__item.is-active > .acbar-nav__row > .acbar-nav__link,
.acbar-nav__submenu
    .acbar-nav__item.is-active
    > .acbar-nav__row
    > .acbar-nav__link,
.acbar-nav__submenu .acbar-nav__item.is-active > .acbar-nav__link {
    background: var(--acbar-nav-green-light);
    color: var(--acbar-nav-text);
    box-shadow: inset 4px 0 0 var(--acbar-nav-green);
}

[dir="rtl"] .acbar-nav__item.is-active > .acbar-nav__row > .acbar-nav__link,
[dir="rtl"] .acbar-nav__submenu .acbar-nav__item.is-active > .acbar-nav__link {
    box-shadow: inset -4px 0 0 var(--acbar-nav-green);
}

.acbar-nav__expand {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    border: none;
    border-inline-start: 1px solid var(--acbar-nav-border);
    background: #fafafa;
    color: var(--acbar-nav-green);
    font-size: 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition:
        background 0.15s ease,
        transform 0.2s ease;
}

.acbar-nav__expand:focus-visible {
    outline: 2px solid var(--acbar-nav-green);
    outline-offset: -2px;
}

.acbar-nav__item.is-open > .acbar-nav__row > .acbar-nav__expand {
    background: var(--acbar-nav-green-light);
}

.acbar-nav__item.is-open > .acbar-nav__row > .acbar-nav__expand i {
    transform: rotate(180deg);
}

/* Submenus — mobile accordion */
.acbar-nav__submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #f4f5f6;
    display: none;
}

.acbar-nav__item.is-open > .acbar-nav__submenu {
    display: block;
}

.acbar-nav__submenu .acbar-nav__link {
    padding-inline-start: calc(var(--acbar-nav-bar-pad-x) + 12px);
    font-size: 14px;
    font-weight: 600;
    background: #fff;
}

.acbar-nav__submenu .acbar-nav__submenu .acbar-nav__link {
    padding-inline-start: calc(var(--acbar-nav-bar-pad-x) + 24px);
    background: #fafafa;
}

.acbar-nav__item--search .acbar-nav__link {
    color: var(--acbar-nav-green);
    font-size: 18px;
}

/* Body scroll lock */
body.acbar-nav-scroll-lock {
    overflow: hidden !important;
    touch-action: none;
}

/* ==========================================================================
   Mobile / tablet bar — logo left, menu right
   ========================================================================== */
@media (max-width: 1023px) {
    #header .header-nav {
        text-align: start;
    }

    #header .header-nav .acbar-nav__bar {
        width: 100%;
    }

    #header .header-nav .container-fluid.acbar-nav__inner {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: var(--acbar-nav-bar-pad-y) var(--acbar-nav-bar-pad-x) !important;
        text-align: start !important;
    }

    #header .acbar-nav__brand {
        float: none !important;
        margin: 0 !important;
        text-align: start !important;
        justify-content: flex-start !important;
    }

    #header .acbar-nav__brand img {
        margin: 0 !important;
        display: block;
    }

    #header .acbar-nav__toggle {
        float: none !important;
        margin: 0 !important;
        margin-inline-start: auto !important;
        flex-shrink: 0;
    }

    /* Drawer sits below header-top + logo bar (not under them) */
    .acbar-nav__backdrop {
        top: var(--acbar-site-header-height, 120px);
        height: calc(100dvh - var(--acbar-site-header-height, 120px));
        bottom: auto;
    }

    .acbar-nav__panel {
        top: var(--acbar-site-header-height, 120px);
        height: calc(100dvh - var(--acbar-site-header-height, 120px));
        max-height: calc(100dvh - var(--acbar-site-header-height, 120px));
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    }

    [dir="rtl"] .acbar-nav__panel {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .acbar-nav-sticky {
        z-index: 3;
    }
}

/* ==========================================================================
   Desktop ≥ 1024px
   ========================================================================== */
@media (min-width: 1024px) {
    :root {
        --acbar-nav-logo-h: 96px;
        --acbar-nav-bar-pad-y: 14px;
    }

    /*
     * Desktop: follows <html dir="">
     * LTR — logo start (left), nav end (right)
     * RTL — logo start (right), nav end (left)
     */
    .acbar-nav__bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        width: 100%;
        box-sizing: border-box;
        padding-inline: var(--acbar-nav-bar-pad-x);
    }

    .acbar-nav__inner {
        flex: 0 0 auto;
        width: auto;
        order: 0;
    }

    .acbar-nav__brand {
        margin: 0;
    }

    .acbar-nav__toggle,
    .acbar-nav__backdrop,
    .acbar-nav__panel-header {
        display: none !important;
    }

    .acbar-nav__panel {
        position: static;
        display: flex !important;
        flex: 1 1 auto;
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
        width: auto;
        height: auto;
        max-width: none;
        padding: var(--acbar-nav-bar-pad-y) 0;
        background: transparent;
        box-shadow: none !important;
        border: none !important;
        overflow: visible;
        transform: none !important;
        visibility: visible !important;
    }

    #header .header-nav .menuzord,
    #header .header-nav .acbar-nav__panel,
    #header .header-nav .acbar-nav__list {
        box-shadow: none !important;
        border: none !important;
    }

    .acbar-nav__list {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 2px 4px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .acbar-nav__item {
        position: relative;
        border: none;
    }

    .acbar-nav__row {
        display: block;
    }

    .acbar-nav__link {
        padding: 8px 12px;
        font-size: 13px;
        font-weight: 700;
        white-space: nowrap;
        border-radius: 30px;
    }

    .acbar-nav__expand {
        display: none !important;
    }

    .acbar-nav__item.is-active > .acbar-nav__row > .acbar-nav__link,
    .acbar-nav__item.is-active-branch > .acbar-nav__row > .acbar-nav__link {
        background: var(--acbar-nav-green);
        color: #fff;
        box-shadow: none;
    }

    .acbar-nav__item.is-active > .acbar-nav__row > .acbar-nav__link:hover,
    .acbar-nav__item.is-active-branch
        > .acbar-nav__row
        > .acbar-nav__link:hover {
        color: #fff;
    }

    .acbar-nav__item--has-children > .acbar-nav__row > .acbar-nav__link:hover {
        background: var(--acbar-nav-green);
        color: #fff;
    }

    /* Dropdown */
    .acbar-nav__submenu {
        display: none !important;
        position: absolute;
        top: 100%;
        inset-inline-start: 0;
        min-width: 220px;
        padding: 6px 0;
        background: #fff;
        border: 1px solid var(--acbar-nav-border);
        border-radius: 4px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
        z-index: 1100;
        border-radius: 14px;
    }

    [dir="rtl"] .acbar-nav__submenu {
        inset-inline-start: auto;
        inset-inline-end: 0;
    }

    .acbar-nav__item--has-children:hover > .acbar-nav__submenu,
    .acbar-nav__item--has-children:focus-within > .acbar-nav__submenu {
        display: block !important;
    }

    .acbar-nav__submenu .acbar-nav__item {
        border: none;
    }

    .acbar-nav__submenu .acbar-nav__link {
        padding: 10px 18px;
        border-radius: 0;
        /* white-space: normal; */
        box-shadow: none !important;
    }

    .acbar-nav__submenu .acbar-nav__link:hover,
    .acbar-nav__submenu .acbar-nav__item.is-active > .acbar-nav__link {
        background: var(--acbar-nav-green);
        color: #fff;
    }

    .acbar-nav__submenu .acbar-nav__item.is-active > .acbar-nav__link {
        background: var(--acbar-nav-green-light);
        color: var(--acbar-nav-text);
    }

    .acbar-nav__submenu .acbar-nav__item.is-active > .acbar-nav__link:hover {
        background: var(--acbar-nav-green);
        color: #fff;
    }

    /* Nested flyout */
    .acbar-nav__submenu .acbar-nav__submenu {
        top: 0;
        inset-inline-start: 100%;
        margin-top: 0;
    }

    [dir="rtl"] .acbar-nav__submenu .acbar-nav__submenu {
        inset-inline-start: auto;
        inset-inline-end: 100%;
    }

    .acbar-nav__submenu
        .acbar-nav__item--has-children:hover
        > .acbar-nav__submenu,
    .acbar-nav__submenu
        .acbar-nav__item--has-children:focus-within
        > .acbar-nav__submenu {
        display: block !important;
    }

    .acbar-nav__submenu .acbar-nav__submenu .acbar-nav__link {
        padding-inline-start: 18px;
        background: #fff;
    }

    .acbar-nav__item--search .acbar-nav__link {
        padding: 8px 14px;
    }
}

@media (min-width: 1400px) {
    :root {
        --acbar-nav-logo-h: 108px;
    }

    .acbar-nav__brand {
        max-width: min(380px, calc(100% - 56px));
    }

    .acbar-nav__link {
        font-size: 14px;
        padding: 9px 14px;
    }
}
