/**
 * The touch navigation panel.
 *
 * Visibility is driven entirely by aria-expanded on the burger, which the
 * exported page script already maintains — one source of truth, no second
 * toggle to drift out of sync. The `max-height` override is there because that
 * script also sets an inline max-height on this element for its old expanding
 * behaviour; !important is the only way past an inline declaration.
 */

.mnav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	/* Sits under the header bar, which stays visible and keeps the close button. */
	top: var(--mnav-top, 118px);
	z-index: 900;
	display: flex;
	max-height: none !important;
	overflow: visible !important;
	background: #080D10;
	/* Hidden by default, and inert so it cannot be tabbed into while closed. */
	visibility: hidden;
	opacity: 0;
	transform: translateY(-10px);
	transition: opacity .34s cubic-bezier(.16, 1, .3, 1),
	            transform .34s cubic-bezier(.16, 1, .3, 1),
	            visibility 0s linear .34s;
}

header:has([data-burger][aria-expanded="true"]) .mnav {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition-delay: 0s, 0s, 0s;
}

/* The in-panel header row belongs to the full-screen layout only; on a phone
   the real header stays visible above the panel and carries the close button. */
.mnav-top {
	display: none;
}

.mnav-inner {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: calc(1920px + 2 * clamp(20px, 3.2vw, 46px));
	margin: 0 auto;
	padding: 0 clamp(20px, 3.2vw, 46px);
	min-height: 0;
}

/* The list scrolls; the call to action below it does not. */
.mnav-scroll {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: clamp(6px, 1.4vh, 16px) 0 clamp(12px, 2vh, 22px);
}

/* --- top-level links ---------------------------------------------------- */

.mnav-link,
.mnav-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	width: 100%;
	min-height: 56px;
	padding: 10px 0;
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
	font-family: 'Bricolage Grotesque', system-ui, sans-serif;
	font-size: clamp(23px, 2.6vw, 29px);
	line-height: 1.15;
	letter-spacing: -0.015em;
	color: #FFFFFF;
	transition: color .25s;
}

.mnav-link[aria-current="page"] {
	color: #4C8DFF;
}

/* --- collapsible groups -------------------------------------------------- */

.mnav-group {
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mnav-group > .mnav-summary {
	border-bottom: 0;
	cursor: pointer;
	list-style: none;
}

/* Safari still paints the default marker without this. */
.mnav-summary::-webkit-details-marker {
	display: none;
}

.mnav-summary:focus-visible {
	outline: 2px solid #4C8DFF;
	outline-offset: 3px;
}

.mnav-chev {
	flex: 0 0 auto;
	width: 11px;
	height: 11px;
	margin-right: 4px;
	border-right: 2px solid rgba(255, 255, 255, 0.55);
	border-bottom: 2px solid rgba(255, 255, 255, 0.55);
	transform: rotate(45deg);
	transform-origin: 60% 60%;
	transition: transform .3s cubic-bezier(.16, 1, .3, 1), border-color .25s;
}

.mnav-group[open] > .mnav-summary .mnav-chev {
	transform: rotate(-135deg);
	border-color: #4C8DFF;
}

.mnav-sub {
	padding: 2px 0 14px;
}

.mnav-sublink {
	display: flex;
	align-items: center;
	min-height: 46px;
	padding: 6px 0 6px 16px;
	border-left: 1px solid rgba(255, 255, 255, 0.14);
	margin-left: 3px;
	font-family: 'Albert Sans', system-ui, sans-serif;
	font-size: 15.5px;
	line-height: 1.35;
	color: rgba(255, 255, 255, 0.72);
	transition: color .25s, border-color .25s;
}

.mnav-sublink--all {
	color: #FFFFFF;
	font-weight: 600;
}

.mnav-sublink[aria-current="page"] {
	color: #4C8DFF;
	border-color: #4C8DFF;
}

/* --- pinned footer ------------------------------------------------------- */

.mnav-foot {
	flex: 0 0 auto;
	padding: clamp(12px, 2vh, 18px) 0 calc(clamp(16px, 2.6vh, 26px) + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid rgba(255, 255, 255, 0.14);
	background: #080D10;
}

.mnav-cta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 58px;
	padding: 16px 22px;
	border-radius: 10px;
	background: #0057FF;
	color: #FFFFFF;
	font-family: 'Albert Sans', system-ui, sans-serif;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	transition: background-color .25s;
}

.mnav-contact {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 10px;
	margin-top: 14px;
	font-family: 'Albert Sans', system-ui, sans-serif;
	font-size: 14.5px;
	color: rgba(255, 255, 255, 0.55);
}

.mnav-contact a {
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	color: rgba(255, 255, 255, 0.82);
	border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}

/* ---------------------------------------------------------------------------
 * Tablet: a full-screen menu with everything on show.
 *
 * A phone has to ration vertical space, so the groups collapse there. A tablet
 * does not — so from 700px up the panel covers the whole viewport, carries its
 * own logo and close button, and shows every link at once with the two groups
 * side by side. Nothing is hidden behind a tap.
 *
 * The min-height is as important as the min-width. Gated on width alone, a
 * phone in landscape (844x390) also matched, and got the full-screen layout
 * with both groups expanded into 212px of usable height — 480px of content in
 * a 212px window, most of the links cut off. Height is what this layout
 * actually needs.
 * ------------------------------------------------------------------------ */
@media (min-width: 700px) and (min-height: 600px) {
	.mnav {
		top: 0;
		/* Above the site header, which this layout deliberately covers. */
		z-index: 1200;
	}

	.mnav-top {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 20px;
		flex: 0 0 auto;
		padding: clamp(18px, 2.4vh, 30px) 0 clamp(14px, 2vh, 24px);
		border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	}

	.mnav-logo img {
		height: clamp(34px, 3vw, 44px);
		width: auto;
		display: block;
	}

	.mnav-close {
		flex: 0 0 auto;
		position: relative;
		width: 54px;
		height: 54px;
		border: 0;
		border-radius: 100px;
		background: #FFFFFF;
		cursor: pointer;
		transition: transform .25s;
	}

	.mnav-close span {
		position: absolute;
		left: 50%;
		top: 50%;
		width: 19px;
		height: 1.6px;
		margin: -0.8px 0 0 -9.5px;
		background: #080D10;
	}

	.mnav-close span:first-child {
		transform: rotate(45deg);
	}

	.mnav-close span:last-child {
		transform: rotate(-45deg);
	}

	.mnav-close:focus-visible {
		outline: 2px solid #4C8DFF;
		outline-offset: 3px;
	}

	.mnav-inner {
		max-width: calc(1400px + 2 * clamp(24px, 4vw, 64px));
		padding: 0 clamp(24px, 4vw, 64px);
	}

	.mnav-scroll {
		display: grid;
		grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr);
		/* Centre the block in whatever height is left rather than hugging the
		   top — on an iPad there is a lot of it, and a menu pinned to the top
		   with half a screen of nothing under it looks unfinished. */
		align-content: center;
		gap: clamp(20px, 2.6vw, 56px);
		padding: clamp(22px, 3.4vh, 44px) 0 clamp(18px, 2.6vh, 32px);
	}

	/* Primary links get the display treatment — this is the "big" part. */
	.mnav-primary {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
	}

	.mnav-primary .mnav-link {
		justify-content: flex-start;
		min-height: 0;
		padding: clamp(8px, 1.4vh, 16px) 0;
		border-bottom: 0;
		font-size: clamp(44px, 6.6vw, 82px);
		line-height: 1.02;
		letter-spacing: -0.028em;
		/* These labels are short; letting them break looks like a mistake. */
		white-space: nowrap;
	}

	/* The two groups sit side by side, fully expanded. */
	.mnav-groups {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: clamp(18px, 2.2vw, 44px);
		align-content: start;
	}

	.mnav-group {
		border-bottom: 0;
	}

	/* The script opens these groups for real (see mobile-nav.js) — a closed
	   <details> gets content-visibility:hidden in current Chrome, so overriding
	   display lays the links out but never paints them. These two rules are the
	   no-JS fallback, and are harmless once the attribute is set. */
	.mnav-group > .mnav-sub {
		display: block !important;
		padding: 4px 0 0;
	}

	.mnav-group::details-content {
		content-visibility: visible;
	}

	/* The summary becomes a plain heading — there is nothing left to toggle. */
	.mnav-summary {
		pointer-events: none;
		min-height: 0;
		padding: 0 0 16px;
		margin-bottom: 6px;
		border-bottom: 1px solid rgba(255, 255, 255, 0.14);
		font-family: 'Albert Sans', system-ui, sans-serif;
		font-size: 12.5px;
		font-weight: 600;
		letter-spacing: 0.15em;
		text-transform: uppercase;
		color: rgba(255, 255, 255, 0.55);
	}

	.mnav-chev {
		display: none;
	}

	.mnav-sublink {
		min-height: 50px;
		padding: 6px 0;
		margin-left: 0;
		border-left: 0;
		font-size: clamp(15.5px, 1.55vw, 19px);
		color: rgba(255, 255, 255, 0.8);
	}

	.mnav-sublink--all {
		color: #FFFFFF;
	}

	.mnav-sublink[aria-current="page"] {
		color: #4C8DFF;
	}

	.mnav-foot {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-between;
		gap: 18px clamp(24px, 3vw, 48px);
		padding-top: clamp(16px, 2.4vh, 26px);
	}

	.mnav-cta {
		flex: 0 1 auto;
		min-width: min(100%, 300px);
		font-size: 15px;
	}

	.mnav-contact {
		margin-top: 0;
		font-size: 16px;
	}
}

/* Landscape tablets are short: tighten the vertical rhythm so the whole menu
   still fits without scrolling. */
@media (min-width: 700px) and (min-height: 600px) and (max-height: 840px) {
	.mnav-primary .mnav-link {
		font-size: clamp(32px, 4.2vw, 54px);
		padding: clamp(4px, 0.8vh, 10px) 0;
	}

	.mnav-scroll {
		padding-top: clamp(12px, 1.8vh, 24px);
		align-content: start;
	}

	.mnav-sublink {
		min-height: 42px;
		padding: 3px 0;
		font-size: clamp(15.5px, 1.5vw, 17px);
	}

	.mnav-summary {
		padding-bottom: 10px;
		margin-bottom: 2px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mnav,
	.mnav-chev {
		transition-duration: .01ms;
	}
}


/* ===========================================================================
 * The header while the panel is open
 *
 * The page script paints the header from scroll position:
 *   const solid = y > 90;  nav.style.backgroundColor = solid ? '#080D10' : 'transparent'
 * It knows nothing about this panel. Opening the menu calls lock(), which sets
 * body{position:fixed} and drops window.scrollY to 0 — so the next scroll event
 * tells the page script it is back at the top and it paints the header
 * transparent. On a light page that put the page's own body copy straight
 * through the header, with the logo and CTA sitting on top of the text.
 *
 * This was first attempted in JS, painting the header on open. That is a race:
 * the offending scroll handler fires after, and won. CSS does not race — an
 * !important declaration beats an inline style outright — and keying off the
 * same aria-expanded attribute the panel already uses means the header reverts
 * on close with nothing to clean up.
 * ======================================================================== */

header:has([data-burger][aria-expanded="true"]) {
	background-color: #080D10 !important;
	box-shadow: none !important;
}

/* Everything in the bar switches to the light-on-dark treatment, because the
   bar is now part of the panel rather than floating over the page. */
header:has([data-burger][aria-expanded="true"]) [data-logo-navy] { opacity: 0 !important; }
header:has([data-burger][aria-expanded="true"]) [data-navlink] { color: #FFFFFF !important; }
header:has([data-burger][aria-expanded="true"]) [data-navcta] {
	background: #FFFFFF !important;
	color: #080D10 !important;
}
header:has([data-burger][aria-expanded="true"]) [data-burger] { background: #FFFFFF !important; }
header:has([data-burger][aria-expanded="true"]) [data-burger-bar] { background: #080D10 !important; }
