/*
 * TTS-328: the site search button (in the header) and its dialog. Loaded with
 * search.js on every page, including pages with their own inline styles (the
 * beta page), which share the site colour variables (--ink, --line, --accent …).
 */
.search-open { margin: 0; display: inline-flex; }
.search-link {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 15px; color: var(--muted); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px 6px 10px; min-height: 36px;
}
.search-link:hover { color: var(--ink); border-color: var(--muted); }
.search-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.search-link kbd {
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 3px 6px; background: var(--bg);
}
@media (max-width: 720px) {
  .search-link .search-label, .search-link kbd { display: none; }
  .search-link { padding: 6px 8px; min-width: 36px; min-height: 36px; justify-content: center; }
}
/* Phones: the menu stays one line (brand, Blog, API, Beta, Search, Dashboard). */
@media (max-width: 420px) {
  header.top .wrap { gap: 10px; }
  nav.links { gap: 9px; flex-wrap: nowrap; }
  .search-link { min-width: 34px; min-height: 34px; padding: 5px 7px; }
}
/* Very narrow screens: two lines rather than a menu wider than the screen. */
@media (max-width: 359px) { nav.links { flex-wrap: wrap; } }

dialog.av-search {
  width: min(640px, calc(100vw - 32px)); max-height: min(72vh, 640px); margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink);
  box-shadow: 0 24px 60px rgba(15, 17, 32, .25); overflow: hidden; display: none; flex-direction: column;
}
dialog.av-search[open] { display: flex; }
dialog.av-search::backdrop { background: rgba(15, 17, 32, .45); backdrop-filter: blur(2px); }
.av-search form { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.av-search input[type="search"] {
  flex: 1; min-width: 0; font: inherit; font-size: 18px; color: var(--ink); background: transparent; border: 0; padding: 8px 4px; outline: none;
}
.av-search input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
.av-search-close {
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
.av-search-status { margin: 0; padding: 10px 18px 4px; font-size: 13px; color: var(--muted); }
.av-search-keys { margin: 0; padding: 8px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.av-search-results { list-style: none; margin: 0; padding: 6px 8px 10px; overflow-y: auto; overscroll-behavior: contain; }
dialog.av-search .av-search-results { flex: 1; }
.av-search-results li a {
  display: grid; gap: 3px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); cursor: pointer;
}
.av-search-results li[aria-selected="true"] a, .av-search-results li a:hover { background: var(--accent-soft); }
.av-search-results li a:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.av-search-results .r-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.av-search-results .r-kind {
  flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 2px 8px;
}
.av-search-results .r-title { font-weight: 650; font-size: 16px; }
.av-search-results .r-snippet { font-size: 14px; color: var(--muted); line-height: 1.5; }
.av-search-results .r-url { font-size: 12px; color: var(--muted); opacity: .85; }
.av-search-results mark { background: transparent; color: var(--accent); font-weight: 700; }
.av-search-results .r-group { padding: 10px 12px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.av-search-results .r-empty { padding: 14px 12px; color: var(--muted); }
@media (max-width: 720px) {
  dialog.av-search { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.av-search[open] { animation: av-search-in .14s ease-out; }
  @keyframes av-search-in { from { opacity: 0; transform: translateY(-6px) scale(.99); } }
}
/* Touch screens have no arrow keys: no key hints. */
@media (pointer: coarse) { .av-search-keys { display: none; } }
