/* Mobile menu: Stripe-style full-screen overlay + single-level accordion
   ---------------------------------------------------------------------------
   Reference = Stripe mobile navigation: full-screen overlay, a single vertical list, each row expands its sub-items in place with + / −,
               navigation and page content never appear at the same time, the CTA stays at the bottom of the list
   Change    = the panel becomes position:fixed inset:0 covering the whole viewport (it used to be a dropdown below the header);
               one accordion level (the original needed three levels: "navigation bar → view all N items → groups → items")
   Reason    = the original design drew "navigation" and "the current category's content" as the same left-aligned dark text, separated only by a 1px line,
               so users could not tell where the switch was and where the content was; measured, the old content was 978px tall with 375px visible, needing 2.6 screens of scrolling.
               Now only one level is shown at a time, the navigation stays at a fixed 5 rows, and content appears only when expanded.

   Sizes follow the project rules: touch row height ≥ 44px (actually 56 / 48px), text links 16px, body 400.
   Colors reuse styles/tokens/figma-tokens.css: --figma-text-primary / secondary / accent (#005AFF),
   --figma-border-primary.

   This file is loaded last in index.html (after the other component styles), so rules of the same specificity
   win over the old @media (width < 55rem) blocks in style.css / menu-layout.css.       */

/* ── 1. Overlay itself: from a "dropdown panel below the header" to full screen ── */
@media (width < 55rem) {
  .mega-panel {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    max-height: none;          /* Overrides calc(100dvh - 66px) in style.css */
    padding-top: 66px;         /* Make room for the header floating on top (logo + X) */
    background: #fff;          /* Pure white; do not use the light blue-gray tint of --figma-bg-primary, a full-screen mobile panel should be clean */
    box-shadow: none;
    border-bottom:0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  /* The header's original z-index:30 would be covered by the panel (31); in full screen the logo and X must float above the panel */
  .site-header { z-index: 32; }
  /* In a drill-down sub-screen the header's logo position becomes a back arrow (reference: Stripe puts the back button at the logo position, instead of adding another row inside the panel content) */
  .brand--back {
    justify-content: center;
    width: var(--spacing-11);
    height: var(--spacing-11);
    padding: 0;
    border-radius:var(--radius-full);
  }
  .brand--back:hover { background:var(--background); }
  .brand--back svg { width: var(--spacing-5); height: var(--spacing-5); color: var(--foreground); }
  /* The three icon buttons on the right of the header (hamburger, search, back) share one size: a 44×44 touch area.
     They used to keep the old style.css sizes (hamburger 42px, search 38px, back 40px), which looked inconsistent */
  .mobile-toggle {
    width: var(--spacing-11);
    height: var(--spacing-11);
    align-items: center;
    color: var(--foreground); /* The lines use currentColor, the same color source as the search icon */
  }
  #search-open.icon-button {
    width: var(--spacing-11);
    height: var(--spacing-11);
  }
  /* The background page must not scroll (inert is set by setBackgroundInert() in app.js,
     which blocks both keyboard and pointer; this only locks scrolling) */
  body.mobile-menu-open { overflow: hidden; }
  /* The demo's chat input is fixed to the bottom and would cover the newly bottom-attached guide row while the menu is open, so hide it for now */
  body.mobile-menu-open .chat-dock { display: none; }
}

/* ── 2. Hamburger → X ── */
@media (width < 55rem) {
  .mobile-toggle span {
    transition: transform .22s cubic-bezier(.22, 1, .36, 1), opacity .16s ease;
  }
  /* Three lines: the top and bottom lines each move 8px (adjacent line height + gap) to the middle line and cross into an X, the middle line fades out */
  .mobile-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .mobile-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .mobile-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  /* The React version's three lines are SVG (fixed 1.5px stroke, consistent with other icons) and move the same way: top and bottom each move 6px and cross into an X, the middle fades out */
  .mobile-toggle .mobile-toggle-bars { display: block; width: var(--spacing-5); height: var(--spacing-5); flex: none; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.5px; stroke-linecap: round; }
  .mobile-toggle .mobile-toggle-bars line { vector-effect: non-scaling-stroke; transform-box: fill-box; transform-origin: center; transition: transform .22s cubic-bezier(.22, 1, .36, 1), opacity .16s ease; }
  .mobile-toggle[aria-expanded="true"] line:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .mobile-toggle[aria-expanded="true"] line:nth-child(2) { opacity: 0; }
  .mobile-toggle[aria-expanded="true"] line:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
}

/* ── 3. List skeleton: flex column, so .mobile-foot sticks to the bottom of the panel (when content is short, margin-top:auto pushes it down;
   when content exceeds one screen, sticky keeps it visible after scrolling to the end, like Stripe mobile's sticky bottom CTA) ── */
.mobile-menu {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 66px);
  padding: 0;
  background:var(--card);
}
.mobile-list { display: block; padding-bottom: var(--spacing-6); }   /* When scrolled to the bottom, leave space between the last row and the sticky bottom button */

/* ── 4. Top-level row: 56px touch height, 16px / 600 ── */
/* The top-level row (.mobile-row) and its arrow on the right have moved into the root styles of UI-components/CMP-01_header-mega-menu/list-row.tsx, so they are no longer written here */

/* ── 5. The drill-down sub-screen no longer shows the category title (the header's back arrow already indicates "you are in a sub-screen", see .brand--back),
   the list starts directly with the first group ── */

/* Group title: not a button, only a section hint. 12px / 600, no letter-spacing for Chinese */
.mobile-group-label {
  margin: 0;
  padding: var(--spacing-4) var(--container-padding) var(--spacing-1);
  color: var(--muted-foreground);
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  letter-spacing: 0;
}
.mobile-group:first-child .mobile-group-label { padding-top: var(--spacing-5); }
/* Divider: a line between group blocks. Uses ::before with absolute positioning inset 20px on both sides (not full width),
   with margin / padding above and below to open up the spacing, so it does not feel too crowded against the surrounding content */
.mobile-group + .mobile-group {
  position: relative;
  margin-top: var(--spacing-5);
  padding-top: var(--spacing-5);
}
.mobile-group + .mobile-group::before {
  content: '';
  position: absolute;
  top: 0;
  left: var(--container-padding);
  right: var(--container-padding);
  height: 1px;
  background:var(--border);
}

/* ── 6. Sub-items (the mobile version of .item-button) have moved into the drill styles of UI-components/CMP-01_header-mega-menu/list-row.tsx, so they are no longer written here ── */

/* The "View all / Compare…" row (.mobile-more) has moved into the more styles of UI-components/CMP-01_header-mega-menu/list-row.tsx (the divider of the last row is `divider`), so it is no longer written here */

/* ── 7. Bottom: Consultation (solid button, always shown) + "Not sure where to start?" card (shown only on first open)
   Sticks to the panel bottom: margin-top:auto pushes short content down, position:sticky keeps it fixed at the bottom while long content scrolls ── */
.mobile-foot {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  padding: var(--spacing-4) var(--container-padding) max(var(--spacing-4), env(safe-area-inset-bottom));
  border-top:1px solid var(--border);
  background:var(--card);
}
/* Consultation: uses the same .a-cta solid blue button as the framework (same as the header), full width on mobile */
.mobile-cta-btn { width: 100%; }

/* "Not sure where to start?": attached below the last row of the list (Resources), no card, text + link on one line (baseline aligned, same rule as .mega-bar-guide in menu-layout.css) */
.mobile-guide {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--spacing-1) var(--spacing-2-5);
  padding: var(--spacing-4) var(--container-padding) var(--spacing-5);
}
.mobile-guide-prompt {
  color: var(--muted-foreground);
  font-size: var(--font-size-16);
  font-weight: var(--font-weight-regular);
  line-height: 1.5;
}
/* "Help me choose a plan" is the link style of the React Button (color, weight and hover all come from the component, consistent with the text links of the desktop menu); here only the font size and line height are aligned with the hint text above (16px / 24px) */
.mobile-guide { --button-link-size: var(--spacing-4); --button-link-lh: 24px; }

/* ── 8. Accessibility: respect reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .mobile-toggle span, .mobile-toggle line { transition: none; }
}
