/* ==========================================================================
   TeamTrek — the listbox that replaces a native select
   --------------------------------------------------------------------------
   Built by src/scripts/sections/combo.js around any select carrying
   data-combo, which stays in the form and holds the value.

   Once the listbox exists the select is clipped rather than hidden:
   display: none would take it out of the form's reach, and a clipped
   control can still be focused if validation needs to point at it.
   ========================================================================== */

.field[data-enhanced] .field__select {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden;
}

.combo { position: relative; }

.combo__button {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%;
  padding: .75rem .875rem;
  border: 1px solid var(--neutral-300); border-radius: var(--r-sm);
  background: #fff;
  font: inherit; font-size: .9375rem; color: var(--neutral-900);
  text-align: left; cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.combo__button[data-empty="true"] .combo__value { color: var(--neutral-400); }
.combo__button:hover { border-color: var(--neutral-400); }
.combo__button:focus-visible,
.combo__button[aria-expanded="true"] {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(0, 122, 112, .16);
}
.combo__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__chevron {
  flex: none; color: var(--neutral-500);
  transition: transform .18s ease;
}
.combo__button[aria-expanded="true"] .combo__chevron { transform: rotate(180deg); }

/* The panel. Absolute, so opening it does not move the fields under it,
   and scrolled rather than grown once a list is long. */
.combo__list {
  position: absolute; z-index: 20;
  top: calc(100% + .375rem); left: 0; right: 0;
  max-height: 15rem; overflow-y: auto;
  padding: .3125rem;
  border: 1px solid var(--neutral-200); border-radius: var(--r-md, 10px);
  background: #fff;
  box-shadow: 0 16px 40px rgba(14, 26, 24, .14);
}
.combo__list[hidden] { display: none; }

.combo__option {
  display: flex; align-items: center; gap: .625rem;
  padding: .625rem .75rem;
  border-radius: var(--r-sm);
  font-size: .9375rem; color: var(--neutral-700);
  cursor: pointer;
}
/* is-active is where the keyboard is, aria-selected is the answer. They
   are different states and they look different: a tinted row the pointer
   is over, and a primary row with a tick that is chosen. */
.combo__option.is-active { background: var(--neutral-50, #F6F7F7); }
.combo__option[aria-selected="true"] {
  background: var(--primary-50, #E7F4F1);
  color: var(--primary-800);
  font-weight: 700;
}
.combo__tick { flex: none; color: var(--primary-600); visibility: hidden; }
.combo__option[aria-selected="true"] .combo__tick { visibility: visible; }

/* Left empty on submit. The message is in the label row, so the eye lands
   on it from the control it belongs to. */
.field[data-invalid] .combo__button {
  border-color: var(--danger-text);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, .12);
}
.field[data-invalid] .field__label::after {
  content: "Pick one";
  font-size: .75rem; font-weight: 700; color: var(--danger-text);
}
