/* Was @scope (.site-header) — replaced 2026-07-24 with plain CSS nesting.
   Found live: @scope's own scope-root element (matched by a plain class
   selector or even :scope itself, not just descendants) intermittently
   failed to receive its declared styles in testing, a narrower/newer
   feature than nesting with real compatibility risk. Nesting achieves the
   identical "no repeated .site-header prefix" ergonomics with none of that
   risk — it's been broadly supported for longer. */
.site-header {
  max-width: var(--wide-content-width);
  margin: 0 auto;
  padding: 2.5rem 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;

  /* :not(.button-primary):not(.button-secondary) — a plain header link
     (logo, nav items) wants this ambient color; a button-classed <a>
     already sets its own color deliberately, and the nesting here
     (:is(.site-header) a) would otherwise outrank a bare .button-primary
     class and silently win, since a single un-nested class has lower
     specificity than a class-plus-element descendant selector. Excluding
     both variant classes (not a shared .button — content-authored button
     links, lib/sanitize.ts's allowedClasses for <a>, only ever carry the
     variant class, never a bare .button) keeps the component's own color
     rules authoritative without a specificity fight. Same exclusion
     needed anywhere content flows through an ambient `a { color: ... }`
     rule — see post.css/docs.css for the identical fix. */
  a:not(.button-primary):not(.button-secondary) {
    color: var(--color-text);
    text-decoration: none;
    /* Deterministic box height regardless of font-size — without this,
       the logo (1.1rem) and nav links (0.95rem) round their default
       line-heights to a different number of sub-pixels, so align-items:
       center centers them a fraction of a pixel apart depending on which
       page happens to repaint first. Visible as the header appearing to
       "shift" by ~1px between page loads, not a real per-page layout
       difference (confirmed by measuring — logo/nav position is what
       varies, not header height or search position). */
    line-height: 1.2;
  }

  a:not(.button-primary):not(.button-secondary):hover {
    color: var(--color-accent);
  }

  .site-logo {
    /* font-weight set globally (globals.css) — every browser-bold-by-
       default element gets this site's subtler 600, not standard 700. */
    font-size: 1.1rem;
  }

  .site-nav {
    display: flex;
    gap: 1.25rem;
    /* Grows to soak up the space between the logo and the search box,
       rather than the three sitting flush together at small widths. */
    flex: 1 1 auto;

    a {
      font-size: 0.95rem;
    }
  }

  .site-search {
    position: relative;
    flex: 0 1 13rem;
  }

  /* Sizing/color come from the shared .button/.button-primary atom
     (globals.css) — .site-cta itself carries no styling, it's just a
     hook for the one specific button that lives in the header, in case a
     header-only override is ever needed. One button, not one per install
     method: a reader doesn't need to pick between "Web Installer" and
     "CLI" from the header, just find where installing starts; the
     destination page (Getting Started) covers create-carapace directly
     and can grow a web-installer link later without this button needing
     a second variant. */

  .site-search input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-text);
    border-radius: 0.3rem;
  }

  .site-search input:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  .site-search-results {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: 0;
    width: min(24rem, 90vw);
    max-height: 70vh;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--color-bg);
    border: 1px solid var(--color-text);
    border-radius: 0.3rem;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
    z-index: 10;
  }

  .site-search-results a {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: 0.2rem;
    font-size: 0.9rem;
  }

  .site-search-results a:hover,
  .site-search-results a:focus-visible {
    background: var(--color-accent);
    color: var(--color-bg);
    outline: none;
  }

  .site-search-result-title {
    display: block;
    font-weight: 600;
  }

  .site-search-result-excerpt {
    display: block;
    font-size: 0.85rem;
    opacity: 0.8;
  }

  .site-search-result-excerpt mark {
    background: none;
    color: inherit;
    font-weight: 700;
  }

  .site-search-empty {
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    opacity: 0.7;
  }
}
