/**
 * Header navigation
 *
 * Design ref: design-preferences/css-exports/Home Page/header-nav.css
 */

.site-header {
	position: relative;
	z-index: 100;
	background: transparent;
	overflow: visible;
}

.header-nav {
	position: relative;
	width: 100%;
	/* Logo sits inside the bar; nothing hangs into the hero. */
	height: var(--header-bar-height);
	overflow: visible;
	background: transparent;
}

.header-nav__wrapper {
	position: relative;
	width: 100%;
	height: var(--header-bar-height);
	background: var(--color-white);
	border-bottom: 1px solid var(--color-border-light);
	box-sizing: border-box;
	z-index: 2;
}

.header-nav__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	max-width: var(--header-content-max);
	height: 100%;
	margin: 0 auto;
	padding: 0 var(--header-inline-pad);
	box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Menu toggle (mobile)
   -------------------------------------------------------------------------- */

.header-nav__menu-toggle {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 8px;
	border: 0;
	background: transparent;
	cursor: pointer;
	flex-shrink: 0;
}

.header-nav__menu-toggle-bar {
	display: block;
	width: 100%;
	height: 2px;
	background: var(--color-heading);
}

/* --------------------------------------------------------------------------
   Logo
   -------------------------------------------------------------------------- */

.header-nav__logo-wrapper {
	position: absolute;
	left: 50%;
	/* Centred in the bar rather than pinned to a top offset — the box and the
	   bar now scale together, so a fixed offset would drift. */
	top: 50%;
	transform: translate(-50%, -50%);
	width: var(--header-logo-width);
	height: var(--header-logo-height);
	z-index: 10; /* above nav bar + hero seam */
	pointer-events: none;
}

/*
 * The mark sits inside the bar rather than on a plate hanging over the hero,
 * so there is no plate to draw — the bar behind it is already white — and with
 * a transparent PNG there is no baked-in white to clip back off either. What
 * is left is a plain centring box.
 */
.header-nav__logo-circle {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	pointer-events: auto;
	box-sizing: border-box;
}

.header-nav__logo {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
}

.header-nav__logo .custom-logo-link {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	line-height: 0;
}

.header-nav__logo .custom-logo {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	/* Trims the white margin baked into the artwork — see --header-logo-trim. */
	transform: scale(var(--header-logo-trim));
}

.header-nav__logo-fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-family: var(--font-heading);
	font-size: 18px;
	font-weight: 400;
	letter-spacing: 0.04em;
	color: var(--color-accent);
	text-decoration: none;
	text-align: center;
	text-transform: uppercase;
	padding: 12px;
	box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Primary + secondary menus
   -------------------------------------------------------------------------- */

/* Reset Underscores .main-navigation defaults for the header layout. */
.header-nav .main-navigation {
	display: flex;
	width: auto;
}

.header-nav .main-navigation ul {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
}

.header-nav .main-navigation ul ul {
	float: none;
	left: auto;
	box-shadow: none;
}

.header-nav__menu {
	display: flex;
	align-items: center;
}

.header-nav__menu--primary {
	flex: 1 1 0;
	min-width: 0;
	justify-content: flex-start;
	padding-right: calc(var(--header-logo-width) / 2 + 16px);
}

.header-nav__menu--secondary {
	flex-shrink: 0;
}

/* Drawer chrome and scrim exist only below 1200px. */
.header-nav__drawer-head,
.header-nav__drawer-extra,
.header-nav__scrim {
	display: none;
}

.header-nav__menu-list {
	display: flex;
	align-items: center;
	gap: var(--header-menu-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.header-nav__menu-list > li {
	display: flex;
	align-items: center;
	gap: 4px;
	position: relative;
	margin: 0;
}

.header-nav__menu-list a {
	font-family: var(--font-body);
	font-style: normal;
	font-weight: var(--nav-link-weight);
	font-size: var(--nav-link);
	line-height: var(--nav-link-lh);
	color: var(--color-heading);
	text-decoration: none;
	white-space: nowrap;
}

.header-nav__menu-list a:hover,
.header-nav__menu-list a:focus {
	color: var(--color-accent);
}

.header-nav__menu-list .menu-item-has-children > a::after {
	content: "";
	display: inline-block;
	width: 20px;
	height: 20px;
	margin-left: 0;
	vertical-align: middle;
	background-color: var(--color-heading);
	/* ri:arrow-drop-down-line-style chevron */
	clip-path: polygon(25% 35%, 75% 35%, 50% 65%);
	box-shadow: 0 0 0 0.2px #fff6e3;
	opacity: 1;
}

.header-nav__menu-list .sub-menu {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 180px;
	margin: 8px 0 0;
	padding: 8px 0;
	list-style: none;
	background: var(--color-white);
	border: 1px solid var(--color-border-light);
	box-shadow: 0 8px 24px rgba(11, 11, 11, 0.08);
	z-index: 20;
}

.header-nav__menu-list > li:hover > .sub-menu,
.header-nav__menu-list > li.focus > .sub-menu {
	display: block;
}

.header-nav__menu-list .sub-menu a {
	display: block;
	padding: 8px 16px;
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Right cluster
   -------------------------------------------------------------------------- */

.header-nav__right {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 24px;
	flex: 1 1 0;
	min-width: 0;
	padding-left: calc(var(--header-logo-width) / 2 + 16px);
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */

.header-nav__search {
	position: relative;
	display: flex;
	align-items: center;
	/*
	 * Elastic rather than fixed. Both halves of the bar are `flex: 1 1 0`, so
	 * each gets exactly half the width no matter what it holds — and the right
	 * cluster is the heavier half. Everything else in it (menu, icons) is
	 * fixed, so if the field does not shrink the cluster overflows leftwards,
	 * straight under the absolutely centred logo. 168px still fits the icon
	 * plus a usable input.
	 */
	flex: 0 1 252px;
	min-width: 168px;
	height: 25px;
	margin: 0;
}

.header-nav__search-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--color-heading);
	cursor: pointer;
	flex-shrink: 0;
	line-height: 0;
}

.header-nav__search-submit:hover,
.header-nav__search-submit:focus,
.header-nav__search-submit:active {
	border: 0;
	background: transparent;
	box-shadow: none;
	outline: none;
}

.header-nav__search-icon {
	width: 24px;
	height: 24px;
	display: block;
}

/* Beat style.css `input[type="search"]` (border: 1px solid #ccc). */
.header-nav__search input[type="search"].header-nav__search-input,
.header-nav__search input[type="search"].header-nav__search-input:focus {
	flex: 1 1 auto;
	width: 217px;
	min-width: 0;
	height: 17px;
	margin: 0 0 0 11px;
	padding: 0;
	border: 0;
	border-radius: 0;
	outline: none;
	background: transparent;
	box-shadow: none;
	-webkit-appearance: none;
	appearance: none;
	font-family: var(--font-body);
	font-weight: 400;
	font-size: var(--nav-link);
	line-height: var(--nav-link-lh);
	color: var(--color-search);
}

.header-nav__search-input::placeholder {
	color: var(--color-search);
	opacity: 1;
}

.header-nav__search-input::-webkit-search-decoration,
.header-nav__search-input::-webkit-search-cancel-button,
.header-nav__search-input::-webkit-search-results-button,
.header-nav__search-input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.header-nav__search-line {
	position: absolute;
	/* Starts past the 24px icon + 11px input margin; right-anchored rather
	   than a fixed 217px so it follows the field when it shrinks. */
	left: 35px;
	right: 0;
	bottom: -2px;
	border-bottom: 1px solid var(--color-search-line);
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   Actions
   -------------------------------------------------------------------------- */

.header-nav__actions {
	display: flex;
	align-items: center;
	gap: var(--header-actions-gap);
	flex-shrink: 0;
}

.header-nav__account,
.header-nav__wishlist,
.header-nav__cart {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	color: var(--color-icon-header);
	text-decoration: none;
	line-height: 0;
}

.header-nav__account svg,
.header-nav__wishlist svg,
.header-nav__cart svg {
	display: block;
	width: 24px;
	height: 24px;
}

.header-nav__account:hover,
.header-nav__wishlist:hover,
.header-nav__cart:hover,
.header-nav__account:focus,
.header-nav__wishlist:focus,
.header-nav__cart:focus {
	opacity: 0.75;
	outline: none;
}

.header-nav__wishlist-count,
.header-nav__cart-count {
	position: absolute;
	right: -6px;
	top: -6px;
	width: 14px;
	height: 14px;
	background: var(--color-badge);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-lang);
	font-weight: var(--badge-text-weight);
	font-size: var(--badge-text);
	line-height: var(--badge-text-lh);
	color: var(--color-white);
}

/* --------------------------------------------------------------------------
   Download App
   -------------------------------------------------------------------------- */

.header-nav__download-app {
	position: absolute;
	right: 30px;
	top: calc(var(--header-bar-height) + 8px);
	z-index: 5;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 10px;
	width: 223px;
	height: 43px;
	padding: var(--button-padding);
	background: var(--color-white);
	border: 1px solid var(--color-accent);
	border-radius: var(--radius-button);
	text-decoration: none;
	box-sizing: border-box;
	color: var(--color-accent);
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.header-nav__download-app:hover,
.header-nav__download-app:focus {
	background: var(--color-white);
	border-color: var(--color-accent-hover);
	color: var(--color-accent-hover);
	outline: none;
}

.header-nav__download-app:hover .header-nav__download-app-text,
.header-nav__download-app:focus .header-nav__download-app-text,
.header-nav__download-app:hover .header-nav__download-app-icon,
.header-nav__download-app:focus .header-nav__download-app-icon {
	color: var(--color-accent-hover);
}

.header-nav__download-app-icon {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	display: block;
}

.header-nav__download-app-text {
	font-family: var(--font-body);
	font-style: normal;
	font-weight: var(--button-text-weight);
	font-size: var(--button-text);
	/* Not var(--button-text-lh): that 30px token is sized for the taller
	   hero/newsletter buttons. This button has an explicit 43px height
	   (Figma spec), so its text needs a tight, unforced line-height. */
	line-height: normal;
	letter-spacing: var(--button-letter-spacing);
	text-transform: none;
	color: var(--color-accent);
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Tablet
   -------------------------------------------------------------------------- */

@media screen and (min-width: 1201px) and (max-width: 1440px) {
	.header-nav__menu-list {
		gap: 24px;
	}

	.header-nav__right {
		gap: 16px;
	}

	.header-nav__search {
		width: 180px;
	}

	.header-nav__actions {
		gap: 16px;
	}

	.header-nav__download-app {
		right: 16px;
		padding: 10px 18px;
	}

	.header-nav__download-app-text {
		font-size: 12px;
		line-height: 24px;
	}
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */

@media screen and (max-width: 1200px) {
	.header-nav {
		height: 64px;
	}

	.header-nav__wrapper {
		height: 64px;
	}

	.header-nav__inner {
		position: relative;
		padding: 0 16px;
		gap: 12px;
	}

	.header-nav__menu-toggle {
		display: flex;
	}

	.header-nav__menu--primary {
		flex: 0 0 auto;
		padding-right: 0;
	}

	/*
	 * Off-canvas drawer. No Figma frame exists for it, so the sizing and type
	 * are derived from the tokens the rest of the header already uses.
	 *
	 * `visibility` rather than `display` so the slide can animate, and it is
	 * flipped after the transition on close so a shut drawer stays out of the
	 * tab order. JS only toggles `is-open`.
	 */
	/*
	 * Two-class selector deliberately: the base sheet carries
	 * `.header-nav .main-navigation { width: auto }` at (0,2,0), which outranks
	 * a lone `.header-nav__menu--primary` and collapses the drawer to its
	 * content width. Match its shape rather than reaching for !important.
	 */
	.header-nav .header-nav__menu--primary {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		flex-direction: column;
		align-items: stretch;
		width: var(--drawer-width);
		max-width: 100%;
		padding: 0;
		background: var(--color-white);
		box-shadow: 4px 0 24px rgba(11, 11, 11, 0.12);
		overflow-y: auto;
		overscroll-behavior: contain;
		visibility: hidden;
		transform: translateX(-100%);
		transition: transform var(--drawer-transition), visibility 0s linear 0.3s;
		z-index: 120;
	}

	.header-nav .header-nav__menu--primary.is-open {
		visibility: visible;
		transform: translateX(0);
		transition: transform var(--drawer-transition), visibility 0s;
	}

	.header-nav__drawer-head {
		display: flex;
		align-items: center;
		justify-content: flex-end;
		/* Matches the 64px mobile bar so the drawer lines up with it. */
		min-height: 64px;
		padding: 0 var(--drawer-pad);
		border-bottom: 1px solid var(--color-border-light);
	}

	.header-nav__drawer-close {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		/* Optical alignment with the 20px gutter, not the icon's own box. */
		margin-right: -8px;
		padding: 0;
		border: 0;
		background: transparent;
		color: var(--color-heading);
		cursor: pointer;
	}

	.header-nav__drawer-close:hover {
		color: var(--color-accent);
	}

	/*
	 * The close button is focused programmatically when the drawer opens, so a
	 * plain :focus ring would paint for mouse users on every open. :focus-visible
	 * keeps the ring for keyboard users only.
	 */
	.header-nav__drawer-close:focus {
		outline: none;
	}

	.header-nav__drawer-close:focus-visible,
	.header-nav__menu-list a:focus-visible {
		outline: 2px solid var(--color-accent);
		outline-offset: 2px;
	}

	.header-nav .main-navigation ul.header-nav__menu-list,
	.header-nav__menu--primary .header-nav__menu-list {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		width: 100%;
		margin: 0;
		padding: 8px var(--drawer-pad);
		box-sizing: border-box;
	}

	.header-nav__menu-list > li {
		display: block;
	}

	.header-nav__menu-list a {
		display: block;
		padding: 14px 0;
		font-size: 16px;
		line-height: 22px;
		white-space: normal;
	}

	.header-nav__drawer-extra {
		display: block;
		margin-top: auto;
		border-top: 1px solid var(--color-border-light);
	}

	.header-nav__menu-list--drawer a {
		color: var(--color-body-80);
	}

	/* Sub-menus open inline in the drawer rather than as a floating panel. */
	.header-nav__menu-list .sub-menu {
		position: static;
		display: block;
		margin: 0 0 0 12px;
		border: 0;
		box-shadow: none;
		padding: 0;
	}

	.header-nav__menu-list .sub-menu a {
		padding: 10px 0;
		font-size: 15px;
	}

	.header-nav__scrim {
		display: block;
		position: fixed;
		inset: 0;
		background: var(--color-drawer-scrim);
		opacity: 0;
		visibility: hidden;
		transition: opacity var(--drawer-transition), visibility 0s linear 0.3s;
		z-index: 110;
	}

	.header-nav__scrim.is-open {
		opacity: 1;
		visibility: visible;
		transition: opacity var(--drawer-transition), visibility 0s;
	}

	/* Stops the page scrolling behind an open drawer. */
	body.has-drawer-open {
		overflow: hidden;
	}

	/*
	 * Below 1200px the logo returns to the flow inside the white bar, where the
	 * rounded corners have nothing to sit against. Square it off there.
	 *
	 * `margin: 0 auto` only centred it within the space the flex row left over,
	 * which put it ~30px left of true centre; absolute centring pins it to the
	 * bar instead. The left toggle ends at ~60px and the right actions start at
	 * ~270px, so a 56px box at centre clears both.
	 */
	/* Containing block for the centred logo below. */
	.header-nav__inner {
		position: relative;
	}

	/*
	 * The 108px desktop band is a desktop proportion — on a phone it would eat
	 * most of the first screen, so the bar keeps its original 72px here and the
	 * mark is sized to fit it rather than to the reference ratio.
	 */
	.header-nav {
		--header-bar-height: 72px;
	}

	/* Artwork's own 3:2 canvas, as on desktop; the mark paints 67×54 inside. */
	.header-nav__logo-wrapper {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		width: 84px;
		height: 56px;
		margin: 0;
	}

	.header-nav__right {
		flex: 0 0 auto;
		padding-left: 0;
		gap: 12px;
	}

	/*
	 * Both of these move into the drawer below 1200px: About Us / Contact are
	 * re-rendered by `.header-nav__drawer-extra`, and search has no room in a
	 * bar that is now toggle + centred mark + icons. Leaving the secondary menu
	 * on the bar would duplicate the drawer entry and, on a folded Fold, run it
	 * straight over the logo.
	 */
	.header-nav__menu--secondary {
		display: none;
	}

	.header-nav__search {
		display: none;
	}

	.header-nav__download-app {
		display: none;
	}

	.header-nav__actions {
		gap: 14px;
	}
}

/* --------------------------------------------------------------------------
   Narrow phones
   -------------------------------------------------------------------------- */

/*
 * The mobile mark is absolutely centred, so it sits outside the flow the
 * toggle and the action icons share and nothing keeps the three apart. With a
 * 16px gutter and a 14px action gap the icons reach the centred 84px mark at
 * about 340px — which the folded Galaxy Fold (280px) is well inside.
 *
 * Tighten the gutter and the icon gap, then cap the mark at the width they
 * actually leave: half the bar, less the 88px the icons occupy and an 8px
 * breathing gap, doubled — i.e. 100vw - 216px, held at its normal 84px until
 * the viewport is narrow enough to bite (~300px).
 */
@media screen and (max-width: 380px) {
	.header-nav {
		--header-logo-w-narrow: min(84px, calc(100vw - 216px));
	}

	.header-nav__inner {
		padding: 0 12px;
	}

	.header-nav__actions {
		gap: 8px;
	}

	.header-nav__logo-wrapper {
		width: var(--header-logo-w-narrow);
		/* The artwork's own 3:2 canvas, as in the drawer block above. */
		height: calc(var(--header-logo-w-narrow) * 2 / 3);
	}
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	/*
	 * Drop the slide and fade but keep the visibility switch, so the drawer
	 * still leaves the tab order when closed.
	 */
	.header-nav .header-nav__menu--primary,
	.header-nav .header-nav__menu--primary.is-open,
	.header-nav__scrim,
	.header-nav__scrim.is-open {
		transition: none;
	}
}
