/*
 * Virtina child: header mega menu.
 * Shared component, no page prefix. Panels are opened by js/vch-mega-menu.js.
 */

:root {
	--vch-mega-bg: #fff;
	--vch-mega-text: #000;
	--vch-mega-focus: #000;
	--vch-mega-hover-bg: #f2f2f2;
	--vch-mega-shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
	--vch-mega-radius: 24px;
}

/* Trigger button: looks like the other header links */
.vch-header__trigger {
	padding: 0;
	border: 0;
	background: none;
	font-family: inherit;
	cursor: pointer;
}

.vch-header__trigger:focus-visible {
	outline: 2px solid var(--vch-mega-focus);
	outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
	.vch-header__chevron {
		transition: transform 0.2s ease;
	}
}

.vch-header__trigger[aria-expanded="true"] .vch-header__chevron {
	transform: rotate(180deg);
}

/* Desktop: panel floats under the header, centred */

/* The nav blur creates its own containing block, which would shift the panel.
   Drop the blur only while a panel is open. */
.vch-header__nav:has(.vch-mega-menu:not([hidden])) {
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}

.vch-mega-menu[hidden] {
	display: none;
}

/* Fly in: the panel fades in and slides down 10px when it opens.
   The animation restarts each time the hidden attribute is removed. */
@keyframes vch-mega-fly-in {
	from {
		opacity: 0;
		translate: 0 -10px;
	}

	to {
		opacity: 1;
		translate: 0 0;
	}
}

/* Fly out: the panel fades out and slides up 10px when it closes.
   The script hides the panel after this animation ends. */
@keyframes vch-mega-fly-out {
	from {
		opacity: 1;
		translate: 0 0;
	}

	to {
		opacity: 0;
		translate: 0 -10px;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.vch-mega-menu:not([hidden]) {
		animation: vch-mega-fly-in 0.25s cubic-bezier(0.22, 0.61, 0.36, 1) both;
	}

	.vch-mega-menu.is-closing {
		animation: vch-mega-fly-out 0.18s cubic-bezier(0.4, 0, 1, 1) both;
		pointer-events: none;
	}
}

.vch-mega-menu {
	position: absolute;
	top: calc(100% + 12px);
	left: 50%;
	z-index: 50;
	transform: translateX(-50%);
	width: min(1200px, calc(100vw - 32px));
	box-sizing: border-box;
	border-radius: var(--vch-mega-radius);
	background: var(--vch-mega-bg);
	box-shadow: var(--vch-mega-shadow);
}

.vch-mega-menu__inner {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 32px;
	padding: 40px;
}

.vch-mega-menu__col {
	min-width: 0;
}

.vch-mega-menu__title {
	margin: 0 0 16px;
	font-size: 14px;
	font-weight: 700;
	letter-spacing: -0.42px;
	color: var(--vch-mega-text);
}

.vch-mega-menu .menu {
	display: grid;
	gap: 12px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.vch-mega-menu a {
	font-size: 16px;
	line-height: 1.3;
	letter-spacing: -0.48px;
	color: var(--vch-mega-text);
	text-decoration: none;
}

.vch-mega-menu a:hover {
	color: var(--vch-header-active-color);
}

.vch-mega-menu a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 4px;
}

.vch-mega-menu a:focus-visible {
	outline: 2px solid var(--vch-mega-focus);
	outline-offset: 3px;
}

/* Sub-item list: narrow panel that lines up under its trigger on desktop */
.vch-header__item--list {
	position: relative;
}

.vch-mega-menu--list {
	left: 0;
	width: 280px;
	transform: none;
}

.vch-mega-menu__list {
	display: grid;
	gap: 2px;
	margin: 0;
	padding: 12px;
	list-style: none;
}

.vch-mega-menu__list a {
	display: block;
	padding: 10px 12px;
	border-radius: 12px;
	font-size: 16px;
	line-height: 1.3;
	letter-spacing: -0.48px;
	color: var(--vch-mega-text);
	text-decoration: none;
}

.vch-mega-menu__list a:hover {
	background: var(--vch-mega-hover-bg);
	color: var(--vch-header-active-color);
}

.vch-mega-menu__list a:focus-visible {
	background: var(--vch-mega-hover-bg);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.vch-mega-menu__list a:focus-visible {
	outline: 2px solid var(--vch-mega-focus);
	outline-offset: 2px;
}

/* Active page inside a dropdown */
.vch-mega-menu__list a.vch-mega-menu__link--active {
	color: var(--vch-header-active-color);
}

/* Below 1280px: the panel opens inline inside the mobile menu */
@media (max-width: 1279px) {
	.vch-header__trigger {
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 14px 20px;
		font-size: 18px;
	}

	.vch-mega-menu {
		position: static;
		width: 100%;
		margin-top: 4px;
		border-radius: 16px;
		box-shadow: none;
		transform: none;
	}

	.vch-mega-menu__inner {
		grid-template-columns: 1fr;
		gap: 16px;
		padding: 8px 20px 16px;
	}
}
