/* ==========================================================================
   GLOBAL SEARCH - css/sections/global-search.css

   The dialog body created by js/features/global-search.js. The dialog chrome
   (surface, close button, focus trap) belongs to css/components/modals.css; this
   file styles the search field, the live status line and the result list.

   The result list scrolls inside the dialog instead of growing it, so the close
   button and the field stay in place while a visitor arrows through 30 items.
   ========================================================================== */

/* ---- Dialog body ---- */
.global-search {
  display: grid;
  gap: var(--spacing-sm);
}

.global-search__field {
  display: grid;
}

.global-search__input {
  padding: 0.8rem 1rem;
  font-size: 1rem;
}

.global-search__status {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Results scroll inside the dialog so the field and the close button stay in
   place; overscroll containment stops the page behind from scrolling too. */
/* ---- Results ---- */
.global-search__results {
  display: grid;
  gap: 0.25rem;
  max-block-size: min(55vh, 24rem);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  overscroll-behavior: contain;
}

.global-search__item {
  margin: 0;
}

.global-search__result {
  display: grid;
  gap: 0.1rem;
  inline-size: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font: inherit;
  text-align: start;
  color: var(--color-text-primary);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.global-search__result:hover,
.global-search__result:focus-visible {
  background-color: var(--color-surface-raised);
  border-color: var(--color-border);
}

.global-search__result-title {
  font-weight: var(--font-weight-semibold);
}

.global-search__result-text {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

.global-search__result-where {
  font-size: 0.6875rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.global-search__empty {
  padding: var(--spacing-md);
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  background-color: var(--color-surface-raised);
  border-radius: var(--radius-sm);
}

/* ---- Section filter ---- */
.global-search__field {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.global-search__field .global-search__input {
  flex: 1 1 16rem;
}

.global-search__section {
  flex: 0 1 12rem;
}

/* ---- Headings, recent queries, highlighting ---- */
.global-search__heading {
  margin-block: var(--spacing-sm) 0.25rem;
  padding-inline: var(--spacing-xs);
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  list-style: none;
}

.global-search__recent {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
  list-style: none;
}

.global-search__recent-button,
.global-search__clear-recent {
  padding: 0.35rem var(--spacing-xs);
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  background: none;
  border: 0;
  text-align: start;
  cursor: pointer;
}

.global-search__recent-button:hover,
.global-search__clear-recent:hover {
  color: var(--color-text-primary);
  text-decoration: underline;
}

.global-search__clear-recent {
  margin-inline-start: auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* A highlighted token must stay readable on both palettes: the mark carries a
   tinted background and inherits the text colour rather than forcing black. */
.global-search__mark {
  padding-inline: 0.1em;
  color: inherit;
  background-color: color-mix(in srgb, var(--color-primary) 28%, transparent);
  border-radius: 2px;
}

/* The active option is the one Enter opens. The border and the background carry
   the state together, so it is not colour-only. */
.global-search__item.is-active {
  background-color: var(--color-surface-raised);
  border-color: var(--color-primary);
  outline: 2px solid var(--color-focus-ring);
  outline-offset: -2px;
}
.global-search__sort {
  flex: 0 1 9rem;
}