/* === search.css === */
/* ---------------------------------------------------------------------------
search.css

Two things: the /search results page, and the autocomplete dropdown that hangs
off the header search box on every page.

The dropdown rules are here rather than in 03-navigation.css because the panel
only ever renders once JS has fetched suggestions -- keeping it out of the core
bundle keeps that bundle to what the first paint actually needs.
--------------------------------------------------------------------------- */

/* The storefront does not set a global border-box, and these components are
   injected into containers that assume content-box. Without this the panel's
   rows were 100% + 28px of padding wide and overflowed their own scroller. */
.ac-panel,
.ac-panel *,
.search-category-list a {
  box-sizing: border-box;
}

/* --- results page ------------------------------------------------------- */

/* main.container carries its own padding rule, so this needs the element in the
   selector to win. */
main.search-page {
  padding-top: 24px;
  padding-bottom: 48px;
}

.search-heading {
  font-size: 1.5rem;
  margin: 0 0 20px;
  overflow-wrap: anywhere;
}

/* Keeps « … » together so the closing guillemet cannot orphan onto its own
   line, which is what happened on a 390px screen. */
.search-heading .search-term {
  color: #D10024;
  display: inline-block;
  max-width: 100%;
}

/* The core h2 rule adds 40px of padding-top, which read as a dead band between
   the page heading and the first section. Spacing here is all margin. */
.search-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 12px;
  padding-top: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e5e5;
}

.search-section-title .search-count {
  font-weight: 400;
  color: #888;
  margin-left: 6px;
}

/* The core stylesheet gives <section> a 40px top margin, which stacked onto the
   heading's own gap and left a dead band under the h1. */
.search-page section {
  margin-top: 0;
}

.search-categories {
  margin-bottom: 32px;
}

.search-category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-category-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid #e0e0e0;
  border-radius: 999px;
  background: #fff;
  color: #222;
  text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}

.search-category-list a:hover {
  border-color: #D10024;
  background: #fff5f6;
}

.search-category-name {
  font-weight: 600;
}

.search-category-parent {
  font-size: 0.8rem;
  color: #999;
}

.search-category-count {
  font-size: 0.78rem;
  color: #666;
  background: #f2f2f2;
  border-radius: 999px;
  padding: 1px 8px;
}

.search-empty {
  padding: 40px 0;
  color: #666;
}

.search-empty-hint {
  font-size: 0.9rem;
  color: #999;
}

/* --- header autocomplete ------------------------------------------------ */

#searchBox {
  position: relative;
}

.ac-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 60;
  width: 420px;
  max-width: 90vw;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  text-align: initial;
}

.ac-panel[hidden] {
  display: none;
}

/* The desktop panel is injected inside #topNavigation, whose `#topNavigation a
   { color: #fff }` outranks a plain `.ac-item` class selector -- every label
   rendered white on white. Winning that back needs the id in the selector too. */
#topNavigation .ac-panel .ac-item {
  color: #222;
}

#topNavigation .ac-panel .ac-footer {
  color: #D10024;
}

.ac-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #999;
  padding: 10px 14px 4px;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: #222;
  text-decoration: none;
  border: 0;
  background: none;
  width: 100%;
  cursor: pointer;
  font: inherit;
}

/* One highlight class for both mouse hover and keyboard focus, so arrowing
   through the list looks identical to pointing at it. */
.ac-item:hover,
.ac-item.is-active {
  background: #f6f6f6;
}

.ac-item img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex: 0 0 40px;
}

.ac-item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.ac-item-name {
  display: block;
  font-size: 0.88rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-item-meta {
  display: block;
  font-size: 0.75rem;
  color: #999;
}

.ac-item-price {
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: #D10024;
  white-space: nowrap;
}

.ac-cat-count {
  flex: 0 0 auto;
  font-size: 0.74rem;
  color: #666;
  background: #f2f2f2;
  border-radius: 999px;
  padding: 1px 8px;
}

.ac-footer {
  display: block;
  padding: 10px 14px;
  border-top: 1px solid #eee;
  font-size: 0.85rem;
  font-weight: 600;
  color: #D10024;
  text-decoration: none;
  text-align: center;
}

.ac-footer:hover,
.ac-footer.is-active {
  background: #f6f6f6;
}

.ac-empty {
  padding: 16px 14px;
  font-size: 0.86rem;
  color: #888;
}

/* Mobile overlay: the panel is a block on the search sheet, below the input
   row, rather than a floating dropdown. It scrolls on its own so the sheet
   cannot grow past the viewport. */
#mobileSearchInputContainer .ac-panel {
  position: static;
  width: auto;
  max-width: none;
  margin: 12px 15px 0;
  border: 0;
  border-top: 1px solid #eee;
  border-radius: 0;
  box-shadow: none;
  max-height: calc(100vh - 150px);
  -webkit-overflow-scrolling: touch;
}

[dir="rtl"] .ac-panel {
  left: auto;
  right: 0;
}

@media only screen and (max-width: 600px) {
  /* Roomier rows: 44px is the smallest comfortable touch target, and product
     names get two lines instead of being ellipsed after ~20 characters. */
  .ac-item {
    padding: 10px 2px;
    gap: 12px;
  }

  .ac-item img {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .ac-item-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .ac-group-title {
    padding-left: 2px;
    padding-right: 2px;
  }

  .ac-footer {
    padding: 14px 2px;
  }

  .search-heading {
    font-size: 1.15rem;
    margin-bottom: 16px;
  }

  .search-section-title {
    font-size: 0.95rem;
  }

  /* Two pills per row on a 390px screen: the parent name is the first thing
     worth dropping, the category's own name carries the meaning. */
  .search-category-list {
    gap: 8px;
  }

  .search-category-list a {
    padding: 8px 12px;
    font-size: 0.88rem;
    gap: 6px;
  }

  .search-category-parent {
    display: none;
  }
}
