/* AMOSHA select popover.
 *
 * Native <select> stays the form/value source. JS intercepts user opening and
 * renders this themed listbox instead of the platform picker.
 */
.amosha-select-popover {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  max-width: min(460px, calc(100vw - 24px));
  max-height: min(360px, 55vh);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid color-mix(in srgb, var(--border, rgba(0,0,0,.12)) 78%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface-solid, #fff) 96%, transparent);
  color: var(--text, #1d1d1f);
  box-shadow:
    0 16px 42px rgba(15, 23, 42, .16),
    0 2px 8px rgba(15, 23, 42, .07),
    inset 0 1px 0 rgba(255,255,255,.66);
  backdrop-filter: blur(20px) saturate(145%);
  -webkit-backdrop-filter: blur(20px) saturate(145%);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.amosha-select-popover::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.amosha-select-popover[hidden] {
  display: none !important;
}

.amosha-select-group-label {
  padding: 8px 10px 5px;
  color: var(--muted, #6e6e73);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.amosha-select-option {
  box-sizing: border-box;
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 9px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.amosha-select-option:hover,
.amosha-select-option.is-active {
  background: color-mix(in srgb, var(--accent, #007aff) 8%, var(--surface-solid, #fff));
}

.amosha-select-option[aria-selected="true"] {
  color: var(--accent, #007aff);
  background: color-mix(in srgb, var(--accent, #007aff) 11%, var(--surface-solid, #fff));
  font-weight: 650;
}

.amosha-select-option[aria-selected="true"]::after {
  content: "✓";
  margin-left: auto;
  flex: 0 0 auto;
  font-weight: 800;
}

.amosha-select-option:disabled {
  opacity: .45;
  cursor: not-allowed;
}

select[data-amosha-select-open="true"] {
  border-color: var(--accent, #007aff) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #007aff) 18%, transparent) !important;
}

@media (max-width: 640px) {
  .amosha-select-popover {
    top: auto !important;
    left: max(12px, env(safe-area-inset-left)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: min(62dvh, 520px);
    padding: 9px;
    border-radius: 18px;
    box-shadow: 0 -10px 42px rgba(0,0,0,.20);
  }

  .amosha-select-option {
    min-height: 48px;
    padding: 11px 12px;
    font-size: 15px;
  }

  .amosha-select-group-label {
    padding: 9px 12px 6px;
    font-size: 12px;
  }
}


.amosha-select-mobile-trigger {
  display: none;
}

@media (max-width: 640px) {
  select.amosha-select-mobile-source {
    position: absolute !important;
    width: 1px !important;
    min-width: 1px !important;
    height: 1px !important;
    min-height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    clip-path: inset(50%) !important;
  }

  .amosha-select-mobile-trigger {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 36px 10px 12px;
    position: relative;
    border: 1px solid var(--border, rgba(0,0,0,.12));
    border-radius: 12px;
    background: var(--surface-solid, #fff);
    color: var(--text, #1d1d1f);
    font: inherit;
    font-size: 16px;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
  }

  .amosha-select-mobile-trigger::after {
    content: "⌄";
    position: absolute;
    right: 12px;
    top: 50%;
    color: var(--muted, #6e6e73);
    font-size: 16px;
    line-height: 1;
    transform: translateY(-56%);
  }

  .amosha-select-mobile-trigger:focus-visible,
  .amosha-select-mobile-trigger[aria-expanded="true"] {
    outline: none;
    border-color: var(--accent, #007aff);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #007aff) 18%, transparent);
  }

  .amosha-select-popover {
    top: auto !important;
    left: max(12px, env(safe-area-inset-left)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: min(62dvh, 520px);
    padding: 9px;
    border-radius: 20px;
    box-shadow:
      0 -14px 48px rgba(15,23,42,.20),
      inset 0 1px 0 rgba(255,255,255,.7);
  }
}
