/* Header search: the magnifier opens a full-width field with live results. */
/* :where keeps this at zero specificity, so a sticky header elsewhere still wins (it is positioned too). */
:where(.top) { position: relative; }

.sx {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 var(--gutter);
  background: var(--bg);
}
.sx[hidden] { display: none; }
.sx-field { position: relative; flex: 1; min-width: 0; }
.sx-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.sx-input {
  width: 100%;
  height: 44px;
  padding: 0 18px 0 44px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font: 16px/1.2 var(--sans);
  -webkit-appearance: none;
  appearance: none;
}
.sx-input::placeholder { color: var(--muted); }
.sx-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.sx-input:focus { outline: none; border-color: var(--accent); }
.sx-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}
.sx-close:hover { border-color: var(--accent); color: var(--accent); }

/* Results: a panel under the header, as wide as the field up to a comfortable reading width. */
.sx-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: var(--gutter);
  width: min(640px, calc(100% - 2 * var(--gutter)));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--bg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}
.sx-panel[hidden] { display: none; }
.sx-status { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 14px; }
.sx-status:empty { display: none; }
.sx-list { display: flex; flex-direction: column; gap: 2px; }
.sx.is-loading .sx-list { opacity: 0.55; }
.sx-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--fg);
  text-decoration: none;
}
.sx-title { font: 600 17px/1.15 var(--display); text-transform: uppercase; overflow-wrap: anywhere; }
.sx-title mark { background: none; color: var(--accent); }
.sx-meta { font-size: 12px; color: var(--muted); }
.sx-all {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sx-count { color: var(--muted); letter-spacing: 0; }
.sx-item[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.sx-item[aria-selected="true"] mark { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.sx-item[aria-selected="true"] .sx-meta,
.sx-item[aria-selected="true"] .sx-count { color: var(--bg); }

/* Phones and tablets: the header is two rows (logo, then rubrics), the field covers both. */
@media (max-width: 900px) {
  .sx { gap: 8px; }
  .sx-panel { right: var(--gutter); width: auto; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); }
}

@media (prefers-reduced-motion: no-preference) {
  .sx { animation: sx-in 0.16s ease-out; }
  .sx-panel { animation: sx-in 0.16s ease-out; }
  .sx.is-loading .sx-list { transition: opacity 0.2s 0.15s; }
  @keyframes sx-in { from { opacity: 0; transform: translateY(-4px); } }
}
