/*
 * ma-combobox.css — Darstellung der Auswahl-Combobox (siehe ma-combobox.js)
 * -------------------------------------------------------------------------
 * Diese Datei verwendet ausschließlich die Variablen der Werksnorm
 * (design-norm.css). Es werden KEINE neuen Einzelfarbwerte angelegt.
 *
 * Die entscheidende Regel gegen das Safari-Höhenproblem: Das sichtbare Feld ist
 * ein <button>, dessen Höhe wir vollständig selbst bestimmen. Dadurch fluchtet
 * die Combobox in Chrome, Firefox UND Safari exakt mit <input>-Feldern gleicher
 * Norm-Höhe. Die Höhe wird NICHT hart in px gesetzt, sondern aus der Norm-
 * Variable abgeleitet — so bleibt eine zentrale Änderung wirksam.
 *
 * Erwartete Norm-Variable: --ma-control-height (aus design-norm.css).
 * Fallback nur, falls die Norm nicht geladen ist.
 */

.ma-combobox {
  --_h: var(--ma-control-height, 48px);
  --_radius: var(--ma-field-radius, 12px);
  position: relative;
  display: block;
  width: 100%;
}

/* Natives Select ausblenden, ohne es aus Formular/DOM zu entfernen. */
.ma-combobox-native {
  position: absolute;
  /* Fest an die Ecke des Wrappers: ohne left/top landet das versteckte Feld an
     seiner statischen Position rechts neben dem Knopf und schiebt auf Handys
     die Seitenbreite um seine Mindestbreite hinaus (Fund 13.09.2026). */
  left: 0;
  top: 0;
  width: 1px;
  min-width: 0;
  max-width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
}

.ma-combobox__trigger {
  box-sizing: border-box;
  width: 100%;
  height: var(--_h);
  min-height: var(--_h);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--_radius);
  background: var(--white, #fff);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.ma-combobox__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Platzhalter (leerer Wert) gedämpft darstellen — aber nie nur über Farbe
   Information transportieren; der Text selbst ("Bitte wählen …") trägt sie. */
.ma-combobox--placeholder .ma-combobox__value {
  color: var(--muted);
}

.ma-combobox__arrow {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform .15s ease;
}

.ma-combobox.is-open .ma-combobox__arrow {
  transform: translateY(1px) rotate(-135deg);
}

/* Sichtbarer, kontrastreicher Fokus — Pflicht laut Accessibility-Norm. */
.ma-combobox__trigger:focus-visible {
  outline: none;
  border-color: var(--aqua-text);
  box-shadow: var(--ma-focus-ring, 0 0 0 4px rgba(23, 195, 200, .18));
}

.ma-combobox__trigger:disabled {
  cursor: not-allowed;
  background: var(--paper);
  color: var(--muted);
}

.ma-combobox__listbox {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: auto;
  /* Seit 09.10.2026: mindestens so breit wie das Feld,
     sonst so breit wie der längste Eintrag – kein Umbruch mitten im Wort. */
  min-width: 100%;
  width: max-content;
  max-width: min(440px, calc(100vw - 32px));
  max-height: 280px;
  margin: 0;
  padding: 6px;
  list-style: none;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--_radius);
  background: var(--white, #fff);
  box-shadow: var(--shadow, 0 18px 50px rgba(16, 33, 53, .12));
}

.ma-combobox__option {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  cursor: pointer;
  /* nur umbrechen, wenn ein Eintrag breiter als die Höchstbreite ist (dann an Silbengrenzen) */
  overflow-wrap: break-word;
  -webkit-hyphens: auto;
  hyphens: auto;
}

/* Ragt die breitere Liste rechts aus dem Fenster, wird sie am rechten Feldrand ausgerichtet. */
.ma-combobox__listbox.is-rechts {
  left: auto;
  right: 0;
}

/* Aktiver (per Tastatur angesteuerter) Eintrag. */
.ma-combobox__option.is-active {
  background: var(--aqua-soft, #e7f7f4);
  color: var(--navy);
}

/* Bereits gewählter Eintrag — zusätzlich zur Farbe ein Häkchen, damit die
   Auswahl nicht allein über Farbe erkennbar ist. */
.ma-combobox__option[aria-selected="true"] {
  font-weight: 800;
}

.ma-combobox__option[aria-selected="true"]::after {
  content: "✓";
  float: right;
  margin-left: 10px;
  color: var(--aqua-text);
}

.ma-combobox__option.is-disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: .7;
}

@media (prefers-reduced-motion: reduce) {
  .ma-combobox__arrow {
    transition: none;
  }
}
