/**
 * custom-select.css - 通用自定义下拉组件
 *
 * 依赖于 `custom-select.js` 中生成的类名：
 * - .custom-select
 * - .custom-select__native
 * - .custom-select__trigger
 * - .custom-select__trigger-value
 * - .custom-select__trigger-icon
 * - .custom-select__list
 * - .custom-select__option
 */

:root {
  --custom-select-min-width: auto;
  --custom-select-max-width: 100%;
  --custom-select-height: clamp(2.5rem, 4vw, 3rem);
  --custom-select-padding-inline-start: var(--space-3, 0.75rem);
  --custom-select-padding-inline-end: var(--space-4, 1rem);
  --custom-select-border-color: var(--color-border, #c9c9c9);
  --custom-select-border-color-focus: var(--color-brand, #1a73e8);
  --custom-select-bg: var(--color-bg, #fff);
  --custom-select-bg-hover: var(--color-bg-hover, #f5f5f5);
  --custom-select-bg-selected: var(--color-bg-subtle, #fff7e6);
  --custom-select-text: var(--color-text, #222);
  --custom-select-text-selected: var(--color-yellow-500, #9a6700);
  --custom-select-radius: var(--radius-sm, 0.375rem);
  --custom-select-shadow: var(--shadow-2, 0 8px 24px rgba(0, 0, 0, 0.12));
  --custom-select-z-index: var(--z-dropdown, 1000);
  --custom-select-list-max-height: min(18rem, 50vh);
  --custom-select-icon-size: var(--size-icon-md, 1.5rem);
  --custom-select-focus-width: var(--focus-width, 2px);
  --custom-select-focus-offset: var(--focus-offset, 2px);
  --custom-select-motion-base: var(--motion-base, 0.2s ease);
  --custom-select-motion-fast: var(--motion-fast, 0.15s ease);
  --custom-select-touch-target: 44px;
}

select.custom-select__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  appearance: none;
  pointer-events: none;
}

.custom-select {
  position: relative;
  display: inline-block;
  min-width: 0;
  max-width: var(--custom-select-max-width);
  height: auto;
  vertical-align: middle;
}

.custom-select-host::after {
  content: none !important;
}

.custom-select--ready {
  visibility: visible;
}

.custom-select__trigger {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  width: 100%;
  min-width: 0;
  padding-block: 8px;
  padding-inline: var(--custom-select-padding-inline-start)
    var(--custom-select-padding-inline-end);
  box-sizing: border-box;
  border: 1px solid var(--custom-select-border-color);
  border-radius: var(--custom-select-radius);
  background: var(--custom-select-bg);
  background-image: none;
  background-repeat: no-repeat;
  background-position: initial;
  background-size: 0;
  color: var(--custom-select-text);
  font: inherit;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
  transition:
    border-color var(--custom-select-motion-base),
    box-shadow var(--custom-select-motion-base),
    background-color var(--custom-select-motion-fast);
  -webkit-tap-highlight-color: transparent;
}

.custom-select__trigger:hover:not(:disabled) {
  border-color: var(--custom-select-border-color-focus);
}

.custom-select__trigger:focus {
  outline: var(--custom-select-focus-width) solid
    var(--custom-select-border-color-focus);
  outline-offset: var(--custom-select-focus-offset);
  border-color: var(--custom-select-border-color-focus);
}

.custom-select__trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  background: var(--custom-select-bg-hover);
}

.custom-select__trigger-value {
  flex: 1 1 auto;
  min-width: 0;
  padding-inline-end: var(--custom-select-padding-inline-end);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__trigger-icon {
  position: absolute;
  inset-inline-end: var(--space-2, 0.5rem);
  top: 50%;
  transform: translateY(-50%);
  line-height: 1;
  font-family: "Material Symbols Outlined";
  font-size: var(--custom-select-icon-size);
  font-variation-settings: var(
    --material-symbols-outlined-variation,
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24
  );
  transition: transform var(--custom-select-motion-base);
  pointer-events: none;
}

.custom-select.is-open .custom-select__trigger-icon {
  transform: translateY(-50%) rotate(180deg);
}

.custom-select__list {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: auto;
  bottom: calc(100% + var(--space-1, 0.25rem));
  margin: 0;
  padding: var(--space-1, 0.25rem) 0;
  list-style: none;
  background: var(--custom-select-bg);
  border: 1px solid var(--custom-select-border-color);
  border-radius: var(--custom-select-radius);
  box-shadow: var(--custom-select-shadow);
  max-height: var(--custom-select-list-max-height);
  overflow-y: auto;
  z-index: var(--custom-select-z-index);
}

.custom-select__option {
  display: block;
  width: 100%;
  padding-block: var(--space-2, 0.5rem);
  padding-inline: var(--custom-select-padding-inline-start)
    var(--custom-select-padding-inline-end);
  box-sizing: border-box;
  color: var(--custom-select-text);
  background: transparent;
  font: inherit;
  line-height: 1.3;
  text-align: start;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--custom-select-motion-fast),
    color var(--custom-select-motion-fast);
}

.custom-select__option:hover {
  background-color: var(--custom-select-bg-hover);
}

.custom-select__option:focus {
  outline: none;
  background-color: var(--custom-select-bg-hover);
}

.custom-select__option[aria-selected="true"] {
  background-color: var(--custom-select-bg-selected);
  color: var(--custom-select-text-selected);
  font-weight: var(--font-weight-bold, 700);
}

.custom-select__option.is-disabled,
.custom-select__option[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

.custom-select__option.is-disabled:hover,
.custom-select__option[aria-disabled="true"]:hover {
  background: transparent;
}

@media (max-width: 768px) {
  .custom-select {
    min-width: 0;
  }

  .custom-select__trigger {
    /* min-height: var(--custom-select-touch-target);
    height: var(--custom-select-touch-target); */
    font-size: max(var(--text-base, 1rem), 16px);
  }

  .custom-select__option {
    min-height: var(--custom-select-touch-target);
    display: flex;
    align-items: center;
    font-size: max(var(--text-base, 1rem), 16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-select__trigger,
  .custom-select__trigger-icon,
  .custom-select__option {
    transition: none;
  }
}
