/**
 * td/hero
 *
 * Mobile/tablet composition follows the 390px frame; desktop (≥1200px) follows
 * the 1440px frame. Sizes scale through --m / --u (1 design pixel, capped at
 * 1px). On desktop the text starts on the left content edge and the main
 * image/video ends on the right content edge (page gutter, --td-frame); on
 * wider screens it grows to fill the extra width.
 */

.td-hero {
	container-type: inline-size;
	overflow: hidden;
	background-color: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--stone);
}

/* Height comes from the text column;
   the minimum keeps the image stack clear. */
.td-hero__stage {
	--m: min(calc(100cqi / 390), 1.6px);
	position: relative;
	min-height: calc(480 * var(--m));
}

.td-hero__content {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 24px;
	width: min(100%, calc(350 * var(--m) + 2 * var(--td-gutter)));
	padding: calc(282 * var(--m)) var(--td-gutter) 56px;
}

.td-hero__header {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.td-hero__eyebrow {
	color: var(--wp--preset--color--ivory);
}

.td-hero__title {
	font-family: var(--wp--preset--font-family--serif);
	font-size: 48px;
	font-weight: 400;
	line-height: 56px;
	color: var(--wp--preset--color--ivory);
}

.td-hero__title em {
	display: block;
	font-style: italic;
	color: var(--wp--preset--color--champagne);
}

.td-hero__body {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

/* Zero-height rule, as in the design (the border paints outside the flow). */
.td-hero__body::before {
	content: "";
	width: 89px;
	height: 0;
	margin-bottom: -1px;
	border-top: 1px solid var(--wp--preset--color--bronze);
}

.td-hero__text {
	font-size: 14px;
	line-height: 22px;
}

.td-hero__actions {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	max-width: 350px;
}

/* As in the reference, the media frame starts behind the header
   (41 design px on mobile, 80 on desktop) and the section clips that
   band. object-fit: cover then crops the photo to the reference frame
   (346×414 / 765×795), not only the visible part, so the framing
   matches the design at every width. */
.td-hero__media {
	position: absolute;
	top: calc(-41 * var(--m));
	right: 0;
	width: calc(346 * var(--m));
	height: calc(414 * var(--m));
	border: 1px solid var(--td-rule);
	border-top: 0;
}

.td-hero__image,
.td-hero__video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Editor-controlled crop of the main image/video
   (focal point per breakpoint). */
.td-hero__image,
.td-hero__video {
	object-position: var(--td-hero-media-x-mobile, 50%) var(--td-hero-media-y-mobile, 50%);
}

/* Vimeo background: the player iframe is sized to cover the media box from
   the video's aspect ratio (object-fit: cover), and left/top + translate by
   the focal point equal object-position. It stays transparent over the
   poster image until view.js reports playback; without JavaScript it shows
   after 4s. */
.td-hero__vimeo {
	position: absolute;
	inset: 0;
	overflow: hidden;
	container-type: size;
	pointer-events: none;
}

.td-hero__vimeo-player {
	--td-hero-vimeo-x: var(--td-hero-media-x-mobile, 50%);
	--td-hero-vimeo-y: var(--td-hero-media-y-mobile, 50%);
	position: absolute;
	top: var(--td-hero-vimeo-y);
	left: var(--td-hero-vimeo-x);
	width: max(100cqw, 100cqh * var(--td-hero-vimeo-ratio, 1.7778));
	height: max(100cqh, 100cqw / var(--td-hero-vimeo-ratio, 1.7778));
	border: 0;
	opacity: 0;
	transform: translate(calc(-1 * var(--td-hero-vimeo-x)), calc(-1 * var(--td-hero-vimeo-y)));
	transition: opacity 0.6s ease;
	animation: td-hero-vimeo-show 0s 4s forwards;
}

.td-hero__vimeo.is-enhanced .td-hero__vimeo-player {
	animation: none;
}

.td-hero__vimeo.is-playing .td-hero__vimeo-player {
	opacity: 1;
}

@keyframes td-hero-vimeo-show {

	to {
		opacity: 1;
	}
}

/* Pause control for the background video (WCAG 2.2.2). Above the text
   column, which overlaps the media box on phones and in Style 2, so it
   stays visible and clickable. */
.td-hero__video-toggle {
	position: absolute;
	right: 12px;
	bottom: calc(100% - 85px);
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 4px;
	border: 0.5px solid var(--wp--preset--color--ivory);
	background-color: rgba(10, 16, 31, 0.4);
	color: var(--wp--preset--color--ivory);
	cursor: pointer;
}

@media (min-width: 1200px) {

	.td-hero__video-toggle {
		right: 12px;
		bottom: 12px;
	}
}

.td-hero__video-toggle[hidden] {
	display: none;
}

.td-hero__video-toggle .td-icon--play,
.td-hero__video-toggle[aria-pressed="true"] .td-icon--pause {
	display: none;
}

.td-hero__video-toggle[aria-pressed="true"] .td-icon--play {
	display: block;
}

.td-hero__media-label {
	display: none;
}

.td-hero__rail {
	display: none;
}

@media (min-width: 1200px) {

	.td-hero__stage,
	.td-hero__rail {
		--u: min(calc(100cqi / 1440), 1px);
	}

	.td-hero__stage {
		max-width: var(--td-frame);

		/* The media ends 715 design px down; 80 more leaves as much air below
		   it as there is above the eyebrow. */
		min-height: calc(795 * var(--u));
		margin-inline: auto;
	}

	.td-hero__content {
		gap: 64px;
		width: calc(427 * var(--u) + var(--td-gutter));
		padding: calc(58 * var(--u)) 0 64px var(--td-gutter);
	}

	.td-hero__header {
		gap: 32px;
	}

	.td-hero__eyebrow {
		color: var(--wp--preset--color--champagne);
	}

	.td-hero__title {
		font-size: calc(82 * var(--u));
		line-height: calc(80 * var(--u));
	}

	.td-hero__title em {
		text-align: center;
	}

	.td-hero__body {
		gap: 32px;
	}

	.td-hero__text {
		font-size: 16px;
		line-height: 25px;
	}

	.td-hero__actions {
		justify-content: flex-start;
		gap: 24px;
		max-width: none;
	}

	.td-hero__image,
	.td-hero__video {
		object-position: var(--td-hero-media-x, 50%) var(--td-hero-media-y, 50%);
	}

	.td-hero__vimeo-player {
		--td-hero-vimeo-x: var(--td-hero-media-x, 50%);
		--td-hero-vimeo-y: var(--td-hero-media-y, 50%);
	}

	.td-hero__media {
		top: calc(-80 * var(--u));
		right: var(--td-gutter);
		left: calc(var(--td-gutter) + 563 * var(--u)); /* design: 619 − 56 */
		width: auto;
		height: calc(795 * var(--u));
	}

	.td-hero__media-label {
		display: block;
		position: absolute;
		top: calc((180 + 30) * var(--u)); /* 30 below the visible top edge */
		right: calc(50 * var(--u));
		color: var(--wp--preset--color--ivory);
		opacity: 0.6;
		white-space: nowrap;
		writing-mode: vertical-rl;
	}
}

/* The rail tagline needs ~640px of rail height; show it once there is room.
   On the front end it is fixed to the left edge of the viewport for the whole
   page (below the sticky header, above no content: the 40px rail sits inside
   the 56px page gutter and ignores pointer events). */
@media (min-width: 1320px) {

	.td-hero__rail {
		position: fixed;
		z-index: 40;
		top: 0;
		bottom: 0;
		left: 0;
		display: flex;
		align-items: flex-start;
		justify-content: center;
		width: var(--td-rail);

		/* Starts 60px below the sticky header: admin bar (when logged in) +
		   79px header + 1px border (see site-header/style.css). */
		padding-top: calc(var(--wp-admin--admin-bar--height, 0px) + 80px + 60px);
		overflow: hidden;
		pointer-events: none;
	}

	/* Editor canvas: stays inside the block, as in the design frame. */
	.editor-styles-wrapper .td-hero__rail {
		position: absolute;
		z-index: auto;
		bottom: auto;
		height: calc(715 * var(--u));
		padding-top: 80px;
	}

	.td-hero__rail-text {
		color: var(--wp--preset--color--slate);
		white-space: nowrap;
		writing-mode: vertical-rl;
	}
}

/* Style 2 — Full image ------------------------------------------------------
   The main image/video fills the section behind the text, with the design's
   bottom fade into the page colour. The design frames (844 / 795px tall)
   start under the 96 / 80px header bar, so the visible section is 748 / 715px
   and the media and fade are laid out on the full frame (their top band is
   clipped, like Style 1). Text sits at the bottom: centred below 1200px, on
   the left content edge from 1200px. No rail or caption. */

.td-hero.is-style-cover {
	--td-hero-frame-top: 96px;
}

.td-hero.is-style-cover::before {
	content: none;
}

.td-hero.is-style-cover .td-hero__stage {
	position: static;
	display: flex;
	align-items: flex-end;
	max-width: var(--td-frame);
	min-height: 748px;
	margin-inline: auto;
}

/* "Fill the screen" (block setting): the hero reaches the bottom of the window
   instead of stopping at the design height, never shorter than that height.
   The header sits above the hero in the page flow (95px + 1px border below
   1200px; see site-header/style.css), so only the header and the admin bar are
   taken off the window height. The text stays at the bottom (flex-end). */
.td-hero.is-style-cover.is-fill-screen .td-hero__stage {
	min-height: max(748px, calc(100vh - var(--wp-admin--admin-bar--height, 0px) - 96px));
	min-height: max(748px, calc(100svh - var(--wp-admin--admin-bar--height, 0px) - 96px));
}

.td-hero.is-style-cover .td-hero__content {
	align-items: center;
	width: 100%;
	padding: 0 var(--td-gutter) 80px;
	text-align: center;
}

.td-hero.is-style-cover .td-hero__eyebrow {
	color: var(--wp--preset--color--champagne);
}

.td-hero.is-style-cover .td-hero__title {
	font-size: 40px;
	line-height: 48px;
}

.td-hero.is-style-cover .td-hero__body::before {
	content: none;
}

.td-hero.is-style-cover .td-hero__actions {
	flex-direction: column;
	justify-content: center;
	align-self: stretch;
	max-width: none;
}

.td-hero.is-style-cover .td-hero__actions .td-btn--light {
	align-self: stretch;
}

.td-hero.is-style-cover .td-hero__content:has(.td-hero__actions) {
	padding-bottom: 48px;
}

.td-hero.is-style-cover .td-hero__media {
	top: calc(-1 * var(--td-hero-frame-top));
	right: 0;
	bottom: 0;
	left: 0;
	width: auto;
	height: auto;
	border: 0;
}

.td-hero.is-style-cover .td-hero__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, rgba(10, 16, 31, 0) 46.23%, var(--wp--preset--color--ink) 81.59%);
	pointer-events: none;
}

@media (min-width: 1200px) {

	.td-hero.is-style-cover {
		--td-hero-frame-top: 80px;
	}

	.td-hero.is-style-cover .td-hero__stage {
		min-height: 715px;
	}

	/* Header bar is 79px + 1px border from 1200px. */
	.td-hero.is-style-cover.is-fill-screen .td-hero__stage {
		min-height: max(715px, calc(100vh - var(--wp-admin--admin-bar--height, 0px) - 80px));
		min-height: max(715px, calc(100svh - var(--wp-admin--admin-bar--height, 0px) - 80px));
	}

	/* Text column on the left (title block up to 652px, intro 539px) and
	   the buttons on the right, aligned to the bottom (design). */
	.td-hero.is-style-cover .td-hero__content,
	.td-hero.is-style-cover .td-hero__content:has(.td-hero__actions) {
		display: grid;
		grid-template-columns: minmax(0, 652px) auto;
		align-items: end;
		justify-content: space-between;
		gap: 24px 64px;
		width: 100%;
		padding: 0 var(--td-gutter) 64px;
		text-align: left;
	}

	.td-hero.is-style-cover .td-hero__header,
	.td-hero.is-style-cover .td-hero__body {
		grid-column: 1;
	}

	.td-hero.is-style-cover .td-hero__body {
		max-width: 539px;
	}

	.td-hero.is-style-cover .td-hero__text {
		font-size: 14px;
		line-height: 22px;
	}

	.td-hero.is-style-cover .td-hero__header {
		gap: 24px;
		max-width: 652px;
	}

	.td-hero.is-style-cover .td-hero__title {
		font-size: clamp(48px, 4.45vw, 64px);
		line-height: 1;
	}

	.td-hero.is-style-cover .td-hero__title em {
		text-align: left;
	}

	.td-hero.is-style-cover .td-hero__actions {
		flex-direction: row;
		grid-row: 1 / span 2;
		grid-column: 2;
		align-self: end;
		gap: 24px;
	}

	.td-hero.is-style-cover .td-hero__actions .td-btn--light {
		align-self: auto;
	}
}
