/**
 * Nav Overlay — Centurion-style Mega Menu
 *
 * Two-panel split: left panel with crossfading background images and
 * nav items, right panel with club info and social links.
 * Enters from top via translateY.
 * Mobile-first: single full-screen panel on mobile, two-panel on 48rem+.
 *
 * @package BuryGolfClub
 * @since   1.0.0
 */

/* ==========================================================================
   Body scroll lock
   ========================================================================== */

body.nav-open {
	overflow: hidden;
	height: 100vh;
	height: 100dvh;
}

/* ==========================================================================
   Overlay container
   ========================================================================== */

.nav-overlay {
	position: fixed;
	inset: 4px;
	z-index: 1200;
	background-color: var(--wp--preset--color--primary-deep);
	transform: translateY(-110%);
	transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
				visibility 0s linear 0.7s;
	overflow: hidden;
	will-change: transform;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

@media (min-width: 30rem) {
	.nav-overlay {
		inset: 8px;
	}
}

.nav-overlay[hidden] {
	display: block;
	transform: translateY(-110%);
	pointer-events: none;
	visibility: hidden;
}

.nav-overlay.is-active {
	transform: translateY(0);
	pointer-events: auto;
	visibility: visible;
	transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
				visibility 0s linear 0s;
}

/* ==========================================================================
   Overlay inner
   ========================================================================== */

.nav-overlay__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 0;
	overflow: hidden;
}

/* ==========================================================================
   Mega Menu — Mobile-first: single column
   ========================================================================== */

.mega-menu {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 100%;
	overflow-y: auto;
}

/* --------------------------------------------------------------------------
   LEFT PANEL — full width on mobile, 65% on desktop
   -------------------------------------------------------------------------- */

.mega-menu__left {
	position: relative;
	flex: none;
	display: flex;
	align-items: center;
	overflow: hidden;
	min-height: 0;
	padding-bottom: 2rem;
}

/* Background images — absolutely stacked, crossfade */
.mega-menu__backgrounds {
	position: absolute;
	inset: 0;
	z-index: 0;
	opacity: 0.3;
}

.mega-menu__bg-image {
	position: absolute;
	inset: 0;
	background-size: cover;
	background-position: center;
	opacity: 0;
	transition: opacity 0.6s ease;
	will-change: opacity;
}

.mega-menu__bg-image.is-active {
	opacity: 1;
}

.mega-menu__bg-overlay {
	position: absolute;
	inset: 0;
	background: rgba(7, 20, 40, 0.92);
	z-index: 1;
}

/* Nav wrapper — sits over background images */
.mega-menu__nav-wrapper {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1.5rem;
	padding: calc(var(--wp--custom--header-height) + 1rem) var(--wp--preset--spacing--30) 1.5rem;
	width: 100%;
}

/* --------------------------------------------------------------------------
   Nav list (left side of left panel)
   -------------------------------------------------------------------------- */

.mega-menu__list {
	list-style: none;
	padding: 0;
	margin: 0;
	flex-shrink: 0;
	width: 100%;
}

.mega-menu__item {
	position: relative;
	margin-bottom: 0.125rem;
}

/* Invisible hover bridge — prevents gap between nav item and sub-panel */
.mega-menu__item::after {
	content: '';
	position: absolute;
	top: 0;
	right: -60px;
	width: 60px;
	height: 100%;
	pointer-events: auto;
}

.mega-menu__link {
	color: var(--wp--preset--color--white);
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.25rem, 4vw, 1.75rem);
	font-weight: 400;
	text-decoration: none;
	display: flex;
	align-items: center;
	padding: 0.625rem 0;
	min-height: 48px;
	transition: opacity 0.3s ease-out, color 0.3s ease-out;
	line-height: 1.2;
	letter-spacing: 0.01em;
}

.mega-menu__link:focus-visible {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: 4px;
}

/* Hover dimming: when ANY item is hovered, dim all siblings */
.mega-menu__list:hover .mega-menu__link {
	opacity: 0.35;
}

.mega-menu__list:hover .mega-menu__item:hover .mega-menu__link,
.mega-menu__list .mega-menu__item.is-active .mega-menu__link {
	opacity: 1;
	color: var(--wp--preset--color--white);
}

/* Keyboard focus should also un-dim */
.mega-menu__list .mega-menu__link:focus-visible {
	opacity: 1;
}

/* Stagger animation on open */
.nav-overlay.is-active .mega-menu__item {
	animation: megaItemFadeIn 0.4s ease forwards;
	opacity: 0;
}

.nav-overlay.is-active .mega-menu__item:nth-child(1) { animation-delay: 0.15s; }
.nav-overlay.is-active .mega-menu__item:nth-child(2) { animation-delay: 0.2s; }
.nav-overlay.is-active .mega-menu__item:nth-child(3) { animation-delay: 0.25s; }
.nav-overlay.is-active .mega-menu__item:nth-child(4) { animation-delay: 0.3s; }
.nav-overlay.is-active .mega-menu__item:nth-child(5) { animation-delay: 0.35s; }
.nav-overlay.is-active .mega-menu__item:nth-child(6) { animation-delay: 0.4s; }
.nav-overlay.is-active .mega-menu__item:nth-child(7) { animation-delay: 0.45s; }

@keyframes megaItemFadeIn {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* When overlay closes, remove animation so items reset */
.nav-overlay:not(.is-active) .mega-menu__item {
	animation: none;
	opacity: 0;
}

/* --------------------------------------------------------------------------
   Sub-panels (right side of left panel)
   -------------------------------------------------------------------------- */

.mega-menu__sub-panels {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: flex-start;
	padding-top: 0;
}

.mega-menu__sub-panel {
	width: 100%;
	opacity: 1;
	transition: opacity 0.4s ease;
}

.mega-menu__sub-panel[hidden] {
	display: none;
	opacity: 0;
}

.mega-menu__sub-heading {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--wp--preset--color--gold);
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.8125rem;
	font-weight: 500;
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	margin-bottom: 1.5rem;
	transition: color 0.3s ease-out;
}

.mega-menu__sub-heading:hover,
.mega-menu__sub-heading:focus {
	color: var(--wp--preset--color--light-gold);
}

.mega-menu__sub-heading:focus-visible {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: 4px;
}

.mega-menu__sub-arrow {
	transition: transform 0.2s ease-out;
}

.mega-menu__sub-heading:hover .mega-menu__sub-arrow {
	transform: translateX(4px);
}

.mega-menu__sub-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.mega-menu__sub-item {
	margin-bottom: 0.25rem;
}

.mega-menu__sub-link {
	color: var(--wp--preset--color--cream);
	font-family: var(--wp--preset--font-family--body);
	font-size: clamp(0.9375rem, 0.5vw + 0.75rem, 1.125rem);
	font-weight: 400;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	padding: 0.5rem 0;
	min-height: 44px;
	transition: opacity 0.3s ease-out, color 0.3s ease-out;
}

.mega-menu__sub-link:hover,
.mega-menu__sub-link:focus {
	color: var(--wp--preset--color--gold);
}

.mega-menu__sub-link:focus-visible {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: 4px;
}

.mega-menu__external-icon {
	opacity: 0.6;
	flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   MOBILE CONTACT — visible on mobile only, hidden on desktop
   -------------------------------------------------------------------------- */

.mega-menu__mobile-contact {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 1rem;
	padding: 1.5rem var(--wp--preset--spacing--30) 2rem;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mega-menu__mobile-phone {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	color: var(--wp--preset--color--gold, #C4A265);
	font-family: var(--wp--preset--font-family--body);
	font-size: 1rem;
	font-weight: 600;
	text-decoration: none;
	letter-spacing: 0.03em;
	transition: color 0.2s ease-out;
}

.mega-menu__mobile-phone:hover,
.mega-menu__mobile-phone:focus {
	color: var(--wp--preset--color--light-gold, #D4B96A);
}

.mega-menu__mobile-phone:focus-visible {
	outline: 2px solid var(--wp--preset--color--gold);
	outline-offset: 4px;
}

.mega-menu__mobile-address {
	font-style: normal;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.875rem;
	color: var(--wp--preset--color--cream, #F5F0E6);
	opacity: 0.7;
	line-height: 1.6;
}

@media (min-width: 48rem) {
	.mega-menu__mobile-contact {
		display: none;
	}
}

/* --------------------------------------------------------------------------
   RIGHT PANEL — hidden on mobile, 35% on desktop
   -------------------------------------------------------------------------- */

/* Right panel — Centurion style: massive vertical spacing, everything centered */
.mega-menu__right {
	display: none;
	background-color: var(--wp--preset--color--cream, #F5F0E6);
	border-left: 8px solid var(--wp--preset--color--cream, #F5F0E6);
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: clamp(3rem, 6vh, 5rem) clamp(2rem, 4vw, 5rem);
	gap: 0;
	text-align: center;
}

/* Logo */
.mega-menu__right-logo {
	margin-bottom: 2rem;
}

.mega-menu__logo-img {
	max-height: 200px;
	width: auto;
}

/* Club identity — name + subtitle */
.mega-menu__identity {
	margin-bottom: clamp(2rem, 5vh, 3.5rem);
}

.mega-menu__club-name {
	font-family: var(--wp--preset--font-family--body);
	font-size: 1.125rem;
	font-weight: 400;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary, #071428);
	margin: 0 0 0.5rem;
}

.mega-menu__club-subtitle {
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.6875rem;
	font-weight: 400;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary, #071428);
	opacity: 0.5;
	margin: 0;
}

/* Vardon quote */
.mega-menu__quote {
	margin-bottom: clamp(2rem, 5vh, 3.5rem);
}

.mega-menu__quote-text {
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(1.125rem, 1.5vw + 0.5rem, 1.5rem);
	font-style: italic;
	font-weight: 400;
	line-height: 1.4;
	color: var(--wp--preset--color--primary, #071428);
	opacity: 0.7;
	margin: 0 0 1rem;
	border: none;
	padding: 0;
}

.mega-menu__quote-attr {
	display: block;
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.625rem;
	font-style: normal;
	font-weight: 400;
	letter-spacing: 0.15em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary, #071428);
	opacity: 0.4;
}

/* Gold divider */
.mega-menu__divider {
	width: 60px;
	height: 1px;
	border: none;
	background-color: var(--wp--preset--color--gold, #C4A265);
	margin: 0 auto clamp(2rem, 5vh, 3.5rem);
}

/* Club details */
.mega-menu__club-details {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0;
}

.mega-menu__address {
	font-style: normal;
	font-family: var(--wp--preset--font-family--heading);
	font-size: 1rem;
	color: var(--wp--preset--color--primary, #071428);
	line-height: 1.8;
	margin-bottom: 2rem;
}

.mega-menu__phone {
	color: var(--wp--preset--color--primary, #071428);
	font-family: var(--wp--preset--font-family--body);
	font-size: 1.0625rem;
	font-weight: 700;
	text-decoration: none;
	letter-spacing: 0.05em;
	transition: color 0.2s ease-out;
	margin-bottom: 0.75rem;
	display: block;
}

.mega-menu__phone:hover,
.mega-menu__phone:focus {
	color: var(--wp--preset--color--gold);
}

.mega-menu__phone:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 4px;
}

.mega-menu__contact-link {
	display: inline-block;
	color: var(--wp--preset--color--primary, #071428);
	font-family: var(--wp--preset--font-family--body);
	font-size: 0.9375rem;
	font-weight: 400;
	text-decoration: underline;
	text-underline-offset: 3px;
	transition: color 0.2s ease-out;
}

.mega-menu__contact-link:hover,
.mega-menu__contact-link:focus {
	color: var(--wp--preset--color--gold);
}

.mega-menu__contact-link:focus-visible {
	outline: 2px solid var(--wp--preset--color--primary);
	outline-offset: 4px;
}

/* Hide the arrow icon — Centurion uses simple underlined text */
.mega-menu__contact-arrow {
	display: none;
}

/* Social links — solid icons, no circle borders, generous top spacing */
.mega-menu__social {
	margin-top: calc(clamp(3rem, 8vh, 6rem) + 50px);
}

.mega-menu__social .social-links {
	gap: 1.5rem;
}

.mega-menu__social .social-links__link {
	color: var(--wp--preset--color--primary, #071428);
	border: none;
	width: auto;
	height: auto;
	border-radius: 0;
}

.mega-menu__social .social-links__icon {
	width: 22px;
	height: 22px;
	fill: currentColor;
	stroke: none;
}

.mega-menu__social .social-links__link:hover,
.mega-menu__social .social-links__link:focus {
	color: var(--wp--preset--color--gold);
	border: none;
	background: none;
}

/* ==========================================================================
   Tablet+ (48rem / 768px) — Two-panel layout
   ========================================================================== */

@media (min-width: 48rem) {
	.mega-menu {
		flex-direction: row;
		overflow-y: hidden;
	}

	.mega-menu__left {
		flex: 0 0 65%;
		padding-bottom: 0;
	}

	.mega-menu__backgrounds {
		opacity: 1;
	}

	.mega-menu__bg-overlay {
		background: linear-gradient(
			to right,
			rgba(7, 20, 40, 0.9) 0%,
			rgba(7, 20, 40, 0.65) 50%,
			rgba(7, 20, 40, 0.45) 100%
		);
	}

	.mega-menu__nav-wrapper {
		flex-direction: row;
		padding: clamp(5rem, 8vh, 8rem) clamp(2rem, 4vw, 5rem);
		gap: 50px;
	}

	.mega-menu__list {
		width: auto;
	}

	.mega-menu__link {
		font-size: clamp(1.5rem, 2vw + 1rem, 2.75rem);
		padding: 0.5rem 0;
		min-height: 0;
		display: inline-block;
	}

	.mega-menu__sub-panels {
		padding-top: 0.5rem;
	}

	.mega-menu__sub-link {
		min-height: 0;
		padding: 0.375rem 0;
	}

	.mega-menu__right {
		display: flex;
		flex: 0 0 35%;
	}

	.mega-menu__logo-img {
		max-height: 280px;
	}
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.nav-overlay {
		transition: none;
	}

	.mega-menu__bg-image {
		transition: none;
	}

	.nav-overlay.is-active .mega-menu__item {
		animation: none;
		opacity: 1;
	}
}
