/**
 * Themed dropdowns built by assets/js/custom-select.js. The trigger keeps the
 * original select's classes (form-input, form-select, ...), so it already
 * matches its field; these rules add the chevron, the popup list, and states.
 * The selected option is marked by a check and weight, never colour alone.
 */
.custom-select { position: relative; min-width: 0; }
.custom-select[hidden] { display: none; }
.custom-select-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }
/* The component draws its own chevron, so the field's static icon steps aside. */
.has-custom-select > .form-select-icon, .has-custom-select > .icon { display: none; }

.custom-select-trigger { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); width: 100%; min-height: var(--tap-target); cursor: pointer; text-align: start; user-select: none; }
.custom-select-trigger.form-input { min-height: 3.25rem; }
.custom-select-trigger:not(.form-input) { padding-inline: var(--space-3); border: 1px solid var(--color-line); background: var(--color-white); }
.custom-select-trigger:focus-visible { outline: var(--focus-ring); outline-offset: 0.125rem; }
.custom-select-trigger.form-input:focus { border-color: var(--color-ink); box-shadow: 0 0 0 0.1875rem rgba(184, 148, 95, 0.18); }
.custom-select-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select.is-placeholder .custom-select-value { color: var(--color-muted); }
.custom-select-chevron { width: 1rem; height: 1rem; flex-shrink: 0; color: var(--color-muted); transition: transform var(--motion-fast); }
.custom-select.is-open .custom-select-trigger { border-color: var(--color-ink); }
.custom-select.is-open .custom-select-chevron { color: var(--color-ink); transform: rotate(180deg); }
.custom-select.is-disabled .custom-select-trigger { cursor: not-allowed; opacity: 0.6; }

/* Fixed to the viewport so scrolling tables and panels never clip the list. */
.custom-select-list {
  position: fixed;
  inset-block-start: calc(var(--custom-select-top, 0px) + var(--space-1));
  inset-inline-start: var(--custom-select-left, 0px);
  z-index: var(--z-overlay);
  width: max(var(--custom-select-width, 12rem), 12rem);
  max-width: calc(100vw - 1rem);
  max-height: min(20rem, var(--custom-select-space, 20rem));
  margin: 0;
  padding: var(--space-1);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--color-ink);
  background: var(--color-paper);
  box-shadow: var(--shadow-md);
  color: var(--color-ink);
  list-style: none;
  animation: custom-select-in var(--motion-fast);
}
.custom-select.opens-up .custom-select-list { transform: translateY(calc(-100% - (2 * var(--space-1)))); animation-name: custom-select-in-up; }
.custom-select-list[hidden] { display: none; }
.custom-select-group ul { margin: 0; padding: 0; list-style: none; }
.custom-select-group + .custom-select-group, .custom-select-option + .custom-select-group { margin-block-start: var(--space-1); padding-block-start: var(--space-1); border-block-start: 1px solid var(--color-line); }
.custom-select-group-label { display: block; padding: var(--space-2) var(--space-3) var(--space-1); color: var(--color-muted); font-size: var(--font-size-min); font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.custom-select-option { display: grid; grid-template-columns: 1rem minmax(0, 1fr); align-items: center; gap: var(--space-2); min-height: var(--tap-target); padding: var(--space-2) var(--space-3); cursor: pointer; font-size: 0.9rem; line-height: 1.35; overflow-wrap: anywhere; }
.custom-select-option[hidden] { display: none; }
.custom-select-check { width: 1rem; height: 1rem; visibility: hidden; color: var(--color-ink); }
.custom-select-option[aria-selected='true'] { font-weight: 700; }
.custom-select-option[aria-selected='true'] .custom-select-check { visibility: visible; }
.custom-select-option.is-active { background: var(--color-ivory); box-shadow: inset 0.1875rem 0 0 var(--color-gold); }
.custom-select-option[aria-disabled='true'] { cursor: not-allowed; color: var(--color-muted); opacity: 0.6; }

@keyframes custom-select-in { from { opacity: 0; transform: translateY(-0.25rem); } }
@keyframes custom-select-in-up { from { opacity: 0; transform: translateY(calc(-100% - (2 * var(--space-1)) + 0.25rem)); } }

@media (prefers-reduced-motion: reduce) {
  .custom-select-list { animation: none; }
  .custom-select-chevron { transition: none; }
}

@media (forced-colors: active) {
  .custom-select-option.is-active { outline: 2px solid Highlight; }
}
