/* ─── Site Header ────────────────────────────────────────────────────────── */

.cpm-header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: var(--cpm-color-white);
	box-shadow: 0 1px 0 var(--cpm-color-border);
}

.cpm-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 2rem;
	height: 80px;
}

/* ─── Logo ───────────────────────────────────────────────────────────────── */

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

.cpm-header__logo-link {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
}

.cpm-header__logo-link img {
	height: 68px;
	width: auto;
	display: block;
}

.cpm-header__logo--text {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--cpm-color-dark);
}

/* ─── Primary navigation ─────────────────────────────────────────────────── */

.cpm-header__nav-desktop {
	flex: 1;
	display: flex;
	justify-content: center;
}

.cpm-header__nav {
	display: none;
}

.cpm-header__menu {
	display: flex;
	align-items: center;
	gap: clamp(1rem, 2.5vw, 2.25rem);
	list-style: none;
	margin: 0;
	padding: 0;
}

.cpm-header__menu > li {
	position: relative;
}

/* Top-level links */
.cpm-header__menu > li > a {
	display: flex;
	align-items: center;
	gap: .3rem;
	padding: .625rem 0;
	font-family: 'Montserrat', sans-serif;
	font-size: 16px;
	font-weight: 600;
	font-style: normal;
	line-height: 20px;
	text-transform: uppercase;
	letter-spacing: .03em;
	color: var(--cpm-color-dark);
	text-decoration: none;
	position: relative;
	white-space: nowrap;
	transition: color var(--cpm-transition);
}

/* Active underline indicator */
.cpm-header__menu > li > a::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 1px;
	background: var(--cpm-color-red);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--cpm-transition);
}

.cpm-header__menu > li > a:hover,
.cpm-header__menu > li:hover > a,
.cpm-header__menu > li:focus-within > a,
.cpm-header__menu > li.current-menu-item > a,
.cpm-header__menu > li.current_page_item > a,
.cpm-header__menu > li.current-menu-ancestor > a,
.cpm-header__menu > li.current-page-ancestor > a {
	color: var(--cpm-color-red);
}

.cpm-header__menu > li > a:hover::after,
.cpm-header__menu > li:hover > a::after,
.cpm-header__menu > li:focus-within > a::after,
.cpm-header__menu > li.current-menu-item > a::after,
.cpm-header__menu > li.current_page_item > a::after,
.cpm-header__menu > li.current-menu-ancestor > a::after,
.cpm-header__menu > li.current-page-ancestor > a::after {
	transform: scaleX(1);
}

.cpm-submenu-toggle {
	display: none;
}

/* Dropdown chevron on items that have children */
.cpm-header__menu > li.menu-item-has-children > a::before {
	content: '';
	display: inline-block;
	width: .4em;
	height: .4em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-.15em);
	margin-left: .15em;
	flex-shrink: 0;
	order: 2;
	transition: transform 0.3s ease;
}

/* ─── Dropdown sub-menus ─────────────────────────────────────────────────── */

.cpm-header__menu .sub-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 260px;
	background: #ffffff;
	border-radius: 0;
	box-shadow: none;
	list-style: none;
	padding: .5rem 0;
	margin: 0;
	z-index: 200;
}

.cpm-header__menu > li:hover > .sub-menu,
.cpm-header__menu > li:focus-within > .sub-menu {
	display: block;
}


.cpm-header__menu .sub-menu a {
	display: block;
	padding: .75rem 1.5rem;
	font-family: 'Montserrat', sans-serif;
	font-size: 15px;
	font-weight: 700;
	color: var(--cpm-color-dark);
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.2s ease, color 0.2s ease;
}

#primary-menu-desktop .sub-menu a:hover,
#primary-menu-desktop .sub-menu a:focus,
#primary-menu-desktop .sub-menu a.is-hovered,
#primary-menu-desktop .sub-menu li.current-menu-item > a,
#primary-menu-desktop .sub-menu li.current_page_item > a,
.cpm-header__menu .sub-menu a:hover,
.cpm-header__menu .sub-menu a:focus,
.cpm-header__menu .sub-menu a.is-hovered,
.cpm-header__menu .sub-menu li.current-menu-item > a,
.cpm-header__menu .sub-menu li.current_page_item > a {
	background: rgb(30, 30, 30) !important;
	color: #ffffff !important;
}

/* ─── Header CTA button ──────────────────────────────────────────────────── */

.cpm-header__cta {
	flex-shrink: 0;
	padding: .625rem 1.5rem;
	font-family: 'Montserrat', sans-serif;
	font-size: 16px;
	font-weight: 600;
	line-height: 20px;
	border-radius: var(--cpm-radius-md);
	position: relative;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.cpm-header__cta::before {
	content: '';
	position: absolute;
	inset: 0;
	background: #cc0000;
	transform: translateX(-100%);
	transition: transform 0.35s ease;
	z-index: 0;
}

.cpm-header__cta:hover::before,
.cpm-header__cta:focus-visible::before {
	transform: translateX(0);
}

.cpm-header__cta-inner {
	position: relative;
	z-index: 1;
	display: inline-block;
	font-size: 0;
	overflow: hidden;
	height: 20px;
	white-space: nowrap;
}

.cpm-header__cta-inner::before,
.cpm-header__cta-inner::after {
	display: block;
	font-family: 'Montserrat', sans-serif;
	font-size: 16px;
	font-weight: 600;
	line-height: 20px;
	color: #ffffff;
	transition: transform 0.35s ease;
	white-space: nowrap;
	content: attr(data-text);
}

.cpm-header__cta-inner::before {
	transform: translateX(0);
}

.cpm-header__cta-inner::after {
	position: absolute;
	top: 0;
	left: 0;
	transform: translateX(-100%);
}

.cpm-header__cta:hover .cpm-header__cta-inner::before,
.cpm-header__cta:focus-visible .cpm-header__cta-inner::before {
	transform: translateX(100%);
}

.cpm-header__cta:hover .cpm-header__cta-inner::after,
.cpm-header__cta:focus-visible .cpm-header__cta-inner::after {
	transform: translateX(0);
}

/* ─── Mobile phone icon ──────────────────────────────────────────────────── */

.cpm-header__phone-icon {
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 1.5px solid rgb(30, 30, 30);
	border-radius: 8px;
	color: rgb(30, 30, 30);
	text-decoration: none;
	flex-shrink: 0;
	transition: color var(--cpm-transition), border-color var(--cpm-transition);
}

.cpm-header__phone-icon:hover {
	color: var(--cpm-color-red);
	border-color: var(--cpm-color-red);
}

.cpm-header__phone-icon svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* ─── Mobile toggle ──────────────────────────────────────────────────────── */

.cpm-header__toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	background: none;
	border: none;
	cursor: pointer;
	padding: .5rem;
	flex-shrink: 0;
	width: 40px;
	height: 40px;
}

.cpm-header__toggle span {
	display: block;
	width: 22px;
	height: 2px;
	background: var(--cpm-color-dark);
	border-radius: 2px;
	transition: transform var(--cpm-transition), opacity var(--cpm-transition);
}

.cpm-header__toggle[aria-expanded="true"] span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}
.cpm-header__toggle[aria-expanded="true"] span:nth-child(2) {
	opacity: 0;
}
.cpm-header__toggle[aria-expanded="true"] span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
	.cpm-header__toggle {
		display: flex;
	}

	/* Hide desktop nav */
	.cpm-header__nav-desktop {
		display: none;
	}

	/* Full-screen overlay nav — outside header, no stacking context issue */
	.cpm-header__nav {
		position: fixed;
		inset: 0;
		background: #ffffff;
		z-index: 9999;
		flex-direction: column;
		padding: 0;
		overflow-y: auto;
		/* Animation: slide in from right */
		display: flex;
		opacity: 0;
		transform: translateX(100%);
		transition: opacity 0.35s ease, transform 0.35s ease;
		pointer-events: none;
		visibility: hidden;
	}

	.cpm-header__nav.is-open {
		opacity: 1;
		transform: translateX(0);
		pointer-events: auto;
		visibility: visible;
	}

	/* Nav top bar — logo + close btn */
	.cpm-header__nav-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20px;
		height: 80px;
		flex-shrink: 0;
	}

	.cpm-header__nav-logo img {
		height: 56px;
		width: auto;
		display: block;
	}

	.cpm-header__nav-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		background: var(--cpm-color-red);
		border: none;
		border-radius: 8px;
		cursor: pointer;
		color: #ffffff;
		font-size: 1.5rem;
		line-height: 1;
		flex-shrink: 0;
	}

	/* Menu list */
	.cpm-header__menu {
		flex-direction: column;
		align-items: flex-start;
		gap: 0;
		padding: 0;
		width: 100%;
	}

	.cpm-header__menu > li {
		width: 100%;
	}

	.cpm-header__menu > li > a {
		display: flex;
		align-items: center;
		padding: .75rem 20px;
		font-size: 16px;
		font-weight: 600;
		letter-spacing: .01em;
		color: rgb(30, 30, 30);
		border-bottom: none;
		width: 100%;
	}

	/* Underline indicator — hide on mobile */
	.cpm-header__menu > li > a::after {
		display: none;
	}

	/* Hide desktop ::before chevron on mobile — real toggle btn used instead */
	.cpm-header__menu > li.menu-item-has-children > a::before {
		display: none;
	}

	/* Parent li needs position relative for absolute toggle btn */
	.cpm-header__menu > li.menu-item-has-children {
		position: relative;
	}

	/* Give room on right for the toggle button */
	.cpm-header__menu > li.menu-item-has-children > a {
		padding-right: 52px !important;
	}

	/* Toggle button: absolute, right side, same height as the <a> row */
	.cpm-submenu-toggle {
		display: flex !important;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		right: 0;
		width: 52px;
		height: 48px;
		background: transparent !important;
		background-color: transparent !important;
		box-shadow: none !important;
		border: none !important;
		border-left: 1px solid rgba(0,0,0,.1) !important;
		cursor: pointer;
		padding: 0 !important;
		border-radius: 0 !important;
		color: rgb(30, 30, 30);
	}

	.cpm-submenu-toggle span {
		display: block;
		width: 8px;
		height: 8px;
		border-right: 2px solid currentColor;
		border-bottom: 2px solid currentColor;
		transform: rotate(45deg) translateY(-2px);
		transition: transform 0.3s ease;
		flex-shrink: 0;
	}

	.cpm-header__menu > li.is-open > .cpm-submenu-toggle {
		color: var(--cpm-color-red);
	}

	.cpm-header__menu > li.is-open > .cpm-submenu-toggle span {
		transform: rotate(-135deg) translateY(2px);
	}

	.cpm-header__menu > li.current-menu-ancestor > .cpm-submenu-toggle,
	.cpm-header__menu > li.current-menu-item > .cpm-submenu-toggle {
		color: #ffffff;
		border-left-color: rgba(255,255,255,.3) !important;
	}

	/* Hide GeneratePress back-to-top when mobile nav is open */
	body.nav-is-open #generate-back-to-top,
	body.nav-is-open .generate-back-to-top,
	body.nav-is-open [id*="back-to-top"],
	body.nav-is-open [class*="back-to-top"] {
		display: none !important;
	}

	/* Active item — full-width red bg */
	.cpm-header__menu > li.current-menu-item > a,
	.cpm-header__menu > li.current_page_item > a,
	.cpm-header__menu > li.current-menu-ancestor > a,
	.cpm-header__menu > li.current-page-ancestor > a {
		background: var(--cpm-color-red);
		color: #ffffff;
	}

	.cpm-header__menu > li > a:hover {
		color: var(--cpm-color-red);
		background: transparent;
	}

	.cpm-header__menu > li.current-menu-item > a:hover,
	.cpm-header__menu > li.current_page_item > a:hover {
		color: #ffffff;
	}

	/* Sub-menu */
	.cpm-header__menu .sub-menu {
		position: static;
		box-shadow: none;
		border: none;
		border-radius: 0;
		padding: 0 0 0 1.25rem;
		background: transparent;
	}

	.cpm-header__menu li.menu-item-has-children .sub-menu {
		display: none;
	}

	.cpm-header__menu li.menu-item-has-children.is-open .sub-menu {
		display: block;
	}

	/* Mobile sub-menu item hover/active = red */
	.cpm-header__menu .sub-menu a:hover,
	.cpm-header__menu .sub-menu li.current-menu-item > a,
	.cpm-header__menu .sub-menu li.current_page_item > a {
		color: var(--cpm-color-red) !important;
		background: transparent !important;
	}

	.cpm-header__cta {
		display: none;
	}

	.cpm-header__phone-icon {
		display: flex;
	}

}

@media (max-width: 375px) {
	.cpm-header__inner {
		gap: 1rem;
	}
	.cpm-header__logo-link img {
		height: 44px;
	}
}
