.site-header {
	position: fixed;
	inset-inline: 0;
	top: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--space-sm) var(--gutter);
}

/* Header protection.
 *
 * The header previously composited with `mix-blend-mode: difference`, which
 * meant its appearance was decided entirely by whatever happened to scroll
 * underneath it: mid-grey over white headings, pink over Spotify's green,
 * indistinguishable from the footer wordmark at maximum scroll.
 *
 * A scrim could not be added while that blend was in place — the whole
 * element blends, and black differenced against content is a no-op, so any
 * backing inside it is literally invisible. Hence normal compositing plus a
 * gradient rather than one or the other.
 *
 * The gradient is deliberately taller than the header and fades to fully
 * transparent, so content is *softened* as it passes beneath rather than
 * clipped by a bar. Over the black page — most of the site — it is
 * imperceptible, and it disappears entirely into the fullscreen nav overlay.
 *
 * z-index -1 keeps it inside the header's own stacking context (established
 * by position:fixed + z-index:100): behind the logo and toggle, still above
 * page content. pointer-events:none so it can never intercept a click.
 */
.site-header::before {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	height: 190%;
	background: linear-gradient(
		to bottom,
		rgba(0, 0, 0, 0.72) 0%,
		rgba(0, 0, 0, 0.52) 42%,
		rgba(0, 0, 0, 0) 100%
	);
	pointer-events: none;
	z-index: -1;
}

/* Held back on small viewports: at the desktop height the scrim would occupy
   ~18% of an 844px screen. */
@media (max-width: 768px) {
	.site-header::before {
		height: 150%;
		background: linear-gradient(
			to bottom,
			rgba(0, 0, 0, 0.66) 0%,
			rgba(0, 0, 0, 0.46) 42%,
			rgba(0, 0, 0, 0) 100%
		);
	}
}

.site-header__logo {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: clamp(1.125rem, 1rem + 0.6vw, 1.5rem);
	letter-spacing: -0.015em;
	text-transform: lowercase;
	color: var(--color-fg);
	z-index: 2;
}

/* Site Identity logo, standing in for the type-set wordmark in the same
   slot. Its height tracks the wordmark's own line box — the font-size
   token above times its 1.5 line-height — so swapping text for an image
   leaves the header height and rhythm identical. object-fit preserves
   the aspect ratio if the mark ever has to shrink on a narrow viewport
   rather than stretching it. */
.site-header__logo img {
	display: block;
	width: auto;
	height: calc(clamp(1.125rem, 1rem + 0.6vw, 1.5rem) * 1.5);
	max-width: 100%;
	object-fit: contain;
	object-position: left center;
}

.menu-toggle {
	position: relative;
	z-index: 210;
	display: flex;
	align-items: center;
	gap: var(--space-2xs);
	color: var(--color-fg);
	font-family: var(--font-display);
	font-weight: 700;
	font-size: var(--size-label);
	letter-spacing: 0;
	text-transform: none; /* Direction C: no capitals */
	padding: var(--space-2xs);
}

/* Label swap is driven by aria-expanded, the same attribute that animates the
   bars below — visual state and ARIA state cannot drift apart. display:none
   keeps the inactive label out of the accessibility tree entirely, so the
   accessible name is exactly one of "Menu" / "Close". min-width holds the
   button's width across the swap so the header chrome does not shift. */
.menu-toggle__label {
	min-width: 4.4em;
	text-align: right;
}

.menu-toggle__label--close,
.menu-toggle[aria-expanded="true"] .menu-toggle__label--open {
	display: none;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__label--close {
	display: block;
}

/* A 44x44 minimum pointer target without changing the button's layout box —
   growing the padding would grow the header and push the whole page down. */
.menu-toggle::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: max(100%, 44px);
	height: max(100%, 44px);
	transform: translate(-50%, -50%);
}

.menu-toggle__bars {
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 26px;
}

.menu-toggle__bars span {
	display: block;
	height: 2px;
	background: currentColor;
	transition: transform var(--duration-fast) var(--ease-out),
		opacity var(--duration-fast) var(--ease-out);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(2) {
	opacity: 0;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bars span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* The toggle carries z-index:210 to sit above the .site-nav overlay, but it
   could never take effect: .site-header establishes a stacking context (both
   z-index:100 and mix-blend-mode), so its children are trapped at the header's
   own level — below the overlay at 200. That is why the control disappeared
   behind the menu it had just opened. Lifting the header itself, only while
   the menu is open, is what makes the intended 210 reachable. */
/* The header stays lifted for the whole of the overlay's exit transition, not
   just while the menu is logically open — `nav-closing` is removed on the
   overlay's own transitionend. Without the second selector the header dropped
   back to z-index 100 on the first frame of the close, while .site-nav was
   still at 200 and still covering the viewport, so the logo and the toggle
   vanished for ~200ms before reappearing. */
body.nav-open .site-header,
body.nav-closing .site-header {
	z-index: 210;
}

/* The logged-in admin bar is fixed at the top with a very high z-index, and
   WordPress's own `html { margin-top }` offset does not move position:fixed
   elements. Without this the Close control sits partly underneath it. 32px /
   46px are WordPress's own admin-bar heights. */
body.admin-bar .site-header {
	top: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar .site-header {
		top: 46px;
	}
}

/* ---------------------------------------------------------------------------
   Header hover / focus: white -> accent.

   One interaction shared by both controls, with no movement of any kind.

   The toggle is straightforward: `.menu-toggle` owns `color`, its bars are
   `background: currentColor` and its label inherits, so a single colour
   change moves the label and the burger/X together — in the open X state too,
   because the bar transforms are untouched.

   The logo is not. It is a Custom Logo <img>, so `color` cannot reach it and
   its URL is per-install (it changes on migration), which rules out masking
   it from CSS. The filter below is therefore the smallest CSS-only way to
   recolour it: `brightness(0) saturate(100%)` first flattens the mark to
   black regardless of what colour it actually is, and the remainder tints
   that silhouette. Measured output is rgb(255, 90, 51) against the
   rgb(255, 90, 54) of --color-accent — a three-point difference on one
   channel, visually identical.

   NOTE: unlike the rest of the theme this chain cannot read --color-accent;
   the value is baked in. If the accent token is ever changed, this filter
   must be regenerated to match.
   --------------------------------------------------------------------------- */

.site-header__logo img,
.menu-toggle {
	transition: filter 170ms var(--ease-out), color 170ms var(--ease-out);
}

.site-header__logo:focus-visible img {
	filter: brightness(0) saturate(100%) invert(0.5) sepia(0.6) saturate(4000%)
		hue-rotate(340deg);
}

/* Colour alone never replaces the focus ring — the global
   :focus-visible outline in base.css still applies to both controls. */
.menu-toggle:focus-visible {
	color: var(--color-accent);
}

/* Hover only where hover genuinely exists, so a tap never strands either
   control in the accent state on a touch device. */
@media (hover: hover) and (pointer: fine) {
	.site-header__logo:hover img {
		filter: brightness(0) saturate(100%) invert(0.5) sepia(0.6) saturate(4000%)
			hue-rotate(340deg);
	}

	.menu-toggle:hover {
		color: var(--color-accent);
	}
}

@media (prefers-reduced-motion: reduce) {
	/* Nothing moves either way; the colour simply changes instantly. */
	.site-header__logo img,
	.menu-toggle {
		transition: none;
	}
}

/* Off-canvas full-screen nav overlay */
.site-nav {
	position: fixed;
	inset: 0;
	z-index: 200;
	background: var(--color-bg);
	display: flex;
	align-items: center;
	justify-content: center;
	transform: translateY(-100%);
	transition: transform var(--duration-base) var(--ease-out);
}

.site-nav.is-open {
	transform: translateY(0);
}

.site-nav__list {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-sm);
	text-align: center;
}

.site-nav__link {
	font-family: var(--font-display);
	font-weight: 800;
	font-size: clamp(2rem, 1.3rem + 3.5vw, 3.5rem);
	letter-spacing: -0.015em;
	color: var(--color-fg);
	position: relative;
	transition: color var(--duration-fast) var(--ease-out);
}

.site-nav__link::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: -0.1em;
	height: 2px;
	background: var(--color-accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--duration-base) var(--ease-out);
}

.site-nav__link:focus-visible::after {
	transform: scaleX(1);
}

/* Movement on hover only where hover genuinely exists (a tap would strand it
   mid-nudge on a touch device); keyboard focus keeps its own state above. */
@media (hover: hover) and (pointer: fine) {
	.site-nav__link:hover::after {
		transform: scaleX(1);
	}
}

.site-nav__meta {
	position: absolute;
	bottom: var(--space-lg);
	left: 0;
	right: 0;
	display: flex;
	justify-content: center;
	gap: var(--space-md);
	font-size: var(--size-small);
	color: var(--color-fg-dim);
}

.site-nav__meta a:hover {
	color: var(--color-fg);
}

body.nav-open {
	overflow: hidden;
}
