/* ===== KwK Live-Search Autocomplete (v4 css, 2026-04-27) =====
 * v4 (2026-04-27 evening):
 *   - DYM-Item-Styles im Suggest-Dropdown (Akzent-Farbe + ↪ Icon).
 *   - Browser-Default Search-Cancel-Button (blaues X) versteckt.
 *   - Custom Backspace-Clear-Button (.kwk-search-clear).
 *   - Popular-Pills im Suggest-Dropdown (Empty-State-Fallback).
 *
 * v3 (2026-04-27): Quick-Suggest-Pills (Empty-State Top-5) + <mark> Highlighting
 *   in Autocomplete-Items. Did-You-Mean-Card auf SERP.
 */

/* ===== Browser-Default Search-Cancel-Button verstecken =====
   WebKit (Safari, Chrome) zeigt im type=search ein blaues X — passt nicht
   ins CI. Wir verstecken es überall und nutzen unseren eigenen
   .kwk-search-clear-Button stattdessen. */
.kwk-search-input::-webkit-search-cancel-button,
.kwk-search-input::-webkit-search-decoration,
.kwk-header-search-input::-webkit-search-cancel-button,
.kwk-mobile-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
/* IE/Edge legacy */
.kwk-search-input::-ms-clear,
.kwk-search-input::-ms-reveal {
  display: none;
  width: 0;
  height: 0;
}

.kwk-header-search-wrap,
.kwk-mobile-search,
.kwk-footer-contact-ki {
  position: relative; /* suggest box is absolutely positioned */
}

/* Override theme's overflow:hidden so suggest dropdown is visible.
   The mobile bot-wrap itself uses overflow:hidden for the slide-in width
   animation — once the search is fully open we MUST switch to visible so
   the absolutely positioned .kwk-search-suggest dropdown isn't clipped. */
.kwk-header-search-wrap.active,
.kwk-mobile-bot-wrap.search-open,
.kwk-mobile-bot-wrap.search-open .kwk-mobile-search,
.kwk-footer-contact-ki {
  overflow: visible !important;
}

.kwk-search-input {
  cursor: text !important;
}
.kwk-search-input[disabled],
.kwk-search-input[readonly] {
  cursor: text !important;
}

/* Suggest dropdown */
.kwk-search-suggest {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(17,17,17,0.97);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 6px;
  min-width: 260px;
  max-height: 420px;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55);
  z-index: 99999;
}
.kwk-search-suggest.is-open {
  display: block;
}

.kwk-search-suggest-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
  transition: background 0.15s, color 0.15s;
}
.kwk-search-suggest-item:hover,
.kwk-search-suggest-item:focus-visible {
  background: rgba(107,66,44,0.18);
  color: #fff;
  outline: none;
}
.kwk-search-suggest-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kwk-search-suggest-kind {
  flex: 0 0 auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(196,145,106,0.8);
  padding: 3px 8px;
  background: rgba(107,66,44,0.14);
  border-radius: 20px;
}
.kwk-search-suggest-empty {
  padding: 14px;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  text-align: center;
}
.kwk-search-suggest-all {
  display: block;
  padding: 10px 14px;
  margin-top: 4px;
  border-top: 1px solid rgba(255,255,255,0.07);
  color: rgba(196,145,106,0.95);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-align: center;
  border-radius: 0 0 8px 8px;
  transition: color 0.15s, background 0.15s;
}
.kwk-search-suggest-all:hover {
  color: #fff;
  background: rgba(107,66,44,0.18);
}

/* Footer variant — opens upward because footer is at bottom */
.kwk-search-suggest--footer {
  top: auto;
  bottom: calc(100% + 6px);
  max-width: 360px;
}

/* Mobile variant — pill is only 180px wide; let dropdown extend to viewport */
.kwk-search-suggest--mobile {
  min-width: 260px;
  max-height: 60vh;
  /* Anchor to right edge of pill so dropdown extends LEFT into the viewport */
  left: auto;
  right: 0;
  width: max-content;
  max-width: calc(100vw - 24px);
}

@media (max-width: 640px) {
  .kwk-search-suggest {
    left: -4px;
    right: -4px;
  }
  /* mobile pill variant — keep right-anchored, ignore the generic mobile rule above */
  .kwk-search-suggest--mobile {
    left: auto;
    right: 0;
  }
}

/* ===== Hit-Highlighting in Autocomplete-Items =====
   Server rendert <mark> in Such-Snippets (kwk-search-mark style). Hier dasselbe
   Look-and-Feel auch im Suggest-Dropdown — in beiden Modi. */
.kwk-search-suggest mark {
  background: rgba(200, 164, 94, 0.30);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}
/* Ergebnisseite: Sicherheit falls die in-page-injection (kwk-search-mark style)
   nicht greift — gleiche Definition als Fallback hier. */
.dnc-search mark {
  background: rgba(200, 164, 94, 0.30);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* ===== Quick-Suggest-Pills (Empty-State) =====
   Erscheinen unter dem Input wenn er fokussiert + leer ist. 5 kuratierte
   Top-Begriffe als Dropdown-Panel (vertikal gestackt) — visuell parallel
   zum .kwk-search-suggest Autocomplete-Dropdown. */
.kwk-search-quick {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: rgba(17, 17, 17, 0.97);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  z-index: 99998;
  min-width: 260px;
  max-height: 420px;
  overflow-y: auto;
}
.kwk-search-quick[hidden] { display: none !important; }
/* JS sorgt dafür, dass Suggest und Quick nie gleichzeitig sichtbar sind (Quick
   = empty-state, Suggest = >=2 chars). Race-Schutz hier weggelassen. */

/* Optionale Überschrift "Häufig gesucht" — falls JS sie rendert.
   Aktuell rendert JS nur Pills, daher rein als Vorbereitung. */
.kwk-search-quick-heading {
  display: block;
  padding: 4px 10px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(196, 145, 106, 0.75);
  font-weight: 600;
}

.kwk-search-quick-pill {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.2px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.kwk-search-quick-pill:hover,
.kwk-search-quick-pill:focus-visible {
  background: rgba(107, 66, 44, 0.18);
  border-color: rgba(196, 145, 106, 0.30);
  color: #fff;
  outline: none;
}

/* Mobile-Variante: gleiche vertikale Logik, nur Padding etwas kompakter. */
.kwk-search-quick--mobile {
  padding: 6px;
}

@media (max-width: 640px) {
  .kwk-search-quick {
    left: -4px;
    right: -4px;
    min-width: 0;
  }
  .kwk-search-quick-pill {
    width: 100%;
    max-width: 100%;
  }
}

/* ===== Did-You-Mean Card (Suchergebnis-Seite, 2026-04-27) =====
   Wird gerendert wenn die Original-Query 0 Treffer hat, aber die
   Levenshtein-Korrektur echte Treffer liefert. KEINE "Keine Ergebnisse"-
   Meldung mehr — Card wird prominent direkt unter dem H1 platziert.

   Render-Funktion: `kwk_search_improved_render_dym_card()` in
   wp-content/mu-plugins/kwk-search-improved.php (Block 6c).

   Liste-Items nutzen `.dnc-search-result` — also gleicher Look wie
   normale Treffer-Liste. Hier nur der Card-Container + Header.
*/

.dnc-search .dnc-search-h1-sub {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.55em;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.2px;
}
@media (max-width: 640px) {
  .dnc-search .dnc-search-h1-sub {
    display: block;
    margin-left: 0;
    margin-top: 6px;
    font-size: 13px;
  }
}

.kwk-search-dym-card {
  margin: 28px 0 36px;
  padding: 28px 28px 12px;
  background: linear-gradient(135deg, rgba(200,164,94,0.10), rgba(200,164,94,0.04));
  border: 1px solid rgba(200,164,94,0.32);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.kwk-search-dym-card__head {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(200, 164, 94, 0.18);
}

.kwk-search-dym-card__eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(200, 164, 94, 0.92);
  background: rgba(200, 164, 94, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.kwk-search-dym-card__title {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.25;
  color: var(--kwk-text, #fff);
  font-weight: 600;
}
.kwk-search-dym-card__title a {
  color: var(--kwk-accent, #c8a45e);
  text-decoration: none;
  border-bottom: 2px solid rgba(200, 164, 94, 0.55);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.kwk-search-dym-card__title a:hover {
  color: #fff;
  border-bottom-color: #fff;
}
.kwk-search-dym-card__title strong {
  font-weight: 700;
}

.kwk-search-dym-card__sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.75);
}
.kwk-search-dym-card__sub span {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.35);
}
.kwk-search-dym-card__sub strong {
  color: var(--kwk-accent, #c8a45e);
  font-weight: 600;
}

/* Items kommen als .dnc-search-result rein — Theme-Defaults greifen.
   Letztes Item: kein extra Bottom-Margin. */
.kwk-search-dym-card__results .dnc-search-result:last-child {
  margin-bottom: 12px;
}

@media (max-width: 640px) {
  .kwk-search-dym-card {
    margin: 20px 0 28px;
    padding: 22px 18px 8px;
    border-radius: 12px;
  }
  .kwk-search-dym-card__head {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }
  .kwk-search-dym-card__title {
    font-size: 21px;
  }
  .kwk-search-dym-card__sub {
    font-size: 14px;
  }
}

/* ===== DYM-Item im Autocomplete-Dropdown (v4, 2026-04-27) =====
   "Meintest du …?" — wird ganz oben gerendert, optisch abgesetzt mit
   Akzent-Farbe + Icon. Klick → Redirect auf SERP mit korrigierter Query. */
.kwk-search-suggest-item--dym {
  background: rgba(200, 164, 94, 0.10);
  border: 1px solid rgba(200, 164, 94, 0.28);
  color: rgba(255, 255, 255, 0.94);
  font-style: italic;
  margin-bottom: 4px;
  gap: 10px;
}
.kwk-search-suggest-item--dym:hover,
.kwk-search-suggest-item--dym:focus-visible {
  background: rgba(200, 164, 94, 0.20);
  border-color: rgba(200, 164, 94, 0.55);
  color: #fff;
}
.kwk-search-suggest-item--dym strong {
  color: rgba(220, 184, 114, 1);
  font-weight: 700;
  font-style: normal;
}
.kwk-search-suggest-dym-icon {
  flex: 0 0 auto;
  font-size: 16px;
  font-style: normal;
  line-height: 1;
  color: rgba(200, 164, 94, 0.95);
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 164, 94, 0.18);
  border-radius: 50%;
}

/* ===== Popular-Pills-Heading im Suggest-Dropdown (Empty-Fallback) ===== */
.kwk-search-suggest-popular-heading {
  display: block;
  padding: 10px 14px 6px;
  margin-top: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(196, 145, 106, 0.78);
  font-weight: 600;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.kwk-search-suggest-empty + .kwk-search-suggest-popular-heading {
  border-top: none;
  margin-top: 0;
}
.kwk-search-suggest-item--popular .kwk-search-suggest-popular-icon {
  flex: 0 0 auto;
  width: 18px;
  text-align: center;
  font-size: 12px;
  color: rgba(200, 164, 94, 0.65);
  margin-right: 2px;
}
.kwk-search-suggest-item--popular {
  gap: 8px;
}

/* ===== Custom Backspace-Clear-Button (v4, 2026-04-27) =====
   Sitzt rechts neben dem Input innerhalb der Pill. SVG-Backspace-Icon
   passend zum CI (Akzent-Farbe). Nur sichtbar wenn Input nicht leer. */
.kwk-search-clear {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0 2px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.kwk-search-clear[hidden] {
  display: none !important;
}
.kwk-search-clear:hover,
.kwk-search-clear:focus-visible {
  background: rgba(200, 164, 94, 0.18);
  color: rgba(220, 184, 114, 1);
  outline: none;
}
.kwk-search-clear:active {
  background: rgba(200, 164, 94, 0.28);
}
.kwk-search-clear svg {
  width: 18px;
  height: 18px;
  display: block;
}

/* Mobile-Variante: Tap-Target etwas größer für Touch */
.kwk-search-clear--mobile {
  width: 34px;
  height: 34px;
}
.kwk-search-clear--mobile svg {
  width: 19px;
  height: 19px;
}

/* Mobile-Search-Field is grid/flex parent — make sure clear button doesn't
   break the input layout. Field wraps input + button horizontally. */
.kwk-mobile-search-field {
  display: flex;
  align-items: center;
  gap: 0;
}
.kwk-mobile-search-field .kwk-mobile-search-input {
  flex: 1 1 auto;
  min-width: 0;
}
