/* Served as a plain file: the CSS build (Lightning CSS) does not know the customizable-select syntax yet and drops it. */
/*
 * Native <select> (60 of them, most in plain GET forms that work without JS): where the browser supports the
 * customizable select, its open list is drawn like DropdownMenu – a raised popover with 36 px items, the hovered
 * one on a quiet fill, a short fade and zoom (docs/DESIGN.md §6.1). Elsewhere (Safari, Firefox) the native list stays.
 * Unlayered on purpose: it must win over `appearance-none` on the closed field; the closed field keeps its own styling.
 */
@supports (appearance: base-select) {
  select:not([multiple]):not([size]) {
    appearance: base-select;
    cursor: pointer;
  }
  select:not([multiple]):not([size])::picker-icon {
    color: var(--muted-foreground);
    transition: rotate 200ms ease;
  }
  select:not([multiple]):not([size]):open::picker-icon {
    rotate: 180deg;
  }
  /* fields that draw their own chevron next to the select (NativeSelect) */
  select:has(+ svg)::picker-icon {
    display: none;
  }
  select:not([multiple]):not([size])::picker(select) {
    appearance: base-select;
    margin-block: 6px;
    padding: 4px;
    min-inline-size: max(8rem, anchor-size(self-inline));
    max-block-size: min(20rem, 60dvh);
    overflow-y: auto;
    border-radius: 0.625rem;
    color: var(--foreground);
    background-color: var(--popover);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-raised);
    transform-origin: top center;
    transition:
      opacity 160ms ease-out,
      scale 160ms ease-out,
      display 160ms allow-discrete,
      overlay 160ms allow-discrete;
  }
  select:not([multiple]):not([size])::picker(select):popover-open {
    opacity: 1;
    scale: 1;
  }
  @starting-style {
    select:not([multiple]):not([size])::picker(select):popover-open {
      opacity: 0;
      scale: 0.96;
    }
  }
  select:not([multiple]):not([size]) option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-block-size: 2.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: transparent;
    color: var(--foreground);
    outline: none;
  }
  select:not([multiple]):not([size]) option:hover,
  select:not([multiple]):not([size]) option:focus-visible {
    background-color: var(--fill-2);
  }
  select:not([multiple]):not([size]) option:checked {
    font-weight: 500;
  }
  select:not([multiple]):not([size]) option::checkmark {
    color: var(--foreground);
  }
  select:not([multiple]):not([size]) option:disabled {
    opacity: 0.5;
  }
  select:not([multiple]):not([size]) optgroup {
    padding-top: 0.25rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    font-weight: 500;
  }
}
