/* =========================================================================
   Eastgate header mega menu
   ========================================================================= */

:root {
	--eg-h-navy: var(--wp--preset--color--navy, #1e3a5f);
	--eg-h-green: var(--wp--preset--color--green, #00875a);
	--eg-h-muted: #6b7785;
	--eg-h-border: #dde4ec;
	--eg-h-display: var(--wp--preset--font-family--avenir-condensed, 'Avenir Next Condensed', sans-serif);
	--eg-h-body: var(--wp--preset--font-family--avenir, 'Avenir Next', sans-serif);
}

/* header needs a positioning + stacking context for the panels */
.site-header { position: relative; z-index: 50; }

/* Constrain the header logo (the block width attr isn't applied to the custom logo) */
.site-header .wp-block-site-logo img { width: 200px; max-width: 100%; height: auto; }

.eg-nav { display: flex; align-items: center; position: relative; }

.eg-nav__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 1.85rem;
}

.eg-nav__item { position: static; }
.eg-nav__cta-item { display: none; } /* drawer-only CTA, shown on mobile */

.eg-nav__link {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	color: #fff;
	text-decoration: none;
	font-family: var(--eg-h-body);
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	padding: 1.5rem 0;
	white-space: nowrap;
	transition: color 0.15s ease;
}
.eg-nav__link:hover { color: var(--eg-h-green); }

/* Animated underline: grows from the left on hover and stays lit while the
   item's panel is open. */
.eg-nav__link::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 1.05rem;
	height: 2px;
	background: var(--eg-h-green);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.eg-nav__link:hover::after,
.eg-has-mega:hover > .eg-nav__link::after,
.eg-has-mega.is-active > .eg-nav__link::after,
.eg-has-mega:focus-within > .eg-nav__link::after { transform: scaleX(1); }
.eg-has-mega:hover > .eg-nav__link,
.eg-has-mega.is-active > .eg-nav__link,
.eg-has-mega:focus-within > .eg-nav__link { color: var(--eg-h-green); }

.eg-nav__caret {
	width: 0;
	height: 0;
	border-style: solid;
	border-width: 4px 4px 0 4px;
	border-color: currentColor transparent transparent transparent;
	opacity: 0.65;
	transition: transform 0.2s ease;
}
.eg-has-mega:hover .eg-nav__caret,
.eg-has-mega.is-active .eg-nav__caret,
.eg-has-mega:focus-within .eg-nav__caret { transform: rotate(180deg); }

/* ---- dropdown panel ---- */
.eg-mega {
	position: absolute;
	top: 100%;
	right: 0;
	left: auto;
	background: #fff;
	border-radius: 0.75rem;
	/* Green top-edge accent (same motif as the dark band dividers) + depth. */
	box-shadow:
		inset 0 3px 0 var(--eg-h-green),
		0 24px 50px -18px rgba(15, 35, 64, 0.35);
	padding: 1.4rem 1.25rem 1.25rem;
	opacity: 0;
	visibility: hidden;
	transform: translateY(10px) scale(0.985);
	transform-origin: top center;
	/* Closing fade. Only fresh opens and full closes ever animate — when
	   switching between items, mega-menu.js swaps panels with transitions
	   disabled (.eg-nav--instant), so two panels are never visible at once.
	   Hover-intent grace lives in the JS (120ms), not in a CSS delay. */
	transition:
		opacity 0.15s ease,
		transform 0.15s ease,
		visibility 0s 0.15s;
	z-index: 100;
}
.eg-mega--right { left: auto; right: 0; }
.eg-nav:not(.eg-nav--js) .eg-has-mega:hover > .eg-mega, /* no-JS fallback */
.eg-has-mega.is-active > .eg-mega,
.eg-has-mega:focus-within > .eg-mega {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	/* Opening: quick, with a tiny delay so skimming the bar doesn't strobe. */
	transition:
		opacity 0.16s ease 0.05s,
		transform 0.2s cubic-bezier(0.22, 1, 0.36, 1) 0.05s,
		visibility 0s 0.05s;
}
/* Instant swap while moving between items (set by mega-menu.js). */
.eg-nav--instant .eg-mega {
	transition: none !important;
}

/* Dim + blur the page behind an open panel (CSS-only via :has). */
body::after {
	content: "";
	position: fixed;
	inset: 0;
	background: rgba(11, 26, 48, 0.45);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	opacity: 0;
	visibility: hidden;
	/* Exit matches the panel's closing fade. While switching panels the
	   is-active class never lapses, so the dim holds steady — no flicker. */
	transition: opacity 0.18s ease, visibility 0.18s;
	pointer-events: none;
	z-index: 40; /* below the sticky header (z-index 100) */
}
@media (min-width: 901px) {
	body:has(.eg-nav:not(.eg-nav--js) .eg-has-mega:hover)::after, /* no-JS fallback */
	body:has(.eg-has-mega.is-active)::after,
	body:has(.eg-has-mega:focus-within)::after {
		opacity: 1;
		visibility: visible;
		transition-delay: 0.05s;
	}
}

.eg-mega .eg-eyebrow {
	display: block;
	font-family: var(--eg-h-display);
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-weight: 700;
	font-size: 0.7rem;
	color: var(--eg-h-green);
	margin-bottom: 0.5rem;
}

.eg-mega__links { list-style: none; margin: 0; padding: 0; }
.eg-mega__links a {
	display: block;
	padding: 0.4rem 0;
	color: var(--eg-h-navy);
	text-decoration: none;
	font-size: 0.95rem;
	font-weight: 600;
	transition: color 0.15s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.eg-mega__links a:hover {
	color: var(--eg-h-green);
	transform: translateX(4px);
}

/* ---- Locations ---- */
.eg-mega__locations {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	width: 560px;
	max-width: calc(100vw - 4rem);
}
.eg-loc-card {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	border: 1px solid var(--eg-h-border);
	border-radius: 0.5rem;
	overflow: hidden;
	transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.eg-loc-card:hover {
	transform: translateY(-3px);
	border-color: var(--eg-h-green);
	box-shadow: 0 14px 28px -14px rgba(15, 35, 64, 0.45);
}
.eg-loc-card__name::after {
	content: "\2192";
	display: inline-block;
	margin-left: 0.35rem;
	color: var(--eg-h-green);
	opacity: 0;
	transform: translateX(-4px);
	transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.eg-loc-card:hover .eg-loc-card__name { color: var(--eg-h-green); }
.eg-loc-card:hover .eg-loc-card__name::after { opacity: 1; transform: none; }
.eg-loc-card__name { transition: color 0.15s ease; }
.eg-loc-card__img {
	display: block;
	aspect-ratio: 16 / 10;
	background-size: cover;
	background-position: center;
	background-color: var(--eg-h-navy);
}
.eg-loc-card__body { padding: 0.75rem 0.85rem 0.9rem; display: flex; flex-direction: column; gap: 0.15rem; }
.eg-loc-card__name { font-family: var(--eg-h-display); font-weight: 700; font-size: 1.1rem; color: var(--eg-h-navy); }
.eg-loc-card__addr,
.eg-loc-card__times { font-size: 0.8rem; color: var(--eg-h-muted); }

/* ---- Sermons: title on top, two campus stills side-by-side ---- */
.eg-mega__sermons {
	width: 480px;
	max-width: calc(100vw - 4rem);
}
.eg-mega-sermon__title {
	display: block;
	font-family: var(--eg-h-display);
	font-weight: 700;
	font-size: 1.25rem;
	line-height: 1.1;
	color: var(--eg-h-navy);
	text-decoration: none;
	margin: 0.1rem 0 0.85rem;
}
.eg-mega-sermon__title:hover { color: var(--eg-h-green); }
.eg-mega-sermon__stills {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.9rem;
}
.eg-mega-sermon__stills.is-single { grid-template-columns: minmax(0, 280px); }
.eg-mega-still { display: block; text-decoration: none; }
.eg-mega-still__img {
	position: relative;
	display: block;
	aspect-ratio: 16 / 9;
	border-radius: 0.5rem;
	background-size: cover;
	background-position: center;
	background-color: var(--eg-h-navy);
}
.eg-mega-still__play {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	display: grid;
	place-items: center;
	transition: background 0.15s ease;
}
.eg-mega-still__play::after {
	content: "";
	width: 0; height: 0;
	margin-left: 3px;
	border-style: solid;
	border-width: 6px 0 6px 10px;
	border-color: transparent transparent transparent var(--eg-h-navy);
}
.eg-mega-still:hover .eg-mega-still__play { background: var(--eg-h-green); }
.eg-mega-still:hover .eg-mega-still__play::after { border-left-color: #fff; }

/* Hover: gentle zoom on the still + a pulsing ring radiating from the play button. */
.eg-mega-still__img {
	transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}
.eg-mega-still:hover .eg-mega-still__img {
	transform: scale(1.03);
	box-shadow: 0 12px 26px -12px rgba(15, 35, 64, 0.5);
}
@media (prefers-reduced-motion: no-preference) {
	.eg-mega-still:hover .eg-mega-still__play {
		animation: eg-play-pulse 1.6s ease-out infinite;
	}
	@keyframes eg-play-pulse {
		0%   { box-shadow: 0 0 0 0 rgba(0, 135, 90, 0.45); }
		100% { box-shadow: 0 0 0 14px rgba(0, 135, 90, 0); }
	}
}
.eg-mega-still__campus {
	display: block;
	margin-top: 0.4rem;
	font-family: var(--eg-h-display);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 700;
	font-size: 0.72rem;
	color: var(--eg-h-navy);
}
.eg-mega-sermon__all {
	display: inline-block;
	margin-top: 1rem;
	font-family: var(--eg-h-display);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 700;
	font-size: 0.82rem;
	color: var(--eg-h-green);
	text-decoration: none;
}
.eg-mega-sermon__all:hover { color: var(--eg-h-navy); }

/* ---- I'm New ---- */
.eg-mega__imnew {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1.75rem;
	width: 480px;
	max-width: calc(100vw - 4rem);
}

/* ---- hamburger (hidden on desktop) ---- */
.eg-nav__toggle { display: none; }

/* =========================================================================
   Mobile
   ========================================================================= */
@media (max-width: 900px) {
	/* drawer anchors to the full-width header, not the (now-relative) nav */
	.eg-nav { position: static; }

	/* logo left, hamburger right (the bar is already space-between) */
	.site-header .wp-block-site-logo img { width: 150px; }

	/* the top-bar app button is squished on mobile — move it into the drawer.
	   !important to beat core's .wp-block-buttons flex rule (equal specificity). */
	.eg-header-cta { display: none !important; }
	.eg-nav__cta-item { display: block; border-top: 0; }
	.eg-nav__cta {
		display: inline-block;
		margin: 1.1rem 0 0.25rem;
		background: var(--eg-h-green);
		color: #fff;
		text-decoration: none;
		font-family: var(--eg-h-body);
		font-weight: 700;
		font-size: 0.8rem;
		letter-spacing: 0.06em;
		text-transform: uppercase;
		padding: 0.8rem 1.6rem;
		border-radius: 6px;
	}

	/* Sermons panel links were center-anchored for the desktop grid */
	.eg-mega__sermons .eg-mega__links { align-self: stretch; }

	.eg-nav__toggle {
		display: flex;
		flex-direction: column;
		justify-content: center;
		gap: 5px;
		width: 44px;
		height: 44px;
		padding: 0;
		background: none;
		border: 0;
		cursor: pointer;
	}
	.eg-nav__toggle span { width: 24px; height: 2px; background: #fff; border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; align-self: center; }
	.eg-nav.is-open .eg-nav__toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
	.eg-nav.is-open .eg-nav__toggle span:nth-child(2) { opacity: 0; }
	.eg-nav.is-open .eg-nav__toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

	.eg-nav__list {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		background: var(--eg-h-navy);
		padding: 0.25rem 1.5rem 1.5rem;
		max-height: calc(100vh - 78px);
		overflow-y: auto;
		box-shadow: 0 20px 30px -16px rgba(0, 0, 0, 0.5);
	}
	.eg-nav.is-open .eg-nav__list { display: flex; }

	.eg-nav__item { position: static; }
	.eg-nav__item:not(:first-child) { border-top: 1px solid rgba(255, 255, 255, 0.1); }
	.eg-nav__link { padding: 0.95rem 0; width: 100%; justify-content: space-between; }
	.eg-has-mega.is-open .eg-nav__caret { transform: rotate(180deg); }

	.eg-mega {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		display: none;
		background: transparent;
		box-shadow: none;
		border-radius: 0;
		padding: 0 0 1rem;
		z-index: auto;
	}
	.eg-has-mega.is-open > .eg-mega { display: block; }

	.eg-mega__locations,
	.eg-mega__sermons,
	.eg-mega__imnew {
		display: flex;
		flex-direction: column;
		align-items: stretch; /* override desktop align-items:start so items span full width */
		gap: 1rem;
		width: auto;
		max-width: none;
	}
	.eg-mega__sermons .eg-mega__links { align-self: stretch; }
	.eg-mega__links a,
	.eg-mega-sermon__title,
	.eg-mega-still__campus { color: #fff; }
	.eg-mega-sermon__title:hover { color: #46bf94; }
	.eg-mega-sermon__all:hover { color: #fff; }
	.eg-mega .eg-eyebrow { color: #46bf94; }
	.eg-loc-card { border-color: rgba(255, 255, 255, 0.14); }
	.eg-loc-card__name { color: #fff; }
	.eg-loc-card:hover .eg-loc-card__name,
	.eg-loc-card__name::after { color: #46bf94; }
	.eg-loc-card__addr,
	.eg-loc-card__times { color: #c9d6e4; }
}

/* =========================================================================
   Mobile drawer choreography (display flips restart these animations)
   ========================================================================= */
@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
	.eg-nav.is-open .eg-nav__list {
		animation: eg-drawer-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
	}
	.eg-nav.is-open .eg-nav__item {
		animation: eg-drawer-item-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
	}
	.eg-nav.is-open .eg-nav__item:nth-child(1) { animation-delay: 0.05s; }
	.eg-nav.is-open .eg-nav__item:nth-child(2) { animation-delay: 0.10s; }
	.eg-nav.is-open .eg-nav__item:nth-child(3) { animation-delay: 0.15s; }
	.eg-nav.is-open .eg-nav__item:nth-child(4) { animation-delay: 0.20s; }
	.eg-nav.is-open .eg-nav__item:nth-child(5) { animation-delay: 0.25s; }

	.eg-has-mega.is-open > .eg-mega {
		animation: eg-drawer-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
	}

	@keyframes eg-drawer-in {
		from { opacity: 0; transform: translateY(-10px); }
		to   { opacity: 1; transform: none; }
	}
	@keyframes eg-drawer-item-in {
		from { opacity: 0; transform: translateY(-6px); }
		to   { opacity: 1; transform: none; }
	}
}

/* Reduced motion: panels appear/disappear without movement or delays. */
@media (prefers-reduced-motion: reduce) {
	.eg-mega {
		transition: opacity 0.01s, visibility 0.01s;
		transform: none;
	}
	.eg-has-mega:hover > .eg-mega,
	.eg-has-mega.is-active > .eg-mega,
	.eg-has-mega:focus-within > .eg-mega { transform: none; }
	.eg-nav__link::after { transition: none; }
	.eg-mega__links a:hover { transform: none; }
	.eg-loc-card,
	.eg-loc-card:hover,
	.eg-mega-still:hover .eg-mega-still__img { transform: none; }
}
