/**
 * Kuehn Discovery – Live Search Styles
 */

/* ── Trigger button ──────────────────────────── */

.kuehn-live-search {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: 0;
}

.kuehn-live-search__trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--wp--preset--color--contrast, #1a1a1a);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.kuehn-live-search__trigger:hover {
  background-color: #f5f6f8;
}

.kuehn-live-search__trigger svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ── Overlay ─────────────────────────────────── */

.kuehn-live-search__overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(15vh, 120px);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  animation: kuehnSearchFadeIn 0.15s ease-out;
}

.kuehn-live-search__overlay[hidden] {
  display: none !important;
}

@keyframes kuehnSearchFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Panel ───────────────────────────────────── */

.kuehn-live-search__panel {
  width: 90vw;
  max-width: 560px;
  max-height: 70vh;
  background: var(--wp--preset--color--base, #fff);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: kuehnSearchSlideIn 0.2s ease-out;
}

@keyframes kuehnSearchSlideIn {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ── Input area ──────────────────────────────── */

.kuehn-live-search__input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--wp--preset--color--neutral, #e0e0e0);
}

.kuehn-live-search__icon {
  flex-shrink: 0;
  color: var(--wp--preset--color--secondary, #666);
}

.kuehn-live-search__input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--wp--preset--color--contrast, #1a1a1a);
  font-family: inherit;
}

.kuehn-live-search__input::placeholder {
  color: var(--wp--preset--color--secondary, #999);
}

.kuehn-live-search__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 4px;
  color: var(--wp--preset--color--secondary, #666);
}

.kuehn-live-search__close:hover {
  color: var(--wp--preset--color--contrast, #1a1a1a);
}

/* ── Results area ────────────────────────────── */

.kuehn-live-search__results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0;
}

/* ── Loading / Empty ─────────────────────────── */

.kuehn-live-search__loading,
.kuehn-live-search__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--wp--preset--color--secondary, #666);
  font-size: 0.9rem;
}

/* ── Groups ──────────────────────────────────── */

.kuehn-live-search__group {
  padding: 4px 0;
}

.kuehn-live-search__group + .kuehn-live-search__group {
  border-top: 1px solid var(--wp--preset--color--neutral, #e8e8e8);
}

.kuehn-live-search__group-label {
  padding: 8px 16px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wp--preset--color--secondary, #888);
}

/* ── Result items ────────────────────────────── */

.kuehn-live-search__item {
  transition: background 0.1s;
}

.kuehn-live-search__item--active,
.kuehn-live-search__item:hover {
  background: var(--wp--preset--color--neutral, #f5f5f5);
}

.kuehn-live-search__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  text-decoration: none;
  color: inherit;
}

.kuehn-live-search__thumb {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.kuehn-live-search__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kuehn-live-search__title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--wp--preset--color--contrast, #1a1a1a);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kuehn-live-search__meta {
  font-size: 0.78rem;
  color: var(--wp--preset--color--secondary, #777);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Access badge ────────────────────────────── */

.kuehn-live-search__badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 4px;
}

.kuehn-live-search__badge--paid,
.kuehn-live-search__badge--supporter {
  background: var(--wp--preset--color--primary, #c6a04a);
  color: #fff;
}

.kuehn-live-search__badge--premium {
  background: #8b5cf6;
  color: #fff;
}

/* ── All results link ────────────────────────── */

.kuehn-live-search__all-results {
  display: block;
  padding: 12px 16px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--wp--preset--color--primary, #c6a04a);
  text-decoration: none;
  border-top: 1px solid var(--wp--preset--color--neutral, #e8e8e8);
  transition: background 0.15s;
}

.kuehn-live-search__all-results:hover {
  background: var(--wp--preset--color--neutral, #f5f5f5);
}

/* ── Body state ──────────────────────────────── */

body.kuehn-search-open {
  overflow: hidden;
}

/* ── Responsive ──────────────────────────────── */

@media (max-width: 600px) {
  .kuehn-live-search__overlay {
    padding-top: 0;
    align-items: stretch;
  }

  .kuehn-live-search__panel {
    width: 100vw;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
