/* Site-wide search: header button + command-palette overlay (base.html, every page).
   Plain CSS (no Tailwind rebuild). Visual language mirrors the sim/chat overlays:
   #0b1120 panel, soft white borders, cyan accents. */

/* ── Header button (sits between the nav pills and the account slot) ─────────── */
.site-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  backdrop-filter: blur(12px);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.site-search-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.site-search-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.6);
}
.site-search-btn-icon { width: 1.05rem; height: 1.05rem; }

/* ── Overlay (top-aligned command palette) ───────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;             /* above the sticky header (z-20) and sim overlay (70) */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 1rem 1rem;
}
.search-overlay[hidden] { display: none; }
.search-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.74);
  backdrop-filter: blur(2px);
}

.search-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(640px, 96vw);
  max-height: min(70vh, 640px);
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem 0.55rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.search-input-icon { width: 1.1rem; height: 1.1rem; color: #64748b; flex-shrink: 0; }
.search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.3rem 0;
}
.search-input:focus { outline: none; }
.search-input::placeholder { color: #64748b; }
/* hide the native WebKit clear button — the ✕ close button is right there */
.search-input::-webkit-search-cancel-button { display: none; }

.search-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.search-close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.search-close svg { width: 1rem; height: 1rem; }

/* ── Results ─────────────────────────────────────────────────────────────────── */
.search-results {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.4rem 0.4rem 0.6rem;
}
.search-hint,
.search-empty {
  margin: 0;
  padding: 0.9rem 0.9rem 1rem;
  font-size: 0.85rem;
  color: #64748b;
}

.search-group-label {
  margin: 0.5rem 0.55rem 0.2rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.search-result {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 0.55rem;
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.search-result:hover { background: rgba(255, 255, 255, 0.06); }
.search-result.is-active {
  background: rgba(34, 211, 238, 0.12);
  outline: 1px solid rgba(34, 211, 238, 0.35);
}
.search-result-title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-title mark {
  background: transparent;
  color: #67e8f9;
  font-weight: 600;
}
.search-result-sub {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-sub mark {
  background: transparent;
  color: #67e8f9;
  font-weight: 600;
}
.search-result-meta {
  flex: 1 0 auto;
  text-align: right;
  font-size: 0.72rem;
  color: #64748b;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .search-overlay { padding-top: 4vh; }
  .search-result-meta { display: none; }
}
