/* Player search listbox.
   Loaded last so it wins over the plain-text .suggestion rules in search.css
   and mobile-search.css without needing !important.

   Caveat: load order only settles ties at equal specificity. tabulator_site.css
   caps this panel with `#search-container #search-form #suggestions` (three
   IDs), which beats a bare `#suggestions` no matter what loads last — so the
   sizing rules below deliberately mirror that selector. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#suggestions,
#search-container #search-form #suggestions {
  /* Three groups (recent / trending / most searched) run to ~12 rows. The
     inherited 260px cap showed barely four and cut the fifth mid-row. */
  max-height: min(460px, 60vh);
  padding: 6px;
  border-radius: var(--radius-lg);
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

@media (max-width: 900px) {
  /* The full-screen surface anchors the field to the top, so the list can use
     the space down to the keyboard instead of a fixed 220px. */
  #search-container #search-form #suggestions,
  body.mobile-search-open #search-container #search-form #suggestions {
    max-height: min(60vh, calc(100dvh - 150px - env(safe-area-inset-top)));
  }
}

/* ---- group headers ---- */

.suggestion-group {
  padding: 8px 10px 5px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.suggestion-group:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

/* ---- rows ---- */

#suggestions .suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.12s ease;
}

#suggestions .suggestion:not(:last-child) {
  border-bottom: 0;
}

.suggestion__photo {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  object-fit: cover;
  object-position: top center;
  border-radius: 50%;
  background: var(--surface-3);
}

/* Rookies and two-way players are often missing from the NBA CDN. Keep the
   circle as a deliberate placeholder rather than showing a broken image. */
.suggestion__photo.is-missing {
  visibility: hidden;
}

.suggestion__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.suggestion__name {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The matched span, so users can see why a result matched. */
.suggestion__name b {
  font-weight: 800;
  color: var(--accent);
}

.suggestion__meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-3);
  white-space: nowrap;
}

.suggestion__value {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Recommendation badges carry search volume / weekly change — metadata, not a
   performance metric. Muting them keeps the accent colour meaning "RAPM". */
.suggestion__value--badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

#suggestions .suggestion.focused,
#suggestions .suggestion:hover {
  background-color: var(--accent-tint) !important;
}

.suggestion-empty {
  padding: 18px 12px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3);
}

/* ---- mobile ---- */

@media screen and (max-width: 900px) {
  body.mobile-search-open #search-container #search-form #suggestions {
    max-height: min(60vh, calc(100dvh - 120px - env(safe-area-inset-top)));
    padding: 6px;
  }

  /* 46px is comfortable with a mouse but under the reliable-tap floor. */
  body.mobile-search-open #search-container #search-form #suggestions .suggestion {
    min-height: 56px;
    padding: 8px 10px;
    border-bottom: 0;
    font-size: 15px;
  }

  .suggestion__photo {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .suggestion__name {
    font-size: 15.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #suggestions .suggestion {
    transition: none;
  }
}
