/**
 * Card #1520 — collapsible sections (Account, and any other menu item with
 * children) in the shared jkit nav-menu drawer/bar.
 *
 * The vendor widget (jeg-elementor-kit) ships its own "dropdown-open"
 * toggle class, but every CSS rule for it in the plugin's own stylesheet is
 * scoped under `body[data-elementor-device-mode=...]` — the Elementor
 * EDITOR's responsive-preview selector — so it has zero effect on the real
 * frontend a visitor sees. That's why Account's seven children previously
 * had no controllable collapsed state at all. This file owns show/hide
 * state independently via its own .bb-menu-expanded class instead of
 * depending on the vendor's dead one, and applies to any
 * `li.menu-item-has-children` inside `.jkit-menu` generically (not just
 * the item literally titled "Account") so future submenus collapse the
 * same way without another card.
 *
 * `.bb-cd-shared-menu`, `.bb-ad-shared-menu` and `.bb-id-shared-menu` are
 * included alongside `.jkit-menu` throughout this file because Coach,
 * Admin and Instructor Dashboards' own page templates bypass the sitewide
 * Elementor header entirely — each re-renders the exact same
 * main-navigation-menu itself via wp_nav_menu() under its own class
 * instead (coach-dashboard.php Card #1512, gm-dashboard.php Card #1521,
 * instructor-dashboard.php Card #1529). Same underlying WP nav-menu markup
 * (`li.menu-item-has-children` > `a` + `.sub-menu`), just a different
 * container class, so all four need the same rules. Card #1521
 * deliberately left `.bb-ad-shared-menu` out of this file ("making Account
 * collapsible is out of scope for this card"); Card #1528 folded it in so
 * GM Dashboard's Account section behaves identically to Member and
 * Coach Dashboard's instead of always rendering fully expanded. Card #1529
 * adds `.bb-id-shared-menu` for the same reason — Instructor Dashboard had
 * no Account content to collapse at all until that card gave it the
 * shared-menu render.
 */
/* Card #1643 — `.jkit-menu` (the sitewide widget that renders as the
   DESKTOP top nav bar at >=768px and as the mobile off-canvas drawer below
   that — same DOM, CSS-repositioned, see site-header-mobile.css) is
   deliberately NOT in this "closed at rest" selector any more. It used to
   be, unconditionally, and that was the bug: this rule's
   `display:none !important` always won over the vendor's own native hover
   reveal for the top nav (jeg-elementor-kit/assets/css/elements/main.css,
   confirmed live: `.jkit-menu li.menu-item-has-children:hover>.sub-menu
   {opacity:1;visibility:visible}`) — a `display:none` element can't be
   revealed by a sibling opacity/visibility rule, so hovering ACCOUNT could
   never show anything, and the only way to reveal it at all was the
   `.bb-menu-expanded` class from the drawer's click JS below. Whenever
   that class was left set from an earlier click/localStorage state, the
   panel rendered open with no way for :hover to intervene at all — the
   reported bug. On desktop this rest state is now left entirely to the
   vendor's own rule (opacity:0;visibility:hidden by default, already
   correctly closed there), restoring native hover. Below 767px — where
   `.jkit-menu` renders as the off-canvas drawer instead of the horizontal
   bar — it still needs this file's own display:none default in the
   media-scoped copy below: the vendor's real collapsed state only exists
   inside `body[data-elementor-device-mode=...]`, the Elementor editor's
   own responsive-preview selector, so it has zero effect on an actual
   mobile browser (Card #1520's original finding).
   `.bb-cd-shared-menu` / `.bb-ad-shared-menu` / `.bb-id-shared-menu` are
   the Coach/Admin/Instructor Dashboards' own custom drawers, not this
   vendor hover widget, at any width — unaffected, unscoped exactly as
   before. */
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
@media (max-width: 767px) {
    .jkit-menu > li.menu-item-has-children > .sub-menu {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }
}

/* The "expanded" reveal. Card #2755: for `.jkit-menu` it is scoped to the
   mobile drawer (<=767px) only — on the desktop top nav (>=768px) the toggle
   that sets `.bb-menu-expanded` is no longer shown (see the Card #2755 block
   at the end of this file), so a stale class left over from a phone-width
   session or old localStorage must not be able to pin the dropdown open with
   no control to close it; the vendor's own hover reveal owns that case. The
   three dashboard drawers (`.bb-cd/.bb-ad/.bb-id-shared-menu`) are drawers at
   every width and keep the unscoped reveal. Unlike the rest-state rule above,
   this one doesn't fight hover: hover is only ever consulted while
   `.bb-menu-expanded` is ABSENT. */
.bb-cd-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu,
.bb-ad-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu,
.bb-id-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}
@media (max-width: 767px) {
    .jkit-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* Below the mobile drawer breakpoint (matches tests/_helpers/account-menu.js's
   MOBILE_SUBMENU_BREAKPOINT), an expanded section lays out in normal flow —
   pushing later drawer items down — rather than floating as an absolutely
   positioned dropdown, so it reads as a true collapsible section over its
   children instead of an overlay. */
@media (max-width: 767px) {
    .jkit-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu,
    .bb-cd-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu,
    .bb-ad-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu,
    .bb-id-shared-menu > li.menu-item-has-children.bb-menu-expanded > .sub-menu {
        position: static !important;
        box-shadow: none !important;
    }
}

/* The vendor auto-appends its own decorative (non-functional) indicator
   icon inside the label link. In the mobile drawer (<=767px) it is hidden so
   only the one working chevron below shows. Card #2768: at >=768px (the
   desktop top nav) there is no chevron button at all, so the vendor icon is
   left visible and is the ONE caret next to Account; hiding it there (as this
   rule used to, at every width) left no indicator once #2755 removed the
   button. Jkit-widget-only — the wp_nav_menu() drawers never get this vendor
   markup in the first place. */
@media (max-width: 767px) {
    .jkit-menu > li.menu-item-has-children > a > i,
    .jkit-menu > li.menu-item-has-children > a > svg {
        display: none !important;
    }
}

/* ============================================================
   Card #1528 — Account row layout: label + toggle on one line
   ============================================================
   2nd attempt within this card. The 1st attempt kept flexbox but tried
   to stop the li's own `flex-wrap:wrap` from ever dropping the toggle
   onto a second line purely via `!important` width/flex-basis overrides
   on the anchor (countering jeg-elementor-kit's `.jkit-menu-wrapper
   .jkit-menu li>a{width:100%}`) — Ted's Phase 3 run still measured the
   toggle 90px below the label after that fix deployed live, meaning
   some other part of the vendor cascade this file hasn't identified was
   still winning that flex-basis/width race. Rather than keep guessing
   at the exact vendor rule responsible, this switches the li to CSS
   Grid, which has no "wrap" failure mode to race against in the first
   place: the label and the toggle are explicitly placed into named grid
   cells on the same row regardless of their own width/flex-basis, and
   the vendor's `width:100%` on the anchor now just fills its own
   "label" column (the intended result) instead of being able to push
   the toggle anywhere. The label <a> and the toggle <button> stay
   direct children of the li exactly as before (menu-drawer-collapse.js
   is unchanged) — this is CSS-only, so every existing `> a` /
   `> .bb-menu-toggle` locator across the other menu-drawer specs
   (#1520, #1521) keeps matching. */
.jkit-menu > li.menu-item-has-children,
.bb-cd-shared-menu > li.menu-item-has-children,
.bb-ad-shared-menu > li.menu-item-has-children,
.bb-id-shared-menu > li.menu-item-has-children {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-areas: "bb-label bb-toggle" "bb-submenu bb-submenu" !important;
    align-items: center !important;
    column-gap: 8px;
}
.jkit-menu > li.menu-item-has-children > a,
.bb-cd-shared-menu > li.menu-item-has-children > a,
.bb-ad-shared-menu > li.menu-item-has-children > a,
.bb-id-shared-menu > li.menu-item-has-children > a {
    grid-area: bb-label !important;
    /* Vendor `width:100%` now just fills this grid cell — kept explicit
       anyway so the anchor degrades safely even outside grid layout
       (e.g. a browser without grid support falling back to block flow). */
    width: auto !important;
    min-width: 0;
}
.jkit-menu > li.menu-item-has-children > .sub-menu,
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu {
    grid-area: bb-submenu !important;
    width: 100% !important;
}

/* ============================================================
   Card #1528 — structural defensive reset (the actual fix for the
   recurring "renders blue" bug, not just a patch on this one button)
   ============================================================
   Root cause, confirmed live (wp-content/uploads/elementor/css/post-1181.css,
   the active Elementor Kit's global CSS, loaded sitewide): the kit ships a
   bare, unscoped `button{...}` rule that paints ANY plain <button> element
   with `background-color: var(--e-global-color-primary)` — #072268, a navy
   blue — plus native appearance chrome. Card #1510 hit the exact same kit
   rule on the coach-roster buttons and fixed it there with !important +
   appearance resets; Card #1520 then added a brand-new <button> (this
   toggle) without repeating that treatment, so the same kit rule won again.
   That is the pattern this card is required to stop recurring a fourth
   time: instead of only patching .bb-menu-toggle below, every <button>
   anywhere inside the shared menu drawer or any of the three dashboards'
   own hamburger drawer sections gets an explicit brand-colored baseline.
   Wrapped in :where() so the container part of the selector contributes
   ZERO specificity — any future button-specific class (like
   .bb-menu-toggle itself) still wins over this baseline purely by having
   one more class in its selector, without needing to out-specificity an
   ID or a longer selector chain here. Every var(--brand-*) reference below
   carries its literal canonical hex as a second argument (Card #1510's
   fallback rule), so this still resolves to a brand color even if
   brand-colors.css fails to load. */
:where(.jkit-menu-wrapper, .bb-cd, .bb-id, .bb-ad) button {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background: var(--brand-black, #000000) !important;
    border: 1px solid var(--brand-red, #cd2727) !important;
    color: var(--brand-white, #ffffff) !important;
    outline: none;
}
:where(.jkit-menu-wrapper, .bb-cd, .bb-id, .bb-ad) button:focus-visible {
    /* Card #1969: brand red, keyboard-only via :focus-visible. */
    outline: 3px solid var(--brand-red, #cd2727) !important;
    outline-offset: 2px !important;
}

/* Card #1528 — same root cause, different tag: the Elementor kit's global
   CSS also leaves plain <a> elements to resolve their `color` (and, via
   `currentColor`, their unset border-color/outline-color) against its own
   navy `--e-global-color-primary` (#072268) rather than anything on brand.
   Ted's Phase 3 run caught this live on the Account submenu links
   (Edit Profile, Update Password, Refer a Friend, My Documents, Update
   Billing Info, Emergency Contacts, Logout) and the drawer's own logo
   link — none had ever been explicitly colored, so all fell back to the
   kit default the moment the computed-style audit actually looked. Same
   :where() zero-specificity wrapper as the button rule above: any link
   that already carries its own class-based color (the top-level nav
   items) keeps winning over this baseline untouched. */
:where(.jkit-menu-wrapper, .bb-cd, .bb-id, .bb-ad) a {
    color: var(--brand-white, #ffffff) !important;
    border-color: var(--brand-white, #ffffff) !important;
    outline-color: var(--brand-yellow, #fefd04) !important;
}

/* ============================================================
   Card #1567 — Account dropdown panel background (the other half of
   #1528's contrast pair)
   ============================================================
   #1528 forced the Account submenu links to brand-white so they'd stop
   resolving against the Elementor kit's navy `--e-global-color-primary`,
   but it only set the TEXT colour. The panel those links sit inside
   (`.sub-menu`) was never given a background anywhere in this file, so it
   kept the kit/theme's own near-white default — white text on a
   near-white panel, unreadable (reported live by the owner, Card #1567).
   This gives the panel an explicit brand-black background so #1528's
   white text has something to read against (21:1 contrast, well past
   WCAG AA's 4.5:1). Same selector list already used for this panel's
   display/grid rules above, so it reaches every place the shared menu
   renders: the sitewide header (.jkit-menu, Member Dashboard included)
   and the Coach/Admin/Instructor dashboards' own drawer copies. The
   drawer copies already sit inside a dark `.tools-panel` (#1a1a1a / grey),
   so this doesn't change whether they read correctly, only makes the
   submenu panel colour explicit and consistent everywhere instead of
   inherited-and-incidental in three places and missing in the fourth.

   The near-white paint isn't only on the outer `.sub-menu` panel, though —
   confirmed live against the deployed widget-instance stylesheet
   (wp-content/uploads/elementor/css/post-485.css): the vendor also sets
   `background-color` directly on each `.sub-menu li > a`
   (`var(--e-global-color-8d04e73)`, #F0F0F0) so every row repaints itself
   near-white regardless of what the panel underneath does. Both rules are
   required together — panel background alone would still leave every row
   individually near-white. */
.jkit-menu > li.menu-item-has-children > .sub-menu,
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu,
.jkit-menu > li.menu-item-has-children > .sub-menu a,
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu a,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu a,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu a {
    background: var(--brand-black, #000000) !important;
}

/* Hover/focus states for the links inside that panel, explicitly on
   palette — the base `a` rule above already covers the resting and
   focus-visible outline colour, but hover/:focus need their own explicit
   colours too or they fall back to the kit's navy currentColor default,
   same failure mode as #1528 fixed for the resting state. Red panel
   background + white text keeps contrast high and matches the existing
   hover treatment used elsewhere in the dashboards (e.g. the cancel
   button's dark-to-red hover). Scoped to `.sub-menu` links only, so the
   top-level nav items (MEMBER DASHBOARD, SESSION CONTROL, ACCOUNT, etc.)
   are untouched — this selector can't reach them regardless of
   specificity since they aren't inside a `.sub-menu`. */
.jkit-menu > li.menu-item-has-children > .sub-menu a:hover,
.jkit-menu > li.menu-item-has-children > .sub-menu a:focus,
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu a:hover,
.bb-cd-shared-menu > li.menu-item-has-children > .sub-menu a:focus,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu a:hover,
.bb-ad-shared-menu > li.menu-item-has-children > .sub-menu a:focus,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu a:hover,
.bb-id-shared-menu > li.menu-item-has-children > .sub-menu a:focus {
    background: var(--brand-red, #cd2727) !important;
    color: var(--brand-white, #ffffff) !important;
    border-color: var(--brand-white, #ffffff) !important;
}

/* ============================================================
   Card #1528 — the Account toggle itself: compact, chevron-sized,
   transparent (not the solid-block baseline above), brand-safe.
   Every property that could let the kit's bare `button` rule (or its
   appearance/padding/border-radius) bleed through is set explicitly with
   !important, matching the Card #1510 precedent for this exact class of
   bug. `.bb-menu-toggle` (one class, specificity 0-1-0) beats the
   defensive baseline above (:where(...) button — :where() always
   contributes zero specificity, so that selector is just the type
   selector `button`, specificity 0-0-1) regardless of declaration order,
   so the toggle keeps its own compact look instead of the solid
   brand-block default. */
.bb-menu-toggle {
    grid-area: bb-toggle !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    margin: 0 0 0 auto !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 4px !important;
    box-shadow: none !important;
    color: inherit !important;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
}
.bb-menu-toggle:hover,
.bb-menu-toggle:focus {
    background: rgba(255, 255, 255, 0.12) !important;
}
.bb-menu-toggle:focus-visible {
    outline: 3px solid var(--brand-red, #cd2727) !important;
    outline-offset: 2px;
}
.bb-menu-toggle-chevron {
    display: inline-block;
    transition: transform .2s ease;
}
.bb-menu-toggle[aria-expanded="true"] .bb-menu-toggle-chevron {
    transform: rotate(180deg);
}

/* ============================================================
   Card #1576 — mobile hamburger drawer panel background (the OTHER
   near-white panel, one level up from #1567's Account submenu fix)
   ============================================================
   #1528 forced every `<a>` and `<button>` inside `.jkit-menu-wrapper`
   to brand-white text (the `:where()` rules above) so links would
   stop resolving to the Elementor kit's navy default, and #1567 gave
   the Account submenu's own panel (`.sub-menu`) an explicit black
   background so that white text had something dark to read against.
   Neither card touched the OUTER off-canvas drawer panel itself,
   though — confirmed live against the deployed vendor stylesheet
   (jeg-elementor-kit/assets/css/elements/main.css, inside its own
   `@media screen and (max-width:768px)` block): `.jkit-menu-wrapper`
   is painted `background-color:#f7f7f7` (near-white) there, with no
   override anywhere in this plugin. So every TOP-LEVEL item
   (Instructors, Hitting League, Roadmap, Member/Coach/Instructor/
   GM Dashboard, Session Control, Account) rendered white text on
   a near-white panel — reported live by the owner, Card #1576. This
   mirrors #1567's fix one level up: an explicit brand-black
   background on the drawer panel itself so #1528's white text is
   finally readable (21:1 contrast, well past WCAG AA's 4.5:1).
   Mobile-only (matches the 767px convention already used by this
   file and site-header-mobile.css, one px inside the vendor's own
   768px off-canvas breakpoint) so desktop's inline horizontal bar —
   a different layout where `.jkit-menu-wrapper` never gets that
   vendor background in the first place — is untouched. */
@media (max-width: 767px) {
    .jkit-menu-wrapper {
        background-color: var(--brand-black, #000000) !important;
    }
}

/* Card #1520 fix (found via live staging inspection, not repro'd locally —
   Ted's Phase 3 run confirms): the sitewide header's `.jkit-menu-wrapper`
   already declares `z-index:1000` in the vendor's own stylesheet, but never
   pairs it with a `position`, so on desktop (where the wrapper is plain
   static, unlike its own `position:fixed` mobile off-canvas rule) that
   z-index is inert — z-index only affects positioned elements. The nav row
   holds nine items at full width and already overflows its own 33% header
   column well past "Account" regardless of this card; a later sibling
   column (the search box) then paints on top of that overflow in plain DOM
   order, which can swallow clicks/taps meant for nav items sitting in the
   overlap — including Account's new toggle button. Giving the wrapper a
   real stacking context here just lets the vendor's already-declared
   z-index do what it was always meant to, with no visual offset and no
   change to the mobile fixed-panel rule in its own breakpoint. */
@media (min-width: 768px) {
    .jkit-menu-wrapper {
        position: relative;
        z-index: 1000;
    }
}

/* ============================================================
   Card #2755 — no Account toggle on the desktop top nav
   ============================================================
   The `.bb-menu-toggle` chevron (Card #1520) exists for the mobile drawer:
   measured on staging, the vendor's `dropdown-open` reveal rules are all
   scoped under `body[data-elementor-device-mode=...]` (the Elementor editor
   preview) and the `max-width:767px` rule above forces every `.jkit-menu`
   submenu to `display:none !important`, so below 768px the chevron is the
   ONLY way to open Account. At >=768px `.jkit-menu` is the horizontal top
   nav and the vendor's native `li.menu-item-has-children:hover>.sub-menu`
   reveal works, which made the bordered caret a redundant second control
   that also collided with the next nav item. It is hidden there on purpose
   (this rule), not incidentally; `display:none` also removes it from the
   tab order and the accessibility tree. The grid row collapses to a single
   column so no empty 8px toggle gutter is left behind. The dashboards'
   own drawers (`.bb-cd/.bb-ad/.bb-id-shared-menu`) are drawers at every
   width and keep their toggle. Breakpoint matches the 768px convention in
   menu-drawer-collapse.js (isDesktopJkitTopNav) and site-header-mobile.css. */
@media (min-width: 768px) {
    .jkit-menu > li.menu-item-has-children > .bb-menu-toggle {
        display: none !important;
    }
    .jkit-menu > li.menu-item-has-children {
        grid-template-columns: 1fr !important;
        grid-template-areas: "bb-label" "bb-submenu" !important;
        column-gap: 0 !important;
    }
    /* The chevron was also the keyboard route to the dropdown (the vendor
       reveal is hover-only, no :focus-within). Keyboard focus anywhere in the
       item now reveals it too. :focus-visible, not :focus, so a mouse click
       on ACCOUNT does not pin the panel open after the pointer leaves.
       !important because the vendor's closed state is a 7-class selector
       (.jeg-elementor-kit.jkit-nav-menu .jkit-menu-wrapper .jkit-menu li...)
       that outranks this rule on specificity alone. */
    .jkit-menu > li.menu-item-has-children:has(:focus-visible) > .sub-menu {
        opacity: 1 !important;
        visibility: visible !important;
    }
}

/* ============================================================
   Card #2768 — one caret, and tap still works, on the desktop top nav
   ============================================================
   menu-drawer-collapse.js no longer builds the `.bb-menu-toggle` button
   while the sitewide `.jkit-menu` is the desktop top nav (>=768px), and
   removes it when the viewport crosses up to that width, so the nav shows
   only the vendor's own caret inside the Account label. The #2755
   `display:none` rule above stays as a backstop for the moment before the
   script runs. Touch/pen/keyboard activation of the label adds
   `.bb-menu-touch-open` (see the JS), which reveals the panel the same way
   hover does; a tap elsewhere removes it. Not persisted, so it can never pin
   the panel open on a later load. */
@media (min-width: 768px) {
    .jkit-menu > li.menu-item-has-children.bb-menu-touch-open > .sub-menu {
        opacity: 1 !important;
        visibility: visible !important;
    }
}
