/*
 * -----------------------------
 * CoreX — Bausteine der Oberflaeche
 * TiNi #Software
 * ------------------------------
 * Created: 2026-10-21
 * Last Change: 2026-11-24
 * Change Log:
 *   2026-11-24  Leiste am Handy: .cxu-bar-chips, .cxu-chip-row, .cxu-swipe,
 *               .cxu-bar-search(-toggle), .cxu-bar-label; Knöpfe in Leiste und Tabelle
 *               am Handy mindestens 24 px (Staff-Board UX-Plan U7).
 * ------------------------------
 *
 * WAS JEDE VERWALTUNG HAT — einmal.
 *
 * Gemessen am 2026-10-21 ueber vierzehn Stylesheets: die Kopfzeile baut
 * jede Suite fuer sich (elf Mal), die Zeile elf Mal, die Liste zehn,
 * Karte und leerer Zustand je neun, Zustandsmarke und Raster je acht.
 * Elf Suiten ueberschreiben Bootstraps `.btn` — jede auf ihre Art.
 *
 * Diese Datei schreibt KEINE Farbe auf. Jede Angabe ist ein Merkmal aus
 * `corex_tokens.css`. Wer hier eine Farbe findet, hat einen Fehler
 * gefunden — `tools/check_design_tokens.php` prueft es.
 *
 * SIE ERSETZT BOOTSTRAP NICHT. Knopf, Formularfeld und Raster bleiben
 * Bootstrap; hier steht nur, was Bootstrap nicht hat und was deshalb
 * bisher achtmal nebeneinander entstanden ist.
 *
 * NAMENSRAUM `cx-`. Das Praefix der Bausteine ist bewusst ein anderes
 * als das der Merkmale (`--ui-`): ein Baustein ist eine Klasse, ein
 * Merkmal ein Wert. Wer `.cxu-badge` liest, weiss, dass er etwas
 * Gemeinsames vor sich hat und keine Suitenklasse.
 */

/* ==================================================================
   BAUSTEINE
   ================================================================== */

/* --- Zustandsmarke ------------------------------------------------
   Ein Zustand muss ohne Lesen erkennbar sein. Deshalb Form UND Farbe:
   die Pille traegt, die Farbe unterscheidet. Wer nur Farbe benutzt,
   verliert jeden, der sie nicht unterscheiden kann. */

.cxu-badge {
  display: inline-flex;
  align-items: baseline;
  gap: var(--ui-gap-1);
  padding: .12rem .55rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-pill);
  background: var(--ui-surface-2);
  color: var(--ui-ink-soft);
  font-size: var(--ui-text-s);
  line-height: 1.5;
  white-space: nowrap;
}

.cxu-badge.is-ok   { background: var(--ui-ok-bg);   border-color: var(--ui-ok-line);   color: var(--ui-ok); }
.cxu-badge.is-warn { background: var(--ui-warn-bg); border-color: var(--ui-warn-line); color: var(--ui-warn); }
.cxu-badge.is-bad  { background: var(--ui-bad-bg);  border-color: var(--ui-bad-line);  color: var(--ui-bad); }
.cxu-badge.is-info { background: var(--ui-info-bg); border-color: var(--ui-info-line); color: var(--ui-info); }

/* --- Merkkasten --------------------------------------------------- */

.cxu-note {
  border-left: 3px solid var(--ui-line);
  background: var(--ui-surface-2);
  color: var(--ui-ink);
  padding: var(--ui-gap-3) var(--ui-gap-4);
  margin-bottom: var(--ui-gap-3);
  font-size: var(--ui-text);
  border-radius: 0 var(--ui-radius) var(--ui-radius) 0;
}

.cxu-note.is-ok   { border-left-color: var(--ui-ok);   background: var(--ui-ok-bg); }
.cxu-note.is-warn { border-left-color: var(--ui-warn); background: var(--ui-warn-bg); }
.cxu-note.is-bad  { border-left-color: var(--ui-bad);  background: var(--ui-bad-bg); }

/* --- Karte --------------------------------------------------------- */

.cxu-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius-l);
  padding: var(--ui-gap-4);
  margin-bottom: var(--ui-gap-3);
  box-shadow: var(--ui-shadow);
}

.cxu-card-head {
  display: flex;
  align-items: center;
  gap: var(--ui-gap-2);
  flex-wrap: wrap;
  margin-bottom: var(--ui-gap-2);
}

.cxu-meta {
  color: var(--ui-ink-soft);
  font-size: var(--ui-text-s);
  margin: 0;
}

/* --- Tabelle -------------------------------------------------------
   Breite Tabellen rollen IN SICH, nicht die Seite. Sonst wandert bei
   vierzehn Spalten das ganze Seitengeruest nach links. */

/* position: relative hält auch absolut gesetzte Kinder im Behälter (etwa
   eine visually-hidden-Beschriftung im Tabellenkopf); ohne sie stand die
   Beschriftung am Rand der Tabelle und machte die Seite am Handy breiter. */
.cxu-scroll { overflow-x: auto; position: relative; margin-bottom: var(--ui-gap-4); }

.cxu-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ui-text);
  background: var(--ui-surface);
}

.cxu-table th {
  text-align: left;
  font-size: var(--ui-text-s);
  font-weight: 600;
  color: var(--ui-ink-soft);
  background: var(--ui-surface-2);
  padding: var(--ui-gap-2) var(--ui-gap-3);
  border-bottom: 1px solid var(--ui-line);
  white-space: nowrap;
}

.cxu-table td {
  padding: var(--ui-gap-2) var(--ui-gap-3);
  border-bottom: 1px solid var(--ui-line-soft);
  color: var(--ui-ink);
  vertical-align: top;
}

.cxu-table tbody tr:last-child td { border-bottom: 1px solid var(--ui-line); }
.cxu-table tbody tr:hover td { background: var(--ui-surface-2); }

/* Zahlen in einer Spalte brauchen gleich breite Ziffern — sonst
   wandern Betraege beim Scrollen. */
.cxu-num { text-align: right; font-variant-numeric: var(--ui-num); }

/* --- Leerer Zustand ------------------------------------------------
   Er sagt, was fehlt, nicht dass etwas fehlt. */

.cxu-empty {
  border: 1px dashed var(--ui-line);
  border-radius: var(--ui-radius-l);
  background: var(--ui-surface-2);
  padding: var(--ui-gap-6) var(--ui-gap-4);
  text-align: center;
  color: var(--ui-ink-soft);
  margin-bottom: var(--ui-gap-4);
}

.cxu-empty i { font-size: 1.6rem; opacity: .5; display: block; margin-bottom: var(--ui-gap-2); }
.cxu-empty p { margin: 0; font-size: var(--ui-text); }

/* --- Formularzeile -------------------------------------------------- */

.cxu-field { margin-bottom: var(--ui-gap-4); max-width: 32rem; }

/* legend: Beschriftung einer Gruppe (fieldset.cxu-field), sonst setzt Bootstrap sie in Überschriftengröße. */
.cxu-field label,
.cxu-field legend {
  display: block;
  font-size: var(--ui-text-s);
  font-weight: 600;
  color: var(--ui-ink-soft);
  margin-bottom: var(--ui-gap-1);
}

.cxu-help {
  display: block;
  font-size: var(--ui-text-s);
  color: var(--ui-ink-faint);
  margin-top: var(--ui-gap-1);
}

/* --- Leiste ---------------------------------------------------------
   Werkzeugleiste und Filter in einem. Die Marken sind anklickbar —
   deshalb tragen sie einen Zeiger und eine Reaktion. Eine Marke, die
   nur beschriftet, gehoert NICHT hierher, sondern ist ein `.cxu-badge`. */

.cxu-bar {
  display: flex;
  align-items: center;
  gap: var(--ui-gap-2);
  flex-wrap: wrap;
  margin-bottom: var(--ui-gap-4);
}

.cxu-bar-sp { flex: 1 1 auto; }

.cxu-chip {
  display: inline-flex;
  align-items: baseline;
  gap: var(--ui-gap-1);
  padding: .3rem .7rem;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-pill);
  background: var(--ui-surface);
  color: var(--ui-ink-soft);
  font-size: var(--ui-text-s);
  cursor: pointer;
  user-select: none;
}

.cxu-chip b { color: var(--ui-ink); font-variant-numeric: var(--ui-num); }
.cxu-chip:hover { background: var(--ui-surface-2); }
.cxu-chip.is-on {
  border-color: var(--ui-accent);
  background: var(--ui-accent-bg);
  color: var(--ui-ink);
}

/* Leiste am Handy (Staff-Board, UX-Plan U7): die Marken stehen in einer
   eigenen Zeile und lassen sich wischen, die Suche wartet hinter einem
   Knopf mit Lupe, Knopftexte stehen nur für Vorleser — die Leiste hat
   zwei Zeilen statt vier oder fünf. Am Desktop wirkt nichts davon.
     .cxu-bar-chips           Gruppe der Filter-Marken in der Leiste
     .cxu-chip-row            eigene Zeile nur mit Marken (Tags)
     .cxu-bar-search          Suchfeld; am Handy erst nach dem Knopf
     .cxu-bar-search-toggle   Knopf mit Lupe, nur am Handy sichtbar
     .cxu-bar-label           Text eines Knopfs mit Symbol; am Handy nur
                              für Vorleser
     .cxu-swipe               jede andere Zeile, die am Handy zum Wischen
                              wird statt umzubrechen (Reiter, Filter)
   Kleine Knöpfe in Leiste und Tabelle bekommen am Handy mindestens
   24 x 24 px (WCAG 2.2, 2.5.8). Verhalten in js/corex_ui.js: der aktive
   Eintrag einer Wischzeile (.is-on, .active, aria-current) steht beim
   Laden im sichtbaren Teil. */

.cxu-bar-search-toggle { display: none; }

@media (max-width: 575.98px) {
  .cxu-bar-chips,
  .cxu-chip-row,
  .cxu-swipe {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .cxu-bar-chips,
  .cxu-chip-row { gap: var(--ui-gap-1); }
  .cxu-bar-chips { flex: 1 0 100%; min-width: 0; }
  .cxu-bar-chips::-webkit-scrollbar,
  .cxu-chip-row::-webkit-scrollbar,
  .cxu-swipe::-webkit-scrollbar { display: none; }
  .cxu-bar-chips > *,
  .cxu-chip-row > *,
  .cxu-swipe > * { flex: none; white-space: nowrap; }
  .cxu-swipe .nav-link { white-space: nowrap; }
  .cxu-bar .cxu-bar-search { display: none; }
  .cxu-bar.is-search .cxu-bar-search { display: block; flex: 1 0 100%; max-width: none; order: 10; }
  .cxu-bar-search-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .cxu-bar-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  .cxu-bar .btn-sm,
  .cxu-table .btn-sm { min-width: 1.5rem; min-height: 1.5rem; }
}

/* --- Meter ----------------------------------------------------------
   Ein Anteil an einem Ganzen: Fortschritt, belegte Quote. Die Spur ist
   ein hellerer Schritt desselben Merkmals wie die Füllung, eine
   Haarlinie zeigt ihre Länge; die Füllung trägt die Schwere. Der Wert
   steht immer auch als Text daneben, der Balken allein sagt ihn nicht.
   Breite der Füllung als `style="width: 42%"` am inneren `span`. */

.cxu-meter {
  display: block;
  height: 6px;
  min-width: 4rem;
  overflow: hidden;
  border-radius: var(--ui-pill);
  background: var(--ui-info-bg);
  box-shadow: inset 0 0 0 1px var(--ui-info-line);
}

.cxu-meter > span {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: var(--ui-pill);
  background: var(--ui-info);
}

.cxu-meter.is-ok          { background: var(--ui-ok-bg);   box-shadow: inset 0 0 0 1px var(--ui-ok-line); }
.cxu-meter.is-ok > span   { background: var(--ui-ok); }
.cxu-meter.is-warn        { background: var(--ui-warn-bg); box-shadow: inset 0 0 0 1px var(--ui-warn-line); }
.cxu-meter.is-warn > span { background: var(--ui-warn); }
.cxu-meter.is-bad         { background: var(--ui-bad-bg);  box-shadow: inset 0 0 0 1px var(--ui-bad-line); }
.cxu-meter.is-bad > span  { background: var(--ui-bad); }

/* --- Bildfeld -------------------------------------------------------
   Logo, Hintergrund, Unterschrift, Favicon einer Einstellung: Vorschau,
   Wählen oder Ablegen, Zurücksetzen, Pfad unter „Erweitert“. Markup aus
   branding_image::field_html(), Verhalten in js/corex_ui.js. Ein
   hochgeladenes Bild gilt erst mit „Speichern“; bis dahin trägt das Feld
   `is-dirty`. Das Schachbrett hinter der Vorschau zeigt durchsichtige
   Flächen eines Logos. */

.cxu-image {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ui-gap-3);
  align-items: flex-start;
}

.cxu-image-frame {
  position: relative;
  flex: 0 0 auto;
  width: 11rem;
  height: 6.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  border: 1px dashed var(--ui-line);
  border-radius: var(--ui-radius);
  background-color: var(--ui-surface-2);
  background-image:
    linear-gradient(45deg, var(--ui-line-soft) 25%, transparent 25%, transparent 75%, var(--ui-line-soft) 75%),
    linear-gradient(45deg, var(--ui-line-soft) 25%, transparent 25%, transparent 75%, var(--ui-line-soft) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}

.cxu-image-frame.is-square { width: 6.5rem; }

.cxu-image-frame:hover,
.cxu-image-frame:focus-visible,
.cxu-image.is-drag .cxu-image-frame {
  border-color: var(--ui-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--ui-accent-bg);
}

.cxu-image-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cxu-image-empty,
.cxu-image-drop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--ui-gap-1);
  padding: var(--ui-gap-2);
  text-align: center;
  font-size: var(--ui-text-s);
  color: var(--ui-ink-soft);
  background: var(--ui-surface-2);
}

.cxu-image.is-empty .cxu-image-preview,
.cxu-image.is-broken .cxu-image-preview { display: none; }
.cxu-image.is-empty .cxu-image-empty { display: flex; }
.cxu-image.is-drag .cxu-image-drop { display: flex; color: var(--ui-accent-ink); background: var(--ui-accent-bg); }
.cxu-image.is-busy .cxu-image-frame { opacity: .6; cursor: progress; }
.cxu-image.is-dirty .cxu-image-frame { border-style: solid; border-color: var(--ui-warn); }
.cxu-image.is-broken .cxu-image-frame { border-color: var(--ui-bad); }

.cxu-image-body {
  flex: 1 1 14rem;
  min-width: 0;
}

.cxu-image-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-gap-1);
}

.cxu-image-pick { margin: 0; cursor: pointer; }

.cxu-image-meta,
.cxu-image-state {
  margin: var(--ui-gap-1) 0 0;
  font-size: var(--ui-text-s);
  color: var(--ui-ink-soft);
}

.cxu-image-state:empty { display: none; }
.cxu-image-state.is-warn { color: var(--ui-warn); }
.cxu-image-state.is-bad  { color: var(--ui-bad); }

.cxu-image-adv { margin-top: var(--ui-gap-1); font-size: var(--ui-text-s); }
.cxu-image-adv > summary { cursor: pointer; color: var(--ui-ink-soft); }
.cxu-image-adv > input { margin-top: var(--ui-gap-1); max-width: 28rem; font-family: var(--bs-font-monospace, monospace); }

.cxu-form-error {
  display: block;
  margin-top: var(--ui-gap-1);
  font-size: var(--ui-text-s);
  color: var(--ui-bad);
}

/* --- Toast ----------------------------------------------------------
   Rückmeldung nach einem Vorgang ohne Neuladen. `window.cxuToast(text,
   art)` aus js/corex_ui.js; Art ok, warn, bad oder info. Die Farbe steht
   nur am Rand, der Text bleibt auf der Fläche lesbar. Fehler bleiben
   länger stehen als Bestätigungen. */

.cxu-toasts {
  position: fixed;
  right: var(--ui-gap-4);
  bottom: var(--ui-gap-4);
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap-2);
  max-width: min(26rem, calc(100vw - 2 * var(--ui-gap-4)));
  pointer-events: none;
}

.cxu-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--ui-gap-2);
  padding: var(--ui-gap-2) var(--ui-gap-3);
  border: 1px solid var(--ui-line);
  border-left: 4px solid var(--ui-info);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-l);
  pointer-events: auto;
  animation: cxu-toast-in .2s ease-out;
  transition: opacity .25s, transform .25s;
}

.cxu-toast.is-ok   { border-left-color: var(--ui-ok); }
.cxu-toast.is-warn { border-left-color: var(--ui-warn); }
.cxu-toast.is-bad  { border-left-color: var(--ui-bad); }
.cxu-toast.is-out  { opacity: 0; transform: translateY(.5rem); }

.cxu-toast-text { flex: 1 1 auto; font-size: var(--ui-text); }

.cxu-toast-close {
  flex: 0 0 auto;
  border: 0;
  padding: 0 var(--ui-gap-1);
  background: transparent;
  color: var(--ui-ink-soft);
  font-size: var(--ui-text-l);
  line-height: 1;
  cursor: pointer;
}

@keyframes cxu-toast-in {
  from { opacity: 0; transform: translateY(.5rem); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .cxu-toast { animation: none; transition: none; }
}
