/*
 * Menu block, modelled on plleki.com's Ledger site nav: 36px pill items with a quiet hover tint,
 * a 12px chevron on anything that opens, a card dropdown for plain sub-menus, and a hamburger
 * below 1024px (the Mega Menu module's own breakpoint). Mega menu triggers (.stripe-mm__trigger)
 * share the pill rules; their hover / open tints are fed to the module through its variables.
 */

.wb-menu {
	--wb-menu-height: 36px;
	--wb-menu-radius: 999px;
	--wb-menu-color: #0c0c0d;
	--wb-menu-chevron: #68655f;
	--wb-menu-hover-color: var(--wb-menu-color);
	--wb-menu-hover-bg: #f6f5f1;
	--wb-menu-active-color: var(--wb-menu-color);
	--wb-menu-active-bg: #f2edfc;
	--wb-menu-dd-bg: #ffffff;
	--wb-menu-dd-border: #e4e2db;
	--wb-menu-dd-color: var(--wb-menu-color);
	--wb-menu-dd-hover-bg: #f6f5f1;
	--wb-menu-dd-width: 240px;
	--wb-menu-dd-radius: 12px;
}

/* The header (or outermost container) a menu lives in, marked by frontend.js: above the page content. */
.wb-menu-host {
	z-index: 100;
}

.wb-menu .wb-menu__nav {
	display: flex;
	align-items: center;
	justify-content: flex-start;
}

.wb-menu .wb-menu__drawer {
	display: contents;
}

.wb-menu .wb-menu__list,
.wb-menu .wb-menu__list ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wb-menu .wb-menu__list {
	display: flex;
	align-items: center;
	gap: 4px;
}

.wb-menu .wb-menu__list li {
	position: relative;
	margin: 0;
}

/* ---------- Top-level pills (plain links and mega menu triggers alike) ---------- */

.wb-menu .wb-menu__item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: var(--wb-menu-height);
	padding: 0 12px;
	border-radius: var(--wb-menu-radius);
	color: var(--wb-menu-color);
	font-size: 14px;
	font-weight: 500;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 150ms cubic-bezier(0.25, 0.1, 0.25, 1), color 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.wb-menu .wb-menu__item:hover,
.wb-menu .wb-menu__item:focus-visible,
.wb-menu li:focus-within > .wb-menu__item {
	color: var(--wb-menu-hover-color);
	background-color: var(--wb-menu-hover-bg);
}

.wb-menu .current-menu-item > .wb-menu__item,
.wb-menu .current-menu-ancestor > .wb-menu__item,
.wb-menu li.stripe-mm.is-open > .wb-menu__item {
	color: var(--wb-menu-active-color);
	background-color: var(--wb-menu-active-bg);
}

.wb-menu .wb-menu__item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Mega menu trigger: the module makes the <span> the pill; its link and chevron sit inside. */
.wb-menu .stripe-mm-nav li.stripe-mm > .stripe-mm__trigger > a {
	padding: 0;
	color: inherit;
	font: inherit;
	text-decoration: none;
}

.wb-menu .stripe-mm-nav .stripe-mm__toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 12px;
	height: 12px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--wb-menu-chevron);
	cursor: pointer;
}

/* The trigger's screen-reader label (module CSS normally hides it; repeated here so the block never shows it). */
.wb-menu .stripe-mm__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.wb-menu .stripe-mm__panel[hidden] {
	display: none;
}

.wb-menu .stripe-mm-nav .stripe-mm__chevron {
	width: 12px;
	height: 12px;
}

/* The module's own pill tints follow the block's controls. */
.wb-menu .stripe-mm-nav {
	--stripe-mm-hover: var(--wb-menu-hover-bg);
	--stripe-mm-active: var(--wb-menu-active-bg);
	--stripe-mm-muted: var(--wb-menu-chevron);
}

/* Chevron on items whose children form a dropdown. */
.wb-menu .menu-item-has-children > .wb-menu__item::after {
	content: "";
	width: 12px;
	height: 12px;
	flex-shrink: 0;
	background: currentColor;
	color: var(--wb-menu-chevron);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.wb-menu .menu-item-has-children:hover > .wb-menu__item::after,
.wb-menu .menu-item-has-children:focus-within > .wb-menu__item::after,
.wb-menu .menu-item-has-children.is-open > .wb-menu__item::after {
	transform: rotate(180deg);
}

/* ---------- Dropdown (plain sub-menus) ---------- */

.wb-menu .wb-menu__list .sub-menu a {
	display: block;
	padding: 8px 10px;
	border-radius: calc(var(--wb-menu-dd-radius) - 4px);
	color: var(--wb-menu-dd-color);
	font-size: 14px;
	text-decoration: none;
	transition: background-color 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.wb-menu .wb-menu__list .sub-menu a:hover,
.wb-menu .wb-menu__list .sub-menu a:focus-visible {
	background-color: var(--wb-menu-dd-hover-bg);
}

@media (min-width: 1024px) {
	.wb-menu .wb-menu__toggle {
		display: none;
	}

	.wb-menu .wb-menu__list > li > .sub-menu {
		position: absolute;
		top: calc(100% + 6px);
		left: 0;
		z-index: 1000;
		min-width: var(--wb-menu-dd-width);
		padding: 6px;
		background: var(--wb-menu-dd-bg);
		border: 1px solid var(--wb-menu-dd-border);
		border-radius: var(--wb-menu-dd-radius);
		box-shadow: 0 1px 2px rgba(12, 12, 13, 0.05), 0 8px 20px rgba(12, 12, 13, 0.08);
		opacity: 0;
		visibility: hidden;
		transform: translateY(-6px);
		transition: opacity 150ms cubic-bezier(0.25, 0.1, 0.25, 1), transform 150ms cubic-bezier(0.25, 0.1, 0.25, 1), visibility 0s linear 150ms;
	}

	/* Keeps the pointer inside the item across the 6px gap. */
	.wb-menu .wb-menu__list > li.menu-item-has-children::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		height: 8px;
	}

	.wb-menu .wb-menu__list > li:hover > .sub-menu,
	.wb-menu .wb-menu__list > li:focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition-delay: 0s;
	}
}

/* ---------- Below 1024px: hamburger and a vertical drawer ---------- */

@media (max-width: 1023.98px) {
	.wb-menu .wb-menu__nav--collapsible {
		position: relative;
	}

	.wb-menu .wb-menu__toggle {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		padding: 0;
		border: 0;
		border-radius: var(--wb-menu-radius);
		background: transparent;
		color: var(--wb-menu-color);
		cursor: pointer;
	}

	.wb-menu .wb-menu__toggle:hover {
		background: var(--wb-menu-hover-bg);
	}

	.wb-menu .wb-menu__toggle-bar,
	.wb-menu .wb-menu__toggle-bar::before,
	.wb-menu .wb-menu__toggle-bar::after {
		display: block;
		width: 18px;
		height: 2px;
		border-radius: 2px;
		background: currentColor;
		transition: transform 150ms cubic-bezier(0.25, 0.1, 0.25, 1), opacity 150ms;
	}

	.wb-menu .wb-menu__toggle-bar {
		position: relative;
	}

	.wb-menu .wb-menu__toggle-bar::before,
	.wb-menu .wb-menu__toggle-bar::after {
		content: "";
		position: absolute;
		left: 0;
	}

	.wb-menu .wb-menu__toggle-bar::before {
		top: -6px;
	}

	.wb-menu .wb-menu__toggle-bar::after {
		top: 6px;
	}

	.wb-menu .wb-menu__toggle[aria-expanded="true"] .wb-menu__toggle-bar {
		background: transparent;
	}

	.wb-menu .wb-menu__toggle[aria-expanded="true"] .wb-menu__toggle-bar::before {
		transform: translateY(6px) rotate(45deg);
	}

	.wb-menu .wb-menu__toggle[aria-expanded="true"] .wb-menu__toggle-bar::after {
		transform: translateY(-6px) rotate(-45deg);
	}

	.wb-menu .wb-menu__nav--collapsible .wb-menu__drawer {
		display: none;
		position: absolute;
		top: calc(100% + 8px);
		right: 0;
		z-index: 1000;
		width: min(100vw - 32px, 360px);
		padding: 8px;
		background: var(--wb-menu-dd-bg);
		border: 1px solid var(--wb-menu-dd-border);
		border-radius: var(--wb-menu-dd-radius);
		box-shadow: 0 1px 2px rgba(12, 12, 13, 0.05), 0 8px 20px rgba(12, 12, 13, 0.08);
	}

	.wb-menu .wb-menu__nav--collapsible.is-open .wb-menu__drawer {
		display: block;
		max-height: calc(100vh - 100px);
		overflow-y: auto;
		overscroll-behavior: contain;
		scrollbar-width: thin;
		scrollbar-color: var(--wb-menu-chevron) transparent;
	}

	.wb-menu .wb-menu__list {
		flex-direction: column;
		align-items: stretch;
		gap: 2px;
	}

	/* Label on the left, chevron on the right, as in a native list. */
	.wb-menu .wb-menu__item {
		display: flex;
		justify-content: space-between;
		width: 100%;
		height: auto;
		min-height: var(--wb-menu-height);
		border-radius: calc(var(--wb-menu-dd-radius) - 4px);
		white-space: normal;
	}

	.wb-menu .stripe-mm-nav li.stripe-mm > .stripe-mm__trigger {
		width: 100%;
		justify-content: space-between;
	}

	/* The whole pill opens the panel (frontend.js); its link never navigates in the drawer, even when it has a real URL. */
	.wb-menu .stripe-mm-nav li.stripe-mm > .stripe-mm__trigger > a {
		pointer-events: none;
	}

	.wb-menu .wb-menu__list .sub-menu {
		padding: 2px 0 6px 12px;
	}

	.wb-menu .wb-menu__list li:not(.stripe-mm) > .sub-menu {
		display: none;
	}

	.wb-menu .wb-menu__list li.is-open > .sub-menu {
		display: block;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wb-menu * {
		transition-duration: 0.01ms !important;
	}
}
