/*
 * Energin — Header.
 *
 * Everything here is breakpoint-independent. The custom properties this file
 * consumes (--eh-*) and the rules that pivot on a breakpoint are generated from
 * the Header Settings screen by energin_header_inline_css(), because a
 * breakpoint is an admin-set value and CSS cannot read a custom property from
 * inside a media query.
 */

/* ---------------------------------------------------------------
   Shell
   --------------------------------------------------------------- */

.energin-header {
	position: relative;
	z-index: 100;
	background: var(--eh-bg);
	color: var(--eh-text);
	font-family: var(--wp--preset--font-family--display, inherit);
}

.energin-header--sticky {
	position: sticky;
	top: 0;
}

.energin-header--edge-hairline {
	box-shadow: inset 0 -1px 0 0 var(--eh-border);
}

.energin-header--edge-soft {
	box-shadow: 0 2px 12px rgba(62, 75, 96, 0.08);
}

.energin-header--edge-none {
	box-shadow: none;
}

/* The bar matches the theme's constrained content width and gutter so the logo
   lines up with the first column of every section below it. */
.energin-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 32px;
	box-sizing: border-box;
	width: 100%;
	max-width: calc(var(--wp--style--global--content-size, 1280px) + (var(--wp--custom--gutter, 80px) * 2));
	margin-inline: auto;
	padding: var(--eh-pad-y, 10px) var(--wp--custom--gutter, 80px);
}

/* ---------------------------------------------------------------
   Logo
   --------------------------------------------------------------- */

.energin-header__logo {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	text-decoration: none;
	color: inherit;
}

.energin-header__logo-img {
	display: block;
	width: var(--eh-logo-w, 161px);
	height: auto;
}

.energin-header__logo--text {
	font-size: var(--wp--preset--font-size--large, 20px);
	font-weight: 700;
}

/* When an admin has supplied a separate mobile mark the swap is done by the
   <picture> element in the renderer, at this same 599px, so that only one of
   the two files is ever downloaded. */
.energin-header__logo picture {
	display: block;
}

/* ---------------------------------------------------------------
   Panel — the horizontal row on desktop, the drawer on small screens
   --------------------------------------------------------------- */

.energin-header__panel {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	flex: 1 1 auto;
	gap: 12px;
	min-width: 0;
}

.energin-header__panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	margin-bottom: 8px;
}

.energin-header__panel-title {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	opacity: 0.6;
}

.energin-header__close,
.energin-header__burger {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.energin-header__close:hover,
.energin-header__burger:hover {
	color: var(--eh-hover);
}

.energin-header__close .energin-icon,
.energin-header__burger .energin-icon {
	width: 22px;
	height: 22px;
}

/* One button, two glyphs: swapping them on the open state avoids a second
   control that would need its own focus management. */
.energin-header__burger .energin-icon--close,
.energin-header.is-open .energin-header__burger .energin-icon--menu {
	display: none;
}

.energin-header.is-open .energin-header__burger .energin-icon--close {
	display: block;
}

/* ---------------------------------------------------------------
   Menu
   --------------------------------------------------------------- */

.energin-menu,
.energin-menu__sub {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: var(--eh-gap, 32px);
	margin: 0;
	padding: 0;
	list-style: none;
}

.energin-menu__item {
	position: relative;
	margin: 0;
}

/* Flex only at the top level: it centres the label against its arrow
   directly, sidestepping the inline-baseline quirk that otherwise nudges an
   inline-flex icon a couple of pixels off the text's true centre. A submenu
   item stays plain inline flow — its link is a full-width block for the
   hover highlight, and turning the <li> into a flex row would shrink that
   back down to the text's own width. */
.energin-menu__item--depth-0 {
	display: inline-flex;
	align-items: center;
	flex-wrap: nowrap;
}

.energin-menu__link {
	display: inline-flex;
	align-items: center;
	color: inherit;
	font-size: var(--wp--preset--font-size--base, 16px);
	text-decoration: none;
	white-space: nowrap;
}

.energin-menu__link:hover,
.energin-menu__link:focus-visible,
.energin-menu__item.is-open > .energin-menu__link {
	color: var(--eh-hover);
}

/* aria-current is set on the current item for assistive tech, but deliberately
   left unstyled: the comps show every top-level label in the same navy, and a
   coloured current item would read as a hover state that will not clear. */

.energin-menu__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	margin-left: 6px;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.energin-menu__sub .energin-menu__toggle {
	margin-left: 0;
}

/* Dropdown panel — 220px wide with a 20px radius, from the Figma "dropdown"
   frame. Hidden with visibility rather than display so it can transition and
   so its links stay out of the tab order while closed. */
.energin-menu__sub {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 10;
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	min-width: 220px;
	margin-top: 8px;
	padding: var(--wp--preset--spacing--20, 8px) 0;
	border: 1px solid var(--eh-border);
	border-radius: var(--eh-radius, 20px);
	background: var(--eh-sub-bg);
	color: var(--eh-sub-text);
	box-shadow: 0 4px 16px rgba(62, 75, 96, 0.08);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
}

.energin-menu__item:hover > .energin-menu__sub,
.energin-menu__item:focus-within > .energin-menu__sub,
.energin-menu__item.is-open > .energin-menu__sub {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s;
}

/* A second-level panel opens beside its parent, not below it. */
.energin-menu__sub .energin-menu__sub {
	top: 0;
	left: 100%;
	margin: 0 0 0 4px;
}

.energin-menu__sub .energin-menu__link {
	display: block;
	padding: 10px var(--wp--preset--spacing--30, 16px);
	font-size: var(--wp--preset--font-size--small, 14px);
}

.energin-menu__sub .energin-menu__link:hover,
.energin-menu__sub .energin-menu__link:focus-visible {
	color: var(--eh-sub-hover);
}

.energin-menu__sub .energin-menu__toggle {
	position: absolute;
	top: 6px;
	right: 8px;
}

/* Bridges the 8px gap between a top-level item and its panel. Without it the
   pointer crosses dead space on the way down and the panel closes. */
.energin-menu__item--depth-0.energin-menu__item--parent::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 0;
	width: 100%;
	height: 12px;
}

/* ---------------------------------------------------------------
   Search
   --------------------------------------------------------------- */

.energin-header__search {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	box-sizing: border-box;
	height: 44px;
	padding: 0 4px 0 12px;
	border: 1px solid var(--eh-border);
	border-radius: var(--eh-radius, 20px);
	background: var(--eh-bg);
}

.energin-header__search--drawer {
	width: 100%;
	margin-top: 20px;
	background: transparent;
}

/* ---------------------------------------------------------------
   Search — icon-triggered slide panel
   ---------------------------------------------------------------
   Closed, the row shows only the toggle button. Opening it slides a
   full-width bar down from under the header (commbank.com.au's pattern),
   holding just the input and a close button — no icon inside, since Enter
   still submits the form and the close button is the way out. */

.energin-header__search-wrap {
	/* Deliberately not a positioning context: the slide panel is position:
	   absolute against .energin-header itself (the nearest positioned
	   ancestor), so it spans the full header width rather than being boxed
	   in under this wrap. */
	flex: 0 0 auto;
}

.energin-header__search-toggle {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--eh-radius, 20px);
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.energin-header__search-toggle:hover,
.energin-header__search-toggle:focus-visible {
	color: var(--eh-hover);
}

.energin-header__search-wrap.is-open .energin-header__search-toggle {
	visibility: hidden;
}

.energin-header__search--bar {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	width: auto;
	height: auto;
	box-sizing: border-box;
	gap: 12px;
	padding: 20px var(--wp--custom--gutter, 80px);
	border: 0;
	border-top: 1px solid var(--eh-border);
	border-radius: 0;
	background: var(--eh-bg);
	box-shadow: 0 16px 32px rgba(20, 26, 35, 0.1);
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transform: translateY(-6px);
	transition: max-height 0.28s ease, opacity 0.2s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}

.energin-header__search-wrap.is-open .energin-header__search--bar {
	max-height: 120px;
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateY(0);
	transition: max-height 0.28s ease, opacity 0.2s ease, transform 0.28s ease, visibility 0s;
}

.energin-header__search--bar .energin-header__search-input {
	flex: 1 1 auto;
	min-width: 0;
	height: 48px;
	padding: 0 18px;
	border: 1px solid var(--eh-border);
	border-radius: var(--eh-radius, 20px);
	font-size: var(--wp--preset--font-size--base, 16px);
}

.energin-header__search--bar .energin-header__search-input:focus {
	outline: none;
	border-color: var(--eh-hover);
}

/* Enter still submits the form; the visible affordance is the toggle icon
   to open and the close button to leave, so the redundant magnifier inside
   the open panel is dropped rather than duplicating the toggle. */
.energin-header__search--bar .energin-header__search-submit {
	display: none;
}

.energin-header__search-close {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: var(--eh-radius, 20px);
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.energin-header__search-close:hover,
.energin-header__search-close:focus-visible {
	color: var(--eh-hover);
}

.energin-header__search-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--small, 14px);
}

.energin-header__search-input:focus {
	outline: none;
}

.energin-header__search-input::placeholder {
	color: currentColor;
	opacity: 0.55;
}

.energin-header__search:focus-within {
	border-color: var(--eh-hover);
}

.energin-header__search-submit {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.energin-header__search-submit:hover {
	color: var(--eh-hover);
}

/* ---------------------------------------------------------------
   Actions and the CTA pill
   --------------------------------------------------------------- */

.energin-header__actions {
	display: flex;
	align-items: center;
	flex: 0 0 auto;
	gap: 10px;
}

.energin-header__cta {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	height: 44px;
	padding: 0 16px;
	border-radius: var(--eh-radius, 20px);
	background: var(--eh-cta-bg);
	color: var(--eh-cta-text);
	font-size: var(--wp--preset--font-size--base, 16px);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.16s ease;
}

.energin-header__cta:hover,
.energin-header__cta:focus-visible {
	background: var(--eh-cta-hover);
	color: var(--eh-cta-text);
}

.energin-header__cta .energin-icon {
	flex: 0 0 16px;
}

/* The login button: same pill, no icon, own colour pair so it can sit beside
   the CTA without the two competing for the same background. */
.energin-header__login {
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	height: 44px;
	padding: 0 20px;
	border-radius: var(--eh-radius, 20px);
	background: var(--eh-login-bg);
	color: var(--eh-login-text);
	font-size: var(--wp--preset--font-size--base, 16px);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color 0.16s ease;
}

.energin-header__login:hover,
.energin-header__login:focus-visible {
	background: var(--eh-login-hover);
	color: var(--eh-login-text);
}

/* ---------------------------------------------------------------
   Drawer scaffolding
   ---------------------------------------------------------------
   The drawer layout itself is generated with the admin's breakpoint. These are
   the parts that hold true at every width. */

.energin-header__backdrop {
	display: none;
}

.energin-header.is-open .energin-header__backdrop {
	display: block;
}

/* Set on <html> while the drawer is open so the page behind it cannot scroll. */
.energin-header-lock {
	overflow: hidden;
}

/* ---------------------------------------------------------------
   Focus and motion
   --------------------------------------------------------------- */

.energin-header a:focus-visible,
.energin-header button:focus-visible,
.energin-header input:focus-visible {
	outline: 2px solid var(--eh-hover);
	outline-offset: 2px;
	border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
	.energin-header__panel,
	.energin-menu__sub,
	.energin-header__backdrop,
	.energin-header__cta,
	.energin-header__login {
		transition: none !important;
	}
}

/* ---------------------------------------------------------------
   Touch targets
   ---------------------------------------------------------------
   Keyed to the input device rather than the viewport, so a small laptop keeps
   its compact hit areas and a large tablet still gets thumb-sized ones. 44px is
   the WCAG 2.5.5 floor. */

@media (pointer: coarse) {
	.energin-menu__item--depth-0 > .energin-menu__link {
		padding-block: 12px;
	}

	/* border-box, or the link's own vertical padding stacks on top of the
	   44px floor instead of counting toward it, inflating every submenu row
	   by its padding and spreading a short list out with dead space. */
	.energin-menu__sub .energin-menu__link {
		box-sizing: border-box;
		min-height: 44px;
		display: flex;
		align-items: center;
	}

	/* Keep the chevron 16px and grow only the area around it, so the arrow does
	   not visually change size on touch devices. */
	.energin-menu__toggle {
		position: relative;
	}

	.energin-menu__toggle::after {
		content: "";
		position: absolute;
		inset: -14px;
	}
}
