/* Dropdown (static/select.js) -- the one place its look is defined.
 *
 * Deliberately its own file, not part of style.css or cockpit.css: the component is shared by the
 * website and (once opted in) the console, and only its BOX chrome needs to match the surrounding
 * form. That chrome is copied from `.field select` in style.css, so an enhanced dropdown is
 * indistinguishable from a plain field until it is opened.
 *
 * The panel is absolutely positioned inside the wrapper: it therefore opens under the field, at the
 * field's width, on every browser -- which is the entire point (see select.js).
 */

.lsel { position: relative; }

/* The native select stays in the form (it is what submits and what `change` handlers watch) but is
 * taken out of sight and out of the tab order. Not `display:none`: a hidden-but-present control keeps
 * autofill and constraint validation working. */
.lsel-native {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}

.lsel-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--field-border);
  border-radius: 0.6rem;
  padding: 0.7rem 2.5rem 0.7rem 0.85rem;
  color: var(--text);
  font-family: inherit;
  font-size: var(--step-0);
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  /* the same quiet chevron the native control was given, in the same spot */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%239D9486' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 0.72rem;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
/* An unanswered optional question reads as an invitation, not as a filled-in field. */
.lsel-trigger.is-empty { color: var(--muted); }
.lsel-trigger:hover { border-color: var(--faint); }
.lsel-trigger:focus-visible,
.lsel-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--ember-deep);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ember-deep) 18%, transparent);
}
.lsel-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lsel-pop {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  z-index: 60;
  padding: 0.35rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 0.7rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  overscroll-behavior: contain;
  /* a short settle rather than a pop, so the list feels attached to the field it came from */
  animation: lsel-in 120ms var(--ease);
}
@keyframes lsel-in {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lsel-pop { animation: none; }
  .lsel-trigger { transition: none; }
}

.lsel-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  /* 2.75rem clears the 44px touch target on a phone without looking airy on a desktop */
  min-height: 2.75rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.45rem;
  color: var(--muted);
  cursor: pointer;
  text-wrap: pretty;
}
.lsel-opt.is-active { color: var(--text); background: var(--surface); }
.lsel-opt[aria-selected="true"] { color: var(--text); }
.lsel-opt[aria-disabled="true"] { color: var(--faint); cursor: default; }
.lsel-tick {
  flex: none;
  width: 0.9rem;
  color: var(--ember);
  text-align: center;
  opacity: 0;
}
.lsel-opt[aria-selected="true"] .lsel-tick { opacity: 1; }
.lsel-label { min-width: 0; }
