.nh-header-origin {
	display: block;
	height: 0;
}

/* A single inherited value keeps both sides of the zoom boundary in phase.
 * Without registered-property interpolation both positions change together. */
@property --nh-header-start-padding {
	syntax: '<length>';
	inherits: true;
	initial-value: 15px;
}

/* Native sticky header retains its original flow footprint while its padding contracts. */
@media screen and (width >= 701px) {
	.nh-display-host {
		--nh-header-start-padding: 15px;
		--nh-header-flow-start-padding: round(nearest, var(--nh-header-start-padding), 1px);
		--nh-header-flow-end-padding: round(nearest, calc(8px + (var(--nh-header-start-padding) - 8px) * 12 / 7), 1px);

		transition: --nh-header-start-padding var(--nh-motion-state) var(--nh-motion-ease);
	}

	.nh-display-host:has(.nh-header-stuck) {
		--nh-header-start-padding: 8px;
	}

	.nh-header {
		position: sticky;
		top: var(--nh-header-sticky-top, 0);
		z-index: 15;

		/* One animation owns all three terms. Whole CSS pixels keep their sum
		 * exactly 35px instead of independently rounding each animated length;
		 * fractional flow movement can rerasterize following images a pixel away. */
		margin-block-end: calc(35px - var(--nh-header-flow-start-padding) - var(--nh-header-flow-end-padding));
		padding-block: var(--nh-header-flow-start-padding) var(--nh-header-flow-end-padding);
		background: #fff;
		transition: none;
	}

	/* The glow paints only below the header, without clipping menus or focus. */
	.nh-header-stuck::after {
		position: absolute;
		inset-inline: 0;
		top: 100%;
		height: 12px;
		background: linear-gradient(rgb(4 52 56 / 6%), transparent);
		content: '';
		pointer-events: none;
	}

	.nh-header .nh-dropdown {
		max-height: var(--nh-dropdown-room, calc(100dvh / var(--nh-display-scale, 1) - 140px));
		overflow-y: auto;
		overscroll-behavior-y: contain;
		scroll-padding-block: 8px;
	}
}

html {
	scroll-padding-top: var(--nh-viewport-clearance, 12px);
}

/* Native section links also clear the header before enhancement or without JS.
 * Enhanced pages keep the existing measured inset; offsets are not added twice. */
html:has(:is(#nh-weekly-menu, #nh-daily-schedule, #vacancies):target) {
	/* stylelint-disable-next-line custom-property-pattern -- Native WordPress admin-bar variable. */
	scroll-padding-top: var(--nh-viewport-clearance, calc(170px + var(--wp-admin--admin-bar--height, 0px)));
}

.nh-floating-controls {
	--nh-floating-control-size: 52px;

	position: fixed;
	right: max(20px, env(safe-area-inset-right));
	bottom: max(20px, env(safe-area-inset-bottom));
	z-index: 12;
	display: grid;
	gap: 12px;
	pointer-events: none;
}

.nh-back-to-top,
.nh-floating-max {
	display: grid;
	place-items: center;
	width: var(--nh-floating-control-size);
	height: var(--nh-floating-control-size);
	padding: 0;
	border: 1px solid var(--nh-mint);
	border-radius: 50%;
	background: #fff;
	color: var(--nh-mint);
	box-shadow: 0 3px 12px rgb(4 52 56 / 10%);
}

.nh-floating-max {
	border-color: #72a8ff;
	pointer-events: auto;
}

.nh-back-to-top {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(8px);
	transition: opacity var(--nh-motion-state) var(--nh-motion-ease),
		transform var(--nh-motion-state) var(--nh-motion-ease),
		background-color var(--nh-motion-state) var(--nh-motion-ease),
		color var(--nh-motion-state) var(--nh-motion-ease),
		visibility var(--nh-motion-state) allow-discrete;
}

.nh-back-to-top > svg {
	width: 34px;
	height: 34px;
	pointer-events: none;
}

.nh-back-to-top.nh-back-to-top-visible {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
}

.nh-back-to-top:hover {
	background: var(--nh-mint);
	color: #fff;
}

.nh-back-to-top:active {
	background: var(--nh-mint-pressed);
	color: #fff;
}

.nh-back-to-top:focus-visible,
.nh-floating-max:focus-visible {
	outline: 3px solid var(--nh-teal);
	outline-offset: 4px;
}

html:has(dialog[open], .nh-navigation.is-open) .nh-floating-max {
	visibility: hidden;
	pointer-events: none;
}

@media screen and (width <= 700px) {
	html.nh-mobile-menu-open {
		overflow: hidden;
	}

	.nh-header,
	.nh-header:has(.nh-navigation.is-open) {
		position: sticky;
		top: var(--nh-header-sticky-top, 0);
		z-index: 20;
		background: #fff;
	}

	.nh-header-stuck::after {
		position: absolute;
		inset-inline: 0;
		top: 100%;
		height: 12px;
		background: linear-gradient(rgb(4 52 56 / 6%), transparent);
		content: '';
		pointer-events: none;
		transition: none;
	}

	.nh-header .nh-navigation {
		top: 100%;
		max-height: var(--nh-mobile-menu-room, calc(100dvh - 70px));
		overscroll-behavior-y: contain;
		scroll-padding-block: 12px;
	}

	/* Retain the closed header glow only after the closing panel has gone. */
	.nh-header:has(.nh-navigation.is-open)::after {
		opacity: 0;
		transition: none;
	}

	/* The first paint is safe even before the native effects become active. */
	.nh-navigation[data-nh-menu-animating] {
		opacity: var(--nh-menu-start-opacity, 0);
	}

	.nh-header::before,
	.nh-header:has(.nh-navigation.is-open)::before {
		position: fixed;
		inset: calc(var(--nh-header-sticky-top, 0px) + var(--nh-mobile-header-height, 70px)) 0 0;
		z-index: -1;
		background: rgb(0 0 0 / 50%);
		content: '';
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transition: opacity var(--nh-motion-close) var(--nh-motion-ease),
			visibility var(--nh-motion-close) allow-discrete;
	}

	.nh-header:has(.nh-navigation.is-open)::before {
		pointer-events: auto;
	}

	.nh-header:has(.nh-navigation.is-open:not([inert]))::before {
		opacity: 1;
		visibility: visible;
		transition-duration: var(--nh-motion-open);
	}

	.nh-header.nh-menu-linked::before,
	.nh-header.nh-menu-linked:has(.nh-navigation.is-open)::before {
		transition: none;
	}

	.nh-header.nh-menu-linked:has(.nh-navigation.is-open)::before {
		opacity: 1;
		visibility: visible;
	}

	.nh-header.nh-menu-linked:has(.nh-navigation[data-nh-menu-animating])::before {
		opacity: var(--nh-menu-start-opacity, 0);
	}

	.nh-header:not(.nh-menu-linked):has(.nh-navigation.is-open)::before {
		opacity: var(--nh-menu-backdrop-opacity, 0);
		visibility: visible;
		transition: none;
	}

	.nh-navigation[inert] {
		pointer-events: none;
	}

	.nh-floating-controls {
		--nh-floating-control-size: 44px;

		right: max(12px, env(safe-area-inset-right));
		bottom: max(12px, env(safe-area-inset-bottom));
	}

	.nh-back-to-top > svg {
		width: 28px;
		height: 28px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.nh-display-host,
	.nh-header,
	.nh-header::before,
	.nh-header:has(.nh-navigation.is-open)::before,
	.nh-back-to-top {
		transition: none;
	}
}

@media (forced-colors: active) {
	.nh-back-to-top,
	.nh-floating-max {
		border-color: ButtonText;
		background: ButtonFace;
		color: ButtonText;
	}
}

@media print {
	.nh-floating-controls {
		display: none;
	}
}
