/**
 * Header navigation — centred desktop row, burger below 1180px.
 *
 * Loaded after style.css and the plugin/Elementor stylesheets, see
 * dido_header_nav_assets() in functions.php. Selectors are deliberately as
 * specific as the rules they replace in style.css, so order alone is never
 * what decides a tie.
 *
 * @package dido
 */

/* ------------------------------------------------------------------ *
 * Shared
 * ------------------------------------------------------------------ */

.header-inner.wrap-second {
	position: relative;
	z-index: 99;
}

/* The CTA sits directly in .header-inner now, so re-state the two rules that
   used to reach it through .header-col--right. */
.header-inner.wrap-second > form {
	margin: 0;
}

/* Injected by header-nav.js; only used by the burger panel. */
.header__nav.b-nav ul#primary-menu > li > .nav-toggle {
	display: none;
}

.header-inner.wrap-second > form button.header__but.but.but--arrow.but-xs {
	width: auto;
	flex: 0 0 auto;
	padding: 17px 25px 17px;
	white-space: nowrap;
}

/* ------------------------------------------------------------------ *
 * Desktop: logo | centred nav | CTA
 * ------------------------------------------------------------------ */

@media (min-width: 1181px) {

	.header-inner.wrap-second {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		gap: 20px;
	}

	/* Equal, zero-basis side columns put the nav on the page centre line
	   regardless of how wide the logo and the CTA happen to be. */
	.header-inner.wrap-second > .header-col--left,
	.header-inner.wrap-second > form {
		flex: 1 1 0;
		min-width: 0;
	}

	.header-inner.wrap-second > .header-col--left {
		display: flex;
		align-items: center;
	}

	.header-inner.wrap-second > form {
		display: flex;
		justify-content: flex-end;
	}

	.header-inner.wrap-second > .header-col--right {
		flex: 0 1 auto;
		width: auto;
		min-width: 0;
		justify-content: center;
	}

	.header-col--right .header__burger {
		display: none;
	}

	/* style.css reserved 60px of padding here and a 10–30px right margin on
	   the nav; both would push a centred row off centre. */
	.header-inner.wrap-second .header__nav-wrap {
		width: 100%;
		padding-right: 0;
		margin-left: 0;
	}

	.header-inner.wrap-second .header__nav.b-nav {
		width: 100%;
		margin-right: 0;
	}

	/* One row that never wraps. Spacing moves to `gap` so the per-breakpoint
	   margin-left/margin-right overrides in style.css stop fighting it. */
	.header__nav.b-nav ul#primary-menu {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: center;
		gap: clamp(14px, 1.5vw, 28px);
		margin: 0;
		padding: 0;
	}

	.header__nav.b-nav ul#primary-menu > li {
		flex: 0 0 auto;
		width: auto;
		margin: 0 !important;
		padding: 30px 0;
		white-space: nowrap;
	}

	.header__nav.b-nav ul#primary-menu > li > a {
		font-size: clamp(15px, 1.15vw, 19px);
	}

	/* The dropdown chevron used to hang outside the item box (right: -19px),
	   so its width was never counted when the row was measured. */
	.header__nav.b-nav ul#primary-menu > li.menu-item-has-children {
		padding-right: 18px;
	}

	.header__nav.b-nav ul#primary-menu > li.menu-item-has-children:after {
		right: 0;
	}

	/* Keep the last dropdowns inside the wrapper now the row is centred. */
	.header__nav.b-nav ul#primary-menu > li:nth-last-child(-n+2) > .sub-menu {
		left: auto;
		right: 0;
	}
}

/* ------------------------------------------------------------------ *
 * Tablet and phone: burger + full-width panel
 *
 * style.css only switched to the burger below 880px, which left 881–1160px
 * with a full nav row and no CTA at all. This block owns everything from
 * 1180px down and replaces the absolute-positioning used below 880px.
 * ------------------------------------------------------------------ */

@media (max-width: 1180px) {

	/* A `.header-inner { min-height: auto }` rule in the site's inline CSS beats
	   the theme's own 128px/80px rules, so the bar was only as tall as the CTA.
	   Reach past it with the wrapper in the selector. */
	.header-fixed-mob .header-inner.wrap-second {
		min-height: 72px;
		padding-top: 10px;
		padding-bottom: 10px;
	}

	.header-inner.wrap-second {
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
		width: 100%;
		float: none;
	}

	.header-inner.wrap-second > .header-col--left {
		flex: 1 1 auto;
		width: auto;
		min-width: 0;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		gap: 12px;
	}

	.header-inner.wrap-second > .header-col--right {
		position: static;
		float: none;
		flex: 0 0 auto;
		width: auto;
		top: auto;
		right: auto;
		margin-right: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		gap: 14px;
	}

	.header-inner a.custom-logo-link img {
		max-width: 170px;
	}

	/* Burger */
	.header-col--right .header__burger {
		position: static;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		width: 28px;
		height: 20px;
		top: auto;
		right: auto;
		flex: 0 0 auto;
		cursor: pointer;
	}

	.header-col--right .header__burger .header__burger-item {
		width: 100%;
		height: 3px;
		min-height: 3px;
		margin: 0;
		border-radius: 8px;
		background-color: #1f263b;
		transition: transform 0.2s ease-out;
	}

	.header-inner.wrap-second.highlight .header-col.header-col--right .header__burger.js-burger .header__burger-item:first-child {
		position: static;
		transform: translateY(8.5px) rotate(45deg);
	}

	.header-inner.wrap-second.highlight .header-col.header-col--right .header__burger.js-burger .header__burger-item:last-child {
		position: static;
		top: auto;
		transform: translateY(-8.5px) rotate(-45deg);
	}

	/* Panel */
	.header-inner.wrap-second .header__nav-wrap {
		display: none;
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		width: auto;
		padding: 6px 0 20px;
		margin: 0;
		background: #fff;
		border-top: 1px solid #e3e6ef;
		box-shadow: 0 18px 40px rgba(31, 38, 59, 0.12);
		max-height: calc(100vh - 80px);
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
	}

	.header-inner.wrap-second.highlight .header__nav-wrap {
		display: block;
	}

	.header__nav-wrap nav.header__nav.b-nav {
		display: block;
		position: static;
		width: 100%;
		min-width: 0;
		left: auto;
		top: auto;
		padding: 0;
		margin: 0;
		background: transparent;
	}

	.header__nav.b-nav ul#primary-menu {
		display: block;
		width: 100%;
		margin: 0;
		padding: 0;
	}

	.header__nav.b-nav ul#primary-menu > li {
		position: relative;
		width: 100%;
		margin: 0 !important;
		padding: 0;
		border-bottom: 1px solid #eef0f6;
	}

	.header__nav.b-nav ul#primary-menu > li:last-child {
		border-bottom: none;
	}

	.header__nav.b-nav ul#primary-menu > li > a,
	.header__nav.b-nav ul#primary-menu > li.menu-item-has-children > a {
		display: flex;
		align-items: center;
		min-height: 52px;
		max-width: none;
		padding: 0 62px 0 20px;
		font-size: 17px;
		font-weight: 600;
	}

	/* Tap target for opening a group, so the parent link stays a link. */
	.header__nav.b-nav ul#primary-menu > li > .nav-toggle {
		position: absolute;
		top: 0;
		right: 0;
		width: 56px;
		height: 52px;
		border: 0;
		padding: 0;
		background: transparent;
		cursor: pointer;
		z-index: 2;
	}

	.header__nav.b-nav ul#primary-menu > li.menu-item-has-children:after {
		right: 24px;
		top: 22px;
		margin: 0;
		pointer-events: none;
	}

	.header__nav.b-nav ul#primary-menu > li.menu-item-has-children.is-open:after {
		transform: rotate(180deg);
	}

	/* Sub-menus become accordions. The theme opened them on :hover, which on a
	   touch screen fires with the same tap that follows the parent link. */
	.header__nav.b-nav ul#primary-menu > li > .sub-menu,
	.header__nav.b-nav ul#primary-menu > li:hover > .sub-menu {
		display: none;
		position: static;
		top: auto;
		left: auto;
		width: 100%;
		visibility: visible;
		opacity: 1;
		overflow: visible;
		border-radius: 0;
		box-shadow: none;
		transition: none;
		background: #f7f8fc;
		padding: 4px 0 8px;
	}

	.header__nav.b-nav ul#primary-menu > li.is-open > .sub-menu,
	.header__nav.b-nav ul#primary-menu > li.is-open:hover > .sub-menu {
		display: block;
	}

	.header__nav.b-nav ul#primary-menu > li > .sub-menu li {
		width: 100%;
		margin: 0;
		padding: 0;
		background: transparent;
	}

	.header__nav.b-nav ul#primary-menu > li > .sub-menu li a {
		display: flex;
		align-items: center;
		min-height: 44px;
		padding: 0 20px 0 34px;
		font-size: 16px;
	}

	/* Book a Call stays available on tablets; style.css dropped it at 1160px. */
	.header-inner.wrap-second > form {
		display: flex;
	}
}

/* ------------------------------------------------------------------ *
 * Phone: the compact Free Audit pill replaces Book a Call
 * ------------------------------------------------------------------ */

@media (max-width: 880px) {

	.header-inner.wrap-second > form {
		display: none;
	}

	.header-inner .only-mobile {
		display: block !important;
		margin-left: 0;
	}

	.header-inner.wrap-second a.header__but.but {
		padding: 7px 14px;
		max-width: 122px;
		min-width: 100px;
		font-size: 14px;
		font-weight: 600;
		color: #fff;
	}
}

@media (max-width: 420px) {

	.header-inner a.custom-logo-link img {
		max-width: 132px;
	}

	.header-inner.wrap-second a.header__but.but {
		padding: 7px 10px;
		font-size: 13px;
		min-width: 0;
	}

	.header-inner.wrap-second > .header-col--left {
		gap: 8px;
	}
}
