/* RESET & BASE ------------------------------------------------------------ */

.menu, .menu ul, .menu li {
	list-style: none;
	margin: 0;
	padding: 0;
}

.menu a {
	font-size: clamp(1rem, 0.25vw + 0.863rem, 1.125rem);
	line-height: clamp(1.65rem, 0.3vw + 1.485rem, 1.8rem);
	font-weight: 500;
	text-decoration: none;
	padding: 0.5rem 1rem;
	display: block;
	white-space: nowrap;
	box-sizing: border-box;
}

/* DESKTOP LAYOUT ---------------------------------------------------------- */

.menu {
	width: 100%;
}
.menu-list {
	display: flex;
	width: 100%;
	justify-content: flex-start;
	gap: 1rem;
}

.has-dropdown {
	position: relative;
}

.has-dropdown > a {
	position: relative;
	padding-right: 1.5rem;
}

.has-dropdown > a::after {
	content: "";
	position: absolute;
	right: 0;
	top: 50%;
	transform: translateY(-50%);
	width: 14px;
	height: 10px;
	background: url("../images/icons/arrow-down.svg") center center no-repeat;
	background-size: 14px 10px;
	pointer-events: none;
	transition: transform 0.25s ease;
}

/* Dropdown (desktop) */

ul.dropdown {
	position: absolute;
	left: 0;
	top: 100%;
	background: white;
	width: max-content;
	max-width: 400px;
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	transform: translateY(5px);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
	overflow-wrap: break-word;
	border-radius: 0 0 var(--borderRadSm) var(--borderRadSm);
	padding: 1rem 1rem 0.875rem;
	z-index: 50;
}

ul.dropdown a {
	font-size: 1rem;
	white-space: normal;
	word-break: break-word;
	background: var(--colMainPale);
	border-radius: var(--borderRadMin);
	margin-bottom: 0.125rem;
}

ul.dropdown a:hover {
	background: var(--colMain);
	color: var(--colWhite);
}

/* search */

li.search {
	margin-left: auto;
	display: flex;
	flex-wrap: wrap;
	align-content: center;
}

li.search a {
	background: url("../images/icons/search.svg") center no-repeat;
	background-size: 1.5rem 1.5rem;
	width: 1.5rem;
	height: 1.5rem;
}

/* Show dropdown on hover (desktop only) */

@media (min-width: 881px) {
	.has-dropdown:hover .dropdown,
	.has-dropdown:focus-within .dropdown {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
	}
}

@media (max-width: 1100px) {
	li:nth-last-child(2) ul.dropdown {
		left: -6.5rem;
	}
}

@media (max-width: 959px) {
	.menu-list {
		gap: 0.75rem;
	}
}

/* MOBILE ------------------------------------------------------------------ */

.menu-toggle {
	display: none;
}

@media (max-width: 880px) {
	.header.wrap::after {
		content: '';
		display: block;
		width: 100%;
		height: 4.875rem;
		position: fixed;
		background: var(--colWhite);
		left: 0;
		top: 0;
		z-index: 99;
	}
	.menu {
		position: fixed !important;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 900;
		pointer-events: none; /* menu closed */
	}
	.menu.open {
		pointer-events: auto;
	}
	.menu-list {
		position: fixed !important;
		height: 100vh;
		overflow-y: auto;
	}
	.menu-toggle {
		display: block;
		position: relative;
		z-index: 1000;
	}

	/* Full-screen menu panel */
	.menu-list {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: white;
		flex-direction: column;
		padding: 5rem 0 1rem 0 !important;
		opacity: 0;
		transition: opacity 0.3s ease-out;
		z-index: 100;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateZ(0);
		box-sizing: border-box;
	}

	.menu.open .menu-list {
		opacity: 1;
	}

	/* Top-level items */
	#main-menu > li > a {
		padding-left: 0;
		padding-right: 0;
		margin-left: calc(4% + 0.5rem);
		margin-right: calc(4% + 0.5rem);
		border-bottom: 1px solid var(--colMainMidAlpha);
	}
	#main-menu > li.has-dropdown.open > a {
		border-bottom-color: transparent;
	}

	/* Accordion dropdowns */
	ul.dropdown {
		max-height: 0;
		overflow: hidden;
		opacity: 1;
		visibility: visible;
		transition: max-height 0.3s ease;
		position: static;
		border: none;
		width: 100%;
		max-width: 100%;
		padding: 0 1.5rem;
	}

	.has-dropdown.open > ul.dropdown {
		max-height: 80vh;
	}
	li:nth-last-child(2) ul.dropdown {
		left: 0;
	}
	/* Scroll long dropdowns */
	/*.has-dropdown.open > ul.dropdown {
		overflow-y: auto;
		max-height: 60vh;
		-webkit-overflow-scrolling: touch;
	}*/

	/* Arrow rotation */
	.has-dropdown > a::after {
		right: 0.5rem;
		transition: transform 0.25s ease;
	}
	.has-dropdown.open > a::after {
		transform: translateY(-50%) rotate(180deg);
	}
	
	li.search {
		margin-left: 0;
		display: block;
	}

	li.search a {
		background: url("../images/icons/search.svg") calc(100% - 0.25rem) 40% no-repeat;
		background-size: 1.25rem 1.25rem;
		width: auto;
		height: 3rem;
		box-sizing: border-box;
		transition: none;
	}
	li.search a::after {
		content: 'Search';
		font-size: clamp(1rem, 0.25vw + 0.863rem, 1.125rem);
	}

}