/* The forms' hand-built selects (js/controls.js; site_web::forms): a .select-styled button
   with role="combobox" and a listbox popup. Needs tokens.css and components.css (the
   button is also a .select, so its border, hover, focus ring and invalid state are the
   other fields'). Without JavaScript none of this applies: the native select shows.
   No inline styles (the CSP refuses them); the script sets only custom properties
   (--combo-max, --y, --h) through the CSSOM. */

.combo { position: relative; min-width: 0; }
.combo.is-open { z-index: 30; }

/* ---------- The button ---------- */
.combo-button {
  position: relative; display: flex; align-items: center; width: 100%; text-align: left;
  background-image: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
/* Open: the ring stays while the list is in use (focus stays on the button anyway). */
.combo.is-open .combo-button { box-shadow: 0 0 0 1px var(--accent), 0 0 0 3px rgba(70, 54, 240, .28); }
.combo-value { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.combo-value.is-changed { animation: combo-value-in .24s var(--ease-out); }
.combo-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-text.is-placeholder { color: var(--soft); }
.combo-chevron {
  position: absolute; right: 14px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .2s var(--ease-out);
}
.combo.is-open .combo-chevron { transform: rotate(180deg); }

/* A state's flag: 24 x 16, the flag contained in it (some aren't 3:2); a hairline that
   follows the flag's own edge keeps a white flag off the white control. */
.combo-flag {
  flex: none; display: block; width: 24px; height: 16px; object-fit: contain;
  filter: drop-shadow(0 0 .6px rgba(11, 19, 36, .55));
}
.combo-flag--none { filter: none; }

/* ---------- The list ---------- */
/* The panel: edge, shadow and motion. The listbox inside scrolls (as a combobox's popup,
   it needs no focus of its own to be scrolled: the arrow keys on the button do it). */
.combo-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(11, 19, 36, .06), 0 24px 44px -20px rgba(15, 25, 60, .3);
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: 50% 0;
  transition: opacity .13s ease-in, transform .13s ease-in;
}
.combo-panel.is-shown {
  opacity: 1; transform: none;
  transition: opacity .16s var(--ease-out), transform .2s var(--ease-out);
}
/* No room below: it opens upward, from the button. */
.combo.is-up .combo-panel { top: auto; bottom: calc(100% + 6px); transform: translateY(6px) scale(.98); transform-origin: 50% 100%; }
.combo.is-up .combo-panel.is-shown { transform: none; }

.combo-list {
  position: relative; list-style: none; margin: 0; padding: 6px; outline: none;
  max-height: calc(var(--combo-max, 320px) - 2px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.combo-option {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 8px 34px 8px 10px; border-radius: 7px;
  font-size: 15.5px; line-height: 1.35; color: var(--ink); cursor: pointer;
  transition: color .15s ease;
}
.combo-option.is-placeholder { color: var(--soft); }
.combo-option[aria-selected="true"] { font-weight: 600; }
.combo-option[aria-disabled="true"] { color: var(--soft); cursor: not-allowed; }
.combo-option-text { min-width: 0; overflow-wrap: anywhere; }
.combo-check {
  position: absolute; right: 11px; top: 50%; width: 13px; height: 13px; margin-top: -6.5px;
  fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transform: scale(.5);
  transition: opacity .15s ease, transform .22s var(--ease-out);
}
.combo-option[aria-selected="true"] .combo-check { opacity: 1; transform: none; }
/* An optional select's placeholder is the empty choice: no weight, no tick. */
.combo-option.is-placeholder[aria-selected="true"] { font-weight: inherit; }
.combo-option.is-placeholder .combo-check { display: none; }

/* The active option's highlight: one block behind the options that slides from one to
   the next (--y and --h: the active option's offset and height, set by the script). */
.combo-list::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 0; height: var(--h, 0);
  transform: translateY(var(--y, 0)); border-radius: 7px; background: var(--accent-tint);
  box-shadow: inset 0 0 0 1px var(--accent-tint-2);
  opacity: 0; pointer-events: none;
  transition: transform .16s var(--ease-out), height .16s var(--ease-out), opacity .12s ease;
}
.combo-list.has-active::before { opacity: 1; }
.combo-list.is-instant::before { transition: opacity .12s ease; }

/* Touch: options a thumb can hit (WCAG 2.5.8 asks 24px; Apple and Google 44 to 48). */
@media (pointer: coarse) {
  .combo-option { min-height: 46px; }
}

@keyframes combo-value-in {
  from { opacity: 0; transform: translateY(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .combo-panel, .combo-panel.is-shown, .combo.is-up .combo-panel { transform: none; transition: none; }
  .combo-list::before, .combo-list.is-instant::before, .combo-chevron, .combo-check, .combo-option { transition: none; }
  .combo-check { transform: none; }
  .combo-value.is-changed { animation: none; }
}

/* Windows High Contrast and other forced colours: the highlight's tint would vanish. */
@media (forced-colors: active) {
  .combo-list::before { display: none; }
  .combo-option.is-active { outline: 2px solid Highlight; outline-offset: -2px; }
  .combo-chevron, .combo-check { stroke: CanvasText; }
  .combo-panel { border-color: CanvasText; }
}
