/**
 * @file
 * Autocomplete dropdown for the header search blocks (wide and narrow).
 */

/* The form-item wrapping the search input is the anchor for the dropdown. */

.search-block-form .form-item {
  position: relative;
}

.search-autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #0F2B5B;
  border: 1px solid rgba(180, 240, 0, 0.25);
  border-top: none;
  border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  max-height: 420px;
  overflow-y: auto;
  z-index: 9999;
}

/* Scrollbar */

.search-autocomplete-results::-webkit-scrollbar {
  width: 6px;
}

.search-autocomplete-results::-webkit-scrollbar-track {
  background: #0a1a38;
}

.search-autocomplete-results::-webkit-scrollbar-thumb {
  background: rgba(180, 240, 0, 0.3);
  border-radius: 3px;
}

.search-autocomplete-results::-webkit-scrollbar-thumb:hover {
  background: rgba(180, 240, 0, 0.5);
}

/* Items */

.search-autocomplete-results .autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.search-autocomplete-results .autocomplete-item:last-child {
  border-bottom: none;
}

.search-autocomplete-results .autocomplete-item:hover,
.search-autocomplete-results .autocomplete-item.selected {
  background-color: rgba(180, 240, 0, 0.08);
}

.search-autocomplete-results .autocomplete-item.selected {
  border-left: 2px solid #B4F000;
  padding-left: calc(1rem - 2px);
}

/* Thumbnail */

.search-autocomplete-results .autocomplete-item__image {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  -o-object-fit: contain;
     object-fit: contain;
  border-radius: var(--border-radius-sm);
  background: #0a1a38;
  padding: 4px;
}

/* Text body */

.search-autocomplete-results .autocomplete-item__body {
  flex: 1;
  min-width: 0;
}

.search-autocomplete-results .autocomplete-item__brand {
  font-size: var(--font-size-xxs, 12px);
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-autocomplete-results .autocomplete-item__title {
  font-size: var(--font-size-s, 14px);
  font-weight: 700;
  color: #F4F6F8;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-autocomplete-results .autocomplete-item__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.search-autocomplete-results .autocomplete-item__rating {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--font-size-xxs, 12px);
  font-weight: 600;
  color: #FFC400;
}

.search-autocomplete-results .autocomplete-item__rating .star {
  font-size: 0.75rem;
}

@media (max-width: 499px) {
  /*
   * On mobile the search form sits inside the expanded header search pill
   * (.block-header-search__wrapper.is-expanded, see header-search-toggle.js)
   * which is wider than the form itself (it also has the leading icon and
   * the close button). Make the pill the positioning context instead of the
   * form-item so the dropdown can stretch to the full pill width.
   */
  .block-header-search__wrapper.is-expanded {
    position: relative;
  }

  .block-header-search__wrapper.is-expanded .form-item {
    position: static;
  }
}

@media (max-width: 768px) {
  .search-autocomplete-results {
    max-height: 320px;
  }

  .search-autocomplete-results .autocomplete-item {
    padding: 0.625rem 0.875rem;
  }

  .search-autocomplete-results .autocomplete-item__image {
    width: 40px;
    height: 40px;
  }
}
