/**
 * HTPLaw Header widget.
 *
 * Elementor style controls set the --htplaw-header-* properties; the values
 * after the commas are the Figma defaults (frame 3:322, desktop 1440): logo
 * 194px, links Inter 15px #0f2a3f with 35px gaps, nav centred between logo
 * and button, 42px navy button with 13px side padding, 94px bar.
 * Hover/current colours and the dropdown/mobile styling are not in Figma.
 *
 * Mobile breakpoint: 1024px (Elementor's default tablet breakpoint). header.js
 * detects mobile mode from the burger's visibility, so this file is the only
 * place the breakpoint is defined.
 */

.htplaw-header {
	--_bg: var(--htplaw-header-bg, var(--htplaw-color-surface));
	--_link: var(--htplaw-header-link, var(--htplaw-color-secondary));
	--_link-hover: var(--htplaw-header-link-hover, var(--htplaw-color-accent-strong));
	--_dd-bg: var(--htplaw-header-dropdown-bg, var(--htplaw-color-surface));
	--_dd-link: var(--htplaw-header-dropdown-link, var(--htplaw-color-text));
	--_gap: clamp(1rem, 2vw, 2rem);
	--_menu-gap: var(--htplaw-header-gap, 35px);
	--_pad-y: var(--htplaw-header-pad-y, 26px);
	--_logo-w: var(--htplaw-header-logo-width, 194px);

	position: relative;
	background: var(--_bg);
	font-family: var(--htplaw-font-body);
	font-size: 15px;
	line-height: 1.2;
}

.htplaw-header__inner {
	display: flex;
	align-items: center;
	gap: var(--_gap);
	max-width: calc(var(--htplaw-container) + 2 * var(--htplaw-gutter));
	margin-inline: auto;
	padding: var(--_pad-y) var(--htplaw-gutter);
}

/* Logo */
.htplaw-header__logo {
	display: inline-flex;
	flex-shrink: 1;
	min-width: 0;
	color: var(--_link);
	text-decoration: none;
}

.htplaw-header__logo-img {
	display: block;
	width: var(--_logo-w);
	max-width: 100%;
	height: auto;
}

.htplaw-header__logo--text {
	font-family: var(--htplaw-font-heading);
	font-size: clamp(1.125rem, 1rem + .5vw, 1.375rem);
	font-weight: 700;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

/* Panel holds nav, contact, and buttons */
.htplaw-header__panel {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: flex-end;
	gap: var(--_gap);
}

.htplaw-header__nav {
	flex: 0 0 auto;
	margin-inline: auto;
}

.htplaw-header__menu,
.htplaw-header__menu .sub-menu,
.htplaw-header__contact {
	margin: 0;
	padding: 0;
	list-style: none;
}

.htplaw-header__menu {
	display: flex;
	align-items: center;
	gap: 0 var(--_menu-gap);
}

.htplaw-header__menu li {
	position: relative;
	display: flex;
	align-items: center;
}

.htplaw-header__menu a {
	display: block;
	padding: .5rem 0;
	color: var(--_link);
	font-weight: 400;
	text-decoration: none;
	white-space: nowrap;
	transition: color var(--htplaw-duration) var(--htplaw-ease);
}

.htplaw-header__menu a:hover,
.htplaw-header__menu .current-menu-item > a,
.htplaw-header__menu .current-menu-ancestor > a,
.htplaw-header__menu a[aria-current="page"] {
	color: var(--_link-hover);
}

.htplaw-submenu-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin-inline-start: .25rem;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: none;
	color: var(--_link);
	cursor: pointer;
}

.htplaw-submenu-toggle svg {
	transition: transform var(--htplaw-duration) var(--htplaw-ease);
}

.htplaw-submenu-toggle[aria-expanded="true"] svg {
	transform: rotate(180deg);
}

/* Desktop dropdowns: open on hover, keyboard focus, or toggle click. */
.htplaw-header__menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 100;
	min-width: 220px;
	padding: .5rem 0;
	border-radius: var(--htplaw-radius);
	background: var(--_dd-bg);
	box-shadow: var(--htplaw-shadow);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity var(--htplaw-duration) var(--htplaw-ease), transform var(--htplaw-duration) var(--htplaw-ease), visibility var(--htplaw-duration);
}

.htplaw-header__menu .sub-menu .sub-menu {
	top: 0;
	left: 100%;
}

.htplaw-header__menu li:hover > .sub-menu,
.htplaw-header__menu li:focus-within > .sub-menu,
.htplaw-header__menu li.is-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}

/* Escape dismisses a hover/focus-opened dropdown until the pointer leaves. */
.htplaw-header__menu li.is-dismissed > .sub-menu {
	opacity: 0;
	visibility: hidden;
}

.htplaw-header__menu .sub-menu li {
	justify-content: space-between;
}

.htplaw-header__menu .sub-menu a {
	flex: 1;
	padding: .5rem 1.25rem;
	color: var(--_dd-link);
	white-space: nowrap;
}

/* Contact details */
.htplaw-header__contact {
	display: flex;
	gap: 1rem;
	font-size: .875rem;
}

.htplaw-header__contact a {
	color: var(--_link);
	text-decoration: none;
}

.htplaw-header__actions {
	display: flex;
	gap: .75rem;
}

.htplaw-header__actions .htplaw-btn {
	padding-inline: 13px;
}

.htplaw-header__notice {
	margin: 0;
	padding: .5rem .75rem;
	border: 1px dashed currentColor;
	font-size: .8125rem;
	color: var(--htplaw-color-secondary);
}

/* Hello Elementor colours every button pink on hover/focus
   (`button:hover, button:focus`); the header's icon buttons stay plain. */
.htplaw-header .htplaw-header__burger:hover,
.htplaw-header .htplaw-header__burger:focus,
.htplaw-header .htplaw-submenu-toggle:hover,
.htplaw-header .htplaw-submenu-toggle:focus {
	background: none;
	color: var(--_link-hover);
}

/* Burger (mobile only) */
.htplaw-header__burger {
	display: none;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	margin-inline-start: auto;
	padding: 0;
	border: 0;
	background: none;
	color: var(--_link);
	cursor: pointer;
}

.htplaw-header__burger-box {
	position: relative;
	display: block;
	width: 24px;
	height: 18px;
}

.htplaw-header__burger-box > span {
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	border-radius: 1px;
	background: currentColor;
	transition: transform var(--htplaw-duration) var(--htplaw-ease), opacity var(--htplaw-duration);
}

.htplaw-header__burger-box > span:nth-child(1) { top: 0; }
.htplaw-header__burger-box > span:nth-child(2) { top: 8px; }
.htplaw-header__burger-box > span:nth-child(3) { top: 16px; }

.htplaw-header__burger[aria-expanded="true"] .htplaw-header__burger-box > span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.htplaw-header__burger[aria-expanded="true"] .htplaw-header__burger-box > span:nth-child(2) { opacity: 0; }
.htplaw-header__burger[aria-expanded="true"] .htplaw-header__burger-box > span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Mobile */
@media (max-width: 1024px) {
	.htplaw-header__menu a {
		white-space: normal;
	}

	/* Compact bar on tablets and phones (94px on desktop). */
	.htplaw-header {
		--_pad-y: var(--htplaw-header-pad-y-mobile, 14px);
	}

	.htplaw-header__burger {
		display: inline-flex;
		margin-inline-end: -10px; /* align the icon, not its 44px tap area, with the gutter */
	}

	/* Full-screen menu: fixed under the visible header bar (header.js sets
	   --htplaw-header-panel-top when opening) and scrollable on its own. */
	.htplaw-header__panel {
		position: fixed;
		top: var(--htplaw-header-panel-top, 72px);
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 1000;
		display: none;
		flex-direction: column;
		align-items: stretch;
		justify-content: flex-start;
		gap: 1.5rem;
		overflow-y: auto;
		padding: 1rem var(--htplaw-gutter) 2rem;
		border-top: 1px solid var(--htplaw-color-border);
		background: var(--_bg);
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
	}

	@media (prefers-reduced-motion: no-preference) {
		.htplaw-header.is-open .htplaw-header__panel {
			animation: htplaw-panel-in var(--htplaw-duration) var(--htplaw-ease);
		}
	}

	.htplaw-header.is-open .htplaw-header__panel {
		display: flex;
	}

	.htplaw-header__nav {
		margin-inline: 0;
	}

	.htplaw-header__menu {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.htplaw-header__menu li {
		flex-wrap: wrap;
		justify-content: space-between;
		border-bottom: 1px solid var(--htplaw-color-border);
	}

	.htplaw-header__menu a {
		flex: 1;
		padding: .875rem 0;
	}

	.htplaw-submenu-toggle {
		width: 44px;
		height: 44px;
	}

	/* Mobile submenus are accordions driven only by the toggle button. */
	.htplaw-header__menu .sub-menu,
	.htplaw-header__menu .sub-menu .sub-menu {
		position: static;
		display: none;
		flex-basis: 100%;
		min-width: 0;
		padding: 0 0 .5rem 1rem;
		box-shadow: none;
		background: transparent;
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: none;
	}

	.htplaw-header__menu li.is-open > .sub-menu {
		display: block;
	}

	.htplaw-header__menu .sub-menu li {
		border-bottom: 0;
	}

	.htplaw-header__menu .sub-menu a {
		padding: .625rem 0;
		white-space: normal;
	}

	.htplaw-header__contact {
		flex-direction: column;
		gap: .5rem;
		font-size: 1rem;
	}

	.htplaw-header__actions {
		flex-direction: column;
	}

	.htplaw-header__actions .htplaw-btn {
		min-height: 48px;
	}

	.htplaw-header__menu > li > a {
		font-size: 17px;
	}
}

@media (max-width: 480px) {
	.htplaw-header {
		--_logo-w: var(--htplaw-header-logo-width-mobile, 160px);
	}
}

@keyframes htplaw-panel-in {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: none; }
}

/* Page behind the open mobile menu doesn't scroll (set by header.js). */
html.htplaw-menu-open,
html.htplaw-menu-open body {
	overflow: hidden;
}
