/* =========================================
   Header layout
   Desktop: CSS grid — logo (spans both rows) | nav (row 1) / search (row 2)
   Mobile:  flex row  — logo | search (flex-grow) | hamburger
   Search is always expanded; no toggle.
   ========================================= */

/* Desktop: 2-column grid */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  align-items: center !important;
  column-gap: 24px !important;
  row-gap: 4px !important;
}

/* Logo: column 1, spans both rows, stretches to full combined row height */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child {
  grid-column: 1 !important;
  grid-row: 1 / 3 !important;
  align-self: stretch !important;
  display: flex !important;
  align-items: stretch !important;
  max-width: 175px !important;
}

/* Chain height through site-title and anchor so the img can fill 100% */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child .wp-block-site-title,
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child .wp-block-site-title a {
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
}

/* Logo image: fixed 190px wide, fills full height of both rows */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child img {
  width: 175px !important;
  height: 100% !important;
  max-width: none !important;
  display: block !important;
  object-fit: contain !important;
  object-position: left center !important;
}

/* Tighten nav item horizontal padding so items don't crowd the logo */
header .wp-block-navigation-item__content {
  padding-left: 0.5em !important;
  padding-right: 0.5em !important;
}

/* Nav list: 20px gap between items, right-justified */
header .wp-block-navigation ul.wp-block-navigation__container {
  gap: 20px !important;
  justify-content: flex-end !important;
}

/* Navigation: column 2, row 1 */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:nth-child(2) {
  grid-column: 2 !important;
  grid-row: 1 !important;
  max-width: none !important;
  min-width: 0 !important;
}

/* Empty spacer: hidden */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:nth-child(3) {
  display: none !important;
}

/* Search container: column 2, row 2, full width so form can right-align inside */
header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:nth-child(4) {
  grid-column: 2 !important;
  grid-row: 2 !important;
  max-width: none !important;
  padding: 0 !important;
  overflow: visible !important;
}

/* ── Search form — always expanded, right-aligned to match nav ── */

header .wp-block-search {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 1.5em;
}

header .wp-block-search .wp-block-search__label {
  display: none;
}

header .wp-block-search .wp-block-search__inside-wrapper {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 0;
  width: auto !important;
}

/* Input: always visible, max 200px */
header .wp-block-search .wp-block-search__input {
  width: 200px;
  max-width: 200px;
  min-width: 0 !important;
  height: 32px;
  padding: 0 10px;
  margin: 0;
  border: 1.5px solid var(--wp--preset--color--quinary) !important;
  border-right: none !important;
  border-radius: 3px 0 0 3px;
  font-size: 13px;
  background: #fff;
  color: var(--wp--preset--color--base);
  box-sizing: border-box;
  outline: none;
  flex-shrink: 0;
}

/* Button: left side always squared off since input is always open */
header .wp-block-search .wp-block-search__button {
  height: 32px !important;
  width: 32px !important;
  min-width: 32px;
  padding: 6px !important;
  margin-left: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 0 3px 3px 0 !important;
  border: none !important;
  cursor: pointer;
  background: var(--wp--preset--color--primary) !important;
  background-image: none !important;
  color: #fff;
}

header .wp-block-search .wp-block-search__button:hover {
  opacity: 0.85;
}

header .wp-block-search .wp-block-search__button svg {
  width: 14px !important;
  height: 14px !important;
  min-width: 14px;
  min-height: 14px;
  fill: #fff;
  color: #fff;
  display: block;
}

/* ── Mobile (≤767px): flex row — logo | search (flex-grow) | hamburger ── */
@media (max-width: 904px) {
  header .wp-block-group.alignwide.wp-block-group-is-layout-grid {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  /* Logo: natural width, stays left, not stretched */
  header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child {
    grid-row: auto !important;
    grid-column: auto !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    display: block !important;
  }

  /* Reset logo image back to fixed width on mobile */
  header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:first-child img {
    height: auto !important;
    width: 120px !important;
  }

  /* Nav group (contains hamburger): far right */
  header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:nth-child(2) {
    grid-column: auto !important;
    grid-row: auto !important;
    flex: 0 0 auto !important;
    min-width: 0 !important;
    order: 3;
  }

  /* Search group: fills space between logo and hamburger */
  header .wp-block-group.alignwide.wp-block-group-is-layout-grid > .wp-block-group:nth-child(4) {
    grid-column: auto !important;
    grid-row: auto !important;
    flex: 1 1 auto !important;
    order: 2;
    overflow: hidden !important;
  }

  /* Search form and input fill available width on mobile */
  header .wp-block-search {
    justify-content: flex-start;
    padding-right: 0;
  }

  header .wp-block-search,
  header .wp-block-search .wp-block-search__inside-wrapper {
    width: 100% !important;
  }

  header .wp-block-search .wp-block-search__input {
    width: 100% !important;
    max-width: 200px !important;
    flex: 1 1 auto !important;
  }
}
