/* ==========================================================================
   Mobile / tablet header menu (hamburger), shared by every page.
   Applies only at 1200px and below. Desktop header is not changed.
   - Toggle: three-line icon morphs into an X while the menu is open.
   - Panel: fixed below the header, full width, scrolls inside itself,
     never clipped, never behind page content (z-index above the page).
   - Scroll: page scrolling is locked while the menu is open.
   - Closing: tapping a link or the X closes it (handled in site.js).
   ========================================================================== */

/* Height of the header bar; the menu opens directly below it */
:root {
  --mm-top: 85px; /* measured header height at 721–1200px, including its 1px border */
}

@media (max-width: 1200px) {
  /* Backdrop: dims the page below the header while the menu is open.
     Sits under the header (z 60) and under the menu panel (z 55 inside the header). */
  body.nav-open::before {
    content: "";
    position: fixed;
    top: var(--mm-top);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 41, 75, .38);
    z-index: 54;
    pointer-events: auto;
  }
  /* Floating buttons would sit above the open menu: hide them while it is open */
  body.nav-open .mobile-apply,
  body.nav-open .tiger-help,
  body.nav-open .to-top {
    display: none !important;
  }
  /* Lock background scrolling while the menu is open. site.js pins the body at the
     current scroll position (inline top), so touch and wheel scrolling cannot move the page. */
  html:has(body.nav-open) {
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.nav-open {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
    /* the header is pinned (below) so it stays out of the locked body; keep the page's
       content where it was by reserving the header's height */
    padding-top: var(--mm-top);
  }
  /* While the menu is open the header is fixed to the top of the screen, so it stays
     visible even when the page was scrolled before the menu was opened. */
  body.nav-open .site-header {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    right: 0;
    z-index: 60;
  }

  /* ----- hamburger toggle ----- */
  .site-header .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    min-width: 46px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-radius: 12px;
    background: transparent !important;
    box-shadow: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .site-header .menu-toggle span {
    position: absolute;
    left: 12px;
    top: 50%;
    width: 22px;
    height: 2px;
    margin-top: -1px;
    border-radius: 2px;
    background: var(--hp-navy);
    transition: background-color .2s ease;
  }
  .site-header .menu-toggle span::before,
  .site-header .menu-toggle span::after {
    content: "";
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: var(--hp-navy);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1), top .3s ease;
  }
  .site-header .menu-toggle span::before { top: -7px; }
  .site-header .menu-toggle span::after { top: 7px; }
  .site-header .menu-toggle:focus-visible {
    outline: 2px solid var(--hp-orange);
    outline-offset: 3px;
  }

  /* open state: three lines become an X */
  body.nav-open .site-header .menu-toggle span {
    background: transparent;
  }
  body.nav-open .site-header .menu-toggle span::before {
    top: 0;
    transform: rotate(45deg);
  }
  body.nav-open .site-header .menu-toggle span::after {
    top: 0;
    transform: rotate(-45deg);
  }

  /* ----- menu panel ----- */
  .site-header .main-nav {
    display: none !important;
  }
  body.nav-open .site-header .main-nav {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    position: fixed;
    top: var(--mm-top);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    margin: 0;
    padding: 8px 20px 36px;
    box-sizing: border-box;
    background: #fbf8f1;
    border: 0;
    border-top: 1px solid var(--hp-rule);
    box-shadow: none;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    z-index: 55;
  }
  body.nav-open {
    overflow: hidden;
  }

  .site-header .main-nav > ul.hp-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .site-header .hp-menu > li {
    width: 100%;
    border-bottom: 1px solid var(--hp-rule);
  }
  .site-header .hp-menu .nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 4px;
    font-size: 19px;
    line-height: 1.3;
    white-space: normal;
    color: var(--hp-navy);
  }
  .site-header .has-dd > .nav-link::after {
    margin-left: auto;
  }

  /* submenus open on tap (site.js adds .open) */
  .site-header .hp-sub {
    position: static !important;
    display: none;
    min-width: 0;
    margin: 0;
    padding: 0 0 10px 12px;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    list-style: none;
  }
  .site-header .has-dd.open > .hp-sub {
    display: block;
  }
  .site-header .hp-sub a {
    display: block;
    padding: 10px 6px;
    font-size: 17px;
    color: #1c2d47;
    white-space: normal;
  }

  .site-header .hp-mobile-cta {
    display: block !important;
    padding: 24px 0 0;
    border: 0;
  }
  .site-header .hp-mobile-cta a {
    width: 100%;
    justify-content: center;
  }
}

/* header is 76px tall on phones */
@media (max-width: 720px) {
  :root {
    --mm-top: 77px; /* measured header height at phone widths, including its 1px border */
  }
}
