/*
 * .select — styled dropdown over a native <select> (select.js; markup: site-form.php, FAQ topic list).
 * Figma "drop-down-click"; the same open look as the listing filters (filter-bar.css, 397:38816).
 *
 * The closed trigger is a button with the .field__input classes, so it keeps the exact look of the
 * native field (field.css, site-form.css). Only the open state is drawn here: mist box with a 2 px
 * blue frame and an arrow up, the list right under it (overlays the content, does not push it).
 */

/* .select__trigger — a button, not an input: text from the left, one line with an ellipsis */
.select__trigger {
  display: block;
  text-align: left;
}

/* .select__value — a long option ends with "…"; text-overflow does not work on the button itself.
   The taller line box with equal negative margins keeps descenders (p, y, g) from being cut by overflow
   and leaves the text where the native select puts it */
.select__value {
  display: block;
  margin-block: -0.15em;
  overflow: hidden;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* .select__trigger--placeholder — "no choice" reads like a placeholder (field.css does it for the native select) */
.field--select .select__trigger--placeholder {
  color: var(--nv-blue);
}

/* .select--open .select__trigger — mist box, 2 px blue frame (the left padding gives back the 0.5 px of the thicker frame), arrow up */
.field--select.select--open .select__trigger {
  border-width: 0.125rem;
  border-color: var(--nv-blue);
  padding-left: calc(1.25rem - 0.0625rem);
  background-color: var(--nv-mist);
  background-image: url("../../img/icons/select-chevron-up.svg");

  /* @media (width >= 48em) .field--select.select--open .select__trigger */
  @media (width >= 48em) {
    padding-left: calc(1.875rem - 0.0625rem);
  }
}

/* .select--open .select__value — the current option at 50 % */
.select--open .select__value {
  opacity: 0.5;
}

/* .select__options — list right under the box: 20 px to the first cap, 15 px around each 1 px line;
   text size as in the trigger (18 → 20 px) */
.select__options {
  position: absolute;
  z-index: 10;
  top: 100%;
  right: 0;
  left: 0;
  max-height: min(25rem, var(--select-options-max, 25rem));
  margin: 0;
  border: 1px solid #f6f7f9;
  border-radius: 0.625rem;
  padding: 0.1875rem 1.25rem 1.1875rem;
  overflow-y: auto;
  background-color: var(--nv-mist);
  font-size: 1.125rem;
  text-align: left;
  list-style: none;

  /* .select__options:focus — the active option marks the position, no ring around the list */
  &:focus {
    outline: none;
  }

  /* @media (width >= 48em) .select__options — 30 px sides, as the box */
  @media (width >= 48em) {
    padding-inline: 1.875rem;
    font-size: 1.25rem;
  }
}

/* .select--up .select__options — no room below (the card clips the list): open upwards, the box keeps its look */
.select--up .select__options {
  top: auto;
  bottom: 100%;
}

/* .select__option — 70 %, line at 10 %; cap top / baseline 15 px from the lines; a long option wraps */
.select__option {
  border-bottom: 1px solid rgba(33, 91, 135, 0.1);
  padding: calc(0.9375rem - 0.14em) 0;
  color: rgba(33, 91, 135, 0.7);
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: color 0.3s ease, border-color 0.3s ease;

  /* .select__option[hidden] — the current option is not listed */
  &[hidden] {
    display: none;
  }
}

/* .select__option--active — hovered or keyboard-active option at full colour */
.select__option--active {
  border-bottom-color: var(--nv-blue);
  color: var(--nv-blue);
}

/* @media (prefers-reduced-motion: reduce) .select */
@media (prefers-reduced-motion: reduce) {
  .select__value,
  .select__option {
    transition: none;
  }
}
