/**
 * Site header. Loaded on every page.
 *
 * Two states:
 * - Transparent over a dark hero (home page and dark-hero templates).
 * - Solid dark: after scrolling (.is-scrolled), while the mobile menu is open
 *   (.is-menu-open), and from first paint on pages without a dark hero
 *   (body.vac-header-solid, set in functions.php).
 * Mobile first; the desktop navigation starts at 1024px.
 */

:root {
	/* Header height in each state, used for page and hero top spacing. */
	--vac-header-height: 5.25rem;
	--vac-header-height-solid: 4.5rem;
	--vac-adminbar: 0px;
}

@media (min-width: 1024px) {
	:root {
		--vac-header-height: 6rem;
	}
}

/* Logged-in admin bar sits above the fixed header. */
body.admin-bar {
	--vac-adminbar: 32px;
}

@media (max-width: 782px) {
	body.admin-bar {
		--vac-adminbar: 46px;
	}
}

/* Pages without a dark hero start below the solid header. */
body.vac-header-solid {
	padding-top: var(--vac-header-height-solid);
}

/* Skip link: hidden until focused, then the first thing on screen. */
.vac-skip {
	position: absolute;
	top: -100px;
	left: 1rem;
	z-index: 1001;
	padding: 0.75rem 1rem;
	border-radius: 3px;
	background: var(--color-white);
	font-weight: 700;
	color: var(--color-dark);
	text-decoration: none;
}

.vac-skip:focus {
	top: calc(var(--vac-adminbar) + 0.5rem);
	outline: 3px solid var(--color-red);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Header bar and states                                               */
/* ------------------------------------------------------------------ */

.vac-header {
	position: fixed;
	top: var(--vac-adminbar);
	right: 0;
	left: 0;
	z-index: 1000;
	font-family: var(--font-body);
	color: var(--color-white);
	background-color: transparent;
}

/*
 * Transparent state: a soft dark fade keeps white links readable over any
 * hero photo. 50% at the top was measured first and left the Blog and
 * Contact links at about 3.9:1 over the bright car, so the fade holds about
 * 62% through the link row (4.5:1 or better) before dropping to nothing.
 */
.vac-header::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: linear-gradient(
		180deg,
		color-mix(in srgb, var(--color-dark) 70%, transparent) 0%,
		color-mix(in srgb, var(--color-dark) 62%, transparent) 60%,
		transparent 100%
	);
	pointer-events: none;
}

.vac-header.is-scrolled,
.vac-header.is-menu-open,
.vac-header-solid .vac-header {
	background-color: var(--color-dark);
	box-shadow: 0 12px 32px -14px color-mix(in srgb, var(--color-dark) 55%, transparent);
}

.vac-header.is-scrolled::before,
.vac-header.is-menu-open::before,
.vac-header-solid .vac-header::before {
	opacity: 0;
}

/* Logo left; the hamburger (mobile) or the nav (desktop) is pushed right with an auto margin. */
.vac-header__bar {
	display: flex;
	align-items: center;
	width: min(100% - 2 * var(--vac-gutter, clamp(1rem, 4vw, 3rem)), 1240px);
	margin-inline: auto;
	padding-block: 1rem;
}

.vac-header.is-scrolled .vac-header__bar,
.vac-header.is-menu-open .vac-header__bar,
.vac-header-solid .vac-header__bar {
	padding-block: 0.75rem;
}

.vac-header__logo {
	display: block;
	flex: none;
	border-radius: 2px;
}

.vac-header__logo img {
	display: block;
	width: auto;
	height: 3.25rem;
}

.vac-header.is-scrolled .vac-header__logo img,
.vac-header.is-menu-open .vac-header__logo img,
.vac-header-solid .vac-header__logo img {
	height: 2.75rem;
}

.vac-header__logo:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: 4px;
}

/* Transitions start after the first frame, so the page never animates on load. */
.vac-header.is-ready,
.vac-header.is-ready::before,
.vac-header.is-ready .vac-header__bar,
.vac-header.is-ready .vac-header__logo img {
	transition-duration: 0.3s;
	transition-timing-function: ease;
}

.vac-header.is-ready {
	transition-property: background-color, box-shadow;
}

.vac-header.is-ready::before {
	transition-property: opacity;
}

.vac-header.is-ready .vac-header__bar {
	transition-property: padding;
}

.vac-header.is-ready .vac-header__logo img {
	transition-property: height;
}

/* ------------------------------------------------------------------ */
/* Mobile: hamburger and full-width panel                              */
/* ------------------------------------------------------------------ */

.vac-header__burger {
	display: inline-grid;
	flex: none;
	place-items: center;
	width: 3rem;
	height: 3rem;
	margin-left: auto;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: transparent;
	color: var(--color-white);
	cursor: pointer;
}

.vac-header__burger:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: 2px;
}

.vac-header__burger-line {
	transform-box: fill-box;
	transform-origin: center;
	transition: transform 0.3s ease, opacity 0.2s ease;
}

.vac-header.is-menu-open .vac-header__burger-line--top {
	transform: translateY(6px) rotate(45deg);
}

.vac-header.is-menu-open .vac-header__burger-line--mid {
	opacity: 0;
}

.vac-header.is-menu-open .vac-header__burger-line--bot {
	transform: translateY(-6px) rotate(-45deg);
}

.vac-header__menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* With JS the panel is closed until the hamburger opens it. */
.vac-header.has-js .vac-header__menu {
	display: none;
}

.vac-header.is-menu-open .vac-header__menu {
	position: absolute;
	top: 100%;
	right: 0;
	left: 0;
	display: block;
	max-height: calc(100dvh - var(--vac-header-height-solid) - var(--vac-adminbar));
	overflow-y: auto;
	padding: 0.5rem var(--vac-gutter, clamp(1rem, 4vw, 3rem)) 1.5rem;
	border-top: 1px solid color-mix(in srgb, var(--color-white) 14%, transparent);
	background: var(--color-dark);
	box-shadow: 0 24px 40px -20px color-mix(in srgb, var(--color-dark) 60%, transparent);
}

/* Without JS the links stay visible in a simple wrapped row. */
.vac-header:not(.has-js) .vac-header__burger {
	display: none;
}

.vac-header:not(.has-js) .vac-header__bar {
	flex-wrap: wrap;
}

.vac-header:not(.has-js) .vac-header__menu {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1rem;
}

.vac-header__item {
	border-bottom: 1px solid color-mix(in srgb, var(--color-white) 10%, transparent);
}

.vac-header__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.vac-header__link,
.vac-header__link:hover,
.vac-header__sub-link,
.vac-header__sub-link:hover {
	color: var(--color-white);
	text-decoration: none;
}

.vac-header__link {
	position: relative;
	display: flex;
	align-items: center;
	min-height: 3.5rem;
	font-size: 1.0625rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

/*
 * Red underline under the text: current page always, other links on hover.
 * Mobile rows are full width, so a text underline is used there; desktop
 * links use the animated bar below.
 */
.vac-header__link[aria-current="page"],
.vac-header__link:hover {
	text-decoration: underline;
	text-decoration-color: var(--color-red);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.45em;
}

.vac-header__link::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 0.6rem;
	left: 0;
	display: none;
	height: 2px;
	background: var(--color-red);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.2s ease;
}

.vac-header__link:focus-visible,
.vac-header__sub-link:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: 2px;
}

.vac-header__sub-toggle {
	display: inline-grid;
	flex: none;
	place-items: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 0;
	border-radius: 3px;
	background: transparent;
	color: var(--color-white);
	cursor: pointer;
}

.vac-header__sub-toggle svg {
	transition: transform 0.2s ease;
}

.vac-header__sub-toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

.vac-header__sub-toggle:focus-visible {
	outline: 2px solid var(--color-white);
	outline-offset: 2px;
}

/* Mobile: services expand inline as an accordion. */
.vac-header__sub {
	display: none;
	margin: 0;
	padding: 0 0 0.75rem 1rem;
	list-style: none;
}

.vac-header__item--has-sub.is-open .vac-header__sub {
	display: block;
}

.vac-header__sub-link {
	display: flex;
	align-items: center;
	min-height: 3rem;
	font-size: 1rem;
}

.vac-header__sub-link[aria-current="page"] {
	text-decoration: underline;
	text-decoration-color: var(--color-red);
	text-decoration-thickness: 2px;
	text-underline-offset: 0.35em;
}

/* Page behind the open mobile menu does not scroll. */
html.vac-nav-open {
	overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Desktop                                                             */
/* ------------------------------------------------------------------ */

@media (min-width: 1024px) {
	.vac-header__logo img {
		height: 4rem;
	}

	.vac-header.is-scrolled .vac-header__logo img,
	.vac-header-solid .vac-header__logo img {
		height: 3rem;
	}

	.vac-header__burger {
		display: none;
	}

	.vac-header.has-js .vac-header__menu,
	.vac-header:not(.has-js) .vac-header__menu {
		position: static;
		display: flex;
		align-items: center;
		gap: clamp(1.25rem, 2.4vw, 2.25rem);
		max-height: none;
		overflow: visible;
		padding: 0;
		border: 0;
		background: none;
		box-shadow: none;
	}

	.vac-header__item {
		position: relative;
		border: 0;
	}

	.vac-header__nav {
		margin-left: auto;
	}

	.vac-header__link {
		min-height: 3rem;
		font-size: 0.8125rem;
		letter-spacing: 0.12em;
	}

	.vac-header__link[aria-current="page"],
	.vac-header__link:hover {
		text-decoration: none;
	}

	.vac-header__link::after {
		display: block;
	}

	.vac-header__link[aria-current="page"]::after,
	.vac-header__link:hover::after,
	.vac-header__link:focus-visible::after {
		transform: scaleX(1);
	}

	.vac-header__sub-toggle {
		width: 1.75rem;
		height: 3rem;
		margin-left: 0.15rem;
	}

	/* Dropdown panel: solid dark, fades and slides in. */
	.vac-header__sub {
		position: absolute;
		top: calc(100% + 0.5rem);
		left: -1rem;
		display: block;
		min-width: 17.5rem;
		padding: 0.5rem;
		border: 1px solid color-mix(in srgb, var(--color-white) 14%, transparent);
		border-radius: 3px;
		background: var(--color-dark);
		box-shadow: 0 20px 44px -12px color-mix(in srgb, var(--color-dark) 60%, transparent);
		opacity: 0;
		visibility: hidden;
		transform: translateY(-6px);
		transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	}

	/* Invisible bridge over the gap, so the mouse can reach the panel without it closing. */
	.vac-header__sub::before {
		content: "";
		position: absolute;
		right: 0;
		bottom: 100%;
		left: 0;
		height: 0.5rem;
	}

	.vac-header__item--has-sub.is-open .vac-header__sub,
	.vac-header:not(.has-js) .vac-header__item--has-sub:hover .vac-header__sub,
	.vac-header:not(.has-js) .vac-header__item--has-sub:focus-within .vac-header__sub {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}

	.vac-header__sub-link {
		padding-inline: 0.875rem;
		border-radius: 2px;
		font-size: 0.9375rem;
	}

	.vac-header__sub-link:hover {
		background: color-mix(in srgb, var(--color-white) 8%, transparent);
	}

	.vac-header__sub-link:focus-visible {
		outline-offset: -2px;
	}
}

/* Fine pointers get a slimmer toggle; touch keeps the 48px target. */
@media (min-width: 1024px) and (pointer: coarse) {
	.vac-header__sub-toggle {
		width: 3rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vac-header.is-ready,
	.vac-header.is-ready::before,
	.vac-header.is-ready .vac-header__bar,
	.vac-header.is-ready .vac-header__logo img,
	.vac-header__burger-line,
	.vac-header__link::after,
	.vac-header__sub-toggle svg,
	.vac-header__sub {
		transition: none;
	}
}
