/* -------------------------------------------------------------------------
   Adage Site Header — front + shared
   Desktop ≥ breakpoint (default 1600, JS) · Mobile overlay full-size list
--------------------------------------------------------------------------- */

.adage-site-header {
	--adage-header-breakpoint: 1600px;
	--adage-header-gap: 1.25rem;
	--adage-header-link-size: 0.95rem;
	--adage-header-pad-y: 0.5rem;
	--adage-header-pad-x: clamp(1rem, 4vw, 2.5rem);
	--adage-header-logo-max-height: 42px;
	--adage-header-z: 1000;
	--adage-header-bg: transparent;
	--adage-header-overlay-bg: oklch(0.96 0.014 78.3);
	--adage-header-overlay-padding: 2rem;
	--adage-header-mobile-gap: 1.25rem;
	--adage-header-mobile-size: 1.35rem;
	--adage-header-toggle-color: currentColor;
	--adage-header-ease-out: cubic-bezier(0.23, 1, 0.32, 1);

	position: relative;
	z-index: var(--adage-header-z);
	width: 100%;
	background: var(--adage-header-bg);
	box-sizing: border-box;
}

.adage-site-header *,
.adage-site-header *::before,
.adage-site-header *::after {
	box-sizing: border-box;
}

.adage-site-header.is-sticky {
	position: sticky;
	inset-block-start: 0;
}

.adage-site-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--adage-header-gap);
	width: 100%;
	max-width: 100%;
	padding-block: var(--adage-header-pad-y);
	padding-inline: var(--adage-header-pad-x);
	min-height: calc(var(--adage-header-logo-max-height) + (var(--adage-header-pad-y) * 2));
}

/* Desktop: keep the whole header bar ≤ 90px */
.adage-site-header.is-desktop {
	--adage-header-logo-max-height: 42px;
	--adage-header-pad-y: 0.4rem;
}

.adage-site-header.is-desktop .adage-site-header__bar {
	max-height: 90px;
	min-height: 0;
	height: auto;
}

.adage-site-header.is-desktop .adage-site-header-brand .custom-logo-link img,
.adage-site-header.is-desktop .adage-site-header-brand .wp-block-site-logo img,
.adage-site-header.is-desktop .adage-site-header-brand .custom-logo {
	height: 42px !important;
	max-height: 42px !important;
	max-width: min(170px, 28vw) !important;
}

.adage-site-header-brand {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex: 0 1 auto;
	min-width: 0;
	max-width: min(420px, 38%);
}

.adage-site-header-brand .wp-block-group {
	flex: 0 1 auto;
	min-width: 0;
}

.adage-site-header-brand .wp-block-site-logo,
.adage-site-header-brand .custom-logo-link {
	display: inline-flex;
	align-items: center;
	line-height: 0;
}

.adage-site-header-brand .custom-logo-link img,
.adage-site-header-brand .wp-block-site-logo img,
.adage-site-header-brand .custom-logo {
	display: block;
	height: var(--adage-header-logo-max-height, 42px) !important;
	max-height: var(--adage-header-logo-max-height, 42px) !important;
	width: auto !important;
	max-width: min(220px, 40vw);
}

/*
 * WP toolbar site icon: never inherit header logo sizing.
 * SVG / full logo used as site icon otherwise blows up to intrinsic size.
 */
#wpadminbar #wp-admin-bar-site-name > .ab-item img,
#wpadminbar .ab-item > img.avatar,
#wpadminbar img.avatar {
	width: 20px !important;
	height: 20px !important;
	max-width: 20px !important;
	max-height: 20px !important;
	padding: 0 !important;
	margin-inline-end: 6px !important;
	border: 0 !important;
	border-radius: 0 !important;
	display: inline-block !important;
	vertical-align: middle !important;
	object-fit: contain !important;
	box-sizing: content-box !important;
}

.adage-site-header-nav {
	display: flex;
	align-items: center;
	justify-content: end;
	flex: 1 1 auto;
	min-width: 0;
}

.adage-site-header-cta {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
}

.adage-site-header-cta .wp-block-buttons {
	margin: 0;
}

.adage-site-header-cta .wp-block-button__link {
	white-space: nowrap;
}

.adage-site-header-cta .wp-block-button__link:active,
.adage-site-header__toggle:active {
	transform: scale(0.97);
}

@media (prefers-reduced-motion: no-preference) {
	.adage-site-header-cta .wp-block-button__link,
	.adage-site-header__toggle {
		transition: transform 160ms var(--adage-header-ease-out, ease-out);
	}
}

/* Desktop navigation styles */
.adage-site-header .wp-block-navigation {
	--navigation-layout-justification-setting: flex-end;
}

.adage-site-header .wp-block-navigation .wp-block-navigation-item__content {
	font-size: var(--adage-header-link-size);
	color: var(--adage-header-link-color, inherit);
	white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
	.adage-site-header .wp-block-navigation .wp-block-navigation-item__content:hover {
		color: var(--adage-header-link-hover, var(--adage-header-link-color, inherit));
	}
}

.adage-site-header .wp-block-navigation .wp-block-navigation-item__content:focus-visible,
.adage-site-header__toggle:focus-visible,
.adage-site-header-cta .wp-block-button__link:focus-visible {
	outline: max(2px, 0.08em) solid currentColor;
	outline-offset: 0.25em;
}

.adage-site-header.has-nowrap .adage-site-header-nav .wp-block-navigation__container,
.adage-site-header.has-nowrap .adage-site-header-nav .wp-block-navigation > ul {
	flex-wrap: nowrap !important;
}

/* Kill core navigation responsive overlay (we use our own at custom breakpoint) */
.adage-site-header .wp-block-navigation__responsive-container-open,
.adage-site-header .wp-block-navigation__responsive-dialog,
.adage-site-header .wp-block-navigation__responsive-container-close {
	display: none !important;
}

.adage-site-header .wp-block-navigation__responsive-container {
	display: contents !important;
	position: static !important;
	width: auto !important;
	height: auto !important;
	background: transparent !important;
	overflow: visible !important;
}

.adage-site-header .wp-block-navigation__responsive-container-content {
	display: contents !important;
	padding: 0 !important;
}

/* Toggle — hidden on desktop */
.adage-site-header__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	margin: 0;
	padding: 0.55rem;
	border: 0;
	background: transparent;
	color: var(--adage-header-toggle-color);
	cursor: pointer;
	flex: 0 0 auto;
	min-width: 44px;
	min-height: 44px;
	line-height: 1;
	touch-action: manipulation;
}

.adage-site-header__toggle-icon {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 22px;
}

.adage-site-header__toggle-icon span {
	display: block;
	height: 2px;
	width: 100%;
	background: currentColor;
	border-radius: 1px;
}

@media (prefers-reduced-motion: no-preference) {
	.adage-site-header__toggle-icon span {
		transition:
			transform 200ms var(--adage-header-ease-out, ease-out),
			opacity 200ms var(--adage-header-ease-out, ease-out);
	}
}

.adage-site-header.is-open .adage-site-header__toggle-icon span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.adage-site-header.is-open .adage-site-header__toggle-icon span:nth-child(2) {
	opacity: 0;
}

.adage-site-header.is-open .adage-site-header__toggle-icon span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

.adage-site-header__panel {
	display: none;
}

/* Visibility helpers for CTA (classes set by block attributes + JS) */
.adage-site-header.hide-cta-mobile.is-mobile .adage-site-header-cta {
	display: none;
}

.adage-site-header.hide-cta-desktop.is-desktop .adage-site-header-cta {
	display: none;
}

/* Mobile / below custom breakpoint — driven by .is-mobile from view.js */
.adage-site-header.is-mobile .adage-site-header__toggle {
	display: inline-flex;
	position: relative;
	z-index: 2;
}

.adage-site-header.is-mobile .adage-site-header__bar {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto auto;
	grid-template-areas: "brand cta toggle";
	align-items: center;
	column-gap: 0.5rem;
	row-gap: 0;
	position: relative;
	z-index: calc(var(--adage-header-z) + 2);
	background: var(--adage-header-bg, oklch(0.96 0.014 78.3));
}

.adage-site-header.is-mobile .adage-site-header-brand {
	grid-area: brand;
	max-width: none;
	width: 100%;
	min-width: 0;
	overflow: clip;
}

.adage-site-header.is-mobile .adage-site-header-brand .custom-logo-link img,
.adage-site-header.is-mobile .adage-site-header-brand .wp-block-site-logo img,
.adage-site-header.is-mobile .adage-site-header-brand .custom-logo {
	height: clamp(36px, 10vw, 42px) !important;
	max-height: clamp(36px, 10vw, 42px) !important;
	max-width: min(150px, 36vw) !important;
}

.adage-site-header.is-mobile .adage-site-header-cta {
	grid-area: cta;
	max-width: 100%;
	min-width: 0;
}

.adage-site-header.is-mobile .adage-site-header-cta .wp-block-buttons,
.adage-site-header.is-mobile .adage-site-header-cta .wp-block-button {
	max-width: 100%;
}

.adage-site-header.is-mobile .adage-site-header-cta .wp-block-button__link {
	font-size: clamp(0.7rem, 2.8vw, 0.78rem);
	line-height: 1.2;
	padding-block: clamp(0.45rem, 1.5vw, 0.55rem);
	padding-inline: clamp(0.55rem, 2vw, 0.7rem);
	white-space: nowrap;
}

.adage-site-header.is-mobile .adage-site-header__toggle {
	grid-area: toggle;
}

/* Keep hamburger / close (X) above the full-screen overlay */
.adage-site-header.is-mobile.is-open .adage-site-header__bar {
	background: var(--adage-header-overlay-bg, oklch(0.96 0.014 78.3));
}

.adage-site-header.is-mobile.is-open .adage-site-header__toggle {
	z-index: calc(var(--adage-header-z) + 3);
}

.adage-site-header.is-mobile .adage-site-header__panel {
	display: block;
	position: fixed;
	inset: 0;
	z-index: calc(var(--adage-header-z) + 1);
	background: var(--adage-header-overlay-bg);
	color: var(--adage-header-overlay-text, inherit);
	/* --adage-header-bar-offset set by view.js from measured bar height */
	padding-block-start: calc(
		var(--wp-admin--admin-bar--height, 0px)
		+ var(--adage-header-bar-offset, 4.75rem)
		+ 0.75rem
	);
	padding-block-end: var(--adage-header-overlay-padding);
	padding-inline: var(--adage-header-overlay-padding);
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}

.adage-site-header.is-mobile .adage-site-header__panel[hidden] {
	display: none !important;
}

.adage-site-header.is-mobile.is-open .adage-site-header__panel {
	display: block;
}

.adage-site-header.is-mobile .adage-site-header-nav {
	width: 100%;
	justify-content: stretch;
}

.adage-site-header.is-mobile .adage-site-header-nav .wp-block-navigation,
.adage-site-header.is-mobile .adage-site-header-nav .wp-block-navigation__container,
.adage-site-header.is-mobile .adage-site-header-nav .wp-block-navigation > ul {
	display: flex !important;
	flex-direction: column !important;
	align-items: stretch !important;
	justify-content: flex-start !important;
	width: 100%;
	gap: var(--adage-header-mobile-gap) !important;
	flex-wrap: nowrap !important;
}

.adage-site-header.is-mobile .adage-site-header-nav .wp-block-navigation-item {
	width: 100%;
}

.adage-site-header.is-mobile .adage-site-header-nav .wp-block-navigation-item__content {
	display: block;
	width: 100%;
	font-size: var(--adage-header-mobile-size);
	white-space: normal;
	line-height: 1.3;
	padding-block: 0.35rem;
	padding-inline: 0;
	color: var(--adage-header-overlay-text, var(--adage-header-link-color, inherit));
}

/* Flatten submenus into the full-size list */
.adage-site-header.is-mobile .wp-block-navigation-submenu > .wp-block-navigation__submenu-icon,
.adage-site-header.is-mobile .wp-block-navigation-submenu > button.wp-block-navigation-submenu__toggle {
	display: none !important;
}

.adage-site-header.is-mobile .wp-block-navigation-submenu > .wp-block-navigation__submenu-container {
	display: flex !important;
	flex-direction: column !important;
	position: static !important;
	width: 100% !important;
	min-width: 0 !important;
	height: auto !important;
	opacity: 1 !important;
	visibility: visible !important;
	overflow: visible !important;
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	padding-block: 0.35rem !important;
	padding-inline: 1rem 0 !important;
	gap: calc(var(--adage-header-mobile-gap) * 0.65) !important;
}

/* Scroll lock while overlay is open — hidden is correct for script-driven lock */
html.adage-header-lock,
body.adage-header-lock {
	overflow: hidden;
}

/* Desktop layout refinements */
.adage-site-header.is-desktop .adage-site-header__toggle,
.adage-site-header.is-desktop .adage-site-header__panel {
	display: none !important;
}

.adage-site-header.is-desktop .adage-site-header__bar {
	display: flex;
}

/*
 * Single FOUC fallback before JS adds .is-desktop / .is-mobile.
 * Matches the default --adage-header-breakpoint (1600). Not a ladder.
 */
@media (width < 1600px) {
	.adage-site-header:not(.is-desktop):not(.is-mobile) .adage-site-header__toggle {
		display: inline-flex;
	}

	.adage-site-header:not(.is-desktop):not(.is-mobile) .adage-site-header-nav {
		display: none;
	}
}

@media (width >= 1600px) {
	.adage-site-header:not(.is-desktop):not(.is-mobile) .adage-site-header__toggle {
		display: none;
	}
}
