/* ============================================================
   CUSTOM-SELECT.CSS — styled single-select (progressive enhancement).

   Pairs with custom-select.js, which upgrades native single <select>s into a
   styled button + popup listbox. The closed button mirrors .ol-ms__btn and the
   popup mirrors .ol-ms__panel / .ol-ms__opt (the export → delivery-location
   look), minus the checkboxes — a single-select with a selected tick instead.
   Token-based only (DESIGN-STANDARD §1); no raw hex.

   If JS is off, .cs* never appears and the native .fld select renders as before.
   ============================================================ */

/* Wrapper anchors the absolutely-positioned popup to the field width. */
.cs {
  position: relative;
  width: 100%;
}

/* The native <select> stays in the DOM as the value + submission source, but is
   visually hidden and out of the tab order (the styled button is the a11y
   control). Not display:none so the form value always posts. */
.cs__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Closed control — mirrors .ol-ms__btn. */
.cs__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  padding: 9px 12px;
  min-height: 40px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--bg-paper);
  color: var(--fg-1);
  cursor: pointer;
}
.cs__btn:hover { border-color: var(--border-3); }
.cs__btn:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.cs.is-open .cs__btn {
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}
.cs.is-disabled { opacity: 0.6; }
.cs__btn:disabled { cursor: not-allowed; }

.cs__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* An empty / placeholder value reads muted, like a real select's placeholder. */
.cs__label--placeholder { color: var(--fg-3); }

.cs__chev {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--fg-3);
  transition: transform 0.12s ease;
}
.cs.is-open .cs__chev { transform: rotate(180deg); }

/* Popup listbox — mirrors .ol-ms__panel. */
.cs__list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: 264px;
  overflow-y: auto;
  padding: 4px 0;
  background: var(--bg-paper);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
.cs__list[hidden] { display: none; }

/* One option row — mirrors .ol-ms__opt (44px touch target). */
.cs__opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 12px;
  font-size: 13.5px;
  color: var(--fg-1);
  cursor: pointer;
}
.cs__opt[hidden] { display: none; }
.cs__opt-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Keyboard/pointer highlight. */
.cs__opt.is-active { background: var(--bg-sunken); }
/* The current selection: soft brand tint + a visible tick. */
.cs__opt.is-selected {
  color: var(--fg-1);
  font-weight: 600;
  background: var(--enroute-green-50);
}
.cs__opt-tick {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--brand);
  visibility: hidden;
}
.cs__opt.is-selected .cs__opt-tick { visibility: visible; }
/* A disabled/filtered-out option (dependent-dropdown JS) reads inert. */
.cs__opt.is-disabled {
  color: var(--fg-3);
  cursor: not-allowed;
  opacity: 0.55;
}
.cs__opt.is-disabled.is-active { background: transparent; }

/* Mobile: keep the 44px rows + a touch-comfortable popup. */
@media (max-width: 640px) {
  .cs__btn { min-height: 44px; }
  .cs__list { max-height: 50vh; }
}
