/* Global header (Figma NavBar 2008:7213). Two looks with identical geometry: solid (white bar, black nav) and overlay
   (transparent over a top image, white nav, NavGradient). Only colours change between them, never positions. */
.site-header {
  --hdr-bg: var(--color-bg-canvas);
  --hdr-fg: var(--color-text-primary);
  --hdr-rule: var(--color-border-rule-ghost);
  --hdr-underline: var(--color-bg-inverse);
  --hdr-btn-bg: var(--color-action-primary);
  --hdr-btn-fg: var(--color-text-inverse);
  --hdr-btn-bg-h: transparent;
  --hdr-btn-fg-h: var(--color-text-primary);
  --hdr-btn-ring-h: var(--color-border-border);
  position: fixed; /* sticky: stays at the top while the page scrolls (the spacer keeps solid pages from jumping) */
  top: 0;
  right: 0;
  left: 0;
  z-index: 40;
  background: var(--hdr-bg);
  color: var(--hdr-fg);
  border-bottom: var(--border-3-pixel) solid var(--color-border-rule);
  transition: background-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

/* Once the page has scrolled, the header is a solid bar (even over a top image) with a slight shadow, so it reads over white. */
/* The white bar: no black rule under it, and a soft, deeper shadow so it reads over white content (4 px down, 16 px blur). */
.site-header.is-scrolled {
  border-bottom-width: 0;
  box-shadow: 0 var(--space-gap-5xs) var(--space-gap-xs) color-mix(in srgb, var(--color-bg-alpha-30) 67%, transparent); /* 30% black at 67% = about 20% (no 20% token yet; see decision-log.md) */
}

.site-header[data-mode="overlay"]:not(.is-open):not(.is-scrolled) {
  --hdr-bg: transparent;
  --hdr-fg: var(--color-text-inverse);
  --hdr-rule: var(--color-border-rule-inverse-ghost);
  --hdr-underline: var(--color-bg-canvas);
  --hdr-btn-bg: var(--color-action-inverse);
  --hdr-btn-fg: var(--color-text-primary);
  --hdr-btn-bg-h: transparent;
  --hdr-btn-fg-h: var(--color-text-inverse);
  --hdr-btn-ring-h: var(--color-border-border-inverse);
  border-bottom-color: transparent;
}

.site-header[data-mode="overlay"].is-open { border-bottom-color: transparent; }

/* NavGradient: legibility scrim behind the nav on top-image pages. */
.site-header__scrim {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: var(--nav-gradient-h);
  background: var(--gradient-nav-scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.site-header[data-mode="overlay"]:not(.is-open):not(.is-scrolled) .site-header__scrim { opacity: var(--scrim-strength); }

.utility-bar,
.site-header__main { position: relative; z-index: 1; }

/* Utility bar: lg and up only; below lg its links live in the drawer. */
.utility-bar { display: none; }

.utility-bar__tagline,
.utility-bar__links { margin: 0; }

.utility-bar a { color: inherit; text-decoration: none; }
.utility-bar a:hover { text-decoration: underline; text-underline-offset: var(--space-gap-5xs); }

.site-header__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-main-h-compact);
  padding-inline: var(--gutter);
  gap: var(--space-gap-5xs);
}

.site-header .logo { color: var(--hdr-fg); }
.site-header[data-mode="overlay"]:not(.is-open):not(.is-scrolled) .logo__img--black { display: none; }
.site-header[data-mode="overlay"]:not(.is-open):not(.is-scrolled) .logo__img--white { display: block; }

.primary-nav { display: none; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  color: var(--hdr-fg);
  text-decoration: none;
}
.nav-link__text { position: relative; display: block; }
/* The current page and hover share one underline: a 3px bar 4px below the text (no thin text underline on top of it). Hover wipes
   it in from left to right with ease-out, as the card titles and arrow links do (home.css link-wipe; Home's CSS is not loaded on every
   page, so the keyframes are repeated here). The duration follows the text's width (--wipe-ms, set in header.js; 150ms without JS),
   so every item wipes at about the same speed. Reduced motion zeroes the duration (base.css). */
@keyframes nav-wipe {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.nav-link[aria-current="page"] .nav-link__text::after,
.nav-link:hover .nav-link__text::after {
  content: "";
  position: absolute;
  top: calc(100% + var(--space-gap-5xs));
  right: 0;
  left: 0;
  height: var(--border-3-pixel);
  background: var(--hdr-underline);
  transform-origin: left;
}
.nav-link:hover .nav-link__text::after { animation: nav-wipe var(--wipe-ms, 150ms) ease-out; }

/* The disclosure button next to a mega-menu link is for keyboard and AT users; it stays focusable but invisible. */
.nav-toggle { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
/* .nav-item stays unpositioned on purpose: the mega panel anchors to the full-width header, not to its own nav item. */
.nav-item:has(.nav-toggle:focus-visible) .nav-link__text { outline: var(--border-2-pixel) solid currentColor; outline-offset: var(--border-2-pixel); }

.header-actions { display: flex; align-items: center; gap: var(--space-gap-5xs); }

.search-trigger,
.menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-gap-4xs);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0;
  border: 0;
  background: none;
  color: var(--hdr-fg);
  cursor: pointer;
}
.search-trigger .icon--search { width: var(--icon-search); height: var(--icon-search); }
.menu-trigger .icon--menu { width: var(--space-inset-md); height: var(--space-inset-md); }

/* Label text is for screen readers on small screens, visible from lg. */
.search-trigger__label { position: absolute; width: var(--border-1-pixel); height: var(--border-1-pixel); overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Contact is desktop only: below lg it lives in the drawer (MobileUtility). */
.header-contact { display: none; }

@media (min-width: 1024px) {
  .utility-bar {
    overflow: hidden;
    transition: height 250ms ease, opacity 200ms ease, border-width 250ms ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-gap-md);
    height: var(--header-utility-h); /* constant: at 1920 only the text steps up, never the bar */
    padding: 0 var(--gutter);
    border-bottom: var(--border-1-pixel) solid var(--hdr-rule);
  }
  .utility-bar__links { display: flex; align-items: center; gap: var(--space-gap-md); }

  /* Main row: logo | nav (centred on the page) | search + Contact. */
  .site-header__main { display: grid; grid-template-columns: 1fr auto 1fr; height: var(--header-main-h); min-height: 0; gap: 0; }
  /* Compact (scrolled down): the utility strip rolls up into the top and only the main bar stays, about 92 px. Scrolling up
     brings it back. */
  /* Keyboard focus inside the strip keeps it open, so its links are never focused while invisible. */
  .site-header.is-compact .utility-bar:not(:focus-within) { height: 0; opacity: 0; border-bottom-width: 0; }
  .primary-nav { display: block; }
  .primary-nav__list { display: flex; align-items: center; gap: var(--space-gap-lg); }
  .header-actions { justify-self: end; gap: var(--space-gap-lg); }
  .search-trigger { min-width: 0; }
  .search-trigger__label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .menu-trigger { display: none; }
  .header-contact { display: inline-flex; padding-inline: calc(var(--space-inset-md) - var(--border-1-pixel)); } /* the 1px button border is inside the padding */
}

/* Spacer under the fixed header on solid pages (height set by header.js from the full-height header). */
.site-header__spacer { height: calc(var(--header-utility-h) + var(--header-main-h) + var(--border-3-pixel)); }
