/*
 * Strategic Capital — Mobile Navigation Hardening V1
 * Scope: mobile navigation reliability only.
 *
 * Invariants:
 * - sticky mobile header
 * - navigation outranks ordinary fixed conversion UI
 * - hamburger maintains safer right gutter
 * - guided-start UI cannot compete with an open nav
 * - background cannot scroll behind an open nav
 * - mobile nav height respects dynamic mobile viewport
 */

@media (max-width: 980px) {

  .site-header[data-site-header] {
    position: sticky !important;
    top: 0;
    z-index: 1600 !important;
    overflow: visible !important;
  }

  .site-header .nav-shell {
    overflow: visible !important;
  }

  .site-header .nav-toggle[data-nav-toggle] {
    position: relative;
    z-index: 1620 !important;

    /* Existing container gutter + this inset puts the control
       approximately 24px from the visual viewport edge. */
    margin-inline-start: auto;
    margin-inline-end: max(.5rem, env(safe-area-inset-right));

    touch-action: manipulation;
  }

  /* Navigation becomes the dominant ordinary UI layer only
     while explicitly open. */
  html.sc-nav-open .site-header[data-site-header] {
    z-index: 3000 !important;
  }

  html.sc-nav-open .site-header .primary-nav[data-nav-menu] {
    z-index: 3010 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    /* vh fallback first; modern mobile browsers then use dvh. */
    max-height: calc(100vh - 7.5rem) !important;
  }

  html.sc-nav-open .site-header .nav-toggle[data-nav-toggle] {
    z-index: 3020 !important;
  }

  @supports (height: 100dvh) {
    html.sc-nav-open .site-header .primary-nav[data-nav-menu] {
      max-height: calc(100dvh - 7.5rem) !important;
    }
  }

  /* Do not allow the page to move underneath an open menu. */
  html.sc-nav-open,
  html.sc-nav-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
  }

  /* Persistent conversion UI is subordinate to global navigation. */
  html.sc-nav-open .situation-widget {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Preserve accessibility priority above the sticky navigation. */
  .skip-link {
    z-index: 4000 !important;
  }
}

/* Explicitly leave desktop navigation outside this hotfix. */
