/**
 * Shared main header (header.php / header2.php). Requires
 * <header class="main-header wam-isolated-nav"> so rules stay scoped and beat page bundles
 * (e.g. new-design.css) without inheriting unrelated typography.
 * Hamburger + collapse work on BS3/BS5; megamenus stack on small screens.
 */

html body header.main-header.wam-isolated-nav .navbar-toggler .wam-menu-icon {
  display: block;
  flex-shrink: 0;
}

html body header.main-header.wam-isolated-nav.fixed .navbar-toggler,
html body header.main-header.wam-isolated-nav.fixed .navbar-toggle {
  color: #fff;
}

/* Keep icon visible on orange bar (some themes zero out button opacity) */
html body header.main-header.wam-isolated-nav.fixed .navbar-toggler .wam-menu-icon,
html body header.main-header.wam-isolated-nav.fixed .navbar-toggle .wam-menu-icon {
  opacity: 1;
}

@media (max-width: 991.98px) {
  /* main.css forces logo img min ~13rem — eats the row and hides the hamburger on small screens */
  html body header.main-header.wam-isolated-nav {
    line-height: normal;
  }

  html body header.main-header.wam-isolated-nav .navbar.navbar-expand-lg.megamenu,
  html body header.main-header.wam-isolated-nav .navbar.megamenu {
    padding-top: 0.95rem !important;
    padding-bottom: 0.95rem !important;
    min-height: 4.5rem;
    align-items: center !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-brand {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 3.5rem);
    margin-right: 0;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-brand img {
    width: auto !important;
    max-width: min(58vw, 12rem) !important;
    max-height: 48px !important;
    height: auto !important;
    object-fit: contain;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-toggler,
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0 !important;
    position: relative;
    z-index: 6;
    padding: 0.55rem 0.7rem !important;
    min-width: 2.85rem;
    min-height: 2.85rem;
  }

  /* Menu open: .fixed still forced white on toggler — icon vanishes on white top bar; keep dark while expanded */
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggler[aria-expanded="true"],
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggle[aria-expanded="true"],
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggler:not(.collapsed),
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggle:not(.collapsed) {
    color: #1a1a1a !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-nav {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    padding-right: 0 !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-nav > .nav-item {
    width: 100%;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    float: none !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-nav > .nav-item:last-of-type {
    border-bottom: 0;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-nav .nav-link {
    text-align: left !important;
    width: 100%;
    white-space: normal;
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .collapse form.float-end {
    float: none !important;
    width: 100%;
    max-width: 100%;
    margin: 0 !important;
    padding-top: 0.35rem;
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .collapse .my-btn {
    display: block;
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapsing {
    display: block !important;
    overflow: hidden !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse:not(.show):not(.in):not(.collapsing) {
    display: none !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse.show,
  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse.in {
    display: block !important;
    max-height: min(80vh, 680px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem 1rem;
    box-sizing: border-box;
    background: #fff;
    border-radius: 0 0 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .dropdown-menu.megamenu-content {
    position: static !important;
    inset: auto !important;
    float: none !important;
    width: 100% !important;
    max-width: 100% !important;
    transform: none !important;
    margin: 0.35rem 0 0.5rem;
    border: 0;
    border-radius: 6px;
    box-shadow: none;
    background: #f0f2f5;
  }

  /* Top megamenu row: intro + links area each full width */
  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content > li > .row > [class*="col-"] {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Links grid: two columns */
  html body header.main-header.wam-isolated-nav .navbar.megamenu .container .dropdown-menu.megamenu-content .links-section .row > [class*="col-"],
  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .links-section .row > [class*="col-"] {
    flex: 0 0 50% !important;
    max-width: 50% !important;
    width: 50% !important;
    min-width: 0 !important;
    padding-left: 0.45rem !important;
    padding-right: 0.45rem !important;
    box-sizing: border-box !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content ul.mega-links {
    width: 100%;
    max-width: 100%;
  }

  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .mega-bgs {
    min-height: 0 !important;
    height: auto !important;
    padding: 1.1rem !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .mega-bgs .position-absolute {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .mega-bgs h1 {
    margin-bottom: 0.75rem !important;
    font-size: clamp(1.2rem, 4vw, 1.65rem) !important;
    font-weight: 600 !important;
  }

  /*
   * Typography scoped to .wam-isolated-nav only: matches scss/main.css (About Us baseline).
   * Higher specificity than css/new-design.css mobile overrides (1rem / 0.95rem).
   */
  html body header.main-header.wam-isolated-nav .navbar .navbar-nav > .nav-item > .nav-link {
    font-size: 1.6rem !important;
    font-weight: 500 !important;
    line-height: 1.35 !important;
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .dropdown-menu.megamenu-content .links-section ul.mega-links li a,
  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .links-section ul.mega-links li a {
    font-size: 1.45rem !important;
    font-weight: 400 !important;
    line-height: 1.42 !important;
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .dropdown-menu.megamenu-content .links-section ul.mega-links li.category a,
  html body header.main-header.wam-isolated-nav .navbar .dropdown-menu.megamenu-content .links-section ul.mega-links li.category a {
    font-size: 1.65rem !important;
    font-weight: 600 !important;
    line-height: 1.28 !important;
  }

  html body header.main-header.wam-isolated-nav .navbar.megamenu .collapse .my-btn {
    font-size: clamp(1.3rem, 1.5vw, 1.6rem) !important;
    font-weight: 600 !important;
  }

  /* After scroll, .fixed + white drawer: keep menu text dark (see custome.css desktop-only #fff links). */
  html body header.main-header.wam-isolated-nav.fixed .navbar-collapse.show .navbar-nav .nav-link,
  html body header.main-header.wam-isolated-nav.fixed .navbar-collapse.in .navbar-nav .nav-link {
    color: #000000 !important;
  }
}

@media (min-width: 992px) {
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggler,
  html body header.main-header.wam-isolated-nav .navbar .navbar-toggle {
    display: none !important;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse {
    display: flex !important;
    flex-basis: auto;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none;
    background: transparent;
    padding: 0;
    margin-top: 0;
  }

  /* BS3 legacy: navbar used floats; keep horizontal row when collapse is flex */
  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse > .navbar-nav {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    margin-bottom: 0;
  }

  html body header.main-header.wam-isolated-nav .navbar .navbar-collapse.collapse > .navbar-nav > .nav-item {
    float: none !important;
  }
}
