/* ==========================================================================
   Typeahead Dropdown — loaded globally for nav search bar
   ========================================================================== */

/* The nav form is already position: absolute, so the dropdown positions
   relative to it. Other forms (footer, hero) need position: relative. */
.site-search:has(.search-typeahead-dropdown) {
  position: relative;
}

/* .site-navigation and .site-search are this component's own classes;
 * .search-typeahead-dropdown inside :has() is this stylesheet's own class
 * too, nested only to scope the rule to forms that actually render a
 * dropdown. */
/* stylelint-disable-next-line selector-max-class */
.site-navigation .site-search:has(.search-typeahead-dropdown) {
  position: absolute;
}

.site-navigation .site-search {
  overflow: visible;
}

/* .searching is site-navigation's own JS-toggled state class. */
/* stylelint-disable-next-line selector-max-class */
.site-navigation.searching .site-search {
  z-index: 100;
}

.search-typeahead-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 0.5rem;
  box-shadow:
    0 1.25rem 3rem rgba(0, 0, 0, 0.18),
    0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
  max-height: 28rem;
  overflow: hidden auto;
  padding: 0.375rem;
  animation: search-typeahead-enter 140ms ease-out;
}

@keyframes search-typeahead-enter {
  from {
    opacity: 0;
    transform: translateY(-0.25rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-typeahead-dropdown {
    animation: none;
  }
  .search-typeahead-item,
  .search-typeahead-view-all {
    transition: none;
  }
}

.site-navigation .search-typeahead-dropdown {
  z-index: 101;
}

/* Keep the dropdown panel white against every nav state (mobile drawer,
   system dark-mode defaults) while leaving the search input's own
   background untouched. */
body.shifted .search-typeahead-dropdown {
  background: #fff;
  color: #222;
  color-scheme: light;
}

.search-typeahead-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0.875rem;
  text-decoration: none;
  color: #222;
  cursor: pointer;
  border-radius: 0.5rem;
  transition:
    background-color 0.12s ease,
    color 0.12s ease;
}

.search-typeahead-item.is-selected,
.search-typeahead-item:hover {
  background: rgba(153, 0, 0, 0.06);
  color: #111;
}

.search-typeahead-item:focus-visible,
.search-typeahead-view-all:focus-visible {
  outline: 2px solid #990000;
  outline-offset: -2px;
}

.search-typeahead-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
}

.search-typeahead-type {
  flex-shrink: 0;
  font-family: var(--wp--preset--font-family--sans);
  font-size: 0.75rem;
  font-weight: 700;
  color: #990000;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search-typeahead-view-all {
  display: block;
  margin-top: 0.25rem;
  padding: 0.75rem 0.875rem;
  text-align: center;
  font-family: var(--wp--preset--font-family--sans);
  font-size: 0.8125rem;
  font-weight: 700;
  color: #990000;
  text-decoration: none;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  letter-spacing: 0.02em;
  border-radius: 0 0 0.5rem 0.5rem;
  transition: background-color 0.12s ease;
}

.search-typeahead-view-all:hover,
.search-typeahead-view-all.is-selected {
  background: rgba(153, 0, 0, 0.06);
}

.search-typeahead-dropdown mark {
  background-color: transparent;
  color: inherit;
  font-weight: 700;
}

.search-typeahead-loading,
.search-typeahead-empty {
  padding: 1rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 400;
  color: #666;
  text-align: center;
}

.search-typeahead-heading {
  padding: 0.625rem 0.875rem 0.375rem;
  font-family: var(--wp--preset--font-family--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #555;
}

.search-typeahead-recent .search-typeahead-title::before {
  content: "";
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.5rem;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E")
    no-repeat center / contain;
  mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E")
    no-repeat center / contain;
  opacity: 0.5;
}
