/*
	Site menu — theme-owned (inc/site-chrome.php)

	Desktop (≥900px): striped panel + white link cells; last item = CTA.
	Mobile: hamburger only; checkbox opens full-viewport overlay.

	Link list only from WP (Navigation CPT / footer Menus).
	Trigger: #nb-nav-toggle + labels; open via html:has():checked.
*/

/* -------------------------------------------------------------------------
	Desktop / shared bar — striped panel + link list (+ hamburger on mobile)
	No .nav-wrap — panel is the flex row.
------------------------------------------------------------------------- */

.header-navigation-panel {
	isolation: isolate;
	position: relative;
	display: flex;
	flex: 1 1 auto;
	align-items: stretch;
	justify-content: flex-end;
	flex-wrap: nowrap;
	gap: 0;
	width: auto;
	min-width: 12rem;
	align-self: stretch;
	background: transparent;
}

.header-navigation-panel::before {
	background: url("../patterns/nav-background.svg") center / cover no-repeat;
	content: "";
	inset: 0;
	pointer-events: none;
	position: absolute;
	z-index: 0;
}

.header-navigation--bar {
	position: relative;
	z-index: 1;
	display: flex;
	flex: 0 0 auto;
	align-self: stretch;
	background: transparent;
	color: var(--wp--preset--color--main, #000);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	text-transform: uppercase;
}

.header-navigation--bar .wp-block-navigation__container {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: stretch;
	align-self: stretch;
	height: 100%;
	margin: 0;
	padding: 0;
	list-style: none;
	width: max-content;
	background: transparent;
	font-size: inherit;
}

.header-navigation--bar .wp-block-navigation-item {
	display: flex;
	flex: 0 0 auto;
	align-items: stretch;
	align-self: stretch;
	margin: 0;
	font-size: inherit;
}

.header-navigation--bar .wp-block-navigation-item__content {
	font-size: inherit;
}

.header-navigation--bar .wp-block-navigation-item__label {
	overflow-wrap: normal;
	word-break: normal;
	font-size: inherit;
}

@media (min-width: 900px) {

	/*
		CTA = last desktop-visible item (ignores .mobile-only siblings).
		:nth-last-child(1 of …) keeps CTA correct when a mobile item is last.
	*/
	.header-navigation--bar
		.wp-block-navigation-item:not(:nth-last-child(1 of :not(.mobile)))
		> .wp-block-navigation-item__content {
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		align-self: stretch;
		height: 100%;
		padding: 0.5em 1.25em;
		white-space: nowrap;
		background: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--main, #000);
		text-decoration: none;
	}

	/* Last desktop-visible item = CTA (outline on black) */
	.header-navigation--bar
		.wp-block-navigation-item:nth-last-child(1 of :not(.mobile))
		> .wp-block-navigation-item__content {
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: center;
		align-self: stretch;
		height: 100%;
		padding: 0.5em 1.25em;
		white-space: nowrap;
		background-color: var(--wp--preset--color--main, #000);
		background-image: none;
		color: var(--wp--preset--color--base, #fff);
		border: 1px solid var(--wp--preset--color--base, #fff);
		line-height: 1;
		text-decoration: none;
	}

	.header-navigation--bar
		.wp-block-navigation-item:nth-last-child(1 of :not(.mobile))
		> .wp-block-navigation-item__content:hover,
	.header-navigation--bar
		.wp-block-navigation-item:nth-last-child(1 of :not(.mobile))
		> .wp-block-navigation-item__content:focus-visible {
		background-color: var(--wp--preset--color--base, #fff);
		color: var(--wp--preset--color--main, #000);
		outline: none;
	}

	.header-navigation--bar
		.wp-block-navigation-item:not(:nth-last-child(1 of :not(.mobile)))
		> .wp-block-navigation-item__content:hover,
	.header-navigation--bar
		.wp-block-navigation-item:not(:nth-last-child(1 of :not(.mobile)))
		> .wp-block-navigation-item__content:focus-visible,
	.header-navigation--bar
		.wp-block-navigation-item:not(:nth-last-child(1 of :not(.mobile))).current-menu-item
		> .wp-block-navigation-item__content {
		text-decoration: underline;
		text-decoration-thickness: 2px;
		text-underline-offset: 0.8em;
	}
}

/* -------------------------------------------------------------------------
	Toggle — always invisible
------------------------------------------------------------------------- */

.nb-nav-toggle,
input.nb-nav-toggle {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	border: 0 !important;
	opacity: 0 !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	pointer-events: none;
}

/* -------------------------------------------------------------------------
	Open control (hamburger) — mobile only
------------------------------------------------------------------------- */

.nb-nav-open {
	position: relative;
	z-index: 1;
	box-sizing: border-box;
	display: none;
	align-items: center;
	justify-content: center;
	align-self: stretch;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid transparent; /* keep 44×44 box; no visible border */
	background: var(--wp--preset--color--main, #000);
	color: var(--wp--preset--color--base, #fff);
	cursor: pointer;
}

.nb-nav-open__icon,
.nb-nav-open__icon::before,
.nb-nav-open__icon::after {
	display: block;
	height: 2px;
	background: currentColor;
}

/* Lines: top mid-length, middle longest, bottom shortest (±2px) */
.nb-nav-open__icon {
	position: relative;
	width: 24px;
}

.nb-nav-open__icon::before,
.nb-nav-open__icon::after {
	content: "";
	position: absolute;
	left: 0;
}

.nb-nav-open__icon::before {
	top: -7px;
	width: 22px;
}

.nb-nav-open__icon::after {
	top: 7px;
	width: 20px;
}

.nb-nav-open:focus-visible,
.nb-nav-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* -------------------------------------------------------------------------
	Overlay shell — full viewport
	Chrome reuses .header-layout.alignwide so logo/close match the sticky bar.
------------------------------------------------------------------------- */

.nb-nav-overlay {
	box-sizing: border-box;
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none !important;
	flex-direction: column;
	width: 100%;
	min-height: 100vh;
	min-height: 100dvh;
	padding: 0;
	background: var(--wp--preset--color--primary, #500eee);
	color: var(--wp--preset--color--base, #fff);
}

html:has(.nb-nav-toggle:checked) {
	overflow: hidden;
}

html:has(.nb-nav-toggle:checked) .nb-nav-overlay {
	display: flex !important;
}

/* Hide sticky bar chrome while open — overlay chrome sits in the same slot */
html:has(.nb-nav-toggle:checked) .site-header > .header-layout {
	visibility: hidden;
}

.nb-nav-overlay__chrome {
	box-sizing: border-box;
	flex: 0 0 auto;
	padding-block: 1.15rem; /* match .site-header */
	color: inherit;
}

.nb-nav-overlay__chrome .header-layout {
	align-items: center;
	justify-content: space-between;
}

.nb-nav-close {
	box-sizing: border-box;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	margin-left: auto;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.nb-nav-close__icon {
	display: block;
	width: 44px;
	height: 44px;
}

.nb-nav-overlay .header-navigation--overlay {
	box-sizing: border-box;
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	padding: 0;
	color: inherit;
}

.nb-nav-overlay__menus {
	box-sizing: border-box;
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	justify-content: flex-start;
	gap: 0;
	padding: 1.5rem 0 3rem;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.nb-nav-overlay__rule {
	box-sizing: border-box;
	width: 100%;
	max-width: min(var(--nb-wide, 1290px), calc(100% - (2 * var(--nb-edge, 3rem))));
	height: 1px;
	margin: 1.25rem auto 1rem;
	padding: 0;
	background: currentColor;
	opacity: 0.35;
}

/* Same wide column as the chrome / sticky header */
.nb-nav-overlay .header-navigation--overlay .wp-block-navigation__container,
.nb-nav-overlay .header-navigation--overlay-social .wp-block-navigation__container {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.35rem;
	width: 100%;
	max-width: min(var(--nb-wide, 1290px), calc(100% - (2 * var(--nb-edge, 3rem))));
	margin: 0 auto;
	padding: 0;
	list-style: none;
}

.nb-nav-overlay .header-navigation--overlay .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	padding: 0.2em 0.05em;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--base, #fff);
	font-family: var(--wp--preset--font-family--primary, "Geist", sans-serif);
	font-size: clamp(1.75rem, 6vw, 2.5rem);
	font-weight: 700;
	letter-spacing: -0.03em;
	line-height: 1.15;
	text-decoration: none;
	text-transform: none;
}

/* Footer / social block in overlay — normal weight + size */
.nb-nav-overlay .header-navigation--overlay-social {
	box-sizing: border-box;
	flex: 0 0 auto;
	display: flex;
	flex-direction: column;
	padding: 0;
	color: inherit;
}

.nb-nav-overlay .header-navigation--overlay-social .wp-block-navigation__container {
	gap: 0.15rem;
}

.nb-nav-overlay .header-navigation--overlay-social .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	padding: 0.35em 0.05em;
	border: 0;
	background: transparent;
	color: var(--wp--preset--color--base, #fff);
	font-family: var(--wp--preset--font-family--mono, "Share Tech Mono", ui-monospace, monospace);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	font-weight: 400;
	letter-spacing: 0;
	line-height: 1.4;
	text-decoration: none;
	text-transform: uppercase;
}

.nb-nav-overlay .header-navigation--overlay .wp-block-navigation-item.current-menu-item > .wp-block-navigation-item__content,
.nb-nav-overlay .header-navigation--overlay .wp-block-navigation-item__content[aria-current="page"] {
	padding: 0.15em 0.4em;
	background: var(--wp--preset--color--base, #fff);
	color: var(--wp--preset--color--primary, #500eee);
}

.nb-nav-overlay .header-navigation--overlay .wp-block-navigation-item:not(.current-menu-item) > .wp-block-navigation-item__content:is(:hover, :focus-visible):not([aria-current="page"]),
.nb-nav-overlay .header-navigation--overlay-social .wp-block-navigation-item__content:is(:hover, :focus-visible) {
	color: var(--wp--preset--color--base, #fff);
	background: transparent;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.2em;
}

.nb-nav-overlay .header-navigation--overlay-social .wp-block-navigation-item__content:is(:hover, :focus-visible) {
	text-decoration-thickness: 1px;
}

/*
	Overlay enter — drop in from above, 180ms.
*/
@keyframes nb-nav-item-in {
	0% {
		opacity: 0;
		transform: translate3d(0, -0.35em, 0);
	}
	100% {
		opacity: 1;
		transform: translate3d(0, 0, 0);
	}
}

@keyframes nb-nav-rule-in {
	0% {
		opacity: 0;
		transform: scaleX(0.4);
	}
	100% {
		opacity: 0.35;
		transform: scaleX(1);
	}
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item
	> .wp-block-navigation-item__content,
html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item
	> .wp-block-navigation-item__content {
	animation: nb-nav-item-in 180ms cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(1)
	> .wp-block-navigation-item__content {
	animation-delay: 0ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(2)
	> .wp-block-navigation-item__content {
	animation-delay: 40ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(3)
	> .wp-block-navigation-item__content {
	animation-delay: 80ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(4)
	> .wp-block-navigation-item__content {
	animation-delay: 120ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(5)
	> .wp-block-navigation-item__content {
	animation-delay: 160ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(6)
	> .wp-block-navigation-item__content {
	animation-delay: 200ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(7)
	> .wp-block-navigation-item__content {
	animation-delay: 240ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay
	.wp-block-navigation-item:nth-child(8)
	> .wp-block-navigation-item__content {
	animation-delay: 280ms;
}

html:has(.nb-nav-toggle:checked) .nb-nav-overlay__rule {
	transform-origin: left center;
	animation: nb-nav-rule-in 180ms cubic-bezier(0.2, 0.85, 0.2, 1) both;
	animation-delay: 120ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(1)
	> .wp-block-navigation-item__content {
	animation-delay: 220ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(2)
	> .wp-block-navigation-item__content {
	animation-delay: 250ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(3)
	> .wp-block-navigation-item__content {
	animation-delay: 280ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(4)
	> .wp-block-navigation-item__content {
	animation-delay: 310ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(5)
	> .wp-block-navigation-item__content {
	animation-delay: 340ms;
}

html:has(.nb-nav-toggle:checked)
	.nb-nav-overlay
	.header-navigation--overlay-social
	.wp-block-navigation-item:nth-child(6)
	> .wp-block-navigation-item__content {
	animation-delay: 370ms;
}

@media (prefers-reduced-motion: reduce) {
	html:has(.nb-nav-toggle:checked)
		.nb-nav-overlay
		.header-navigation--overlay
		.wp-block-navigation-item
		> .wp-block-navigation-item__content,
	html:has(.nb-nav-toggle:checked)
		.nb-nav-overlay
		.header-navigation--overlay-social
		.wp-block-navigation-item
		> .wp-block-navigation-item__content,
	html:has(.nb-nav-toggle:checked) .nb-nav-overlay__rule {
		animation: none;
	}
}

/* -------------------------------------------------------------------------
	Item visibility — Appearance → Menus → CSS Classes
	Add `desktop` or `mobile` on a menu item (scoped to nav/footer only).
------------------------------------------------------------------------- */

@media (max-width: 899px) {
	.header-navigation .desktop,
	.footer-social .desktop {
		display: none !important;
	}
}

@media (min-width: 900px) {
	.header-navigation .mobile,
	.footer-social .mobile {
		display: none !important;
	}
}

/* -------------------------------------------------------------------------
	Breakpoint
------------------------------------------------------------------------- */

@media (min-width: 900px) {
	.nb-nav-open {
		display: none !important;
	}

	.nb-nav-overlay {
		display: none !important;
	}
}

@media (max-width: 899px) {
	.header-layout {
		align-items: center;
		justify-content: space-between;
		gap: clamp(1em, 4vw, 1.5em);
	}

	.header-navigation-panel {
		flex: 0 0 auto;
		min-width: 0;
		width: auto;
		margin-left: auto;
	}

	.header-navigation-panel::before {
		display: none;
	}

	.nb-nav-open {
		display: inline-flex;
		height: auto;
		min-height: 44px;
	}

	/*
		Mobile bar: hamburger only.
		Primary links live in the overlay — keeps side air even
		and avoids a second CTA fighting the menu control.
	*/
	header .header-navigation--bar {
		display: none;
	}
}
