/* Hero (front-page + single post) — hero-viewport wrapper, hero-featured-post
   cover/overlay/badge/byline, hero logo overlay. Loaded on
   is_front_page() || is_singular('post'). Slice 4. */

/* Layer 3 — hero photo banner (under the primary nav). The hero-featured-post
   pattern in the template fills it with a cover block + image + overlay; the
   empty placeholder in parts/header.html collapses when nothing is injected. */
.header-hero-banner {
	background-color: var(--wp--preset--color--primary-dark);
	max-width: 1440px;
	margin-inline: auto;
	min-height: 0;
}

/* Collapse the empty placeholder cover when no content was injected. */
.header-hero-banner > .wp-block-cover__inner-container:empty {
	display: none;
}

.header-hero-banner:has(> .wp-block-cover__inner-container:empty) {
	display: none;
}

/* Remove WP root blockGap around hero on front-page and single.
   position:relative makes the wrapper the containing block for
   .hero-logo-overlay (emitted as its first child), so the logo's
   top offset is measured from the hero's top edge, per the canonical
   hero guidelines (implementation-overrides.md). */
.hero-featured-post {
	position: relative;
	margin-block: 0;

	/* The tallest the hero cover may be: the window minus the 36px utility
	   bar above it (shown from 768px, navigation.css), so on a window wider
	   than 16:9 the bottom of the hero — byline, date — is not cut off by
	   the fold. */
	--ghn-hero-max-height: 100vh;

	/* The width the hero cover renders at (.hero-featured-post__cover below:
	   16:9 capped at that height, centred). On a window wider than 16:9 the
	   cover is narrower than this wrapper, and the logo overlay positions
	   itself against the cover's edge, not the window's. */
	--ghn-hero-cover-width: min(100%, calc(var(--ghn-hero-max-height) * 16 / 9), 2560px);
}

@media (min-width: 768px) {

	.hero-featured-post {
		--ghn-hero-max-height: calc(100vh - 36px);
	}
}

/* Author link on hero — white, underline on hover */
.hero-featured-post__author a,
.hero-featured-post__author a:visited {
	color: var(--wp--preset--color--surface);
	text-decoration: none;
}

.hero-featured-post__author a:hover {
	text-decoration: underline;
}

/* ===================================================================
   Hero Viewport — front-page wrapper around header + hero.
   Hero always maintains 16:9 aspect ratio. On 16:9 viewports the hero
   fills the screen exactly, so the utility bar overlays the top and
   the primary nav overlays the bottom. On other aspect ratios, navs
   sit normally above/below the hero.
   =================================================================== */
.hero-viewport {
	position: relative;
	margin-block: 0;
}

/* Hero always uses 16:9 aspect ratio */
.hero-viewport .hero-featured-post {
	margin-block: 0;
}

/* Scroll-down arrow — hidden by default, shown at 16:9 */
.hero-scroll-arrow {
	display: none;
	position: absolute;
	bottom: 96px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 201;
	color: var(--wp--preset--color--surface);
	opacity: 0.8;
	transition: opacity 0.2s ease;
	text-decoration: none;
	animation: hero-bounce 2s ease-in-out infinite;
}

.hero-scroll-arrow:hover {
	opacity: 1;
	color: var(--wp--preset--color--surface);
}

@keyframes hero-bounce {

	0%, 100% { transform: translateX(-50%) translateY(0); }

	50% { transform: translateX(-50%) translateY(8px); }
}

/* === 16:9 overlay layout ===
   At 16:8–16:10 viewports, the hero fills the viewport exactly.
   Accounts for OS taskbar, browser chrome reducing effective viewport.
   Utility bar overlays top, primary nav overlays bottom. */
@media (min-aspect-ratio: 16/10) and (max-aspect-ratio: 2/1) {

	.hero-viewport {
		height: 100vh;
		overflow: hidden;
	}

	/* Utility bar overlays the top of the hero */
	.hero-viewport > .wp-block-template-part:first-child {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		z-index: 200;
	}

	.hero-viewport .utility-bar {
		background: rgba(0, 0, 0, 0.3);
	}

	/* Hero fills the entire viewport. Core prints `height:unset` inline on
	   this cover (explicit aspect ratio, WP 7.0+); functions.php strips that
	   declaration in render_block_core/cover so this rule can apply. */
	.hero-viewport .hero-featured-post {
		--ghn-hero-cover-width: 100%;
	}

	.hero-viewport .hero-featured-post__cover.wp-block-cover {
		height: 100vh;
		width: 100%;
		max-width: none;
		max-height: none;
		aspect-ratio: auto;
	}

	/* Primary nav pulled up over hero bottom, then sticky.
	   Solid white bg — the 0.92 opacity caused a tinted color artifact.
	   z-index raised above hero overlay (200) so nav stays on top. */
	.hero-viewport + .wp-block-template-part:has(.primary-nav-bar) {
		margin-top: -80px;
		background: var(--wp--preset--color--surface);
		z-index: 200;
	}

	/* Overlay content clearance — push content away from nav bars.
	   Top: 36px utility bar + 40px gap = 76px.
	   Bottom: 80px primary nav + 40px gap = 120px. */
	.hero-viewport .hero-featured-post__cover .wp-block-cover__inner-container {
		padding-bottom: 120px;
	}


	/* Hero logo must clear the utility bar on 16:9 viewports */
	.hero-viewport .hero-logo-overlay {
		top: 76px;
	}

	/* Show scroll arrow — positioned between overlay bottom and nav top */
	.hero-scroll-arrow {
		display: block;
		bottom: 96px;
	}
}

/* 14. Hero template part */
.site-hero img[data-object-fit][src=""],
.site-hero img[data-object-fit]:not([src]) {
	display: block;
}

.site-hero {
	aspect-ratio: 16 / 9;
	max-height: 100vh;
	max-width: 2560px;
	width: min(100%, calc(100vh * 16 / 9));
	margin-inline: auto;
	position: relative;
}

.site-hero img[data-object-fit] {
	aspect-ratio: unset;
	max-height: none;
}

/* Hero logo overlay — top-left of the hero cover, not the inner container.
   Positioned relative to the .hero-featured-post wrapper (position:relative) —
   its top offset is measured from the hero's top edge, never from the cover's
   bottom-anchored text container. */
.hero-logo-overlay {
	display: none;
	position: absolute;
	top: 32px;
	left:
		calc(
			(100% - var(--ghn-hero-cover-width)) / 2 +
			max(20px, (var(--ghn-hero-cover-width) - 1440px) / 2)
		);
	z-index: 2;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* Shrinks with the viewport height on short windows (wide-but-short screens,
   browser zoom) so it keeps clear of a bottom-anchored headline instead of
   disappearing: full size from ~730px tall down. */
.hero-logo-overlay__img {
	display: block;
	width: min(168px, 23vh);
	height: auto;
	object-fit: contain;
}

@media (min-width: 782px) {

	.hero-logo-overlay { display: block; }
}

/* Hide the hero logo when the viewport is too short to hold both the logo
   band and a bottom-anchored multi-line headline — e.g. 150–175% browser
   zoom or a short laptop window — and the nav logo is on screen to take
   over: at 2:1 or narrower the primary nav overlays the hero's bottom
   (16:9 band) or sits just under a hero shorter than the window. Wider than
   2:1 the hero fills the window's height and pushes the nav below the fold,
   so the logo stays (shrunk with the height, above) down to 560px, where an
   8× headline still clears it by 24px (hero-viewport.spec.ts). Deliberately
   NOT scoped to .hero-viewport: navigation.css shows the nav logo under
   exactly these conditions, from CSS alone, so the two must be identical or
   a short window would show both logos and break the "logo never doubles"
   invariant. */
@media (min-width: 782px) and (max-height: 720px) and (max-aspect-ratio: 2/1), (min-width: 782px) and (max-height: 559px) {

	.hero-logo-overlay { display: none; }
}

/* Hero cover — full-bleed. On near-16:9 windows it fills 100vh under the
   overlaid bars (overridden above). Otherwise 16:9, capped so that it and the
   utility bar above it fit the window (--ghn-hero-max-height). */
.hero-featured-post__cover.wp-block-cover {
	max-width: 2560px;
	max-height: var(--ghn-hero-max-height);
	width: var(--ghn-hero-cover-width);
	margin-inline: auto;
	aspect-ratio: 16 / 9;
	min-height: 0;
	align-items: flex-end;
	justify-content: flex-start;
}

/* Inner container constrained to 1440px for nav-level alignment. */
.hero-featured-post__cover .wp-block-cover__inner-container {
	width: 100%;
	max-width: 1440px;
	margin-inline: auto;
	padding-left: 20px;
	padding-right: 20px;
}

/* Left-align overlay content within the hero cover. Width matches Figma:
   900px wide. The 120px left offset (Figma R.04) is applied at desktop
   below, where the logo is visible. */
.hero-featured-post__cover .hero-featured-post__overlay {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
	max-width: 900px;
	margin-left: 0;
	margin-right: auto;
	padding-left: 0;
	padding-right: 0;
}

/* Desktop (logo visible): the overlay column starts 120px from the hero's
   left edge per Figma (QA spec R.04 — scripts/qa/specs/front-page.js).
   Core's 1em cover padding is zeroed horizontally so the 120px is measured
   from the actual hero edge, not from 18px inside it.

   Logo/headline separation is guaranteed by bounding the headline (next
   rule), not by reserving space: the text column is bottom-anchored, so
   padding above it does nothing to where it sits — only its own height
   decides how far up it reaches. */
@media (min-width: 782px) {

	.hero-featured-post__cover.wp-block-cover {
		padding-left: 0;
		padding-right: 0;
	}

	.hero-featured-post__cover .wp-block-cover__inner-container {
		padding-left: 120px;
	}

}

/* The 4-line cap applies ONLY where the hero logo is actually displayed —
   wide enough (>=782px) AND tall enough (>=721px, or >=560px wider than 2:1;
   otherwise the logo hides, see above). At 200% browser zoom the viewport is
   narrower than 782px, so the heading is never clamped there (WCAG 1.4.4); a
   headline long enough to hit 4 lines at desktop size (~150 characters)
   shows an ellipsis rather than colliding with the logo. */
@media (min-width: 782px) and (min-height: 721px), (min-width: 782px) and (min-height: 560px) and (min-aspect-ratio: 2/1) {

	.hero-featured-post__cover .hero-featured-post__title {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 4;
		overflow: hidden;

		/* The last line's descenders hang below its 1.1 line box, where the
		   clamp cut them off. Less than the blank top of a clipped 5th line. */
		padding-bottom: 0.08em;
	}

	/* The clamp counts the heading's own line boxes; an inline-block link
	   would wrap internally and count as a single atomic line. */
	.hero-featured-post__cover .hero-featured-post__title a {
		display: inline;
	}
}

/* Hero category badge — yellow chip on the overlay.
   wp:post-terms renders as <div class="...hero-featured-post__badge"><a>Cat</a></div>.
   The block JSON sets backgroundColor/textColor but we also need padding + shape. */
.hero-featured-post__badge {
	display: inline-block;
	width: auto;
	margin: 0;
}

.hero-featured-post__badge a {
	display: inline-block;
	background: var(--wp--preset--color--accent-1);
	color: var(--wp--preset--color--primary-dark);
	padding: 4px 12px;
	text-decoration: none;
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	line-height: 1.4;
}

.hero-featured-post__badge a:hover {
	background: var(--wp--preset--color--accent-1-hover);
	color: var(--wp--preset--color--primary-dark);
}

.hero-featured-post__category,
.hero-featured-post__category a {
	text-decoration: none;
}

.hero-featured-post__category a {
	color: inherit;
}

.hero-featured-post__category a:hover {
	color: var(--wp--preset--color--accent-2);
}

/* Title on hero cover: white-on-photo, link-color override via descendant
   specificity (no !important — spec policy). */
.hero-featured-post__cover .hero-featured-post__title,
.hero-featured-post__cover .hero-featured-post__title a,
.hero-featured-post__cover .hero-featured-post__title a:visited,
.hero-featured-post__cover .hero-featured-post__title a:hover {
	color: var(--wp--preset--color--surface);
	text-decoration: none;
}

/* Reset WP default block margins inside the hero overlay — Figma uses gap:12px */
.hero-featured-post__cover .hero-featured-post__title { margin-block: 0; }

.hero-featured-post__cover .hero-featured-post__meta { margin-block: 0; }

/* On mobile, reduce hero overlay padding so headline has more room in 16:9 frame */
@media (max-width: 768px) {

	.hero-featured-post__cover .hero-featured-post__overlay {
		gap: 4px;
		padding-bottom: 0;
	}

	.hero-featured-post__badge a { font-size: 10px; padding: 3px 8px; }

	/* Reduce gap between title and meta to near-zero so long titles fit */
	.hero-featured-post__cover .hero-featured-post__title { margin-block-end: 0; }

	.hero-featured-post__meta { margin-block-start: 2px; }

	/* Push overlay closer to the bottom edge of the hero.
	   WP cover block has its own 18px padding; inner container adds more.
	   Zero both and let the overlay's gap handle minimal spacing. */
	.hero-featured-post__cover.wp-block-cover {
		padding-bottom: 8px;
	}

	.hero-featured-post__cover .wp-block-cover__inner-container {
		padding-bottom: 4px;
	}

	/* Remove bottom margin on meta row */
	.hero-featured-post__cover .hero-featured-post__meta {
		margin-block-end: 0;
	}

}

/* Hero byline row: all elements must match — Figma: Roboto 14px white.
   The gap between "By", name, "·" and date is the byline group's own
   blockGap (4px ≈ one space, editable in the Site Editor) — not set here. */
.hero-featured-post__meta,
.hero-featured-post__meta .wp-block-post-author-name,
.hero-featured-post__meta .wp-block-post-date,
.hero-featured-post__meta .wp-block-post-date time {
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--surface);
}

.hero-featured-post__meta .wp-block-post-author-name {
	font-weight: 700;
}

/* Print (Figma print-single): category as a plain teal label, dark title,
   muted byline, then the featured photo full-width beneath them. Drop the
   gradient, logo overlay and scroll cue, and the cover's fixed 16:9 box (its
   leftover height was the gap under the byline). No URL expansion in the
   hero — the badge would print it uppercased. !important beats the cover's
   inline aspect-ratio/min-height and the title's inline colour (print
   exception). */
@media print {

	.hero-logo-overlay,
	.hero-scroll-arrow,
	.hero-featured-post__cover > .wp-block-cover__background {
		display: none !important;
	}

	.hero-viewport,
	.hero-featured-post__cover {
		height: auto !important;
		min-height: 0 !important;
		aspect-ratio: auto !important;
		background: none !important;
		padding: 0 !important;
	}

	/* Same column as the article body: the content-size container inside
	   the root padding, then the 800px text measure of single.html's content
	   column / post-content contentSize, left-aligned (page-print.spec.ts
	   guards the alignment). !important beats core's
	   `.is-layout-constrained > .alignfull { max-width: none }`. */
	.hero-featured-post__cover {
		display: flex !important;
		flex-direction: column !important;
		align-items: flex-start !important; /* core's is-position-* sets flex-end */
		justify-content: flex-start !important;
		box-sizing: border-box;
		max-width:
			min(
				var(--wp--style--global--content-size, 1200px),
				calc(100% - var(--wp--style--root--padding-left, 20px) - var(--wp--style--root--padding-right, 20px))
			) !important;
		margin-inline: auto !important;
	}

	.hero-featured-post__cover > .wp-block-cover__inner-container,
	.hero-featured-post__overlay {
		position: static;
		order: 1;
		width: 100%;
		max-width: 800px;
		margin: 0;
		padding: 0 !important;
	}

	.hero-featured-post__cover > .wp-block-cover__image-background {
		position: static;
		order: 2;
		width: 100%;
		max-width: 800px !important; /* beats core's img.wp-block-cover__image-background { max-width: none } */
		height: auto;
		margin-top: 24px;
		object-fit: contain;
	}

	/* Catch-all first: every hero text node defaults to the dark title colour.
	   The cover's dark background is gone in print, and blocks such as the
	   front page's no-sticky fallback (category, date) carry core's
	   `.has-surface-color { color: #fff !important }` — white on paper. The
	   specific rules below win by source order / specificity. */
	.hero-featured-post__cover * {
		color: var(--wp--preset--color--primary-dark) !important;
	}

	/* Screen-only 4-line clamp (hero logo collision) must not truncate a
	   printed headline. */
	.hero-featured-post__cover .hero-featured-post__title {
		display: block !important;
		-webkit-line-clamp: none !important;
		overflow: visible !important;
	}

	.hero-featured-post__badge,
	.hero-featured-post__badge a,
	.hero-featured-post__category,
	.hero-featured-post__category a {
		background: none !important;
		padding: 0 !important;
		color: var(--wp--preset--color--primary) !important;
		text-decoration: none;
	}

	.hero-featured-post__title {
		color: var(--wp--preset--color--primary-dark) !important;
	}

	.hero-featured-post__meta,
	.hero-featured-post__meta *,
	.hero-featured-post__date,
	.hero-featured-post__date * {
		color: var(--wp--preset--color--text-muted) !important;
		text-decoration: none;
	}

	/* Category/author archive URLs add nothing on paper; the badge would
	   print one uppercased. The front-page title link keeps its URL. */
	.hero-featured-post__badge a[href]::after,
	.hero-featured-post__category a[href]::after,
	.hero-featured-post__meta a[href]::after {
		content: none;
	}
}
