/* Shared mobile header. Restore the existing portal CTA hidden by the parent
   stylesheet at 1050px and below. Desktop styling and menu logic are retained. */
@media (max-width: 1050px) {
  #masthead.site-header .site-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand portal" "links links";
    align-items: center;
    gap: 8px 12px;
    padding-block: 8px;
  }
  #masthead .site-branding { grid-area: brand; min-width: 0; max-width: 100%; }
  #masthead .site-branding .site-logo-link { max-width: 100%; gap: 8px; }
  #masthead .site-branding .site-logo-image { width: clamp(44px, 11vw, 68px); height: clamp(44px, 11vw, 68px); max-width: 100%; flex-shrink: 0; }
  #masthead .site-branding .site-wordmark { font-size: clamp(18px, 4.4vw, 26px); line-height: 1.15; white-space: nowrap; }
  #masthead .site-branding .custom-logo-link, #masthead .site-branding .custom-logo { max-width: 100%; }
  #masthead .site-branding .custom-logo { max-height: 68px; height: auto; object-fit: contain; }
  #masthead .site-header__navigation { grid-area: links; min-width: 0; width: 100%; justify-content: flex-start; }
  #masthead .primary-navigation { min-width: 0; max-width: 100%; }
  #masthead .primary-menu { flex-wrap: wrap; }
  #masthead .primary-menu a { min-height: 44px; display: inline-flex; align-items: center; }
  #masthead .site-header__cta.button {
    grid-area: portal;
    display: inline-flex !important; /* The inherited header hides this specific CTA. */
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    margin: 0;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    text-align: center;
  }
  #masthead .site-header__cta:focus-visible, #masthead .menu-toggle:focus-visible { outline: 2px solid #755513; outline-offset: 3px; }
  /* Only flatten the existing wrapper when the parent script enables its toggle.
     No-JS and intermediate tablet widths retain the visible wrapping menu. */
  html.js-nav-enabled #masthead .site-header__inner:has(.menu-toggle:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas: "brand portal toggle" "links links links";
  }
  html.js-nav-enabled #masthead .site-header__navigation:has(> .menu-toggle:not([hidden])) { display: contents; }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) {
    grid-area: toggle;
    display: inline-flex;
    min-height: 44px;
    padding: 8px 12px;
    margin: 0;
    white-space: nowrap;
  }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) + .primary-navigation {
    grid-area: links;
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden])[aria-expanded="false"] + .primary-navigation { display: none; }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden])[aria-expanded="true"] + .primary-navigation { display: block; }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) + .primary-navigation .primary-menu { flex-direction: column; align-items: stretch; }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) + .primary-navigation .primary-menu a { display: flex; }
}

/* Compact mobile masthead: single row when the menu is collapsed.
   Use the existing accessible text button; its visual icon is decorative. */
@media (max-width: 800px) {
  :root { --rx-header-offset: 4.75rem; }
  #masthead.site-header .site-header__inner {
    width: min(calc(100% - 24px), var(--rx-content-width));
    min-height: 64px;
    padding-block: 8px;
    column-gap: 8px;
    row-gap: 0;
  }
  #masthead .site-branding .site-logo-link { display: flex; width: max-content; gap: 5px; justify-content: flex-start; }
  #masthead .site-branding .site-logo-image { width: clamp(36px, 10vw, 52px); height: clamp(36px, 10vw, 52px); }
  #masthead .site-branding .site-wordmark { font-size: clamp(17px, 5.2vw, 23px); font-weight: 750; letter-spacing: -.035em; color: #626a6c; }
  #masthead .site-branding .site-wordmark__x { color: #b88e2f; }
  #masthead .site-branding .custom-logo { max-height: 48px; max-width: 100%; object-fit: contain; }
  #masthead .site-header__cta.button {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 650;
    border-radius: 3px;
    color: #152226;
    background: #bf9847;
    border-color: #bf9847;
    box-shadow: none;
  }
  #masthead .site-header__cta.button:hover { background: #d0ac60; border-color: #d0ac60; }
  html.js-nav-enabled #masthead .site-header__inner:has(.menu-toggle:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) auto 44px;
    grid-template-areas: "brand portal toggle";
    grid-template-rows: auto;
  }
  html.js-nav-enabled #masthead .site-header__inner:has(.menu-toggle[aria-expanded="true"]:not([hidden])) {
    grid-template-areas: "brand portal toggle" "links links links";
  }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #152226;
    font-size: 0;
    box-shadow: none;
  }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden])::before {
    content: "";
    display: block;
    width: 21px;
    height: 2px;
    background: currentColor;
    box-shadow: 0 -7px currentColor, 0 7px currentColor;
    border-radius: 1px;
  }
  html.js-nav-enabled #masthead .menu-toggle[aria-expanded="true"]:not([hidden])::before {
    transform: rotate(45deg);
    box-shadow: none;
  }
  html.js-nav-enabled #masthead .menu-toggle[aria-expanded="true"]:not([hidden])::after {
    content: "";
    position: absolute;
    width: 21px;
    height: 2px;
    background: currentColor;
    transform: rotate(-45deg);
    border-radius: 1px;
  }
  html.js-nav-enabled #masthead .menu-toggle:not([hidden]) + .primary-navigation {
    border-top: 1px solid #e5e5e2;
    margin-top: 8px;
    padding-top: 4px;
  }
  /* Preserve visible navigation without JavaScript. */
  #masthead .primary-navigation .primary-menu { row-gap: 0; }
}
@media (max-width: 360px) {
  #masthead .site-header__cta.button { padding-inline: 9px; }
  #masthead .site-branding .site-wordmark { font-size: 17px; }
}
