/* ============================================================
   CW Header Rollout — cw-master "P2" header over Twenty Twenty-Two.
   Self-contained (own --cw-* tokens; no dependency on theme.json presets).
   Loaded by mu-plugins/cw-header-rollout.php after cw-brand-rollout.
   Revert: delete cw-header-rollout.php/.css/.js (instant) and restore
   wp_template_part 8948 + wp_navigation 8964 from ~/backups/.
   ============================================================ */

:root {
	--cw-max: 1200px;
	--cw-ink: #171717;
	--cw-paper: #FFFFFF;
	--cw-off: #F7F7F5;
	--cw-muted: #686868;
	--cw-line: #E7E7E7;
	--cw-brand: #F36B32;
	--cw-brand-deep: #D95320;
	--cw-accent: #F36B32;
	--cw-crimson: #C8102E;
	--cw-band: #171717;
	--cw-link: #C14E1F;
	--cw-radius: 20px;
}

/* Skip link + focus ring (from cw-master base.css). */
.skip-link.screen-reader-text {
	position: absolute; left: 12px; top: -60px; z-index: 100;
	background: var(--cw-ink); color: #fff; padding: 10px 18px; border-radius: 999px;
	transition: top .15s ease;
}
.skip-link.screen-reader-text:focus { top: 12px; color: #fff; }
:focus-visible { outline: 3px solid var(--cw-accent); outline-offset: 2px; border-radius: 6px; }

/* ---- cw-master header components ---- */

/* ================= CW header P2 — pill + search transformation (editorial) ================= */
/* Sticky + stacking live on the outer template-part wrapper (full-width bar sticks). */
header.wp-block-template-part { position: sticky; top: 20px; z-index: 60; }
.cw-site-header { position: relative; }
.cw-header-pill {
	max-width: var(--cw-max); margin: 0 auto; padding: 18px 20px 18px 30px;
	background-color: rgba(255, 255, 255, 0.8); border: 0; border-radius: 50px;
	-webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
	gap: 22px; position: relative; z-index: 1;
	transition: opacity .25s ease, transform .25s ease, border-radius .3s ease, background-color .25s ease;
}
/* Union surface: an EMPTY pseudo that only carries the card's radius + shadow.
   It grows downward to cover an open panel (--cw-panel-h, set by JS), so
   pill+panel read as ONE card. Closed it stays clear and the pill keeps its own
   frosted background; open, the pill delegates its surface here and the card
   turns SOLID WHITE (no translucency) while the panel content floats above it. */
.cw-header-pill::before {
	content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 0;
	bottom: calc(-1 * var(--cw-panel-h, 0px));
	background-color: transparent; border-radius: inherit;
	box-shadow: rgba(0, 0, 0, 0.04) 0px 4px 24px 0px;
	transition: bottom .36s cubic-bezier(.2,.7,.25,1), border-radius .3s ease, box-shadow .25s ease, background-color .25s ease;
}
body.is-scrolled .cw-header-pill::before { box-shadow: rgba(0, 0, 0, 0.08) 0px 8px 30px 0px; }
/* The mobile nav overlay is position:fixed (core), but the pill's backdrop-filter
   makes the pill a CONTAINING BLOCK for fixed descendants — which trapped the
   overlay inside the 92px pill instead of the viewport. Drop the filter (and the
   entrance transform) while the overlay is open so the menu covers the screen. */
.cw-header-pill:has(.wp-block-navigation__responsive-container.is-menu-open) {
	-webkit-backdrop-filter: none; backdrop-filter: none; animation: none;
}
/* open (search, any width): pill goes clear + solid-white surface on the pseudo.
   The submenu variant is desktop-only (added inside the min-width:861 block),
   because on mobile the submenu flows in place instead of extending the card. */
body.cw-search-open .cw-header-pill {
	background-color: transparent;
	-webkit-backdrop-filter: none; backdrop-filter: none;
	border-radius: 50px 50px 0 0;
}
body.cw-search-open .cw-header-pill::before {
	background-color: #fff; border-radius: 50px; box-shadow: 0 24px 50px rgba(23,23,23,.12);
}
.cw-logo-mark img { display: block; border-radius: 12px; }
.cw-mega-nav { flex: 1; }
.cw-mega-nav .wp-block-navigation-item__content {
	font-family: "Manrope", system-ui, sans-serif; font-weight: 700; font-size: 1.12rem;
	color: var(--cw-ink); position: relative;
}
/* underline: grows from a center dot to full width on hover/focus/current.
   Scoped to the TOP-level list only — if it matched nested items too, its
   absolute positioning/size (higher specificity) leaked onto the submenu row
   arrows, hijacking their place and hiding the chevrons. */
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content { text-decoration: none; }
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content:hover { text-decoration: none; }
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content::after {
	content: ""; position: absolute; left: 50%; right: 50%; bottom: -0.34em; height: 3px;
	border-radius: 3px; background: var(--cw-brand);
	transition: left .25s ease, right .25s ease;
}
.cw-mega-nav ul.wp-block-navigation__container > li.current-menu-item > .wp-block-navigation-item__content::after,
.cw-mega-nav ul.wp-block-navigation__container > li.current-menu-ancestor > .wp-block-navigation-item__content::after,
.cw-mega-nav ul.wp-block-navigation__container > li.cw-open > .wp-block-navigation-item__content::after,
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content:hover::after,
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content:focus-visible::after {
	left: 0; right: 0;
}
.cw-mega-nav ul.wp-block-navigation__container > li > .wp-block-navigation-item__content:focus-visible { outline-offset: 5px; }
/* chevron rotates only when its panel is actually open */
.cw-mega-nav .wp-block-navigation__submenu-icon { transition: transform .2s ease; color: var(--cw-brand-deep); }
.cw-mega-nav .wp-block-navigation-item.cw-open > .wp-block-navigation-item__content .wp-block-navigation__submenu-icon { transform: rotate(180deg); }
/* In click mode the parent label is a real <button>. Core deliberately skips its
   button reset for the toggle class, so strip the UA chrome ourselves to keep it
   reading as a plain nav label, and keep the chevron as a clickable affordance
   beside it (core ships it as a decorative, pointer-events:none sibling). */
.cw-mega-nav .wp-block-navigation-item.has-child > .wp-block-navigation-item__content.wp-block-navigation-submenu__toggle {
	appearance: none; -webkit-appearance: none;
	background: none; border: 0; box-shadow: none;
	padding: 0; margin: 0; color: inherit; text-align: inherit; cursor: pointer;
}
.cw-mega-nav .wp-block-navigation-item.has-child.open-on-click > .wp-block-navigation__submenu-icon {
	pointer-events: auto; cursor: pointer; margin-left: .2em;
}
/* mega submenu — Mastercard-style expanding header: clicking a parent nav item
   grows the pill into a card and reveals its submenu on the left. Open state is
   owned by OUR JS (.cw-open on the li, toggled by click or keyboard activation
   of the parent button) — core's own visibility, background and hover rules are
   fully suppressed below, so hover can neither open nor close the panel. */
.cw-mega-nav .wp-block-navigation-item.has-child { position: static; }

/* ---- desktop: panel expands to the full pill width under the header ---- */
@media (min-width: 861px) {
	/* The panel must span the PILL, not the nav: core puts position:relative on
	   its inner wrappers, which would trap the absolutely-positioned submenu at
	   nav width. Neutralize every ancestor between pill and submenu. */
	.cw-header-pill .cw-mega-nav,
	.cw-header-pill .cw-mega-nav .wp-block-navigation__responsive-container,
	.cw-header-pill .cw-mega-nav .wp-block-navigation__responsive-dialog,
	.cw-header-pill .cw-mega-nav .wp-block-navigation__responsive-container-content,
	.cw-header-pill .cw-mega-nav .wp-block-navigation__container { position: static !important; }

	/* pill morphs into an expanded card while a submenu is open */
	.cw-header-pill:has(.wp-block-navigation-item.cw-open) {
		background-color: transparent;
		-webkit-backdrop-filter: none; backdrop-filter: none;
		border-radius: 50px 50px 0 0;
	}
	.cw-header-pill:has(.wp-block-navigation-item.cw-open)::before {
		background-color: #fff; border-radius: 50px; box-shadow: 0 24px 50px rgba(23,23,23,.12);
	}

	/* Panel is a transparent content layer: the frosted surface, radius and the
	   single shadow all live on the pill's ::before (which extends behind it).
	   Base hides with !important so core's own submenu rules (higher specificity,
	   incl. its transparent background and its hover/aria-expanded open states)
	   can never leak through — only our .cw-open rule below can re-show it. */
	.cw-header-pill .cw-mega-nav ul.wp-block-navigation__submenu-container {
		position: absolute; top: 100%; left: 0; right: 0; z-index: 70;
		background-color: transparent !important;
		-webkit-backdrop-filter: none; backdrop-filter: none;
		border: 0 !important; border-radius: 0 0 34px 34px;
		box-shadow: none !important;
		padding: 20px 30px 28px; margin: 0;
		display: block; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important;
		transform: translateY(-10px) !important; clip-path: inset(0 0 100% 0) !important;
		transition: opacity .25s ease, transform .32s cubic-bezier(.2,.7,.25,1), clip-path .34s cubic-bezier(.2,.7,.25,1), visibility 0s linear .35s;
	}
	.cw-header-pill .cw-mega-nav .wp-block-navigation-item.cw-open > ul.wp-block-navigation__submenu-container {
		display: block !important;
		visibility: visible !important;
		opacity: 1 !important;
		height: auto !important;
		width: auto !important;
		overflow: visible !important;
		border: 0 !important;
		box-shadow: none !important;
		pointer-events: auto !important;
		transform: none !important;
		clip-path: inset(0 0 0 0) !important;
		transition: opacity .28s ease .04s, transform .36s cubic-bezier(.2,.7,.25,1), clip-path .38s cubic-bezier(.2,.7,.25,1);
	}
	/* rows enter in sequence from the left */
	.cw-mega-nav ul.wp-block-navigation__submenu-container > li {
		max-width: 430px; opacity: 0; transform: translateX(-12px);
		transition: opacity .25s ease, transform .3s cubic-bezier(.2,.7,.25,1);
	}
	.cw-header-pill .cw-mega-nav .wp-block-navigation-item.cw-open > ul.wp-block-navigation__submenu-container > li { opacity: 1; transform: none; }
}
.cw-mega-nav ul.wp-block-navigation__submenu-container > li:nth-child(2) { transition-delay: .06s; }
.cw-mega-nav ul.wp-block-navigation__submenu-container > li:nth-child(3) { transition-delay: .1s; }
.cw-mega-nav ul.wp-block-navigation__submenu-container > li:nth-child(4) { transition-delay: .14s; }
.cw-mega-nav ul.wp-block-navigation__submenu-container > li:nth-child(5) { transition-delay: .18s; }
.cw-mega-nav ul.wp-block-navigation__submenu-container > li:nth-child(n+6) { transition-delay: .22s; }
.cw-mega-nav ul.wp-block-navigation__submenu-container a {
	display: flex; align-items: center; justify-content: space-between; gap: 18px;
	padding: 13px 8px; border-radius: 12px; font-size: 1.06rem; font-weight: 600;
	color: var(--cw-ink); text-decoration: none;
}
.cw-mega-nav ul.wp-block-navigation__submenu-container a::after {
	content: "\203A"; font-size: 1.5rem; line-height: 1; font-weight: 400; color: var(--cw-muted);
	transition: transform .2s ease, color .2s ease;
}
.cw-mega-nav ul.wp-block-navigation__submenu-container a:hover,
.cw-mega-nav ul.wp-block-navigation__submenu-container a:focus-visible { background: var(--cw-off); }
.cw-mega-nav ul.wp-block-navigation__submenu-container a:hover::after,
.cw-mega-nav ul.wp-block-navigation__submenu-container a:focus-visible::after { transform: translateX(5px); color: var(--cw-brand-deep); }
/* "All <category>" row: the broader destination — bolder, its own arrow, and a
   hairline divider separating it from the deeper sub-category rows below */
.cw-mega-nav ul.wp-block-navigation__submenu-container > li.cw-menu-all {
	border-bottom: 1px solid var(--cw-line); margin-bottom: 10px; padding-bottom: 8px;
}
.cw-mega-nav ul.wp-block-navigation__submenu-container > li.cw-menu-all > a { font-weight: 700; }
.cw-mega-nav ul.wp-block-navigation__submenu-container > li.cw-menu-all > a::after { content: "\2192"; }
/* header actions */
.cw-header-actions { align-items: center; }
.cw-search-toggle {
	width: 56px; height: 56px; padding: 0; border-radius: 50%; border: 2px solid var(--cw-ink);
	background: transparent; color: var(--cw-ink); cursor: pointer; position: relative;
	display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.cw-search-toggle:hover { background: var(--cw-ink); color: #fff; }
.cw-search-toggle svg { position: absolute; width: 24px; height: 24px; transition: opacity .2s ease, transform .25s ease; }
.cw-search-toggle .cw-ic-close { opacity: 0; transform: rotate(-90deg) scale(.5); }
body.cw-search-open .cw-search-toggle { background: var(--cw-ink); color: #fff; }
body.cw-search-open .cw-search-toggle .cw-ic-search { opacity: 0; transform: rotate(90deg) scale(.5); }
body.cw-search-open .cw-search-toggle .cw-ic-close { opacity: 1; transform: none; }
/* header <-> search transformation: menu swaps for the field, logo stays */
body.cw-search-open .cw-mega-nav { display: none; }
.cw-pill-search { display: none; flex: 1 1 240px; min-width: 0; max-width: 560px; margin-inline: auto; width: 100%; }
body.cw-search-open .cw-pill-search { display: block; }
/* Search panel = the SAME unified card as the submenu: an absolute, transparent
   content layer just under the pill, revealed by a clip-path wipe, sitting over
   the pill's solid-white ::before surface (which grows by --cw-panel-h, JS-set). */
.cw-search-panel {
	position: absolute; top: 100%; left: 0; right: 0; z-index: 70;
	max-width: var(--cw-max); margin: 0 auto; width: 100%;
	background: transparent; border: 0; border-radius: 0 0 50px 50px; box-shadow: none;
	display: block; visibility: hidden; opacity: 0; pointer-events: none;
	transform: translateY(-10px); clip-path: inset(0 0 100% 0);
	transition: opacity .25s ease, transform .32s cubic-bezier(.2,.7,.25,1), clip-path .34s cubic-bezier(.2,.7,.25,1), visibility 0s linear .35s;
}
.cw-search-panel[hidden] { display: none; }
body.cw-search-open .cw-search-panel {
	visibility: visible; opacity: 1; pointer-events: auto;
	transform: none; clip-path: inset(0 0 0 0);
	transition: opacity .28s ease .04s, transform .36s cubic-bezier(.2,.7,.25,1), clip-path .38s cubic-bezier(.2,.7,.25,1);
}
.cw-search-inner { padding: 32px clamp(20px,3vw,44px) 44px; }
/* The search panel spans the FULL header width. Core caps the panel's children to
   the theme content-size (780px) because the inner/columns sit in a constrained
   layout — that shrank the content to a narrow centered band. Lift that cap so
   the columns use the whole card, like the header itself. */
.cw-search-panel .cw-search-inner,
.cw-search-panel .cw-search-cols { max-width: none; }
.cw-search-big input[type="search"] { border-radius: 999px; padding: 13px 26px; font-size: 1.08rem; border: 2px solid var(--cw-line); width: 100%; background: #fff; }
.cw-search-big input[type="search"]:focus { border-color: var(--cw-brand); box-shadow: 0 0 0 4px rgba(243,107,50,.25); outline: none; }
.cw-pill-search input[type="search"]::selection { background: var(--cw-brand); color: var(--cw-ink); }
.cw-pill-search .wp-block-search__inside-wrapper { border: 0; background: transparent; padding: 0; gap: 0; }
.cw-pill-search .wp-block-search__button { display: none; }
.cw-search-cols { gap: 48px; }
.cw-search-h { font-size: .82rem; letter-spacing: .14em; text-transform: uppercase; color: var(--cw-ink); }
.cw-search-panel ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.cw-search-panel ul a { display: block; padding: 10px 14px; border-radius: 12px; color: var(--cw-ink); font-weight: 600; text-decoration: none; }
.cw-search-panel ul a:hover { background: #fff; }
.cw-search-feat .wp-block-post { background: #fff; border: 1px solid var(--cw-line); border-radius: 20px; padding: 22px 24px; margin-bottom: 14px; }
.cw-search-feat .wp-block-post-title { font-size: 1.2rem; margin: 0 0 6px; }
.cw-search-feat .wp-block-post-title a { color: var(--cw-ink); text-decoration: none; }
.cw-search-feat .wp-block-post-excerpt { color: var(--cw-muted); font-size: .95rem; margin: 0; }
/* entrance + motion guards */
@media (prefers-reduced-motion: no-preference) {
	.cw-header-pill { animation: cw-drop .7s cubic-bezier(.2,.7,.25,1) both; }
}
@keyframes cw-drop { from { transform: translateY(-120%); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
	.cw-search-panel, .cw-search-inner, .cw-header-pill, .cw-search-toggle svg,
	.cw-mega-nav ul.wp-block-navigation__submenu-container,
	.cw-mega-nav ul.wp-block-navigation__submenu-container > li { transition: none !important; }
}
@media (max-width: 860px) {
	/* mobile overlay: submenu flows in place (no animation, no reserved space when closed) */
	.cw-mega-nav ul.wp-block-navigation__submenu-container {
		position: static; transform: none; clip-path: none;
		min-width: 0; box-shadow: none !important; border-radius: 0;
		background: transparent !important; -webkit-backdrop-filter: none; backdrop-filter: none;
		padding: 4px 0 4px 14px;
		display: none; visibility: visible; opacity: 1; pointer-events: auto;
		transition: none;
	}
	.cw-header-pill .cw-mega-nav .wp-block-navigation-item.cw-open > ul.wp-block-navigation__submenu-container { display: block !important; }
	.cw-mega-nav ul.wp-block-navigation__submenu-container > li { max-width: none; opacity: 1; transform: none; transition: none; }
	.cw-mega-nav ul.wp-block-navigation__submenu-container a::after { content: none; }
	.cw-mega-nav ul.wp-block-navigation__submenu-container > li.cw-menu-all { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
	/* core's overlay padding is clamp(1rem, var(--wp--style--root--padding-*), 20rem);
	   our theme.json defines no root padding, so the var is empty → the declaration is
	   dropped and the menu sits flush against the viewport edges. Put it back. */
	.wp-block-navigation__responsive-container.is-menu-open { padding-left: 22px !important; padding-right: 22px !important; padding-bottom: 40px !important; }
	.wp-block-navigation__responsive-container-close { top: 16px; right: 16px; }
	/* search open → ONE compact row: hide the mark, field shares the row with the X */
	body.cw-search-open .cw-logo-mark { display: none; }
	body.cw-search-open .cw-pill-search { flex: 1 1 0; margin-inline: 0; }
}
@media (max-width: 600px) {
	.cw-header-pill { border-radius: 26px; flex-wrap: wrap; }
	body.cw-search-open .cw-header-pill { border-radius: 26px 26px 0 0; }
	body.cw-search-open .cw-header-pill::before { border-radius: 26px; }
	.cw-search-big input[type="search"] { font-size: 1rem; padding: 12px 18px; }
	.cw-search-inner { padding: 24px 20px 36px; }
}
