/* Cross-page search palette — the ⌕ toggle (sits left of Contents) and the
   ⌘K command palette built by setupGlobalSearch() in site.js.
   Single source: site.css @imports this for every lab/article page; the blog
   reader (a self-contained page that doesn't load site.css) links it directly.
   Relies on the host page's :root vars (--navy/--ink/--muted/--accent/
   --accent-dark/--card-border), which both site.css and the blog reader define. */

.site-search-toggle {
  position: fixed;
  top: 18px; right: 18px;           /* right (and top) re-set by JS to sit left of Contents */
  z-index: 1001;
  background: var(--navy);
  color: #67e8f9;
  border: 1px solid rgba(103,232,249,0.40);
  border-radius: 8px;
  padding: 9px 14px;
  font: 700 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15,23,42,0.30);
  display: inline-flex; align-items: center; gap: 8px;
}
.site-search-toggle:hover { background: #0f1d44; color: #a5f3fc; }
.site-search-toggle .ss-icon { font-size: 15px; line-height: 1; }

/* Blog reader sits its Contents button lower (below the reader hero); match it
   so the Search button shares that row when Contents is hidden. JS nudges it
   left of Contents whenever Contents is visible. */
body[data-search-only] .site-search-toggle { top: 152px; right: 22px; }

.site-search-overlay {
  position: fixed; inset: 0;
  z-index: 1100;
  background: rgba(10,18,40,0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px;
  opacity: 0; visibility: hidden;
  transition: opacity 0.15s ease;
}
body.site-search-open .site-search-overlay { opacity: 1; visibility: visible; }

.site-search-panel {
  width: 560px; max-width: 100%;
  background: #fff; color: var(--ink);
  border: 1px solid var(--card-border); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(10,18,40,0.45);
  overflow: hidden;
  transform: translateY(-8px);
  transition: transform 0.15s ease;
}
body.site-search-open .site-search-panel { transform: translateY(0); }

.site-search-inputwrap {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--card-border);
}
.site-search-inputwrap .ss-icon { color: var(--muted); font-size: 18px; flex-shrink: 0; }
.site-search-input {
  flex: 1; border: 0; outline: none; background: none;
  font-size: 16px; color: var(--ink); font-family: inherit;
}
.site-search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.site-search-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.site-search-results:empty { display: none; }
.site-search-results .group-label {
  font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 8px 12px 4px;
}
.site-search-results .group-label:first-child { padding-top: 4px; }
.site-search-results .item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  font-size: 14px; color: var(--ink); line-height: 1.3; cursor: pointer;
}
.site-search-results .item:hover,
.site-search-results .item.active {
  background: rgba(28,181,211,0.12); color: var(--accent-dark);
  text-decoration: none;
}
.site-search-results .item-title {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-search-results .item-meta {
  font-size: 11px; font-family: ui-monospace, monospace; flex-shrink: 0;
  letter-spacing: 0.02em;
  background: rgba(28,181,211,0.10); color: var(--accent-dark);
  padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(28,181,211,0.30);
}
.site-search-results .item.content { align-items: flex-start; }
.site-search-results .item.content .item-meta {
  background: rgba(124,58,237,0.10); color: #6d28d9; border-color: rgba(124,58,237,0.30);
}
.site-search-results .item-title-wrap {
  flex: 1 1 0%; min-width: 0;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.site-search-results .item-title-wrap .item-title { display: block; width: 100%; }
.site-search-results .item-snippet {
  display: block; font-size: 12px; color: var(--muted);
  line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.site-search-results .item-snippet .match { color: var(--ink); }
.site-search-results .item .match { font-weight: 700; color: var(--accent-dark); }
.site-search-results .item-arrow { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.site-search-results .ss-empty {
  padding: 14px 12px; font-size: 13px; color: var(--muted); font-style: italic;
}

@media (max-width: 880px) {
  /* Search toggle mirrors the Contents button's mobile position/styling and
     drops its label to an icon so both fit the top-right column. */
  body .site-search-toggle {
    top: 62px;
    padding: 8px 11px; font-size: 11px;
    background: #67e8f9; color: #0a1330; border-color: #67e8f9;
    box-shadow: 0 4px 14px rgba(15,23,42,0.45);
  }
  body .site-search-toggle:hover { background: #a5f3fc; color: #0a1330; }
  .site-search-toggle .ss-label { display: none; }
  .site-search-overlay { padding-top: 8vh; }
}
