/* stylelint-disable no-descending-specificity -- hover/active state ordering */

/**
 * Apex header — overlay navigation that sits over the hero image.
 *
 * The menu items come from a classic WP menu (Appearance > Menus, location
 * "primary") rendered by the [apex_primary_menu] shortcode. Submenus are
 * styled as the Figma "glass" dropdown (backdrop blur + translucent gradient).
 *
 * Colours reference theme.json tokens: --wp--preset--color--cream / --ink.
 */

/* Standard pages: the header is a sticky bar that carries the glass background
   from the start. Hero pages add .apex-header--overlay to turn it into a fixed
   transparent overlay that only gains the glass once the page is scrolled. */
.apex-header {
	position: sticky;
	top: 0;
	inset-inline: 0;
	z-index: 100;
	background: transparent;
}

.apex-header--overlay {
	position: fixed;
	inset: 0 0 auto 0;
}

/* Keep the sticky / fixed header clear of the logged-in admin bar. */
.admin-bar .apex-header {
	top: 32px;
}

@media screen and ( max-width: 782px ) {

	.admin-bar .apex-header {
		top: 46px;
	}
}

/* The overlay header is out of flow, so the hero must start at the very top
   (cancel the block-gap margin the flow layout adds to the following main). */
.apex-header + main {
	margin-block-start: 0;
}

/* Darker "glass" bar that spans the full width of the site. It lives on a
   pseudo-element rather than .apex-header itself: a backdrop-filter on the
   header would make it the containing block for the position:fixed mobile-menu
   overlay nested inside it, breaking the full-screen menu. */
.apex-header::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background-color: rgba(6, 12, 20, 0.78);
	-webkit-backdrop-filter: blur(12px);
	backdrop-filter: blur(12px);
	border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
	opacity: 1;
	transition: opacity 0.3s ease;
}

/* Hero overlay header: transparent at the top, glass fades in once scrolled. */
.apex-header--overlay::after {
	opacity: 0;
}

.apex-header--overlay.is-scrolled::after {
	opacity: 1;
}

/* Top gradient overlay (Figma: grey #5e6770 40% -> transparent navy) for
   legibility of the cream menu over a bright hero — only on the overlay header,
   and only until the glass takes over on scroll. */
.apex-header--overlay::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 177px;
	background: linear-gradient(180deg, rgba(94, 103, 112, 0.4) 0%, rgba(2, 18, 34, 0) 100%);
	pointer-events: none;
	z-index: -1;
	opacity: 1;
	transition: opacity 0.3s ease;
}

.apex-header--overlay.is-scrolled::before {
	opacity: 0;
}

.apex-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 2rem;
	padding: 29px clamp(1rem, 3.5vw, 2rem) 29px;
	color: var(--wp--preset--color--cream);
}

/* Cancel the flow-layout block-gap margins WP adds to group children, which
   would otherwise push the nav and CTA down out of vertical alignment. */
.apex-header__bar > * {
	margin-block: 0;
}

/* Logo ------------------------------------------------------------------ */
.apex-header__logo {
	display: inline-flex;
	flex: 0 0 auto;
	color: var(--wp--preset--color--cream);
	line-height: 0;
}

.apex-header__logo svg {
	display: block;
	width: 130px;
	height: auto;
}

/* Primary navigation ---------------------------------------------------- */
.apex-nav {
	flex: 1 1 auto;
	display: flex;
	justify-content: center;
}

.apex-menu {
	display: flex;
	align-items: center;
	gap: 2.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.apex-menu .menu-item {
	position: relative;
}

.apex-menu a {
	position: relative;
	display: block;
	color: var(--wp--preset--color--cream);
	font-family: Inter, sans-serif;
	font-weight: 500;
	font-size: 12px;
	line-height: 24px;
	text-decoration: none;
}

/* Hover / active indicator: a short line that sits ~6px below the item
   (Figma "Vector 28": 24px wide, 0.5px, at y72 under a y54 item). */
.apex-menu a::after {
	content: "";
	position: absolute;
	left: 50%;
	top: calc(100% + 5px);
	width: 0;
	border-top: 0.5px solid var(--wp--preset--color--cream);
	transform: translateX(-50%);
	transition: width 0.25s ease;
	pointer-events: none;
}

/* Underline grows out from the centre on hover / active. */
.apex-menu a:focus-visible::after,
.apex-menu .current-menu-item > a::after,
.apex-menu .current-menu-ancestor > a::after,
.apex-menu .menu-item:hover > a::after {
	width: 24px;
}

/* Glass dropdown -------------------------------------------------------- */
.apex-menu .sub-menu {
	position: absolute;
	top: 100%;
	left: 50%;

	/* ~30px below the menu item (Figma: item y54 -> dropdown y89). */
	margin-top: 23px;
	transform: translateX(-50%) translateY(-6px);
	min-width: 200px;
	margin-bottom: 0;
	margin-left: 0;
	margin-right: 0;

	/* 30px breathing room between items and above the first / below the last
	   (paired with zeroed vertical padding on the links below). */
	display: flex;
	flex-direction: column;
	gap: 30px;
	padding: 30px 0;
	list-style: none;
	background: linear-gradient(108deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 100%);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	border: 0.5px solid var(--wp--preset--color--cream);
	border-radius: 10px;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
	z-index: 10;
}

/* Invisible bridge so the hover intent survives the gap to the dropdown. */
.apex-menu .menu-item-has-children > .sub-menu::after {
	content: "";
	position: absolute;
	top: -25px;
	left: 0;
	right: 0;
	height: 25px;
}

.apex-menu .menu-item-has-children:hover > .sub-menu,
.apex-menu .menu-item-has-children:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transform: translateX(-50%) translateY(0);
}

.apex-menu .sub-menu a {
	padding: 0 24px;
	font-weight: 500;
	text-align: center;
	white-space: nowrap;
}

/* Dropdown items use the glass panel as the hover cue — no underline. */
.apex-menu .sub-menu a::after {
	content: none;
}

/* Items settle in sequence (subtle stagger + blur-in) as the panel opens. */
.apex-menu .sub-menu .menu-item {
	opacity: 0;
	transform: translateY(-4px);
	filter: blur(2px);
	transition: opacity 0.25s ease, transform 0.25s ease, filter 0.25s ease;
}

.apex-menu .menu-item-has-children:hover > .sub-menu .menu-item,
.apex-menu .menu-item-has-children:focus-within > .sub-menu .menu-item {
	opacity: 1;
	transform: none;
	filter: none;
}

.apex-menu .sub-menu .menu-item:nth-child(2) {
	transition-delay: 0.04s;
}

.apex-menu .sub-menu .menu-item:nth-child(3) {
	transition-delay: 0.08s;
}

.apex-menu .sub-menu .menu-item:nth-child(4) {
	transition-delay: 0.12s;
}

.apex-menu .sub-menu .menu-item:nth-child(5) {
	transition-delay: 0.16s;
}

/* Contact CTA ----------------------------------------------------------- */
.apex-header__cta {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 12px;
	padding: 13px 18px;
	border: 0.5px solid var(--wp--preset--color--cream);
	color: var(--wp--preset--color--cream);
	font-family: Inter, sans-serif;
	font-weight: 400;
	font-size: 12px;
	line-height: 1;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	background-color: transparent;
	-webkit-backdrop-filter: blur(0);
	backdrop-filter: blur(0);
	transition:
		background-color 0.3s ease,
		-webkit-backdrop-filter 0.3s ease,
		backdrop-filter 0.3s ease;
}

/* Glass fill blurs in on hover (same translucent + blur as the dropdown). */
.apex-header__cta:hover,
.apex-header__cta:focus-visible {
	background-color: rgba(255, 255, 255, 0.12);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
}

.apex-header__cta svg {
	display: block;
	width: 9px;
	height: 9px;
	flex: 0 0 auto;
	transition: transform 0.2s ease;
}

/* Nudge the arrow up-right on hover. */
.apex-header__cta:hover svg,
.apex-header__cta:focus-visible svg {
	transform: translate(2px, -2px);
}

/* Hamburger toggle — hidden on desktop, shown on mobile. */
.apex-header__toggle {
	display: none;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	padding: 6px;
	margin: -6px;
	border: 0;
	background: none;
	color: var(--wp--preset--color--cream);
	cursor: pointer;
}

/* Three-bar icon shared by the header toggle and the overlay close button.
   Staggered widths at rest (Figma); morphs to an X when the menu opens
   (see assets/css/mobile-menu.css). */
.apex-header__toggle-icon {
	position: relative;
	display: block;
	width: 30px;
	height: 18px;
}

.apex-header__toggle-bar {
	position: absolute;
	left: 0;
	height: 2px;
	background-color: currentcolor;
	transition:
		width 0.3s ease,
		transform 0.3s ease,
		top 0.3s ease,
		opacity 0.2s ease;
}

.apex-header__toggle-bar:nth-child(1) {
	top: 0;
	width: 66%;
}

.apex-header__toggle-bar:nth-child(2) {
	top: 50%;
	width: 100%;
	transform: translateY(-50%);
}

.apex-header__toggle-bar:nth-child(3) {
	top: calc(100% - 2px);
	left: auto;
	right: 0;
	width: 70%;
}

/* Small screens: swap the inline nav + CTA for the hamburger. */
@media ( max-width: 899.98px ) {

	.apex-header__bar {
		justify-content: space-between;
	}

	.apex-nav,
	.apex-header__cta {
		display: none;
	}

	.apex-header__toggle {
		display: inline-flex;
	}

	.apex-header__logo svg {
		width: 120px;
	}
}

/* Respect reduced-motion: keep the hover/active states, drop the movement. */
@media ( prefers-reduced-motion: reduce ) {

	.apex-menu a::after,
	.apex-menu .sub-menu .menu-item,
	.apex-header__cta svg,
	.apex-header__toggle-bar,
	.apex-header::after,
	.apex-header--overlay::before {
		transition: none;
	}

	.apex-menu .sub-menu .menu-item {
		transform: none;
		filter: none;
	}
}
