/* MegaMenu — ported from Pawn Marketplace v3.0.1 (2026-10-06), translated to v3.1 conventions. */

/* ================================================================
   1. The blue dropdown (Components/MegaMenu.razor), 768px and up.
   v3.0.1 Nav.css (.fc-megamenu*) for the look and motion; v3.1 for tokens, the 8px scale, the ☰
   z-index layer and the header-follow anchors. Phones (≤767) never show it: they keep v3.1's own
   menu sheets (section 3 below).
   ================================================================ */

/* Transparent click-catcher below the header: a click outside the panel closes it. */
.fc-megamenu-backdrop {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* 768–1024 (web) and the app: under the small/native header, following its hide/reveal on the
       header's own curve (Home.css --native-header-offset; 0 while the header is hidden). */
    top: var(--native-header-offset, 0px);
    z-index: 1299;
    transition: top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fc-megamenu-backdrop--closing { pointer-events: none; }

.fc-megamenu {
    /* Text on the brand blue (#004FAA). One-line changes, pending Kelly's sign-off:
       description + links .85 white = 6.1:1 (v3.0.1's .6 description was 3.8:1, failing AA at 14px);
       chevron .6 white = 3.8:1 (decorative, aria-hidden);
       column-head icons white = 7.8:1, like v3.1's header icons (Home.css .topbar-tab-icon). v3.0.1's
       brand red (--color-brand-accent #B50407) is 1.1:1 on this blue, so the icons all but vanished. */
    --fc-mega-icon-color: var(--color-surface-default);
    --fc-mega-desc-color: rgba(255, 255, 255, 0.85);
    --fc-mega-link-color: rgba(255, 255, 255, 0.85);
    --fc-mega-chev-color: rgba(255, 255, 255, 0.6);
    --fc-mega-rule-color: rgba(255, 255, 255, 0.2);
    --fc-mega-hover-bg: rgba(255, 255, 255, 0.12);   /* v3.1's white wash on blue (PressFeedback.css) */

    position: fixed;
    left: 0;
    right: 0;
    top: var(--native-header-offset, 0px);
    z-index: 1300;
    max-height: calc(100dvh - var(--native-header-offset, 0px));
    overflow-y: auto;
    box-sizing: border-box;
    padding: var(--space-4) 0;
    background: var(--color-topbar-bg);
    /* Bottom-only shadow (negative spread) — v3.0.1 literal, no v3.1 token matches it (flagged). */
    box-shadow: 0 16px 24px -12px rgba(0, 0, 0, 0.35);
    /* Entrance: v3.0.1 fc-mega-in, 0.2s ease. Exit: the same move reversed, as a TRANSITION, so a
       re-open during the exit reverses from where it is instead of restarting from 0 (v3.0.1 flicker). */
    animation: fc-mega-in 0.2s ease;
    transition: opacity 0.2s ease, transform 0.2s ease, top 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fc-megamenu.fc-megamenu--closing {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
}
@keyframes fc-mega-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── While the menu is open, the header outranks it ───────────────────────────────────────────
   #native-sticky-header is `position: fixed; z-index: 1000` (Home.css), which makes it a STACKING
   CONTEXT. Everything inside it therefore composites at 1000, including the tooltip bubbles on its
   icon buttons — so Tooltip.css's `z-index: 10000` on [data-tooltip]::after is capped at 1000 no
   matter how large that number is, and this panel at 1300 painted straight over it. The bubble
   hangs 8px BELOW its button, which on an iPad puts it past y=122 — exactly where this panel
   starts (measured: header bottom 122, panel top 122) — so long-pressing the hamburger showed a
   tooltip sliced off at the panel's top edge.

   Raising the header is the only fix available: a pseudo-element cannot escape its ancestor's
   stacking context, so no change to Tooltip.css could have worked.

   Gated on `html:has(.fc-megamenu)`, which is exactly "menu open or closing" — the panel is removed
   from the DOM otherwise (verified on device). So the header keeps z-index 1000 at every other
   moment and nothing else that is meant to cover it (dialogs, drawers, toasts) is affected.
   Nothing else about the open state changes either: the two never overlap geometrically, the
   panel's top IS the header's bottom. The only other difference is the 0.2s slide-in, which starts
   at translateY(-8px) and now correctly emerges from UNDER the header instead of across it. */
html:has(.fc-megamenu) #native-sticky-header { z-index: 1301; }

/* Desktop web (≥1025): directly under #topbar_large_screen, following its hide/reveal (Home.css
   html.fc-header-hidden, 0.42s). The app never measures --fc-appbar-h, so an iPad in landscape keeps
   the native-header anchor above. */
@media (min-width: 1025px) {
    html:not(:has(.page.has-bottomnav)) .fc-megamenu-backdrop {
        top: var(--fc-appbar-h, 100px);
        transition: top 0.42s cubic-bezier(0.4, 0, 0.2, 1);
    }
    html:not(:has(.page.has-bottomnav)) .fc-megamenu {
        top: var(--fc-appbar-h, 100px);
        max-height: calc(100dvh - var(--fc-appbar-h, 100px));
        transition: opacity 0.2s ease, transform 0.2s ease, top 0.42s cubic-bezier(0.4, 0, 0.2, 1);
    }
    html.fc-header-hidden:not(:has(.page.has-bottomnav)) .fc-megamenu-backdrop,
    html.fc-header-hidden:not(:has(.page.has-bottomnav)) .fc-megamenu {
        top: 0;
    }
}

@media (max-width: 767px) {
    .fc-megamenu-backdrop,
    .fc-megamenu { display: none; }
}

/* Same 1280px box and 16px inset as the header row, so the columns line up with it. */
.fc-megamenu-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-2);
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    align-items: start;
}
.fc-mega-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
/* Column heads: non-interactive headings (no button, no tab stop). */
.fc-mega-col-head {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin: 0;
    padding: 0 var(--space-2);
    font-family: var(--font-heading);
    font-size: var(--text-body-md-size);
    line-height: var(--text-body-md-lh);
    font-weight: var(--fw-bold);
    color: var(--color-surface-default);
}
.fc-mega-icon {
    font-size: 18px;
    color: var(--fc-mega-icon-color);
}
.fc-mega-desc {
    margin: var(--space-1) 0;
    padding: 0 var(--space-2) var(--space-1);
    border-bottom: 1px solid var(--fc-mega-rule-color);
    font-family: var(--font-body);
    font-size: var(--text-label-md-size);
    line-height: var(--text-label-md-lh);
    color: var(--fc-mega-desc-color);
}
.fc-mega-col-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.fc-mega-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-1);
    width: 100%;
    box-sizing: border-box;
    padding: var(--space-1) var(--space-2);
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    text-align: left;
    font-family: var(--font-body);
    font-size: var(--text-label-md-size);
    line-height: var(--text-label-md-lh);
    color: var(--fc-mega-link-color);
    transition: background-color 0.15s ease;
}
.fc-mega-link i {
    flex-shrink: 0;
    font-size: 16px;
    color: var(--fc-mega-chev-color);
}
@media (hover: hover) {
    .fc-mega-link:hover { background: var(--fc-mega-hover-bg); }
}
/* Press: scale only, no darken. This is v3.1's on-blue rule (PressFeedback.css, the Set Location chip):
   the catch-all's brightness(.8) would only dim the white text. (0,2,0) beats the catch-all's (0,1,1). */
.fc-mega-link:active {
    transform: scale(0.99);
    filter: none;
}

@media (prefers-reduced-motion: reduce) {
    .fc-megamenu,
    .fc-megamenu-backdrop {
        animation: none;
        transition: none !important;
    }
}

/* ================================================================
   2. Desktop Menu tab (#menu_tab, Topbar ≥1025) — open state.
   v3.1 .topbar-tab-container look (Home.css) plus v3.0.1's open state: a white highlight that also
   wins over :hover (the --active:hover pattern), fading on the tab's own 0.15s; bars ↔ ✕ swap is instant.
   ================================================================ */
.topbar-tab-container--open,
.topbar-tab-container--open:hover {
    background: rgba(255, 255, 255, 0.2);
}
#menu_tab:not(.topbar-tab-container--open) .fc-menutab-x,
#menu_tab.topbar-tab-container--open .fc-menutab-bars {
    display: none;
}

/* ================================================================
   3. Phone menus (≤767) — Layaway + the Pawn Loans accordion, added to v3.1's existing ☰ sheets
   (Topbar's drawer, NativeHeader's sheet) in their own row style (Home.css .drawer_*).
   ================================================================ */

/* The new rows are real <button>s (keyboard + aria-expanded): strip the UA chrome so they read
   exactly like the sheet's existing rows. */
button.drawer_items_div {
    border: none;
    background: none;
    font: inherit;
    color: inherit;
}
/* MudBlazor.min.css centres every button (`button { justify-content: center }`), so the plain rows
   (Information Center, My Profile, Saved, Store Locator, Sign In / Sign Out) moved to the middle once
   they became buttons. Start them at the left, where they sat as <div>s. button:where() weighs the
   same as MudBlazor's `button` and loads after it, so this wins; the chevron rows' space-between
   (.drawer_shop_online, .fc-menu-sublink) weighs more and still wins over this. */
button:where(.drawer_items_div) {
    justify-content: flex-start;
}
/* Touch screens keep :hover on a tapped element. The accordion head toggles in place (every other
   row closes the sheet), so Home.css's ungated .drawer_items_div:hover grey would stick to it. This
   applies to the new head only. */
@media (hover: none) {
    .fc-menu-acc > .drawer_items_div:hover { background: none; }
}

/* The accordion sits 8px under the row above it, like every other row (.drawer_items_div + .drawer_items_div). */
.drawer_items_div + .fc-menu-acc {
    margin-top: var(--space-1);
}
.fc-menu-acc-chev {
    opacity: 1;                          /* a toggle, not a link: full strength (v3.0.1) */
    transition: transform 0.25s ease;
}
.fc-menu-acc--open .fc-menu-acc-chev {
    transform: rotate(180deg);
}
/* Opens and closes like v3.1's sheet accordions (Sort & Filter, app.css): grid rows 0fr → 1fr. */
.fc-menu-acc-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.fc-menu-acc--open .fc-menu-acc-panel {
    grid-template-rows: 1fr;
}
/* Collapsed links leave the tab order once the close has finished. */
.fc-menu-acc-inner {
    min-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: visibility 0s linear 0.28s;
}
.fc-menu-acc--open .fc-menu-acc-inner {
    visibility: visible;
    transition-delay: 0s;
}
.fc-menu-acc-inner > .drawer_items_div:first-child {
    margin-top: var(--space-1);
}
/* Sub-links: 40px indent = 8 row padding + 24 icon box + 8 gap, so labels line up with the parent's. */
.fc-menu-sublink {
    justify-content: space-between;
    padding-left: var(--space-5);
}
/* The inner clips (overflow: hidden), so the focus ring is drawn inside the row. */
.fc-menu-acc-inner .fc-menu-sublink:focus-visible {
    outline-offset: -2px !important;
}
/* App sheet: its item list scrolls (overflow auto, no side padding), which also clipped the left and right of
   the ring on the new button rows (Layaway, Pawn Loans header, Notifications). Same inside-the-row ring. */
.fc-native-menu .drawer_items > button.drawer_items_div:focus-visible,
.fc-native-menu .fc-menu-acc > button.drawer_items_div:focus-visible {
    outline-offset: -2px !important;
}

@media (prefers-reduced-motion: reduce) {
    .fc-menu-acc-chev,
    .fc-menu-acc-panel,
    .fc-menu-acc-inner { transition: none; }
}
