/*
  Shared marketplace select menu.

  Native <select> elements remain in the form for submission and no-JS use.
  select-menu.js progressively replaces their visible interaction with an
  accessible listbox so Windows/browser popup chrome cannot override the CSDP
  interface.
*/

:root {
  --ui-select-layer: 60;
  --ui-select-ink: #17202a;
  --ui-select-muted: #5f6b76;
  --ui-select-line: #c9d0d7;
  --ui-select-paper: #ffffff;
  --ui-select-hover: #f3f6f8;
  --ui-select-selected: #e8f4f4;
  --ui-select-focus: #0a6170;
  --ui-select-danger: #b3261e;
}

.ui-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.ui-select.is-open {
  z-index: var(--ui-select-layer);
}

.ui-select__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.ui-select__trigger {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 9px 38px 9px 12px;
  border: 1px solid var(--ui-select-line);
  border-radius: 8px;
  color: var(--ui-select-ink);
  background: var(--ui-select-paper);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.ui-select__trigger::after {
  position: absolute;
  top: 50%;
  right: 15px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateY(-68%) rotate(45deg);
  transition: transform 140ms ease-out;
}

.ui-select.is-open .ui-select__trigger::after {
  transform: translateY(-28%) rotate(225deg);
}

.ui-select__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-select__trigger:hover {
  border-color: #9da8b2;
}

.ui-select__trigger:disabled {
  color: var(--ui-select-muted);
  cursor: not-allowed;
  opacity: .68;
}

.ui-select__trigger:focus-visible {
  border-color: var(--ui-select-focus);
  outline: 2px solid var(--ui-select-focus);
  outline-offset: 2px;
}

.ui-select.is-invalid .ui-select__trigger {
  border-color: var(--ui-select-danger);
  box-shadow: inset 0 0 0 1px var(--ui-select-danger);
}

.ui-select__menu {
  position: absolute;
  z-index: var(--ui-select-layer);
  top: calc(100% + 7px);
  right: -1px;
  left: -1px;
  max-height: min(320px, calc(100vh - 28px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--ui-select-line);
  border-radius: 8px;
  background: var(--ui-select-paper);
  box-shadow: 0 14px 34px rgba(16, 40, 63, .18);
  overscroll-behavior: contain;
}

.ui-select.is-up .ui-select__menu {
  top: auto;
  bottom: calc(100% + 7px);
}

.ui-select__backdrop {
  display: none;
}

.ui-select__backdrop[hidden],
.ui-select__menu[hidden] {
  display: none;
}

.ui-select__option {
  position: relative;
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 9px 38px 9px 11px;
  border-radius: 8px;
  color: var(--ui-select-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.ui-select__option[hidden] {
  display: none;
}

.ui-select__option:hover,
.ui-select__option.is-active {
  background: var(--ui-select-hover);
}

.ui-select__option[aria-selected="true"] {
  color: var(--ui-select-focus);
  background: var(--ui-select-selected);
  font-weight: 700;
}

.ui-select__option[aria-selected="true"]::after {
  position: absolute;
  right: 14px;
  width: 11px;
  height: 6px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(-45deg);
}

.ui-select__option[aria-disabled="true"] {
  color: var(--ui-select-muted);
  cursor: not-allowed;
  opacity: .62;
}

.ui-select__option:focus-visible {
  outline: 2px solid var(--ui-select-focus);
  outline-offset: -2px;
}

/* Homepage search: one 56px target with its label sitting inside the field. */
.hp-search__field.ui-select-field {
  position: relative;
  display: block;
  padding: 0 18px;
}

.hp-search__field.ui-select-field > label {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 18px;
  pointer-events: none;
}

.hp-search__field .ui-select__trigger {
  min-height: 56px;
  padding: 19px 36px 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 700;
}

.hp-search__field .ui-select__trigger:hover {
  border-color: transparent;
}

.hp-search__field .ui-select__trigger:focus-visible {
  border-color: transparent;
  outline-offset: 4px;
}

.hp-search__field .ui-select__menu {
  right: -18px;
  left: -18px;
  min-width: 260px;
}

/* Persistent guide/profile search uses the same integrated-label treatment. */
.dir-search__field.ui-select-field {
  position: relative;
  display: block;
  padding: 0 12px;
}

.dir-search__field.ui-select-field > label {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 12px;
  pointer-events: none;
}

.dir-search__field .ui-select__trigger {
  min-height: 52px;
  padding: 17px 34px 1px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
}

.dir-search__field .ui-select__trigger:hover {
  border-color: transparent;
}

.dir-search__field .ui-select__trigger:focus-visible {
  border-color: transparent;
  outline-offset: 3px;
}

.dir-search__field .ui-select__menu {
  right: -12px;
  left: -12px;
}

/* Guide filter rail: conventional label-above-control treatment. */
.sr-rail .ui-select__trigger {
  min-height: 44px;
  border-color: var(--ui-select-line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}

.sr-rail .ui-select__option {
  font-size: 14px;
}

@media (max-width: 700px) {
  .ui-select__backdrop:not([hidden]) {
    position: fixed;
    z-index: calc(var(--ui-select-layer) - 1);
    display: block;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(16, 40, 63, .34);
    cursor: default;
  }

  .ui-select__menu {
    position: fixed;
    z-index: var(--ui-select-layer);
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    max-height: min(68vh, 520px);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -12px 34px rgba(16, 40, 63, .18);
  }

  .ui-select__menu::before {
    display: block;
    padding: 8px 11px 12px;
    border-bottom: 1px solid var(--ui-select-line);
    color: var(--ui-select-ink);
    content: attr(data-sheet-title);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
  }

  .hp-search__field .ui-select__menu,
  .dir-search__field .ui-select__menu {
    right: 0;
    left: 0;
    min-width: 0;
  }

  .ui-select__option {
    min-height: 48px;
    padding-top: 11px;
    padding-bottom: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-select__trigger::after,
  .ui-select__option {
    transition-duration: .01ms;
  }
}
