/* stylelint-disable no-descending-specificity -- focus-visible state order */

/**
 * Apex mobile menu — full-screen overlay (Figma "Mobile Menu").
 *
 * Toggled by the header hamburger (assets/js/mobile-menu.js). Reuses the
 * "primary" menu (via [apex_mobile_nav]) and the footer legal menu. Charters
 * (any item with children) expands as an accordion.
 */

.apex-mobile-menu {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--cream);
	visibility: hidden;
	pointer-events: none;

	/* Iris reveal: the panel grows out of (and collapses back into) the
	   hamburger / close corner, top-right. */
	clip-path: circle(0% at calc(100% - 2rem) 2.3rem);
	transition:
		clip-path 0.45s ease-in-out,
		visibility 0s linear 0.45s;
}

.apex-mobile-menu.is-open {
	visibility: visible;
	pointer-events: auto;
	clip-path: circle(150% at calc(100% - 2rem) 2.3rem);
	transition:
		clip-path 0.45s ease-in-out,
		visibility 0s;
}

/* Graceful entrance: the panel fades in while its rows rise + fade in sequence
   (and back out, in order, on close). Delays sit on the rows so the cascade
   runs both ways. */
.apex-mobile-menu-list > .menu-item,
.apex-mobile-menu__contact,
.apex-mobile-menu .apex-footer-legal {
	opacity: 0;
	transform: translateY(18px);
	transition: opacity 0.4s ease, transform 0.4s ease;
}

.apex-mobile-menu.is-open .apex-mobile-menu-list > .menu-item,
.apex-mobile-menu.is-open .apex-mobile-menu__contact,
.apex-mobile-menu.is-open .apex-footer-legal {
	opacity: 1;
	transform: none;
}

.apex-mobile-menu-list > .menu-item:nth-child(1) {
	transition-delay: 0.08s;
}

.apex-mobile-menu-list > .menu-item:nth-child(2) {
	transition-delay: 0.14s;
}

.apex-mobile-menu-list > .menu-item:nth-child(3) {
	transition-delay: 0.2s;
}

.apex-mobile-menu-list > .menu-item:nth-child(4) {
	transition-delay: 0.26s;
}

/* (contact + legal rows get their stagger delays on their base rules below.) */

/* Cancel the group block-gap margins. */
.apex-mobile-menu > * {
	margin-block: 0;
}

/* Never render on desktop (the inline nav is used instead). */
@media ( min-width: 900px ) {

	.apex-mobile-menu {
		display: none !important;
	}
}

body.apex-menu-open {
	overflow: hidden;
}

/* Keyboard-only focus ring (cream), no ring for mouse/programmatic focus. */
.apex-header__toggle:focus:not(:focus-visible),
.apex-mobile-menu__close:focus:not(:focus-visible),
.apex-mobile-nav__expand:focus:not(:focus-visible) {
	outline: none;
}

.apex-header__toggle:focus-visible,
.apex-mobile-menu__close:focus-visible,
.apex-mobile-nav__expand:focus-visible,
.apex-mobile-menu a:focus-visible {
	outline: 1px solid var(--wp--preset--color--cream);
	outline-offset: 3px;
}

/* Top bar: logo + close ---------------------------------------------------- */
.apex-mobile-menu__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 27px clamp(1rem, 3.5vw, 2rem);
}

.apex-mobile-menu__logo {
	display: inline-flex;
	color: var(--wp--preset--color--cream);
	line-height: 0;
}

.apex-mobile-menu__logo svg {
	display: block;
	width: 120px;
	height: auto;
}

.apex-mobile-menu__close {
	flex: 0 0 auto;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--cream);
	cursor: pointer;
}

/* The close button reuses the shared three-bar icon (assets/css/header.css)
   and morphs hamburger -> X as the overlay opens, so it reads as the header
   hamburger transforming into a close icon in place. */
.apex-mobile-menu.is-open .apex-mobile-menu__close .apex-header__toggle-bar:nth-child(1) {
	top: 50%;
	width: 100%;
	transform: translateY(-50%) rotate(45deg);
}

.apex-mobile-menu.is-open .apex-mobile-menu__close .apex-header__toggle-bar:nth-child(2) {
	opacity: 0;
}

.apex-mobile-menu.is-open .apex-mobile-menu__close .apex-header__toggle-bar:nth-child(3) {
	top: 50%;
	width: 100%;
	transform: translateY(-50%) rotate(-45deg);
}

/* Primary navigation ------------------------------------------------------- */
.apex-mobile-nav {
	margin-top: 40px;
	padding: clamp(1.5rem, 7vw, 3rem) clamp(1.75rem, 8vw, 2.75rem) 0;
}

.apex-mobile-menu-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.apex-mobile-menu-list > .menu-item {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	border-bottom: 0.5px solid rgba(250, 249, 244, 0.4);
}

.apex-mobile-menu-list > .menu-item > a {
	flex: 1 1 auto;
	padding: 0.7rem 0;
	color: var(--wp--preset--color--cream);
	font-family: Inter, sans-serif;
	font-weight: 200;
	font-size: 30px;
	line-height: 40px;
	text-decoration: none;
}

/* Accordion toggle (the "+" / "−"). */
.apex-mobile-nav__expand {
	flex: 0 0 auto;
	width: 2.5rem;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--cream);
	font-family: Inter, sans-serif;
	font-weight: 100;
	font-size: 30px;
	line-height: 1;
	text-align: right;
	cursor: pointer;
}

.apex-mobile-nav__expand::after {
	content: "+";
}

.apex-mobile-nav__expand[aria-expanded="true"]::after {
	content: "\2212"; /* minus sign */
}

/* Submenu (hidden until expanded). */
.apex-mobile-menu-list .sub-menu {
	flex: 1 1 100%;
	max-height: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	list-style: none;
	transition: max-height 0.3s ease;
}

.apex-mobile-menu-list .menu-item-has-children.is-expanded > .sub-menu {
	max-height: 60vh;
}

.apex-mobile-menu-list .sub-menu .menu-item:first-child {
	padding-top: 0.25rem;
}

.apex-mobile-menu-list .sub-menu .menu-item:last-child {
	padding-bottom: 1rem;
}

.apex-mobile-menu-list .sub-menu a {
	display: block;
	padding: 0.5rem 0 0.5rem 36px;
	color: var(--wp--preset--color--cream);
	font-family: Inter, sans-serif;
	font-weight: 300;
	font-size: 18px;
	line-height: 28px;
	text-decoration: none;
	opacity: 0.85;
}

/* Contact quick links ------------------------------------------------------ */
.apex-mobile-menu__contact {
	transition-delay: 0.32s; /* entrance stagger (see graceful entrance above) */
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
	padding: clamp(1.5rem, 7vw, 2.5rem) clamp(1.75rem, 8vw, 2.75rem) 0;
}

.apex-mobile-menu__contact-link {
	display: inline-flex;
	width: fit-content;
	color: var(--wp--preset--color--cream);
}

.apex-mobile-menu__icon {
	display: block;
	width: 40px;
	height: 40px;
	background-color: var(--wp--preset--color--cream);
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-size: contain;
	mask-size: contain;
}

.apex-mobile-menu__icon--clock {
	-webkit-mask-image: url(../images/icon-clock.svg);
	mask-image: url(../images/icon-clock.svg);
}

.apex-mobile-menu__icon--email {
	-webkit-mask-image: url(../images/icon-email.svg);
	mask-image: url(../images/icon-email.svg);
}

/* Legal links (reuses footer legal menu, restyled to a left column). */
.apex-mobile-menu .apex-footer-legal {
	margin-top: auto;
	padding: clamp(2rem, 9vw, 3rem) clamp(1.75rem, 8vw, 2.75rem) clamp(2rem, 9vw, 3rem);
	transition-delay: 0.38s; /* entrance stagger (see graceful entrance above) */
}

.apex-mobile-menu .apex-footer-legal-menu {
	flex-direction: column;
	align-items: flex-start;
	justify-content: flex-start;
	gap: 1rem;
}

.apex-mobile-menu .apex-footer-legal-menu a {
	color: var(--wp--preset--color--cream);
	font-size: 12px;
	text-decoration: none;
}

/* Respect reduced-motion: no slides or morph, just show / hide. */
@media ( prefers-reduced-motion: reduce ) {

	.apex-mobile-menu,
	.apex-mobile-menu-list > .menu-item,
	.apex-mobile-menu__contact,
	.apex-mobile-menu .apex-footer-legal,
	.apex-header__toggle-bar {
		transition: none;
	}

	.apex-mobile-menu-list > .menu-item,
	.apex-mobile-menu__contact,
	.apex-mobile-menu .apex-footer-legal {
		transform: none;
	}
}
