/*
 * Site NavBar — Figma node 6196:4201 (1425×131).
 * White bar: logo left (40px inset), "How it Works" link + dark pill CTA
 * right (52px inset). The design's hairline under the bar (Line 8, y=141) is
 * intentionally dropped: the hero is full-bleed here, so the rule sat flush on
 * the photo and read as an artefact instead of a separator.
 *
 * Behavior (site-header.js):
 * - The bar is IN FLOW by default and simply scrolls away with the page. Past
 *   a threshold `.is-floating` makes it sticky and it slides back down over
 *   the content.
 * - It must NOT be sticky by default, and must never be hidden with a
 *   transform. A sticky bar stays in flow and so reserves its own 131px at the
 *   top of the document; translating it away uncovers that reserved gap, and
 *   what shows through is the white <body> — which read as "the bar leaves its
 *   background behind". Letting it scroll away naturally means nothing is ever
 *   displaced, so there is no gap to uncover.
 * - <768px the actions collapse into a toggle-driven drawer (`.is-open`).
 *   The drawer is only hidden under `html.js`, so no-JS users always see
 *   the nav stacked in flow below the bar.
 */

.hp-header {
	/*
	 * `relative` is load-bearing twice over, and its absence broke both:
	 *
	 * 1. The mobile drawer is `position: absolute; top: 100%` (see the <=768px
	 *    block below). With no positioned ancestor it resolved against the
	 *    initial containing block, so it opened ~600px BELOW the header and
	 *    scrolled off the top of the screen entirely -- mobile navigation was
	 *    unreachable. Verified: menu.offsetParent was <body>, not .hp-header.
	 * 2. `z-index` has no effect on a static element, so the stacking order
	 *    this rule asks for was never actually applied.
	 *
	 * `.is-floating` swaps this for `sticky`, which is also a positioned
	 * ancestor, so the drawer anchors correctly in both states.
	 */
	position: relative;
	z-index: 100; /* above page content, far below the skip link (100000) */
	background-color: var(--hp-color-paper);
}

/*
 * Sticky, not fixed: sticky keeps the bar in flow, so gaining and losing this
 * class never pulls 131px out from under the document and the page cannot jump.
 */
html.js .hp-header.is-floating {
	position: sticky;
	top: 0;
	box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

/*
 * Entrance and exit are two names on the same element, never a transition: the
 * bar has no "hidden" resting state to transition to — dropping .is-floating
 * returns it to static, which at this scroll position is simply off-screen, so
 * it would vanish in one frame. .is-leaving keeps it sticky for the 300ms it
 * takes to slide out, and site-header.js drops both classes after.
 *
 * `forwards` on the exit holds the off-screen frame until that happens;
 * without it the bar snaps back into view for a frame at the end.
 *
 * Splitting on :not(.is-leaving) is what lets a cancelled exit recover: taking
 * .is-leaving off changes the animation NAME, which restarts it, so a visitor
 * who scrolls back down mid-exit sees the bar slide in again instead of
 * jumping.
 */
@media (prefers-reduced-motion: no-preference) {
	html.js .hp-header.is-floating:not(.is-leaving) {
		animation: hp-header-slide-down 0.3s var(--hp-reveal-ease);
	}

	html.js .hp-header.is-floating.is-leaving {
		animation: hp-header-slide-up 0.3s var(--hp-reveal-ease) forwards;
	}
}

@keyframes hp-header-slide-down {
	from {
		transform: translateY(-100%);
	}
}

@keyframes hp-header-slide-up {
	to {
		transform: translateY(-100%);
	}
}

.hp-header__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	column-gap: 40px;
	box-sizing: border-box;
	max-width: var(--hp-container-max);
	min-height: 131px;
	margin-inline: auto;
	padding: 18px 52px 18px 40px;
}

.hp-header__brand {
	display: inline-flex;
	flex-shrink: 0;
}

.hp-header__logo {
	display: block;
	width: 132px;
	height: 59px;
}

.hp-header__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	column-gap: 34px;
	row-gap: 12px;
}

.hp-header__nav ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 32px;
	row-gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.hp-header__nav a {
	position: relative;
	font-family: var(--hp-font-body);
	font-size: 18px;
	font-weight: 500;
	line-height: 23px;
	color: var(--hp-color-ink);
	text-decoration: none;
}

/* Directional underline: draws in from the left on hover, wipes out to the
   right on leave (the origin flip does both). Desktop only — in the mobile
   drawer the links are full-width blocks, where a 100%-wide 2px wipe reads
   heavy, so the drawer keeps a plain underline instead. Reduced motion: the
   bar appears/disappears instantly (transition is gated below). */
@media (min-width: 768px) {
	.hp-header__nav a::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: -5px;
		height: 2px;
		background: currentColor;
		transform: scaleX(0);
		transform-origin: right center;
	}

	.hp-header__nav a:hover::after {
		transform: scaleX(1);
		transform-origin: left center;
	}

	/*
	 * Focus draws the SAME wipe but thicker and a touch lower, so a keyboard
	 * user can tell focus from hover. Sharing one rule (as this did before)
	 * would have made the keyboard state byte-identical to the mouse state
	 * once the old outline was removed — the very thing the pill rule in
	 * buttons.css exists to avoid.
	 */
	.hp-header__nav a:focus-visible::after {
		bottom: -7px;
		/* 3px against the hover wipe's 2px: the 2px drop alone was too subtle
		   to read as a different state. */
		height: 3px;
		transform: scaleX(1);
		transform-origin: left center;
	}
}

@media (min-width: 768px) and (prefers-reduced-motion: no-preference) {
	.hp-header__nav a::after {
		transition: transform 0.28s var(--hp-ease-out);
	}
}

@media (max-width: 767px) {
	.hp-header__nav a:hover {
		text-decoration: underline;
		text-underline-offset: 4px;
	}

	/*
	 * :focus-visible, not :focus — the old rule underlined the drawer link on
	 * every TAP, i.e. a hover style firing on touch. Thicker than the hover
	 * underline so the two stay distinguishable.
	 */
	.hp-header__nav a:focus-visible {
		text-decoration: underline;
		text-decoration-thickness: var(--hp-focus-underline);
		text-underline-offset: var(--hp-focus-underline-offset);
	}
}

/* Metrics + typography only — colors and the hover sweep come from the shared
   .hp-button class (assets/css/buttons.css). */
.hp-header__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	min-height: 54px;
	padding: 0 33px;
	border-radius: 27px;
	font-family: var(--hp-font-body);
	font-size: 18px;
	font-weight: 500;
	line-height: 23px;
	text-decoration: none;
	white-space: nowrap;
}

/*
 * Keyboard focus (client feedback 2026-09, item 5): the shape follows the
 * element instead of boxing everything.
 *
 *   .hp-header__brand  — an image link, so its box IS its shape: it keeps the
 *                        global ring from assets/css/focus.css. No rule here.
 *   .hp-header__cta    — the pill ring lives once in assets/css/buttons.css.
 *                        No rule here, and one must NOT be added: this sheet
 *                        prints after buttons.css, so it would win the tie and
 *                        the pill would carry two indicators.
 *   .hp-header__nav a  — the indicator is the underline it already has (the
 *                        thicker wipe above at >=768px, the drawer underline
 *                        below it).
 *   .hp-header__toggle — an inverted disc, the theme's icon-button language.
 */
.hp-header__nav a:focus-visible {
	outline: none;
}

.hp-header__toggle:focus-visible {
	outline: none;
	border-radius: 50%;
	background-color: var(--hp-focus-color);
}

.hp-header__toggle:focus-visible .hp-header__toggle-icon span {
	background-color: var(--hp-focus-contrast);
}

/* Hamburger toggle: shown only <768px, and only when JS drives the drawer. */
.hp-header__toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.hp-header__toggle-icon {
	position: relative;
	display: block;
	width: 24px;
	height: 18px;
}

.hp-header__toggle-icon span {
	position: absolute;
	left: 0;
	display: block;
	width: 100%;
	height: 2px;
	background-color: var(--hp-color-ink);
}

.hp-header__toggle-icon span:nth-child(1) {
	top: 0;
}

.hp-header__toggle-icon span:nth-child(2) {
	top: 8px;
}

.hp-header__toggle-icon span:nth-child(3) {
	top: 16px;
}

.hp-header.is-open .hp-header__toggle-icon span:nth-child(1) {
	transform: translateY(8px) rotate(45deg);
}

.hp-header.is-open .hp-header__toggle-icon span:nth-child(2) {
	opacity: 0;
}

.hp-header.is-open .hp-header__toggle-icon span:nth-child(3) {
	transform: translateY(-8px) rotate(-45deg);
}

@media (prefers-reduced-motion: no-preference) {
	.hp-header__toggle-icon span {
		transition: transform 0.2s ease, opacity 0.2s ease;
	}
}

@media (max-width: 1023px) {
	.hp-header__bar {
		column-gap: 24px;
		padding-inline: 20px;
	}
}

@media (max-width: 767px) {
	.hp-header__bar {
		flex-wrap: wrap;
		min-height: 0;
		padding-block: 16px;
		row-gap: 16px;
	}

	html.js .hp-header__toggle {
		display: inline-flex;
	}

	/* Drawer panel. Default (no JS): visible, stacked in flow below the bar. */
	.hp-header__menu {
		flex-basis: 100%;
		border-top: 1px solid var(--hp-color-ink);
		padding-top: 12px;
	}

	.hp-header__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.hp-header__nav ul {
		flex-direction: column;
		align-items: stretch;
		row-gap: 0;
	}

	.hp-header__nav a {
		display: block;
		padding: 14px 0; /* comfortable tap target */
		/*
		 * Client feedback 2026-09, item 2: centre the "How it Works" link (then
		 * "Tour the Platform") in the drawer, matching the CTA pill below it, which already centres its
		 * own label.
		 *
		 * text-align, NOT align-items: center on the <ul> above: that would
		 * shrink the <li>/<a> to the label's width and destroy the full-width
		 * tap target the padding here deliberately creates. Scoped to this
		 * media block, so the desktop row and its full-box ::after underline
		 * wipe are untouched.
		 *
		 * This centres every primary-menu link at mobile. The menu has exactly
		 * one item today and the design intends one; keying off the item's own
		 * id would be fragile, since that id changes if the item is recreated.
		 */
		text-align: center;
	}

	.hp-header__cta {
		width: 100%;
		margin-top: 8px;
	}

	/* With JS the panel overlays below the header, hidden until .is-open.
	   Only transform/opacity/visibility change — no layout animation. */
	html.js .hp-header__menu {
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
		visibility: hidden;
		opacity: 0;
		transform: translateY(-8px);
		box-sizing: border-box;
		padding: 8px var(--hp-container-pad) 24px;
		background-color: var(--hp-color-paper);
		border-top: 1px solid var(--hp-color-ink);
		box-shadow: 0 16px 24px rgba(0, 0, 0, 0.08);
	}

	html.js .hp-header.is-open .hp-header__menu {
		visibility: visible;
		opacity: 1;
		transform: none;
	}
}

@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
	html.js .hp-header__menu {
		transition:
			opacity 0.2s ease,
			transform 0.2s ease,
			visibility 0s linear 0.2s;
	}

	html.js .hp-header.is-open .hp-header__menu {
		transition-delay: 0s;
	}
}
