/* ---------- site search (js/search.js): header button, expanding field, results dropdown ---------- */
.ps-search { position: relative; flex: none; }
.ps-search-btn { color: var(--text-2); }
.ps-search-btn:focus-visible, .ps-search-close:focus-visible { outline: none; box-shadow: var(--ring); }
.ps-search-label, .ps-search-kbd { display: none; }
@media (min-width: 1180px) {
  .ps-search-btn { width: auto; gap: 8px; padding: 0 8px 0 12px; justify-content: start; grid-auto-flow: column; min-width: 168px; }
  .ps-search-btn svg { width: 16px; height: 16px; }
  .ps-search-label { display: inline; font: 500 14px/1 var(--font-text); color: var(--muted); margin-right: auto; }
  .ps-search-kbd {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-left: 18px;
    font: 600 11px/1 var(--font-mono); color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  }
}
.ps-search.open .ps-search-btn { visibility: hidden; }

.ps-search-panel {
  position: absolute; top: 0; right: 0; z-index: 45; width: min(440px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop .14s ease-out; overflow: hidden;
}
.ps-search-panel[hidden] { display: none; }
.ps-search-field { display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--border); }
.ps-search-field > svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.ps-search-field input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; color: var(--text);
  font: 500 15px/1.2 var(--font-text);
}
.ps-search-field input:focus { outline: none; box-shadow: none; background: none; } /* the panel carries the ring */
.ps-search-field input::placeholder { color: var(--muted); font-weight: 400; }
.ps-search-panel:focus-within { box-shadow: var(--shadow-lg), var(--ring); }
.ps-search-close {
  width: 30px; height: 30px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; padding: 0;
}
.ps-search-close:hover { background: var(--surface-2); color: var(--text); }
.ps-search-close svg { width: 16px; height: 16px; }

.ps-search-list { list-style: none; margin: 0; padding: 6px; max-height: min(460px, calc(100vh - var(--header-h) - 80px)); overflow-y: auto; overscroll-behavior: contain; }
.ps-search-list:empty { display: none; }
.ps-search-head { padding: 6px 10px 4px; font: 600 11px/1.4 var(--font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.ps-opt {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
}
.ps-opt[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 45%, transparent); }
.ps-txt { display: grid; gap: 1px; min-width: 0; }
.ps-txt b, .ps-txt small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-txt b { font: 600 14px/1.3 var(--font-text); }
.ps-txt small { font-size: 12.5px; color: var(--muted); }
.ps-txt mark { background: none; color: var(--accent); font-weight: 700; }
.ps-kind { font-size: 11.5px; color: var(--muted); }
.ps-badge {
  justify-self: start; font: 700 10px/1.7 var(--font-text); letter-spacing: .06em; padding: 0 6px; border-radius: 6px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
}
.ps-b-cbb { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.ps-b-ufc { color: var(--critical); background: var(--critical-soft); border-color: transparent; }
.ps-b-site { color: var(--muted); background: none; }
.ps-search-status { margin: 0; padding: 10px 16px 12px; font-size: 13px; color: var(--muted); }
.ps-search-status:empty, .ps-search-status.ps-quiet { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* phones: an icon in the header opens a full-width panel under it */
@media (max-width: 640px) {
  .ps-search.open .ps-search-btn { visibility: visible; color: var(--accent); background: var(--accent-soft); }
  .ps-search-panel {
    position: fixed; top: var(--header-h); left: 0; right: 0; width: auto; z-index: 31;
    border-radius: 0; border-width: 0 0 1px; background: var(--bg); box-shadow: var(--shadow-lg);
    /* a solid sheet over the page: no fade-in (the page showed through mid-animation), and the page behind is dimmed */
    animation: none; opacity: 1; isolation: isolate;
  }
  .ps-search-panel::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 100vh; background: rgb(0 0 0 / .45); pointer-events: none; }
  .ps-search-panel:focus-within { box-shadow: var(--shadow-lg); }
  .ps-search-panel { overflow: visible; }
  .ps-search-status { background: var(--bg); }
  .ps-search-field { margin: 10px 16px; height: 44px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
  .ps-search-field:focus-within { box-shadow: var(--ring); border-color: var(--accent); }
  .ps-search-field input { font-size: 16px; } /* 16px stops iOS zooming in */
  .ps-search-list { padding: 0 10px 10px; max-height: calc(100dvh - var(--header-h) - 70px); }
  .ps-kind { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ps-search-panel { animation: none; } }
