/* ==========================================================================
   Type-ahead list for dropdowns (#529) — static/js/typeahead.js.

   Loaded by base.html and by the Django admin, which does not load
   base.css: every colour reads the site's token first, then the admin's
   own variable, then a system colour, so the list matches either and
   follows light/dark in both.
   ========================================================================== */

.typeahead {
  position: fixed;
  /* Above the save bar (20) and the jump rail / session quick nav (25). */
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  max-height: 18rem;
  overflow: hidden;
  background: var(--surface-container-low, var(--body-bg, Canvas));
  color: var(--on-surface, var(--body-fg, CanvasText));
  border: 1px solid var(--outline, var(--border-color, GrayText));
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  font-size: 0.95rem;
  line-height: 1.35;
}

.typeahead[hidden] {
  display: none;
}

.typeahead-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--outline-variant, var(--border-color, GrayText));
  color: var(--on-surface-variant, var(--body-quiet-color, GrayText));
  font-size: 0.85rem;
  white-space: nowrap;
}

.typeahead-query {
  color: var(--on-surface, var(--body-fg, CanvasText));
  overflow: hidden;
  text-overflow: ellipsis;
}

.typeahead-count {
  font-variant-numeric: tabular-nums;
}

.typeahead-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* offsetTop of the rows is measured from here (scrolling to the
     highlighted row). */
  position: relative;
  padding: 0.2rem 0;
}

.typeahead-group {
  padding: 0.35rem 0.6rem 0.15rem;
  color: var(--on-surface-variant, var(--body-quiet-color, GrayText));
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: default;
}

.typeahead-option {
  padding: 0.3rem 0.6rem 0.3rem 1.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

/* The highlighted row — what Enter would pick: a wash and a bar in the
   focus colour. */
.typeahead-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--focus, var(--primary, Highlight)) 14%, transparent);
  box-shadow: inset 3px 0 0 var(--focus, var(--primary, Highlight));
}

/* The value the select holds now. */
.typeahead-option.is-current {
  position: relative;
  font-weight: 600;
}

.typeahead-option.is-current::before {
  content: "\2713";
  position: absolute;
  left: 0.45rem;
}

.typeahead-option.is-disabled {
  color: var(--on-surface-variant, var(--body-quiet-color, GrayText));
  cursor: default;
}

/* Announced to screen readers, never seen. */
.typeahead-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media print {
  .typeahead {
    display: none !important;
  }
}
