/* ============================================================
   Site search — navbar combobox

   Uses the design tokens already defined in each page's :root.
   This file loads on both stylesheet families, and they disagree
   on one name: home-shell.css calls the border colour --border /
   --border-2 while portfolio-pages.css calls the same values
   --line / --line-2. So the border rules ask for one, then the
   other, then fall back to the literal.

   The results panel is position:absolute so opening it never
   shifts layout — the site holds CLS 0 and must keep doing so.
   ============================================================ */

.site-search {
  position: relative;
  flex: 0 1 260px;
  min-width: 0;
}

.site-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border, var(--line, #21262d));
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color .18s var(--ease);
}
.site-search-field:focus-within { border-color: var(--accent); }

.site-search-field svg {
  flex: none;
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.site-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  outline: none;
}
.site-search input::placeholder { color: var(--muted); }
.site-search input::-webkit-search-cancel-button { display: none; }

/* ---- results panel ---- */

.site-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: min(420px, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--border-2, var(--line-2, #30363d));
  border-radius: var(--r);
  box-shadow: var(--sh-lg, 0 18px 48px rgba(0,0,0,.5));
  padding: 6px;
  z-index: 200;
}
.site-search-panel[hidden] { display: none; }

.site-search-group {
  padding: 10px 10px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text, var(--accent));
}

.site-search-option {
  display: block;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.35;
  cursor: pointer;
}
.site-search-option:hover,
.site-search-option[aria-selected="true"] {
  background: var(--accent-light, rgba(79,110,247,.14));
}
.site-search-option mark {
  background: transparent;
  color: var(--accent-text, var(--accent));
  font-weight: 700;
}

.site-search-empty {
  padding: 16px 12px;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Screen-reader-only live region for the result count */
.site-search-status {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- narrow viewports ---- */

@media (max-width: 1100px) {
  .site-search { flex-basis: 200px; }
}

/* Below 768px the navbar has no room for a usable field — it collapses to
   about 47px, which is an icon and nowhere to type. Hide it there and let the
   full-width copy inside the hamburger panel do the job. */
@media (max-width: 768px) {
  .nav-inner .site-search { display: none; }
}

/* The industry pages' nav (.page-shell.nav from portfolio-pages.css) switches
   to flex-direction:column on narrow screens. In a column container the
   flex-basis above would size the HEIGHT, which made the field 260px tall and
   the whole bar 378px. Pin it to auto height and full width instead. */
.page-shell.nav .site-search {
  flex: none;
  width: 100%;
  max-width: 320px;
}
@media (max-width: 900px) {
  .page-shell.nav .site-search { max-width: none; }
}

/* That nav is inside a sticky .topbar, and below 768px it stacks into a
   column. Leaving the field in would make the sticky bar ~218px — 27% of a
   375x812 viewport, permanently. Hide it there, same as the main navbar. */
@media (max-width: 768px) {
  .page-shell.nav .site-search { display: none; }
}

/* Inside the mobile panel the search is a full-width first row. */
.nav-mobile-panel .site-search {
  flex: none;
  width: 100%;
  margin-bottom: 8px;
}
.nav-mobile-panel .site-search-panel {
  position: static;
  width: 100%;
  max-height: 50vh;
  margin-top: 6px;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .site-search-field { transition: none; }
}
