/*
 * Grouped members menu (administrators only for now). Loaded only on the grouped render path,
 * after style.css. Everything is scoped to bb-nav / bb-item / bb-m so nothing else on the site is touched.
 * The site stylesheet forces `.navbar a { color: ... !important }`, so link colours below are
 * !important with a higher-specificity selector.
 */

.navbar .bb-nav,
.navbar .bb-nav *,
.navbar .bb-m,
.navbar .bb-m * {
    box-sizing: border-box;
}

.navbar .bb-nav,
.navbar .bb-m {
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.4;
    letter-spacing: normal;
    text-transform: none;
}

.bb-chev {
    width: 10px;
    height: 10px;
    flex: none;
    transition: transform .18s;
}

/* ---------- Desktop ---------- */

.bb-nav__desk {
    margin-left: auto;
}

.bb-nav__list {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.bb-nav__li {
    margin: 0;
    padding: 0;
}

.navbar .bb-nav__toggle,
.navbar .bb-nav__link {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
}

.navbar .bb-nav__toggle {
    color: #fff;
}

.navbar a.bb-nav__link {
    color: #fff !important;
}

.navbar .bb-nav__toggle:hover,
.navbar .bb-nav__toggle[aria-expanded="true"],
.navbar a.bb-nav__link:hover {
    background: rgba(255, 255, 255, .1);
    text-decoration: none;
}

.navbar .bb-nav__toggle[aria-expanded="true"] .bb-chev {
    transform: rotate(180deg);
}

/* Panels are anchored to their trigger by nav.js (it sets `left`, in px, relative to the header). */
.bb-nav__drop {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
}

.bb-nav__drop.is-open {
    display: block;
}

/* Invisible hover bridge below the open trigger, so the pointer can cross the gap to the panel without closing it.
   The panel comes later in the DOM, so it paints over the overlap and its items stay clickable. */
.navbar .bb-nav__toggle[aria-expanded="true"] {
    position: relative;
}

.navbar .bb-nav__toggle[aria-expanded="true"]::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 40px;
}

.bb-nav__card {
    margin-top: 10px;
    background: #1d2120;
    border: 1px solid #333a36;
    border-radius: 14px;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(var(--bb-cols, 1), minmax(200px, 240px));
    width: max-content;
    max-width: calc(100vw - 32px);
    gap: 8px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

.bb-grp__h {
    margin: 0 0 6px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    color: #35b46f;
    letter-spacing: .2px;
}

.navbar a.bb-item {
    display: block;
    padding: 10px 12px;
    border-radius: 9px;
    text-decoration: none;
    color: #f3f6f4 !important;
}

.navbar a.bb-item:hover,
.navbar a.bb-item:focus-visible {
    background: #262c29;
    text-decoration: none;
}

.bb-item__t {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
}

.bb-item__d {
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: #a7b5ac;
    line-height: 1.45;
}

.bb-tag,
.bb-lock {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    padding: 1px 7px;
    border-radius: 5px;
}

.bb-tag {
    background: #1f3b2b;
    color: #35b46f;
}

.bb-lock {
    background: rgba(255, 255, 255, .08);
    color: #c9d4cd;
}

.navbar a.bb-item.is-locked .bb-item__t {
    color: #b3bfb8;
}

.navbar .bb-nav :focus-visible,
.navbar .bb-m :focus-visible,
.navbar .bb-nav__burger:focus-visible {
    outline: 2px solid #35b46f;
    outline-offset: 2px;
}

/* Desktop rows (the phone and accordion layouts keep their own sizes). */
@media (min-width: 992px) {
    .navbar a.bb-item {
        padding: 6px 10px;
    }

    .bb-item__t {
        font-size: 14px;
    }

    .bb-item__d {
        margin-top: 1px;
        font-size: 12px;
        line-height: 1.35;
    }

    .bb-grp__h {
        margin-bottom: 4px;
        padding: 0 10px;
    }
}

/* ---------- Upgrade button (free members) ---------- */

.navbar a.bb-upgrade,
.navbar a.bb-btn {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 8px;
    background: #2d8659;
    color: #fff !important;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
}

.navbar a.bb-upgrade:hover,
.navbar a.bb-btn:hover {
    background: #256f4a;
    text-decoration: none;
}

.bb-nav__li--upgrade,
.bb-nav__li--btn {
    align-self: center;
}

.bb-nav__li--upgrade,
.bb-nav__li--first {
    margin-left: 8px;
}

.bb-m__upgrade {
    padding: 16px 20px;
}

.bb-m__upgrade .bb-upgrade {
    display: block;
    text-align: center;
}

/* ---------- Burger and mobile panel (below the navbar-expand-lg breakpoint) ---------- */

.bb-nav__burger {
    display: none;
}

.bb-m {
    display: none;
}

@media (max-width: 991.98px) {
    .bb-nav {
        display: none;
    }

    .navbar .bb-nav__burger {
        display: grid;
        place-items: center;
        margin-left: auto;
        width: 48px;
        height: 42px;
        padding: 0;
        background: none;
        border: 1px solid #fff;
        border-radius: 5px;
        cursor: pointer;
    }

    .bb-nav__burger span,
    .bb-nav__burger span::before,
    .bb-nav__burger span::after {
        display: block;
        width: 22px;
        height: 2px;
        background: #fff;
        position: relative;
        border-radius: 2px;
        content: "";
    }

    .bb-nav__burger span::before {
        position: absolute;
        top: -7px;
    }

    .bb-nav__burger span::after {
        position: absolute;
        top: 7px;
    }

    /* Fixed below the header, down to the bottom of the viewport. nav.js sets --bb-m-top on every open. */
    .bb-m.is-open {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        top: var(--bb-m-top, 74px);
        bottom: 0;
        z-index: 1200;
        background: #143a24;
    }

    .bb-m__scroll {
        position: relative;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .bb-m__sec {
        border-bottom: 1px solid #24563a;
    }

    .navbar .bb-m__head {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: none;
        border: 0;
        margin: 0;
        padding: 17px 20px;
        color: #fff;
        font-size: 18px;
        font-weight: 400;
        text-align: left;
        cursor: pointer;
        text-decoration: none;
    }

    .navbar a.bb-m__head {
        color: #fff !important;
    }

    .bb-m__head .bb-chev {
        width: 12px;
        height: 12px;
    }

    .bb-m__sec.is-open .bb-m__head .bb-chev {
        transform: rotate(180deg);
    }

    .bb-m__body {
        display: none;
        padding: 0 10px 14px;
    }

    .bb-m__sec.is-open .bb-m__body {
        display: block;
    }

    .bb-m__body .bb-grp__h {
        padding: 12px 12px 4px;
    }

    .navbar .bb-m__body a.bb-item:hover {
        background: #1f4a32;
    }

    .bb-m__body .bb-item__d {
        color: #a9c3b2;
    }

    .bb-m__foot {
        flex: none;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
        background: #0f2c1b;
        border-top: 1px solid #24563a;
        font-size: 14px;
        color: #a9c3b2;
    }

    .navbar .bb-m__foot a {
        color: #5fd38f !important;
        text-decoration: none;
    }

    .bb-m__name {
        font-weight: 600;
    }

    /* Logged-out footer: Log in and Sign Up side by side in place of Refer a Friend / Log Out. */
    .bb-m__btns {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    .navbar .bb-m__btns a.bb-btn {
        flex: 1;
        text-align: center;
        color: #fff !important;
    }
}

/* ---------- Phones (820px and below): compact accordion and header, grouped menu only ---------- */

@media (max-width: 820px) {
    /* Header: smaller logo and padding, secondary row hidden (the panel footer has Refer a Friend, name, Log Out). */
    #masthead:has(#bb-nav) .nav-secondary {
        display: none;
    }

    .navbar.primary-menu:has(#bb-nav) {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .navbar:has(#bb-nav) .container {
        align-items: center;
    }

    .navbar:has(#bb-nav) .custom-logo {
        width: auto;
        height: auto;
        max-height: 36px;
    }

    #masthead:has(#bb-nav) .navbar.fixed-top + .space {
        height: 56px;
    }

    .navbar .bb-nav__burger {
        width: 44px;
        height: 38px;
    }

    /* Section rows */
    .navbar .bb-m__head {
        min-height: 52px;
        padding: 0 20px;
        font-size: 17px;
    }

    /* Items: two-column grid of compact tiles, no descriptions */
    .bb-m__body {
        padding: 0 10px 8px;
    }

    .bb-m__foot {
        padding-top: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .bb-m__body .bb-grp {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .bb-m__body .bb-grp__h {
        grid-column: 1 / -1;
        margin-bottom: -4px; /* pulls the first row up: the grid row-gap would otherwise add 8px under the heading */
        padding: 2px 2px 0;
        font-size: 12px;
        line-height: 1.1;
    }

    .bb-m__body .bb-grp + .bb-grp .bb-grp__h {
        padding-top: 6px;
    }

    .navbar .bb-m__body a.bb-item {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 6px 10px;
        background: rgba(255, 255, 255, .06);
    }

    .bb-m__body .bb-item__t {
        flex-wrap: nowrap;
        gap: 6px;
        font-size: 15px;
        line-height: 1.25;
    }

    .bb-m__body .bb-item__t > .bb-item__name {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }

    .bb-m__body .bb-item__d {
        display: none;
    }

    /* Locked: lock icon only. The tier text stays for screen readers (and on desktop). */
    .bb-m__body .bb-lock {
        flex: none;
        margin-left: auto;
        padding: 3px;
        font-size: 0;
        gap: 0;
    }

    .bb-m__body .bb-lock .bb-lock-ico {
        width: 12px;
        height: 12px;
    }
}

html.bb-nav-lock {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .bb-chev {
        transition: none;
    }
}
