/*
 * Shared mobile header
 *
 * The homepage header is the canonical mobile structure: search on the left,
 * a centered logo, and the menu trigger on the right. Keep this stylesheet
 * late in the enqueue order so older template-specific header rules cannot
 * rearrange or stretch those controls.
 */
@media (max-width: 900px) {
  #site-header,
  #site-header .header-inner {
    max-width: 100vw;
    overflow: visible;
  }

  #site-header .header-inner {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 96px;
    padding: 12px 18px 0 !important;
    box-sizing: border-box;
  }

  #site-header .header-titles-wrapper {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: start !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    box-sizing: border-box;
  }

  #site-header .header-titles {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #site-header .site-logo,
  #site-header .site-logo a {
    display: flex !important;
    align-items: flex-start;
    justify-content: center;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
  }

  #site-header .custom-logo {
    width: clamp(122px, 32vw, 150px) !important;
    max-width: clamp(122px, 32vw, 150px) !important;
    height: auto !important;
    max-height: 84px;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .56));
  }

  #site-header .mobile-nav-toggle {
    position: static !important;
    inset: auto !important;
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    order: initial !important;
    display: flex !important;
    flex: 0 0 44px !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: rgba(8, 24, 12, .48);
  }

  #site-header .mobile-nav-toggle .toggle-inner {
    position: relative !important;
    inset: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transform: none !important;
  }

  #site-header .header-navigation-wrapper,
  #site-header .header-navigation-right,
  #site-header .header-toggles,
  #site-header .mobile-asp-search {
    display: none !important;
  }

  #site-header .mobile-bh-live-search {
    position: relative !important;
    display: block !important;
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    order: initial !important;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 40px;
    margin: 10px 0 0 !important;
    padding: 0 !important;
    z-index: 10040;
  }

  #site-header .mobile-bh-live-search .bh-live-search {
    width: 44px !important;
    height: 40px;
  }

  #site-header .bh-live-search--mobile .bh-live-search__toggle {
    position: absolute;
    inset: 0 auto auto 0;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 10px;
    background: rgba(8, 24, 12, .48);
    color: #fff;
    cursor: pointer;
    transition: background .2s ease;
  }

  #site-header .bh-live-search--mobile .bh-live-search__toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
  }

  #site-header .bh-live-search--mobile .bh-live-search__toggle-close {
    display: none;
  }

  #site-header .bh-live-search--mobile .bh-live-search__form {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(100vw - 84px);
    min-height: 40px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-12px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  }

  #site-header .bh-live-search--mobile .bh-live-search__icon {
    display: none;
  }

  #site-header .bh-live-search--mobile .bh-live-search__input {
    padding-left: 54px !important;
  }

  #site-header .bh-live-search--mobile.is-expanded {
    width: calc(100vw - 84px) !important;
    max-width: calc(100vw - 84px) !important;
  }

  #site-header .bh-live-search--mobile.is-expanded .bh-live-search__form {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0);
  }

  #site-header .bh-live-search--mobile.is-expanded .bh-live-search__toggle {
    border-color: transparent;
    background: transparent;
  }

  #site-header .bh-live-search--mobile.is-expanded .bh-live-search__toggle-open {
    display: none;
  }

  #site-header .bh-live-search--mobile.is-expanded .bh-live-search__toggle-close {
    display: block;
  }

  #site-header .bh-live-search--mobile .bh-live-search__panel {
    left: 0;
    right: auto;
    width: calc(100vw - 36px);
  }
}

/*
 * Legacy archive/single styles include a body-class selector. Match that
 * specificity here so this late-loading shared layer remains authoritative.
 */
@media (max-width: 900px) {
  body:not(.wp-admin) #site-header .header-inner {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 96px !important;
    padding: 12px 18px 0 !important;
  }

  body:not(.wp-admin) #site-header .header-titles-wrapper {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    align-items: start !important;
    justify-content: normal !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
  }

  body:not(.wp-admin) #site-header .header-titles {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    order: initial !important;
    flex: none !important;
  }

  body:not(.wp-admin) #site-header .site-logo,
  body:not(.wp-admin) #site-header .site-logo a {
    align-items: flex-start !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
  }

  body:not(.wp-admin) #site-header .custom-logo {
    width: clamp(122px, 32vw, 150px) !important;
    max-width: clamp(122px, 32vw, 150px) !important;
    height: auto !important;
    max-height: 84px !important;
  }

  body:not(.wp-admin) #site-header .mobile-nav-toggle {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    align-self: start !important;
    order: initial !important;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 10px 0 0 !important;
  }

  body:not(.wp-admin) #site-header .mobile-bh-live-search {
    grid-column: 1 !important;
    grid-row: 1 !important;
    order: initial !important;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 40px !important;
    margin: 10px 0 0 !important;
  }

  body:not(.wp-admin) #site-header .mobile-bh-live-search.is-expanded {
    width: calc(100vw - 84px) !important;
    max-width: calc(100vw - 84px) !important;
  }
}
