#main-nav {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 40;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	padding-inline: 1em;
	/* padding-top: 0.2em; */
	background: transparent;
	user-select: none;
	/* Only holds the (non-interactive) page title now that the burger
	   lives outside of it — without this its box (sized to the large
	   title font) sits above the mega menu and blocks clicks on the
	   first link even while the title itself is invisible. */
	pointer-events: none;
}

.nav-site-title {
	font-size: var(--nav-scale);
	line-height: 1;
	letter-spacing: -0.04em;
	font-weight: 400;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.nav-site-title.is-hidden {
	opacity: 0;
	pointer-events: none;
}

.nav-burger {
	--burger-w: calc(var(--nav-scale) * 0.75);
	--burger-h: calc(var(--nav-scale) * 0.55);
	--burger-gap: calc(var(--nav-scale) * 0.5);

	position: fixed;
	z-index: 41;
	top: calc(var(--burger-gap) / 1.5);
	right: calc(var(--burger-gap) / 1.5);

	width: var(--burger-w);
	height: var(--burger-h);
	background: none;
	border: none;
	cursor: pointer;
}

.nav-back {
	--back-w: calc(var(--nav-scale) * 0.4);
	--burger-w: calc(var(--nav-scale) * 0.75);
	--burger-h: calc(var(--nav-scale) * 0.55);
	--burger-gap: calc(var(--nav-scale) * 0.5);

	position: fixed;
	z-index: 41;
	top: calc(var(--burger-gap) / 1.5);
	right: calc(var(--burger-gap) / 1.5 + var(--burger-w) + var(--burger-gap) * 0.3);

	width: var(--back-w);
	height: var(--burger-h);
	display: flex;
	align-items: flex-start;
	color: #000;
	transition: color 0.2s ease-in-out;
}

.nav-back:hover {
	color: var(--primary);
}

/* Bigger tap target on touch screens — the arrow's hit area is otherwise
   too small to reliably tap. --back-w drives both the box size and the
   svg's centering margin above, so bumping it here keeps the arrow
   centered at the larger size too. */
@media (max-width: 767px) {
	.nav-back {
		--back-w: calc(var(--nav-scale) * 0.6);
	}
}

/* The burger's 3 bars don't fill their box symmetrically (top bar at
   0%, bottom bar ending at 83.9% — see .nav-burger span rules below),
   so their optical center sits above the box's true vertical middle.
   Centering the arrow on the box itself would then look low; the
   margin-top nudges it up to match the bars' actual center of mass. */
.nav-back svg {
	width: 100%;
	height: auto;
	display: block;
	margin-top: calc(var(--burger-h) * 0.4195 - var(--back-w) / 2);
}

.nav-burger span {
	position: absolute;
	left: 0;
	width: 100%;
	height: calc(var(--burger-h) * 0.125);
	background: #000;
	transition:
		transform 0.3s ease,
		opacity 0.3s ease,
		top 0.3s ease,
		background 0.2s ease-in-out;
}

.nav-burger:hover span {
	background: var(--primary);
}

.nav-burger span:nth-child(1) {
	top: 0;
}

.nav-burger span:nth-child(2) {
	top: calc(var(--burger-h) * 0.357);
}

.nav-burger span:nth-child(3) {
	top: calc(var(--burger-h) * 0.714);
}

.nav-burger.open span:nth-child(1) {
	top: calc(var(--burger-h) * 0.428);
	transform: rotate(45deg);
}

.nav-burger.open span:nth-child(2) {
	opacity: 0;
}

.nav-burger.open span:nth-child(3) {
	top: calc(var(--burger-h) * 0.428);
	transform: rotate(-45deg);
}
