/* Native selects keep keyboard, touch and form validation behavior.
 * Browsers with customizable selects also receive the Rondaris option menu. */
select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  min-block-size: 48px;
  padding: 11px 42px 11px 14px;
  border: 1px solid var(--r-line-control);
  border-radius: 8px;
  background-color: var(--r-surface);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 20px center, right 14px center;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  color: var(--r-ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

select:not([multiple]):not([size]):required:invalid {
  color: var(--r-muted);
}

@media (hover: hover) {
  select:not([multiple]):not([size]):not(:disabled):hover {
    border-color: var(--r-blue);
    background-color: var(--r-wash);
  }
}

select:not([multiple]):not([size]):focus-visible {
  border-color: var(--r-blue);
  outline: 2px solid var(--r-focus);
  outline-offset: 3px;
}

select:not([multiple]):not([size])[aria-invalid="true"],
select:not([multiple]):not([size]):user-invalid {
  border-color: var(--r-danger);
}

select:not([multiple]):not([size]):disabled {
  background-color: var(--r-quiet);
  border-color: var(--r-line);
  color: var(--r-muted);
  -webkit-text-fill-color: var(--r-muted);
  opacity: 1;
  cursor: not-allowed;
}

select option {
  background-color: var(--r-surface);
  color: var(--r-ink);
}

/* Without both features, the phone or browser owns the open option picker. */
@supports (appearance: base-select) and selector(::picker(select)) {
  select:not([multiple]):not([size]),
  select:not([multiple]):not([size])::picker(select) {
    appearance: base-select;
  }

  select:not([multiple]):not([size]) {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  select:not([multiple]):not([size])::picker-icon {
    display: none;
  }

  select:not([multiple]):not([size]):open {
    border-color: var(--r-blue);
    background-color: var(--r-wash);
  }

  select:not([multiple]):not([size])::picker(select) {
    min-inline-size: anchor-size(width);
    max-inline-size: calc(100vw - 24px);
    max-block-size: min(22rem, 60dvh);
    margin-block-start: 6px;
    padding: 4px;
    border: 1px solid var(--r-line-control);
    border-radius: 8px;
    background: var(--r-surface);
    color: var(--r-ink);
    box-shadow: var(--r-shadow-pop);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  select:not([multiple]):not([size]) option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-block-size: 48px;
    padding: 11px 12px;
    border: 0;
    border-radius: 5px;
    font-size: 16px;
    line-height: 1.4;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
  }

  select:not([multiple]):not([size]) option:checked {
    background: var(--r-blue-soft);
    color: var(--r-blue-dark);
    font-weight: 600;
  }

  select:not([multiple]):not([size]) option:hover,
  select:not([multiple]):not([size]) option:focus-visible {
    background: var(--r-wash);
    color: var(--r-ink);
    outline: 2px solid var(--r-focus);
    outline-offset: -2px;
  }

  select:not([multiple]):not([size]) option::checkmark {
    color: var(--r-blue);
    flex-shrink: 0;
  }

  select:not([multiple]):not([size]) option:disabled {
    background: var(--r-quiet);
    color: var(--r-muted);
    cursor: not-allowed;
  }

  select:not([multiple]):not([size]) optgroup {
    color: var(--r-muted);
    font-weight: 600;
  }
}

@media (prefers-reduced-motion: reduce) {
  select:not([multiple]):not([size]) {
    transition: none;
  }
}

@media (forced-colors: active) {
  select:not([multiple]):not([size]) {
    -webkit-appearance: auto;
    appearance: auto;
    background-image: none;
    border-color: ButtonText;
    color: ButtonText;
  }

  select:not([multiple]):not([size]):disabled {
    border-color: GrayText;
    color: GrayText;
    -webkit-text-fill-color: GrayText;
  }

  select:not([multiple]):not([size])::picker(select) {
    appearance: auto;
  }
}
