/**
 * Mobile menu: sub-menus open as animated drop-downs (toggled by js/mobile-menu.js).
 * Loaded after child-theme.min.css, which hides .mobile-menu ul.sub-menu.
 */

.mobile-menu {
	--mm-speed: .35s; /* keep in step with DURATION in js/mobile-menu.js */
	--mm-ease: cubic-bezier(.4, 0, .2, 1);
	--mm-green: #3db737;
}

/* Let the panel scroll when several drop-downs are open.
   dvh = the visible height on phones whose browser bars come and go (iOS Safari, Chrome Android). */
.mobile-menu {
	height: 100vh;
	height: 100dvh;
	align-items: flex-start !important;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}
.mobile-menu > .w-100 {
	margin: auto 0;
	padding: 6rem 1rem 3rem;
	padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
}

/* Top-level items: a little smaller on very narrow phones so names fit on one line */
@media (max-width: 359px) {
	.mobile-menu .mobile-menu-ul > li { font-size: 1.6rem; }
}

.mobile-menu li > a {
	display: inline-block;
	vertical-align: middle;
	-webkit-tap-highlight-color: transparent;
}
/* Long names wrap inside the link, so the chevron always stays beside them */
.mobile-menu li.menu-item-has-children > a {
	max-width: calc(100% - 44px);
	line-height: 1.2;
}

/* ---- Chevron button next to an item that has a sub-menu ---- */
.mobile-menu .mm-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	vertical-align: middle;
	width: 44px;   /* Apple / Google minimum tap size */
	height: 44px;
	margin: -6px -6px -6px 0;
	padding: 0;
	border: 0;
	background: transparent;
	color: #fff;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	touch-action: manipulation;
}
.mobile-menu .mm-chevron {
	position: relative;
	display: block;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .1);
	transition: background-color var(--mm-speed) var(--mm-ease), transform var(--mm-speed) var(--mm-ease);
}
/* the "v" */
.mobile-menu .mm-chevron::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 8px;
	height: 8px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translate(-50%, -70%) rotate(45deg);
}
.mobile-menu li.is-expanded:not(.is-closing) > .mm-toggle .mm-chevron {
	transform: rotate(180deg);
	background: var(--mm-green);
}
.mobile-menu .mm-toggle:active .mm-chevron {
	background: rgba(255, 255, 255, .25);
}
@media (hover: hover) {
	.mobile-menu .mm-toggle:hover .mm-chevron { background: rgba(255, 255, 255, .2); }
	.mobile-menu li.is-expanded:not(.is-closing) > .mm-toggle:hover .mm-chevron { background: var(--mm-green); }
}
.mobile-menu .mm-toggle:focus { outline: none; }
.mobile-menu .mm-toggle:focus-visible .mm-chevron {
	outline: 2px solid var(--mm-green);
	outline-offset: 2px;
}

/* Smaller chevron for nested levels */
.mobile-menu .sub-menu .mm-chevron { width: 24px; height: 24px; }
.mobile-menu .sub-menu .mm-chevron::before { width: 7px; height: 7px; }

/* The open item's name turns green */
.mobile-menu li.is-expanded:not(.is-closing) > a { color: var(--mm-green); }

/* ---- Sub-menus ---- */
.mobile-menu ul.sub-menu {
	padding: 1rem 0 .25rem; /* padding, not margin, so the height animation includes it */
	margin: 0;
	list-style: none;
}
.mobile-menu li.is-expanded > ul.sub-menu {
	display: block;
}
.mobile-menu ul.sub-menu.is-animating {
	overflow: hidden;
	transition: height var(--mm-speed) var(--mm-ease);
}

/* Items fade and slide in as the drop-down opens */
.mobile-menu .sub-menu > li {
	font-size: 1.25rem;
	margin-bottom: 1rem;
	letter-spacing: .5px;
	transition: opacity var(--mm-speed) var(--mm-ease), transform var(--mm-speed) var(--mm-ease);
}
.mobile-menu li.is-expanded > .sub-menu.is-animating > li {
	animation: mm-in var(--mm-speed) var(--mm-ease) both;
}
.mobile-menu li.is-expanded > .sub-menu.is-animating > li:nth-child(2) { animation-delay: .03s; }
.mobile-menu li.is-expanded > .sub-menu.is-animating > li:nth-child(3) { animation-delay: .06s; }
.mobile-menu li.is-expanded > .sub-menu.is-animating > li:nth-child(4) { animation-delay: .09s; }
.mobile-menu li.is-expanded > .sub-menu.is-animating > li:nth-child(n+5) { animation-delay: .12s; }
.mobile-menu li.is-closing > .sub-menu > li {
	animation: none;
	opacity: 0;
	transform: translateY(-6px);
}
@keyframes mm-in {
	from { opacity: 0; transform: translateY(-8px); }
	to   { opacity: 1; transform: none; }
}

.mobile-menu .sub-menu .sub-menu {
	padding-top: .75rem;
}
.mobile-menu .sub-menu .sub-menu > li {
	font-size: 1rem;
	margin-bottom: .75rem;
	text-transform: none;
}
.mobile-menu .sub-menu .sub-menu a {
	color: rgba(255, 255, 255, .75);
}

/* Highlight the current page */
.mobile-menu .current-menu-item > a,
.mobile-menu .sub-menu .current-menu-item > a {
	color: var(--mm-green);
}

@media (prefers-reduced-motion: reduce) {
	.mobile-menu .mm-chevron,
	.mobile-menu ul.sub-menu.is-animating,
	.mobile-menu .sub-menu > li {
		transition: none;
		animation: none !important;
	}
}
