/**
 * core/lib/ui/search.css — .ui-search typeahead primitive.
 *
 * Self-contained + theme-neutral: every colour is a CSS var with a sensible
 * default, so it looks right on a dark landing out of the box and a host can
 * retint by setting --uis-* on the wrapper. Loaded once by render_ui_search().
 */

.ui-search {
  /* Theme-aware: inherit the host's design tokens when present, so the box flips with the
     site's light/dark theme; fall back to self-contained dark values otherwise. hover,
     active and the focus ring derive from --fg/--accent via color-mix, so they adapt too. */
  --uis-bg:        var(--card, #12151c);
  --uis-panel:     var(--card, #171b24);
  --uis-border:    var(--border, rgba(255, 255, 255, .10));
  --uis-fg:        var(--fg, #e8ecf3);
  --uis-muted:     var(--muted, #93a0b4);
  --uis-accent:    var(--p1, #6b8afd);
  --uis-ok:        #7fe0a6;
  --uis-hover:     color-mix(in srgb, var(--uis-fg) 8%, transparent);
  --uis-active:    color-mix(in srgb, var(--uis-accent) 16%, transparent);
  --uis-radius:    14px;
  --uis-shadow:    0 16px 44px rgba(10, 15, 40, .28);

  position: relative;
  z-index: 30;                     /* float the box + dropdown above adjacent content */
  display: block;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  font: inherit;
}
/* light skin: the one self-owned accent (the "reviewed" green) needs a darker tone for
   contrast on a light surface; structural colours already flip via the host tokens. */
[data-theme="light"] .ui-search { --uis-ok: #12905a; --uis-shadow: 0 14px 40px rgba(20, 30, 60, .14); }

/* ---- input row ---- */
.ui-search__box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
  background: var(--uis-bg);
  border: 1px solid var(--uis-border);
  border-radius: var(--uis-radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ui-search__box:focus-within {
  border-color: var(--uis-accent);
  box-shadow: 0 0 0 3px var(--uis-active);
}
.ui-search__icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--uis-muted);
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.ui-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--uis-fg);
  font-size: 16px;                 /* ≥16px: no iOS focus-zoom */
  line-height: 1.2;
  outline: none;
}
.ui-search__input::placeholder { color: var(--uis-muted); }
.ui-search__spin {
  flex: 0 0 auto;
  width: 16px; height: 16px;
  border: 2px solid var(--uis-border);
  border-top-color: var(--uis-accent);
  border-radius: 50%;
  animation: uis-spin .7s linear infinite;
  display: none;
}
.ui-search.is-loading .ui-search__spin { display: block; }
@keyframes uis-spin { to { transform: rotate(360deg); } }

/* ---- results panel ---- */
.ui-search__panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(62vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--uis-panel);
  border: 1px solid var(--uis-border);
  border-radius: var(--uis-radius);
  box-shadow: var(--uis-shadow);
  padding: 6px;
  display: none;
  text-align: left;
}
.ui-search.is-open .ui-search__panel { display: block; }

.ui-search__group {
  padding: 8px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--uis-muted);
}

.ui-search__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--uis-fg);
  text-decoration: none;
  cursor: pointer;
}
.ui-search__row:hover,
.ui-search__row.is-active { background: var(--uis-hover); }
.ui-search__row[aria-disabled="true"] { cursor: default; opacity: .72; }

.ui-search__thumb {
  flex: 0 0 auto;
  width: 46px; height: 30px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--uis-hover);
  border: 1px solid var(--uis-border);
}
.ui-search__body {
  flex: 1 1 auto;
  min-width: 0;                    /* lets the two lines ellipsis instead of pushing the badge */
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ui-search__name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ui-search__meta {
  display: block;
  font-size: 12px;
  line-height: 1.2;
  color: var(--uis-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ui-search__meta b { color: var(--uis-fg); font-weight: 600; }

.ui-search__badge {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--uis-muted);
  border: 1px solid var(--uis-border);
  white-space: nowrap;
}
.ui-search__badge--ok    { color: #7fe0a6; border-color: rgba(127, 224, 166, .35); }
.ui-search__badge--go    { color: #cdd8ff; border-color: rgba(107, 138, 253, .55); background: var(--uis-active); }

/* external "↗ TV" click-out — its own tap target, right of the badge */
.ui-search__ext {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  color: var(--uis-muted);
  border: 1px solid var(--uis-border);
  text-decoration: none;
  white-space: nowrap;
}
.ui-search__ext:hover {
  color: var(--uis-fg);
  border-color: var(--uis-accent);
  background: var(--uis-hover);
}

.ui-search__empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--uis-muted);
  font-size: 13.5px;
}

@media (max-width: 560px) {
  .ui-search__thumb { width: 40px; height: 26px; }
  .ui-search__box { height: 50px; }
}
