/* Site header (partials/site-header.php, inc/nav-menu.php, assets/js/header.js), from the prototype header
   (methodology.html "GLOBAL: site-header") and cmc.css §1 (focus, button reset), §5 link-rule, §5d nav dropdown,
   §8 header glass, §8b buttons, mobile-nav-item.
   Fixed, z 50, transparent at rest; .is-scrolled (header.js, after 24px) condenses the bar 90 → 70 and frosts it.
   One breakpoint, 1280px (the prototype's xl): below it the menu button opens the bar as a full-screen popover
   (the same markup restyled; header.js uses the same width). Sizes in px are the prototype's (its spacing keys are px). */

:root {
	--header-height: 90px; /* published by header.js from the measured header */
}

/* Anchor jumps land below the fixed header (cmc.css §1). */
html {
	scroll-padding-top: calc(var(--header-height, 90px) + 20px);
}

/* The open mobile menu locks the page behind it (the prototype sets body overflow hidden). */
body:has(.cmc-header__bar:popover-open) {
	overflow: hidden;
}

/* Border-box, as the prototype (Tailwind preflight). */
.cmc-header,
.cmc-header *,
.cmc-header ::before,
.cmc-header ::after {
	box-sizing: border-box;
}

.cmc-header {
	--cmc-bar: 90px;
	position: fixed;
	top: var(--wp-admin--admin-bar--height, 0px);
	inset-inline: 0;
	z-index: 50;
	color: var(--wp--preset--color--charcoal);
}

.cmc-header.is-scrolled {
	--cmc-bar: 70px;
}

/* The glass: white 75% + blur 14px saturate 1.6 (cmc.css .header-glass), on the header itself (on a pseudo-element
   Safari blurs nothing: its backdrop stops at the header's stacking context). Never while the mobile menu is open
   (the prototype's header-plain), so nothing can make the header the containing block of that popover. */
.cmc-header {
	transition: background-color 300ms var(--wp--custom--ease), backdrop-filter 300ms var(--wp--custom--ease), -webkit-backdrop-filter 300ms var(--wp--custom--ease);
}

.cmc-header.is-scrolled:not(:has(.cmc-header__bar:popover-open)) {
	background-color: rgb(255 255 255 / 0.75);
	-webkit-backdrop-filter: blur(14px) saturate(1.6);
	backdrop-filter: blur(14px) saturate(1.6);
}

:where(.cmc-header) button {
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: inherit;
	cursor: pointer;
}

.cmc-header .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* The bar. Logo 50px from the left, the nav ends 30px from the right (drawn), 20 / 20 below 1024.
   It is also the mobile menu's popover: these rules undo the UA popover box while it is closed. */
.cmc-header__bar {
	position: relative;
	inset: auto;
	z-index: 10;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: auto;
	height: var(--cmc-bar);
	margin: 0;
	padding: 0 30px 0 50px;
	overflow: visible;
	border: 0;
	background: transparent;
	color: inherit;
	transition: height 300ms var(--wp--custom--ease);
}

.cmc-header__logo {
	flex-shrink: 0;
}

.cmc-header__logo img {
	width: auto;
	height: 50px;
}

@media (width < 1024px) {
	.cmc-header__bar {
		padding-inline: 20px;
	}

	.cmc-header__logo img {
		height: 40px;
	}
}

.cmc-nav__menu {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cmc-nav__menu li {
	margin: 0;
}

/* -------------------------------------------------------------------------------------------------------------------
 * Desktop (1280 and up): the inline nav. Links 16px / 500, 29px apart, the link-rule underline on hover, focus and
 * the current page.
 * ---------------------------------------------------------------------------------------------------------------- */
@media (width >= 1280px) {
	.cmc-header__toggle,
	.cmc-header .cmc-nav .is-mobile {
		display: none;
	}

	.cmc-nav__menu {
		display: flex;
		align-items: center;
		gap: 29px;
		font-weight: 500;
	}

	.cmc-nav__menu > li {
		position: relative;
		display: flex;
	}

	.cmc-nav__link {
		position: relative;
		display: inline-flex;
		align-items: center;
		gap: 4px;
		padding: 9px 0 4px;
		font-size: var(--wp--preset--font-size--text-9);
		line-height: 1.35;
		white-space: nowrap;
		color: var(--wp--preset--color--charcoal);
	}

	.cmc-nav__link::after {
		content: "";
		position: absolute;
		inset-inline: 0;
		bottom: 0;
		height: 2px;
		background: currentColor;
		transform: scaleX(0);
		transform-origin: left center;
		transition: transform 0.35s var(--wp--custom--ease);
	}

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

	/* The chevron: eases right on hover (the link-rule arrow), turns over while open. */
	.cmc-nav__chevron {
		flex-shrink: 0;
		margin-top: 1px;
		transition: transform 300ms var(--wp--custom--ease);
	}

	.cmc-nav__toggle:hover .cmc-nav__chevron,
	.cmc-nav__toggle:focus-visible .cmc-nav__chevron {
		transform: translateX(3px);
	}

	.cmc-nav__toggle[aria-expanded="true"] .cmc-nav__chevron {
		transform: rotate(180deg);
	}

	/* A parent item with its own URL: the link, then the chevron as its toggle. */
	.cmc-nav__toggle.is-icon {
		padding: 9px 0 4px 4px;
	}

	/* The dropdown card, centred under its trigger 8px down (::before bridges the gap for the pointer). */
	.cmc-nav__menu > li > .sub-menu {
		position: absolute;
		top: calc(100% + 8px);
		left: 50%;
		z-index: 50;
		min-width: 320px;
		margin: 0;
		padding: 20px;
		border-radius: var(--wp--custom--radius--card);
		background: var(--wp--preset--color--white);
		box-shadow: 0 0 0 1px rgb(48 59 56 / 0.1), 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
		opacity: 0;
		visibility: hidden;
		translate: -50% 1px;
		transition: opacity 100ms cubic-bezier(0.4, 0, 1, 1), translate 100ms cubic-bezier(0.4, 0, 1, 1), visibility 0s 100ms;
	}

	.cmc-nav__menu > li > .sub-menu::before {
		content: "";
		position: absolute;
		inset-inline: 0;
		bottom: 100%;
		height: 8px;
	}

	.cmc-nav__menu > li.is-open > .sub-menu {
		opacity: 1;
		visibility: visible;
		translate: -50% 0;
		transition: opacity 150ms cubic-bezier(0, 0, 0.2, 1), translate 150ms cubic-bezier(0, 0, 0.2, 1), visibility 0s;
	}

	.cmc-nav__item {
		display: block;
		padding: 12px;
		color: var(--wp--preset--color--charcoal);
		transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1);
	}

	.cmc-nav__item:hover {
		background-color: var(--wp--preset--color--off-white);
	}

	.sub-menu > li + li > .cmc-nav__item {
		border-top: 1px solid rgb(48 59 56 / 0.08);
	}

	.cmc-nav__item .cmc-nav__title {
		display: block;
		font-size: var(--wp--preset--font-size--text-9);
		line-height: 1.35;
		font-weight: 600;
	}

	.cmc-nav__item .cmc-nav__desc {
		display: block;
		font-size: var(--wp--preset--font-size--text-11);
		line-height: 1.3;
		font-weight: 400;
		color: rgb(48 59 56 / 0.6);
	}

	/* Contact: the gradient button, 8px further out than the gap. */
	.cmc-nav__menu > li.is-button {
		margin-left: 8px;
	}

	.cmc-nav__button {
		padding: 18px 20px 16px 22px;
		font-size: var(--wp--preset--font-size--text-8);
		line-height: 1.3;
		transition: transform 300ms var(--wp--custom--ease);
	}

	.cmc-nav__button:hover {
		transform: translateY(-2px);
	}
}

/* The gradient button (both menus): cmc.css §8b ripple + arrow. */
.cmc-nav__button {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	border-radius: var(--wp--custom--radius--btn);
	background-image: var(--wp--preset--gradient--warm);
	font-weight: 600;
	color: var(--wp--preset--color--charcoal);
}

.cmc-nav__button::after {
	content: "";
	position: absolute;
	z-index: -1;
	top: 50%;
	left: 50%;
	width: 6px;
	height: 6px;
	margin: -3px 0 0 -3px;
	border-radius: 50%;
	background: rgb(255 255 255 / 0.45);
	opacity: 0;
	pointer-events: none;
}

.cmc-nav__button:hover::after,
.cmc-nav__button:focus-visible::after {
	animation: cmc-btn-ripple 900ms ease-out;
}

@keyframes cmc-btn-ripple {
	0% { transform: scale(0); opacity: 1; }
	20% { transform: scale(25); opacity: 1; }
	100% { transform: scale(45); opacity: 0; }
}

.cmc-nav__button svg {
	flex-shrink: 0;
	transition: transform 300ms var(--wp--custom--ease);
}

.cmc-nav__button:hover svg,
.cmc-nav__button:focus-visible svg {
	transform: translateX(3px);
}

/* -------------------------------------------------------------------------------------------------------------------
 * Below 1280: the menu button (44px, burger / close) and the full-screen menu (cloud, the bar's logo and button stay
 * where they were, links 26–41px / 500, entering one after another).
 * ---------------------------------------------------------------------------------------------------------------- */
@media (width < 1280px) {
	.cmc-header__toggle {
		position: relative;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		color: var(--wp--preset--color--charcoal);
	}

	.cmc-header__toggle .is-close,
	.cmc-header__bar:popover-open .cmc-header__toggle .is-burger,
	.cmc-header .cmc-nav .is-desktop,
	.cmc-header__bar:not(:popover-open) .cmc-nav {
		display: none;
	}

	.cmc-header__bar:popover-open .cmc-header__toggle .is-close {
		display: block;
	}

	.cmc-header__bar:popover-open {
		position: fixed;
		inset: 0;
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-rows: var(--cmc-bar) auto;
		align-items: center;
		align-content: start;
		justify-content: stretch;
		height: auto;
		overflow-y: auto;
		background: var(--wp--preset--color--cloud);
	}

	.cmc-header__bar:popover-open .cmc-header__logo {
		grid-area: 1 / 1;
		justify-self: start;
	}

	.cmc-header__bar:popover-open .cmc-header__toggle {
		grid-area: 1 / 2;
	}

	.cmc-header__bar::backdrop {
		background: transparent;
	}

	/* The sheet's own 20px sides, whatever the bar's padding. */
	.cmc-header__bar:popover-open .cmc-nav {
		grid-area: 2 / 1 / 3 / -1;
		align-self: start;
		margin-inline: -30px -10px;
		padding: 30px 0 50px;
	}

	.cmc-nav__menu {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 25px;
	}

	.cmc-nav__menu > li {
		animation: cmc-nav-in 420ms var(--wp--custom--ease) both;
		animation-delay: calc(var(--i, 0) * 55ms);
	}

	.cmc-nav__menu > li:nth-child(2) { --i: 1; }
	.cmc-nav__menu > li:nth-child(3) { --i: 2; }
	.cmc-nav__menu > li:nth-child(4) { --i: 3; }
	.cmc-nav__menu > li:nth-child(5) { --i: 4; }
	.cmc-nav__menu > li:nth-child(6) { --i: 5; }
	.cmc-nav__menu > li:nth-child(7) { --i: 6; }
	.cmc-nav__menu > li:nth-child(8) { --i: 7; }
	.cmc-nav__menu > li:nth-child(9) { --i: 8; }

	.cmc-nav__link {
		display: block;
		font-size: var(--wp--preset--font-size--text-3);
		line-height: 1.1;
		font-weight: 500;
		color: var(--wp--preset--color--charcoal);
	}

	/* News & Insights: a full-width row that expands its links in place. */
	.cmc-nav__menu > li.menu-item-has-children {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.cmc-nav__menu > li.menu-item-has-children > .sub-menu {
		flex-basis: 100%;
	}

	.cmc-nav__toggle.is-icon {
		width: auto;
	}

	.cmc-nav__toggle {
		display: inline-flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
	}

	.cmc-nav__menu > li.menu-item-has-children.is-open {
		row-gap: 15px;
	}

	.cmc-nav__chevron {
		flex-shrink: 0;
		transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
	}

	.cmc-nav__toggle[aria-expanded="true"] .cmc-nav__chevron {
		transform: rotate(180deg);
	}

	.cmc-nav__menu .sub-menu {
		display: none;
		flex-direction: column;
		gap: 15px;
		padding-left: 15px;
	}

	.cmc-nav__menu > li.is-open > .sub-menu {
		display: flex;
	}

	.cmc-nav__item {
		display: block;
		font-size: var(--wp--preset--font-size--text-5);
		line-height: 1.2;
		font-weight: 500;
		color: var(--wp--preset--color--charcoal);
		animation: cmc-nav-in 420ms var(--wp--custom--ease) both;
	}

	.cmc-nav__item span {
		display: block;
	}

	.cmc-nav__item .cmc-nav__desc {
		font-size: var(--wp--preset--font-size--text-10);
		line-height: 1.3;
		font-weight: 400;
		color: rgb(48 59 56 / 0.6);
	}

	.cmc-nav__menu > li.is-button {
		margin-top: 15px;
	}

	.cmc-nav__button {
		padding: 18px 25px;
		font-size: var(--wp--preset--font-size--text-6);
		line-height: 1.2;
	}

	.cmc-nav__button svg {
		width: 18px;
		height: 18px;
	}
}

@media (width < 1024px) {
	.cmc-header__bar:popover-open .cmc-nav {
		margin-inline: 0;
	}
}

@keyframes cmc-nav-in {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: none; }
}

/* Incident banner (Settings → Site Settings): a charcoal strip under the bar. */
.cmc-banner {
	margin: 0;
	padding: 10px 20px;
	background: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--text-10);
	line-height: 1.3;
	font-weight: 500;
	text-align: center;
}

.cmc-banner a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: inherit;
}

.cmc-banner a span {
	text-decoration: underline 2px transparent;
	text-underline-offset: 4px;
	transition: text-decoration-color 300ms var(--wp--custom--ease);
}

.cmc-banner a:hover span,
.cmc-banner a:focus-visible span {
	text-decoration-color: currentColor;
}

.cmc-banner svg {
	flex-shrink: 0;
	transition: transform 300ms var(--wp--custom--ease);
}

.cmc-banner a:hover svg,
.cmc-banner a:focus-visible svg {
	transform: translateX(3px);
}

.cmc-banner :focus-visible {
	outline-color: var(--wp--preset--color--amber);
}

/* Skip link: core's (#wp-skip-link), shown as the prototype's (charcoal, top left; core's rule is !important). */
#wp-skip-link:focus {
	position: fixed !important;
	top: 20px;
	left: 20px;
	margin: 0;
	z-index: 51;
	padding: 12px 20px;
	border-radius: var(--wp--custom--radius--btn);
	background-color: var(--wp--preset--color--charcoal);
	color: var(--wp--preset--color--white);
	font-size: 1rem;
	line-height: 1.5;
	font-weight: 400;
}

/* The editor shows the header in the flow, not over the canvas. */
.editor-styles-wrapper .cmc-header {
	position: relative;
	top: 0;
}

@media (prefers-reduced-motion: reduce) {
	.cmc-header,
	.cmc-header * {
		transition: none !important;
	}

	.cmc-nav__menu > li,
	.cmc-nav__item,
	.cmc-nav__button::after {
		animation: none !important;
	}

	.cmc-nav__button:hover,
	.cmc-nav__button:hover svg,
	.cmc-nav__toggle:not([aria-expanded="true"]):hover .cmc-nav__chevron {
		transform: none;
	}
}
