/* Site-wide header search (search-controller.js): the icon button that sits
   in the navrow next to the hamburger, and the dropdown panel it opens.
   Matches nova.css/refinements.css tokens (--ink/--muted/--line/--blue) and
   the existing .menu-btn/.account-link visual language rather than
   introducing a new style. */

.header-search-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 10px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: 800 13px var(--sans);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.header-search-toggle:hover,
.header-search-toggle:focus-visible { background: #f7f9fc; }
.header-search-toggle.is-active {
  background: #eaf1fb;
  border-color: var(--blue);
  color: var(--blue);
}
.header-search-toggle svg { flex-shrink: 0; }

.header-search-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 60;
  background: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px 0;
  max-height: calc(100vh - 84px);
  overflow-y: auto;
}
.header-search-panel[hidden] { display: none; }

.header-search-panel__inner { position: relative; }

.header-search-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.header-search-field {
  position: relative;
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: center;
}
.header-search-field svg {
  position: absolute;
  left: 14px;
  color: var(--muted);
  pointer-events: none;
}
.header-search-input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 500 16px var(--sans);
  color: var(--ink);
  background: #fff;
}
.header-search-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.header-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }
.header-search-form .btn {
  flex: 0 0 auto;
  height: 48px;
  white-space: nowrap;
}
.header-search-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}
.header-search-close:hover,
.header-search-close:focus-visible { background: #f7f9fc; color: var(--ink); }

.header-search-hint,
.header-search-empty {
  margin: 12px 0 0;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 13px;
}

.header-search-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(60vh, 480px);
  overflow-y: auto;
}
.header-search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.header-search-result:hover,
.header-search-result:focus-visible,
.header-search-result.is-active {
  background: #f1f5f9;
  outline: none;
}
.header-search-result strong { font: 700 14px var(--sans); color: var(--ink); }
.header-search-result span { font-size: 12px; color: var(--muted); }

.header-search-seeall {
  display: block;
  padding: 12px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
  border-radius: 8px;
}
.header-search-seeall:hover,
.header-search-seeall:focus-visible,
.header-search-seeall.is-active {
  background: #f1f5f9;
  text-decoration: underline;
  outline: none;
}

.header-search-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin: 4px 0 0;
  border: 0;
  border-radius: 8px;
  background: var(--orange-soft);
  color: #a74310;
  font: 700 13px var(--sans);
  cursor: pointer;
}
.header-search-suggestion:hover,
.header-search-suggestion:focus-visible { background: #ffe8d8; outline: none; }
.header-search-suggestion strong { font-weight: 800; }

/* Below 1260px the nav links, account link and CTA all hide (see
   refinements.css) - the toggle collapses to an icon-only square matching
   .menu-btn right next to it. */
@media (max-width: 1260px) {
  .header-search-toggle {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    background: #f7f9fc;
  }
  .header-search-toggle__label { display: none; }
  .header-favorites-link { width: 44px; height: 44px; background: #f7f9fc; }
  .account-menu__button { width: 44px; height: 44px; background: #f7f9fc; }
}

/* At phone widths, the brand logo + search + heart + hamburger (plus the
   .navrow gap between each) no longer fit one row at 44px icons with a
   16px gap - the hamburger overflowed off the right edge entirely once the
   heart icon was added as a 4th item competing for the same row. Shrinking
   all three icon buttons and tightening the gap here (header-search.css
   loads last among nova.css/refinements.css/header-search.css, so this is
   the one place a same-specificity override actually sticks instead of
   being re-overridden by one of those two files' own unconditional or
   wider-breakpoint rules). */
@media (max-width: 480px) {
  .navrow { gap: 6px; }
  .header-search-toggle,
  .header-favorites-link,
  .account-menu__button,
  .menu-btn {
    width: 38px;
    height: 38px;
    margin-left: 0;
  }
  .account-menu { margin-left: 0; }
  /* The real space hog at this width, measured directly: refinements.css's
     own 1400px-breakpoint .brand-logo{height:38px} renders the wordmark at
     ~274px wide (its aspect ratio is roughly 7:1) - that alone, plus three
     38px icon buttons and the gaps between all four items, overflows a
     362px-wide mobile container (390px viewport minus the 14px/14px side
     padding .container applies below 620px) by about 50px. Shrinking the
     logo here is what actually recovers the space the icon-button fix
     above couldn't on its own. */
  .brand-logo { height: 26px; }
  /* With the account button as a fifth item the row needs about 16px more than
     a 360px screen has (and ~1px more on a 375px one): let the logo give way,
     keeping its proportions, instead of pushing the menu button off the screen.
     Wider phones still get the full 26px logo. */
  .brand { flex: 0 1 auto; min-width: 0; }
  .brand-logo { height: auto; max-height: 26px; max-width: 100%; width: auto; }
}

@media (max-width: 620px) {
  .header-search-panel { padding: 14px 0; max-height: calc(100vh - 72px); }
}

@media (max-width: 480px) {
  .header-search-field { flex: 1 1 100%; }
  .header-search-form .btn { flex: 1 1 auto; }
}
