/**
 * Eminence Grey: page hero (graphic + centered H1 only).
 * Graphics: image | network | grid | type | video (chosen per page).
 */

.eg-hero,
.eg-hero * {
	box-sizing: border-box;
}

:root {
	--eg-chrome-height: 80px; /* JS sets the exact value; these avoid a jump before it runs */
}

:root:has(.eg-banner) {
	--eg-chrome-height: 110px;
}

@media (max-width: 600px) {
	:root {
		--eg-chrome-height: 64px;
	}

	:root:has(.eg-banner) {
		--eg-chrome-height: 94px;
	}
}

.eg-hero {
	--eg-hero-progress: 0; /* 0 at top of page, 1 when scrolled one hero-height (set by hero.js) */
	--eg-hero-bg: var(--global-palette8);
	--eg-hero-ink: var(--global-palette3);
	--eg-hero-line: rgb(89 113 153 / 0.18);
	--eg-hero-node: #597199;
	--eg-hero-accent: #694e9b;
	--eg-hero-ink-2: var(--global-palette2); /* second line of the H1 */
	position: relative;
	isolation: isolate;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 48px var(--eg-gutter);
	text-align: center;
	background: var(--eg-hero-bg);
	color: var(--eg-hero-ink);
}

/* Dark scheme (the site default; matches the approved comp) */
.eg-hero--text-light {
	--eg-hero-bg: #08090f;
	--eg-hero-ink: #fff;
	--eg-hero-line: rgb(139 155 189 / 0.14);
	--eg-hero-node: #8b9bbd;
	--eg-hero-accent: #cbb8ee;
	--eg-hero-ink-2: #fff; /* both H1 lines white (was lavender second line) */
}

/* Fill the first viewport, minus the banner + header (and admin bar when logged in).
   min-height (not height) so the hero grows with text zoom. */
.eg-hero--full {
	min-height: calc(100svh - var(--eg-chrome-height, 80px) - var(--wp-admin--admin-bar--height, 0px));
}

/* ---- Exit: the hero stays put and the page content slides up over it ---- */
.eg-hero--full {
	position: sticky;
	top: calc(var(--eg-chrome-height, 80px) + var(--wp-admin--admin-bar--height, 0px));
	z-index: 0;
}

.eg-custom-header .eg-hero--full ~ :is(#inner-wrap, main, .site-main, footer, .eg-footer) {
	position: relative;
	z-index: 1;
	background-color: var(--global-palette8);
}

.eg-custom-header .eg-hero--full ~ :is(footer, .eg-footer) {
	background-color: var(--global-palette9);
}

.eg-hero__title {
	position: relative;
	z-index: 1;
	margin: 0 auto;
	font-size: clamp(2.2rem, 5.12vw, 6rem); /* 20% smaller than the first build */
	font-weight: 500;
	line-height: 0.95;
	letter-spacing: -0.045em;
	color: inherit;
	text-wrap: balance;
	opacity: calc(1 - var(--eg-hero-progress) * 1.4);
	transform: translateY(calc(var(--eg-hero-progress) * -60px));
}

/* Eyebrow above the H1 (Hero panel > Eyebrow) */
.eg-hero:has(> .eg-hero__eyebrow) {
	flex-direction: column;
}

.eg-hero__eyebrow {
	position: relative;
	z-index: 1;
	margin: 0 0 clamp(14px, 1.6vw, 24px);
	color: var(--eg-hero-accent);
	font-size: clamp(0.8125rem, 0.95vw, 1rem);
	font-weight: 500;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	opacity: calc(1 - var(--eg-hero-progress) * 1.4);
	transform: translateY(calc(var(--eg-hero-progress) * -60px));
}

@media (prefers-reduced-motion: reduce) {
	.eg-hero__eyebrow {
		opacity: 1;
		transform: none;
	}
}

/* Each line of the H1 (all white; --eg-hero-ink-2 kept for a second-line tone if wanted) */
.eg-hero__line {
	display: block;
	overflow: hidden;
	padding-bottom: 0.06em;
}

.eg-hero__line + .eg-hero__line {
	color: var(--eg-hero-ink-2);
}

/* Word reveal: each word rises from behind its line (hero.js wraps the words) */
.eg-hero__word {
	display: inline-block;
	animation: eg-word-rise 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
	animation-delay: calc(var(--i, 0) * 80ms + 150ms);
}

@keyframes eg-word-rise {
	from {
		transform: translateY(105%);
	}
}

/* Hold the H1 until hero.js has wrapped its words (avoids a flash); failsafe shows it after 2s regardless. */
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
	.eg-hero--full .eg-hero__title:not(.is-split) {
		visibility: hidden;
		animation: eg-failsafe 0s linear 2s forwards;
	}
}

@keyframes eg-failsafe {
	to {
		visibility: visible;
	}
}

/* Registration marks framing the stage */
.eg-hero__marks {
	position: absolute;
	inset: 28px var(--eg-gutter);
	z-index: 1;
	pointer-events: none;
	opacity: calc(0.55 - var(--eg-hero-progress) * 1.5);
}

.eg-hero__marks i {
	position: absolute;
	width: 22px;
	height: 22px;
	border: 0 solid var(--eg-hero-ink);
}

.eg-hero__marks i:nth-child(1) { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.eg-hero__marks i:nth-child(2) { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.eg-hero__marks i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.eg-hero__marks i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }

/* ---- Media layer ---- */
.eg-hero__media {
	position: absolute;
	inset: 0;
	z-index: -1;
	transform: scale(calc(1 + var(--eg-hero-progress) * 0.06));
	transform-origin: 50% 40%;
}

.eg-hero__image,
.eg-hero__video,
.eg-hero__canvas {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none; /* Kadence caps img at 100%, which left a gap at the edge */
	max-height: none;
	object-fit: cover;
	object-position: center;
}

/* Background image: oversized so the slow drift never shows an edge */
.eg-hero:is(.eg-hero--image, .eg-hero--network, .eg-hero--grid, .eg-hero--type) .eg-hero__image {
	inset: -4%;
	width: 108%;
	height: 108%;
	opacity: 0.85;
	animation: eg-media-drift 40s ease-in-out infinite alternate;
}

@keyframes eg-media-drift {
	to {
		scale: 1.08;
		translate: -2% 1.5%;
	}
}

/* Shade over photos/video in the dark scheme */
.eg-hero--text-light:is(.eg-hero--image, .eg-hero--video) .eg-hero__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(rgb(0 0 0 / 0.1), rgb(0 0 0 / 0.3)); /* light shade: the brand backgrounds are already dark */
}

/* ---- Grid and planes ---- */
.eg-hero__grid {
	position: absolute;
	inset: 0;
	background-image:
		linear-gradient(var(--eg-hero-line) 1px, transparent 1px),
		linear-gradient(90deg, var(--eg-hero-line) 1px, transparent 1px);
	background-size: 96px 96px;
	-webkit-mask-image: linear-gradient(90deg, transparent 10%, #000 100%);
	mask-image: linear-gradient(90deg, transparent 10%, #000 100%);
}

.eg-hero__plane {
	position: absolute;
	right: -12%;
	top: 24%;
	width: 60%;
	height: 48%;
	border: 1px solid var(--eg-hero-node);
	background: color-mix(in srgb, var(--eg-hero-node) 7%, transparent);
	transform: skewY(-19deg);
	opacity: 0.72;
}

.eg-hero__plane--2 {
	top: 33%;
	right: -6%;
	border-color: color-mix(in srgb, var(--eg-hero-ink) 45%, transparent);
	background: none;
}

.eg-hero__plane--3 {
	top: 42%;
	right: 0;
	border-color: var(--eg-hero-accent);
	background: none;
}

/* Animated only when "Grid and planes" is chosen */
.eg-hero--grid .eg-hero__grid {
	animation: eg-grid-drift 24s linear infinite;
}

.eg-hero--grid .eg-hero__plane {
	animation: eg-plane-float 14s ease-in-out infinite alternate;
}

.eg-hero--grid .eg-hero__plane--2 {
	animation-duration: 18s;
	animation-delay: -4s;
}

.eg-hero--grid .eg-hero__plane--3 {
	animation-duration: 22s;
	animation-delay: -9s;
}

@keyframes eg-grid-drift {
	to {
		background-position: 96px 96px, 96px 96px;
	}
}

@keyframes eg-plane-float {
	from {
		transform: skewY(-19deg) translate3d(0, 0, 0);
	}
	to {
		transform: skewY(-15deg) translate3d(-4%, -6%, 0);
	}
}

/* ---- Type reveal: plain stage + line sweep (word reveal applies to every hero) ---- */
.eg-hero__sweep {
	position: absolute;
	left: 0;
	right: 0;
	top: 74%;
	height: 1px;
	background: linear-gradient(90deg, transparent, var(--eg-hero-accent), transparent);
	transform: scaleX(0);
	transform-origin: 0 50%;
	animation: eg-sweep 1.8s cubic-bezier(0.65, 0, 0.35, 1) 0.6s forwards;
}

@keyframes eg-sweep {
	to {
		transform: scaleX(1);
	}
}

/* ---- Scroll cue ---- */
.eg-hero__cue {
	position: absolute;
	left: 50%;
	bottom: 28px;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	transform: translateX(-50%);
	color: inherit;
	font-family: "JetBrains Mono", ui-monospace, monospace;
	font-size: 0.6875rem;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	opacity: calc(0.7 - var(--eg-hero-progress) * 3);
	pointer-events: none;
}

.eg-hero__cue::after {
	content: "";
	width: 1px;
	height: 40px;
	background: linear-gradient(currentColor, transparent);
	transform-origin: 50% 0;
	animation: eg-cue 2s ease-in-out infinite;
}

@keyframes eg-cue {
	0% {
		transform: scaleY(0);
	}
	50% {
		transform: scaleY(1);
	}
	100% {
		transform: scaleY(1);
		opacity: 0;
	}
}

/* ---- Compact title band for legal/utility pages ---- */
.eg-hero--compact {
	padding-block: clamp(48px, 8vw, 96px) clamp(24px, 4vw, 48px);
	border-bottom: 1px solid var(--global-palette7);
}

.eg-hero--compact .eg-hero__line + .eg-hero__line {
	color: inherit;
}

.eg-hero--compact .eg-hero__title {
	font-size: clamp(2.25rem, 5vw, 4rem);
	line-height: 1.05;
	letter-spacing: -0.02em;
	opacity: 1;
	transform: none;
}

@media (max-width: 600px) {
	.eg-hero {
		padding-block: 32px;
	}

	.eg-hero__title {
		font-size: 8.4vw;
		line-height: 0.95;
	}

	.eg-hero__marks {
		inset: 16px var(--eg-gutter);
	}

	.eg-hero--compact .eg-hero__title {
		font-size: clamp(2rem, 9vw, 2.75rem);
	}

	.eg-hero__plane {
		width: 100%;
		right: -48%;
	}
}

/* Reduced motion: everything static, no exit effect */
@media (prefers-reduced-motion: reduce) {
	.eg-hero,
	.eg-hero * {
		animation: none !important;
	}

	.eg-hero__word {
		transform: none;
	}

	.eg-hero__sweep {
		transform: none;
	}

	.eg-hero__title,
	.eg-hero__media {
		opacity: 1;
		transform: none;
	}

	.eg-hero--full {
		position: relative;
		top: auto;
	}
}

/* ---- See-through header: the full hero runs up behind the header bar ----
   (the news banner stays solid above it). --eg-header-height is the bar's height
   from header.css; --eg-chrome-height is banner + bar. */
.eg-custom-header .eg-hero--full {
	margin-top: calc(-1 * var(--eg-header-height, 80px));
	min-height: calc(100svh - var(--eg-chrome-height, 80px) + var(--eg-header-height, 80px) - var(--wp-admin--admin-bar--height, 0px));
	top: calc(var(--eg-chrome-height, 80px) - var(--eg-header-height, 80px) + var(--wp-admin--admin-bar--height, 0px));
	padding-top: calc(48px + var(--eg-header-height, 80px));
}

/* Registration marks start below the header bar, not behind it */
.eg-custom-header .eg-hero--full .eg-hero__marks {
	top: calc(28px + var(--eg-header-height, 80px));
}

@media (max-width: 600px) {
	.eg-custom-header .eg-hero--full {
		padding-top: calc(32px + var(--eg-header-height, 64px));
	}

	.eg-custom-header .eg-hero--full .eg-hero__marks {
		top: calc(16px + var(--eg-header-height, 64px));
	}
}

@media (prefers-reduced-motion: reduce) {
	.eg-custom-header .eg-hero--full {
		top: auto;
	}
}

/* ---- Corner glow (opt-in): soft light rising from the lower left ----
   On when "Corner glow" is ticked in the page's Hero panel (adds .eg-glow).
   Best on plain heroes; it reads oddly over photo backgrounds.
   Sits above the background/network (z -1) and below the H1, marks and cue (z 1).
   Colors/strength come from the .eg-glow tokens in sections.css (fallbacks here). */
.eg-hero--full.eg-glow::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background:
		radial-gradient(ellipse 55% 70% at 0% 100%, color-mix(in srgb, var(--eg-glow-core, #aa78ff) 50%, transparent) 0%, color-mix(in srgb, var(--eg-glow-core, #aa78ff) 28%, transparent) 30%, color-mix(in srgb, var(--eg-glow-core, #aa78ff) 10%, transparent) 58%, transparent 85%),
		radial-gradient(ellipse 110% 120% at 0% 100%, color-mix(in srgb, var(--eg-glow-mid, #694e9b) 50%, transparent) 0%, color-mix(in srgb, var(--eg-glow-mid, #694e9b) 22%, transparent) 40%, color-mix(in srgb, var(--eg-glow-mid, #694e9b) 6%, transparent) 70%, transparent 95%);
	mix-blend-mode: screen;
	transform-origin: 0 100%;
	opacity: calc(var(--eg-glow-strength, 1) - var(--eg-hero-progress) * 1.2);
	animation: eg-glow-breathe 14s ease-in-out infinite alternate;
}

@keyframes eg-glow-breathe {
	to {
		scale: 1.12;
	}
}

@media (prefers-reduced-motion: reduce) {
	.eg-hero--full.eg-glow::before {
		animation: none;
	}
}
