/* ============================================================
   Site-wide header (Solar Air Energy) — clean /intro aesthetic.
   Rendered by template-parts/header/header-wrapper.php (child override),
   inside Flatsome's #header wrapper. Uses --ds-* tokens from
   dynamic-sections.css (loaded globally before this file).

   Desktop (>1024px): horizontal nav, Solar hover dropdown, no hamburger.
   Mobile  (<=1024px): nav collapses behind a hamburger (CSS checkbox toggle).
   ============================================================ */

/* Neutralise Flatsome's native header chrome so our markup controls the look. */
#header .header-wrapper { background: transparent; box-shadow: none; }
#header .header-bg-container { display: none; }
#header { background: transparent; }

.sae-header {
	font-family: var(--ds-font-body);
	/* Stick the whole header (its parent is the tall page body, so it holds the full scroll —
	   sticking the inner .sae-main alone fails because its parent is only header-height). */
	position: sticky;
	top: 0;
	z-index: 1000;
}

/* ---------- Announcement bar ---------- */
.sae-topbar {
	background: var(--ds-ink);
	color: #ffffff;
}
.sae-topbar__inner {
	max-width: var(--ds-container);
	margin-inline: auto;
	padding: 7px var(--ds-edge);
	display: flex;
	justify-content: flex-end;
	box-sizing: border-box;
}
.sae-topbar__menu {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 22px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.sae-topbar__menu li { margin: 0; }
.sae-topbar__menu a {
	color: rgba(255, 255, 255, 0.82);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	letter-spacing: 0.01em;
	transition: color 0.18s ease;
}
.sae-topbar__menu a:hover { color: var(--ds-gold); }

/* ---------- Main row ---------- */
.sae-main {
	background: #ffffff;
	box-shadow: 0 1px 0 rgba(21, 28, 36, 0.08), 0 6px 18px rgba(21, 28, 36, 0.06);
}
.sae-main__inner {
	max-width: var(--ds-container);
	margin-inline: auto;
	padding: 12px var(--ds-edge);
	display: flex;
	align-items: center;
	gap: 28px;
	box-sizing: border-box;
}

/* ---------- Logo ---------- */
.sae-logo { flex: 0 0 auto; display: flex; }
.sae-logo a { display: inline-flex; align-items: center; }
.sae-logo__img { display: block; height: 48px; width: auto; }
.sae-logo__img--mobile { display: none; }
.sae-logo__text { font-weight: 800; color: var(--ds-ink); font-size: 20px; }

/* ---------- Primary nav (desktop) ---------- */
.sae-nav { margin-inline-start: auto; }
.sae-nav__menu {
	display: flex;
	align-items: center;
	gap: 30px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.sae-nav__menu > li { position: relative; }
.sae-nav__menu > li > a {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--ds-ink);
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	padding: 8px 0;
	white-space: nowrap;
	transition: color 0.18s ease;
}
.sae-nav__menu > li > a:hover,
.sae-nav__menu > li.current-menu-item > a { color: var(--ds-orange); }

/* Caret on parent items */
.sae-nav__menu > li.menu-item-has-children > a::after {
	content: "";
	width: 7px; height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translateY(-2px);
	transition: transform 0.18s ease;
	opacity: 0.7;
}
.sae-nav__menu > li.menu-item-has-children:hover > a::after { transform: rotate(225deg) translateY(2px); }

/* ---------- Dropdowns (main nav + top bar) — clean vertical ---------- */
.sae-nav__menu .sub-menu,
.sae-topbar__menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 220px;
	margin: 0;
	padding: 10px;
	list-style: none;
	background: #ffffff;
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-card), 0 18px 40px rgba(21, 28, 36, 0.14);
	display: flex;
	flex-direction: column;
	gap: 2px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.18s ease, transform 0.2s ease, visibility 0.2s;
	z-index: 1200;
}
/* Hover bridge so the cursor can travel to the panel */
.sae-nav__menu > li.menu-item-has-children::after,
.sae-topbar__menu > li.menu-item-has-children::after {
	content: "";
	position: absolute;
	left: 0; right: 0; top: 100%;
	height: 12px;
}
.sae-nav__menu > li.menu-item-has-children:hover > .sub-menu,
.sae-nav__menu > li.menu-item-has-children:focus-within > .sub-menu,
.sae-topbar__menu > li.menu-item-has-children:hover > .sub-menu,
.sae-topbar__menu > li.menu-item-has-children:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}
.sae-nav__menu .sub-menu li,
.sae-topbar__menu .sub-menu li { margin: 0; }
.sae-nav__menu .sub-menu a,
.sae-topbar__menu .sub-menu a {
	display: block;
	padding: 9px 14px;
	border-radius: 10px;
	font-family: var(--ds-font-body);
	font-size: 14.5px;
	font-weight: 600;
	color: var(--ds-ink);
	text-decoration: none;
	white-space: nowrap;
	letter-spacing: 0;
	text-transform: none;
	transition: background 0.15s ease, color 0.15s ease;
}
.sae-nav__menu .sub-menu a:hover,
.sae-topbar__menu .sub-menu a:hover { background: var(--ds-green-tint); color: var(--ds-green-ink); }

/* Top-bar dropdown parents need a positioning context + a small caret */
.sae-topbar__menu > li { position: relative; }
.sae-topbar__menu > li.menu-item-has-children > a::after {
	content: "";
	display: inline-block;
	width: 5px; height: 5px;
	margin-left: 6px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: rotate(45deg) translateY(-1px);
	opacity: 0.7;
}
.sae-topbar__menu .sub-menu a { color: var(--ds-ink); }

/* ---------- Right actions (phone + Free Quote) ---------- */
.sae-actions {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 18px;
}
.sae-phone {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: var(--ds-ink);
}
.sae-phone__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px; height: 38px;
	border-radius: 50%;
	background: rgba(239, 130, 0, 0.12);
	color: var(--ds-orange);
	flex: none;
}
.sae-phone__text { display: flex; flex-direction: column; line-height: 1.1; }
.sae-phone__label { font-size: 11.5px; font-weight: 500; color: var(--ds-grey-light); }
.sae-phone__number { font-size: 17px; font-weight: 800; color: var(--ds-ink); letter-spacing: 0.2px; }
.sae-phone:hover .sae-phone__number { color: var(--ds-orange); }

.sae-quote { font-size: 14px; }

/* ---------- Hamburger (mobile only) ---------- */
.sae-burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 44px; height: 44px;
	padding: 10px;
	box-sizing: border-box;
	cursor: pointer;
	border-radius: 10px;
	-webkit-appearance: none;
	appearance: none;
	background: transparent;
	border: 0;
}
.sae-burger span {
	display: block;
	height: 2px;
	width: 100%;
	background: var(--ds-ink);
	border-radius: 2px;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Focus visibility */
.sae-phone:focus-visible,
.sae-nav__menu a:focus-visible,
.sae-topbar__menu a:focus-visible,
.sae-quote:focus-visible,
.sae-burger:focus-visible {
	outline: var(--ds-focus);
	outline-offset: 2px;
	border-radius: 8px;
}

/* ============================================================
   Responsive — collapse to hamburger at <=1024px
   The inline desktop nav is hidden; the JS slide-in drawer
   (.sae-drawer, see assets/js/site-header.js) takes over.
   ============================================================ */
@media screen and (max-width: 1024px) {
	.sae-burger { display: flex; }
	.sae-nav { display: none; }
	/* Top bar's hover dropdowns don't work on touch — its items live in the drawer below this. */
	.sae-topbar { display: none; }
	/* The inline "Get my free quote" CTA overflows on mobile — it lives in the drawer + hero form instead. */
	.sae-quote { display: none; }
	/* .sae-nav's right-push is display:none here, so push the actions (phone + burger) hard-right ourselves. */
	.sae-actions { margin-inline-start: auto; }
	.sae-main__inner { gap: 14px; }
}

/* Phones: keep a compact tap-to-call icon, drop the number text so the header never overflows. */
@media screen and (max-width: 640px) {
	.sae-phone__text { display: none; }
	.sae-phone { gap: 0; }
}

/* ============================================================
   Mobile slide-in drawer
   ============================================================ */
.sae-drawer-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(21, 28, 36, 0.5);
	opacity: 0;
	transition: opacity 0.28s ease;
	z-index: 1090;
}
body.sae-drawer-open .sae-drawer-backdrop { opacity: 1; }

.sae-drawer {
	position: fixed;
	top: 0; right: 0; bottom: 0;
	width: min(86vw, 360px);
	background: #ffffff;
	box-shadow: -12px 0 40px rgba(21, 28, 36, 0.18);
	z-index: 1100;
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	visibility: hidden;
}
body.sae-drawer-open .sae-drawer,
.sae-drawer[aria-hidden="false"] { visibility: visible; }
body.sae-drawer-open .sae-drawer { transform: translateX(0); }

/* Lock the page behind the drawer */
body.sae-drawer-open { overflow: hidden; }

.sae-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px var(--ds-edge);
	border-bottom: 1px solid rgba(21, 28, 36, 0.08);
	position: sticky;
	top: 0;
	background: #ffffff;
}
.sae-drawer__logo img { display: block; height: 34px; width: auto; max-width: 200px; }
.sae-drawer__close {
	-webkit-appearance: none; appearance: none;
	background: transparent; border: 0; cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; margin-right: -10px;
	border-radius: 10px; color: var(--ds-ink);
}
.sae-drawer__close:hover { background: rgba(21, 28, 36, 0.05); }

.sae-drawer__body { padding: 8px var(--ds-edge) 28px; }

.sae-drawer__menu,
.sae-drawer__secondary-menu { list-style: none; margin: 0; padding: 0; }
.sae-drawer__menu li { margin: 0; }
.sae-drawer__menu > li { border-bottom: 1px solid rgba(21, 28, 36, 0.07); }

/* Parent row = link (flex-grow) + caret toggle button on one line */
.sae-drawer__menu li.menu-item-has-children {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}
.sae-drawer__menu > li > a {
	display: block;
	flex: 1 1 auto;
	padding: 15px 0;
	font-size: 17px;
	font-weight: 700;              /* primary services carry more weight than the secondary menu */
	color: var(--ds-ink);
	text-decoration: none;
}
.sae-drawer__menu a:hover { color: var(--ds-orange); }

.sae-drawer__toggle {
	-webkit-appearance: none; appearance: none;
	background: transparent; border: 0; cursor: pointer;
	flex: 0 0 auto;
	width: 44px; height: 44px;
	display: inline-flex; align-items: center; justify-content: center;
	color: var(--ds-grey-light);
}
.sae-drawer__caret {
	width: 9px; height: 9px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	transition: transform 0.2s ease;
}
.sae-drawer__menu li.is-open > .sae-drawer__toggle .sae-drawer__caret {
	transform: rotate(-135deg) translate(-1px, -1px);
}

/* Sub-menus: stacked + indented, collapsed until expanded (JS sets [hidden]) */
.sae-drawer__menu .sub-menu {
	list-style: none;
	margin: 0;
	padding: 0 0 10px 14px;
	flex: 1 1 100%;
	width: 100%;
}
.sae-drawer__menu .sub-menu a {
	display: block;
	padding: 10px 0;
	font-size: 14.5px;
	font-weight: 500;
	color: var(--ds-ink);
	text-decoration: none;
}
.sae-drawer__menu .menu-image { display: none !important; }
/* Some leaf links use Flatsome's image-title-below markup (image + centered title span).
   In the drawer they are plain text links — force left alignment on both the anchor and
   its inner .menu-image-title span to match the rest. */
.sae-drawer__menu a.menu-image-title-below,
.sae-drawer__menu .sub-menu a { display: block; text-align: left; }
.sae-drawer__menu .menu-image-title { display: block; text-align: left; margin: 0; padding: 0; width: auto; }
/* The Solar/AC/Electrical sub-menus are flat leaf links (Solar, Residential Solar, …) — they must stay
   clickable, styled by the .sae-drawer__menu .sub-menu a rule above. (Previously a stale 2-level "group
   heading" override applied pointer-events:none + uppercase, which made these real links non-clickable.) */

.sae-drawer__divider { height: 1px; background: rgba(21, 28, 36, 0.08); margin: 10px 0; }

.sae-drawer__secondary-menu a {
	display: block;
	padding: 10px 0;
	font-size: 14px;
	font-weight: 500;
	color: var(--ds-grey-light);
	text-decoration: none;
}
.sae-drawer__secondary-menu a:hover { color: var(--ds-orange); }

.sae-drawer__cta { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.sae-drawer__phone {
	display: inline-flex; align-items: center; gap: 10px;
	font-size: 18px; font-weight: 800; color: var(--ds-ink); text-decoration: none;
}
.sae-drawer__phone:hover { color: var(--ds-orange); }
.sae-drawer__quote { display: block; text-align: center; }

/* Burger -> X while the drawer is open */
body.sae-drawer-open .sae-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sae-drawer-open .sae-burger span:nth-child(2) { opacity: 0; }
body.sae-drawer-open .sae-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sae-drawer__close:focus-visible,
.sae-drawer__toggle:focus-visible,
.sae-drawer a:focus-visible {
	outline: var(--ds-focus);
	outline-offset: 2px;
	border-radius: 8px;
}

@media screen and (max-width: 640px) {
	.sae-logo__img--desktop { display: none; }
	.sae-logo__img--mobile { display: block; height: 40px; }
	.sae-phone__label { display: none; }
	.sae-phone__text { display: none; }
	.sae-quote { padding: 10px 16px; }
}

/* ============================================================
   Drawer polish — scrolling body + pinned footer CTA, and the
   secondary menu (Learn / Earn / Service Areas / About / Contact)
   as accordions matching the primary menu.
   ============================================================ */
.sae-drawer { overflow: hidden; }               /* body scrolls, head + foot pin */
.sae-drawer__head { flex: 0 0 auto; }
.sae-drawer__body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Secondary menu = same accordion treatment as the primary menu */
.sae-drawer__secondary-menu { list-style: none; margin: 0; padding: 0; }
.sae-drawer__secondary-menu > li { border-bottom: 1px solid rgba(21, 28, 36, 0.07); }
.sae-drawer__secondary-menu li.menu-item-has-children { display: flex; flex-wrap: wrap; align-items: center; }
.sae-drawer__secondary-menu > li > a {
	display: block; flex: 1 1 auto;
	padding: 13px 0; font-size: 15px; font-weight: 500;   /* lighter/smaller than the primary services */
	color: var(--ds-grey); text-decoration: none;
}
.sae-drawer__secondary-menu > li > a:hover { color: var(--ds-orange); }
.sae-drawer__secondary-menu li.is-open > .sae-drawer__toggle .sae-drawer__caret { transform: rotate(-135deg) translate(-1px, -1px); }
.sae-drawer__secondary-menu .sub-menu { list-style: none; margin: 0; padding: 0 0 10px 14px; flex: 1 1 100%; width: 100%; }
.sae-drawer__secondary-menu .sub-menu a { display: block; padding: 10px 0; font-size: 14.5px; font-weight: 500; color: var(--ds-ink); text-decoration: none; }
.sae-drawer__secondary-menu .sub-menu a:hover { color: var(--ds-orange); }
/* the "#" section parents (Learn/Earn/Service Areas) don't navigate — the caret expands them */
.sae-drawer__secondary-menu > li.menu-item-has-children > a[href="#"],
.sae-drawer__secondary-menu > li.menu-item-has-children > a:not([href]) { pointer-events: none; }

/* Pinned footer CTA */
.sae-drawer__foot {
	flex: 0 0 auto;
	display: flex; flex-direction: column; gap: 12px;
	padding: 16px var(--ds-edge) calc(16px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid var(--ds-line, #e6e9e7);
	background: #fff;
	box-shadow: 0 -8px 24px rgba(21, 28, 36, 0.06);
}
.sae-drawer__foot .sae-drawer__phone { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 17px; font-weight: 800; color: var(--ds-ink); text-decoration: none; }
.sae-drawer__foot .sae-drawer__phone:hover { color: var(--ds-orange); }
.sae-drawer__foot .sae-drawer__quote { display: block; width: 100%; text-align: center; }
