/* Header search: the round button opens into a field; results drop down over
   the page as a card of rows. Loaded only when the site is built with SEARCH=1.
   Uses the variables and row styles from styles.css. */

/* ---------- the button and the field ---------- */

.srch { display: flex; align-items: center; }
.srch[hidden] { display: none; }
.srch__form { display: none; }

.top--search .srch__open { display: none; }
.top--search .top__edition { display: none; }
.top--search .srch__form {
  display: flex; align-items: center; gap: 8px;
  width: min(380px, 56vw); height: 36px; padding: 0 5px 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  animation: srch-open 160ms ease-out;
}
.top--search .srch__form:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
@keyframes srch-open { from { width: 36px; opacity: 0.4; } }

.srch__icon { display: grid; color: var(--faint); }
.srch__input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; outline: none;
  background: none; color: var(--ink); font: inherit; font-size: 15px;
  -webkit-appearance: none; appearance: none;
}
.srch__input::placeholder { color: var(--faint); }
.srch__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.srch__close {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer;
}
.srch__close:hover { color: var(--ink); background: var(--bg); }

/* ---------- the results card ---------- */

.srch__backdrop {
  position: fixed; inset: 0; z-index: 15;
  background: rgb(12 12 14 / 0.16);
  animation: srch-fade 140ms ease-out;
}
:root[data-theme="dark"] .srch__backdrop { background: rgb(0 0 0 / 0.5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .srch__backdrop { background: rgb(0 0 0 / 0.5); } }
@keyframes srch-fade { from { opacity: 0; } }

.srch__panel {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: calc(min(var(--w), 100vw) - 2 * var(--pad));
  max-height: min(70vh, 660px); overflow: auto; overscroll-behavior: contain;
  padding: 4px 6px 6px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg);
  box-shadow: 0 24px 60px -18px rgb(0 0 0 / 0.28), 0 2px 8px rgb(0 0 0 / 0.05);
  animation: srch-drop 150ms ease-out;
}
.srch__panel[hidden] { display: none; }
@keyframes srch-drop { from { opacity: 0; transform: translate(-50%, -6px); } }
.srch__panel.is-loading .srch__list { opacity: 0.55; transition: opacity 120ms ease 120ms; }

/* Same label style as the "On RepoRanking" headings on repo pages. */
.srch__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 10px 4px;
  color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
}
.srch__head span { letter-spacing: 0; text-transform: none; font-weight: 500; }

.srch__list { margin: 0; }
.srch__list .row__card { grid-template-columns: 40px minmax(0, 1fr) auto; column-gap: 12px; padding: 12px 10px; border-radius: 12px; }
.srch__list .row + .row .row__card::before { left: 10px; right: 10px; }
.srch__list .row__card.is-active { background: var(--surface); }
.srch__list .row__card.is-active::before, .srch__list .row:has(.is-active) + .row .row__card::before { opacity: 0; }
.srch__list .row__link::after { border-radius: 12px; }
.srch__list .thumb { width: 40px; height: 40px; border-radius: 10px; font-size: 17px; }
.srch__list .row__title { font-size: 15.5px; }
.srch__list .row__desc {
  font-size: 14.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.srch__snip {
  margin-top: 4px; color: var(--faint); font-size: 13.5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.srch__list .stars { min-width: 52px; padding: 6px 6px 5px; font-size: 12px; }
.srch__list mark {
  padding: 0 1px; border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit;
}

.srch__empty { padding: 22px 10px 18px; color: var(--muted); font-size: 15px; }
.srch__empty strong { color: var(--ink); }
.srch__empty p + p { margin-top: 4px; color: var(--faint); font-size: 14px; }

.srch__foot {
  display: flex; gap: 14px; padding: 10px 10px 4px; margin-top: 4px; border-top: 1px solid var(--line);
  color: var(--faint); font-size: 12px;
}
.srch__foot kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-right: 3px; border: 1px solid var(--line); border-radius: 5px;
  font: 600 11px/16px var(--font); text-align: center; color: var(--muted); background: var(--surface);
}

/* ---------- small screens: the field takes the whole header row ---------- */

@media (max-width: 600px) {
  .top--search .logo, .top--search .theme:not(.srch__open) { display: none; }
  .top--search .top__end, .top--search .srch { flex: 1; }
  .top--search .srch__form { width: 100%; }
  .srch__panel { top: calc(100% + 6px); max-height: calc(100dvh - 140px); padding: 2px 4px 4px; }
  .srch__foot, .srch__head span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .top--search .srch__form, .srch__panel, .srch__backdrop { animation: none; }
}
