/* Durchgehende Suche in der Kopfzeile (Lupe neben der Glocke, Suchfenster), seit 2026-10-15.
   Nur Tokens aus tokens.css, nichts hartcodiert. Klassen mit Präfix such- .
   Verhalten und Aufbau: js/suche.js. Das Fenster trägt .overlay (der Schleier kommt von dort). */

/* ─── Lupe in der Kopfleiste ───
   Größe, Rundung und Hover erbt sie von .tb-trigger. Auf dem Handy bleibt sie so groß wie ihre Nachbarn
   (36 bis 38 px), damit die schwebende Pille der Startseite nicht höher wird und die Zeile darunter
   nicht überdeckt. Die Trefferfläche wächst trotzdem auf mindestens 44 px: ein durchsichtiges
   Pseudoelement ragt 4 px über den Rand, und 4 px Abstand zur Glocke lassen es nicht unter deren
   Fläche geraten. */
@media (max-width: 768px) {
  #tbSuche { margin-right: var(--s-1); }
  #tbSuche::before { content: ''; position: absolute; inset: calc(var(--s-1) * -1); }
}

/* ─── Schleier und Fenster ─── */
/* .overlay macht nur die Deckkraft unsichtbar, ein geschlossenes Fenster bliebe per Tab erreichbar.
   visibility schaltet erst nach dem Ausblenden um, und sofort beim Öffnen. */
.overlay.such-overlay {
  align-items: flex-start;
  justify-content: center;
  padding: var(--s-16) var(--s-4) var(--s-4);
  visibility: hidden;
  transition: opacity var(--dur-base) var(--ease-standard),
              visibility 0s linear var(--dur-base);
}
.overlay.such-overlay.open {
  visibility: visible;
  transition: opacity var(--dur-base) var(--ease-standard),
              visibility 0s;
}

.such-fenster {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(560px, calc(100vh - var(--s-16) - var(--s-4)));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  overflow: hidden;
  transform: translateY(calc(var(--s-2) * -1)) scale(0.98);
  transition: transform var(--dur-base) var(--ease-standard);
}
.overlay.such-overlay.open .such-fenster { transform: none; }

/* ─── Kopf mit Eingabefeld ─── */
.such-kopf {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
  padding: var(--s-4);
  border-bottom: 1px solid var(--c-border);
}
.such-kopf .such-feld { flex: 1; min-width: 0; }
.such-lupe {
  position: absolute;
  left: var(--s-3);
  width: 20px;
  height: 20px;
  color: var(--c-muted);
  pointer-events: none;
}
/* Doppelte Klasse: schlägt .form-input (components.css) und die Regel für das Kreuz-Polster */
.such-kopf .such-eingabe.such-eingabe {
  height: var(--s-12);
  padding: 0 var(--s-3) 0 var(--s-10);
  font-size: var(--fs-md);
  border-radius: var(--r-sm);
}
.such-kopf .such-feld > .such-eingabe:not(:placeholder-shown) { padding-right: var(--s-10); }
.such-kopf .such-eingabe:focus-visible,
.such-kopf .such-eingabe:focus { border-color: var(--c-accent); box-shadow: var(--sh-focus); }
.such-kopf .such-x { width: var(--s-8); height: var(--s-8); right: var(--s-2); }
.such-schliessen { display: none; flex-shrink: 0; }

/* ─── Körper ─── */
.such-koerper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-2);
  scroll-padding: var(--s-8) 0 var(--s-2);
}
.such-gruppe + .such-gruppe { margin-top: var(--s-2); }
.such-gruppentitel {
  position: sticky;
  top: calc(var(--s-2) * -1);
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-1);
  background: var(--c-surface);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--c-slate-600);
}
.such-zahl { font-weight: var(--fw-medium); text-transform: none; letter-spacing: 0; white-space: nowrap; }

/* ─── Zeile ─── */
.such-eintrag {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 44px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
/* Der aktive Eintrag trägt Fläche, Balken links und das Enter-Zeichen: nicht nur Farbe. */
.such-eintrag.is-aktiv { background: var(--c-neutral-soft); }
.such-eintrag.is-aktiv::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--s-2);
  bottom: var(--s-2);
  width: var(--s-1);
  border-radius: var(--r-full);
  background: var(--c-accent);
}
.such-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.such-titel {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--c-text);
}
.such-unter,
.such-fund {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--c-slate-600);
}
.such-fund { font-size: var(--fs-xs); }
.such-fund-bez { font-weight: var(--fw-semibold); }
/* Treffer: Fläche und kräftigere Schrift, nicht nur eine andere Farbe */
.such-mark {
  border-radius: var(--r-xs);
  background: var(--c-accent-soft);
  color: var(--c-text);
  font-weight: var(--fw-bold);
}
.such-marken {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 55%;
  gap: var(--s-1);
}
/* Eine Zeile: reicht der Platz nicht, kürzen die hinteren Marken mit Auslassungspunkten (der volle
   Text steht im Tooltip), die erste Marke (Status) bleibt immer ganz. */
.such-marke {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 var(--s-2);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: var(--s-5);
  background: var(--c-surface);
  color: var(--c-slate-600);
}
.such-marke:first-child { flex-shrink: 0; }
.such-marke-info { border-color: transparent; background: var(--c-info-bg); color: var(--c-info-strong); }
.such-marke-ok   { border-color: transparent; background: var(--c-success-bg); color: var(--c-success-strong); }
.such-marke-warn { border-color: transparent; background: var(--c-warning-bg-2); color: var(--c-warning-deep); }
.such-marke-rot  { border-color: transparent; background: var(--c-danger-bg-2); color: var(--c-danger-deep); }
.such-enter {
  flex-shrink: 0;
  width: var(--s-4);
  text-align: center;
  color: var(--c-slate-600);
  opacity: 0;
}
.such-eintrag.is-aktiv .such-enter { opacity: 1; }
.such-mehr .such-titel { color: var(--c-accent); }
.such-rest { padding: var(--s-1) var(--s-3) var(--s-2); font-size: var(--fs-xs); color: var(--c-slate-600); }

/* ─── Zustände, Hinweise ─── */
.such-zustand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-8) var(--s-4);
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--c-slate-600);
}
.such-zustand-titel { font-size: var(--fs-base); font-weight: var(--fw-semibold); color: var(--c-text); overflow-wrap: anywhere; }
.such-zeit { font-size: var(--fs-xs); }
.such-spinner { width: var(--s-6); height: var(--s-6); border-width: 2px; }
.such-knopf { margin-top: var(--s-2); }
.such-ladehinweis {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-1) var(--s-1) var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  background: var(--c-surface-2);
  font-size: var(--fs-sm);
  color: var(--c-slate-600);
}
.such-spinner-klein { width: var(--s-4); height: var(--s-4); border-width: 2px; flex-shrink: 0; }
.such-leerhinweis { padding: var(--s-3) var(--s-3) var(--s-2); font-size: var(--fs-sm); color: var(--c-slate-600); }
.such-hinweis {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-1) var(--s-1) var(--s-2);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-warning-border-2);
  border-radius: var(--r-sm);
  background: var(--c-warning-bg-3);
  font-size: var(--fs-sm);
  color: var(--c-warning-deep);
}
.such-knopf-klein {
  flex-shrink: 0;
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--c-warning-border);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}
.such-knopf-klein:focus-visible,
.such-knopf:focus-visible,
.such-schliessen:focus-visible { outline: none; box-shadow: var(--sh-focus); }

/* ─── Fusszeile mit Tastenhinweisen (nur ab 769 px, der Rest der App kippt bei 768 px) ─── */
.such-fuss { display: none; }
@media (min-width: 769px) {
  .such-fuss {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2) var(--s-4);
    flex-shrink: 0;
    padding: var(--s-2) var(--s-4);
    border-top: 1px solid var(--c-border);
    background: var(--c-surface-2);
    font-size: var(--fs-xs);
    color: var(--c-slate-600);
  }
  .such-fuss > span { display: inline-flex; align-items: center; gap: var(--s-1); }
  .such-fuss-rechts { margin-left: auto; }
  .such-fuss kbd {
    display: inline-block;
    min-width: var(--s-5);
    padding: 0 var(--s-1);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--r-xs);
    background: var(--c-surface);
    font-family: inherit;
    font-size: var(--fs-xs);
    line-height: var(--lh-normal);
    text-align: center;
    color: var(--c-slate-600);
  }
}

/* ─── Bis 768 px: fast vollflächig, Zeilen und Knöpfe mindestens 44 px ─── */
@media (max-width: 768px) {
  .overlay.such-overlay { padding: var(--s-2); }
  .such-fenster { max-height: calc(100vh - var(--s-4)); max-height: calc(100dvh - var(--s-4)); }
  .such-kopf { padding: var(--s-3); }
  .such-schliessen { display: inline-flex; min-height: 44px; }
  .such-kopf .such-x { width: 44px; height: 44px; right: 0; }
  .such-eintrag { flex-wrap: wrap; min-height: 44px; }
  .such-marken { flex-wrap: wrap; max-width: none; justify-content: flex-start; order: 3; flex-basis: 100%; }
  .such-marke:first-child { flex-shrink: 1; }
  .such-enter { display: none; }
  .such-knopf, .such-knopf-klein { min-height: 44px; }
}
