/**
 * Aperture Reveal geometry, variants and states.
 *
 * Variants:
 *   cinematic — full-width first-fold scene (~72-84svh desktop).
 *   calm      — contained editorial scenes for Quiet/Warm/Secure steps.
 *
 * States (data-state): open | ready | entering | reduced | image-error.
 * Server default is "open": without JavaScript every scene is complete,
 * visible and usable. Panels are decorative (aria-hidden) and only exist
 * visually in "ready"/"entering"; the centre stile of each leaf forms the
 * window mullion while closed. The final photograph has no centre overlay.
 */

.ew-reveal {
	position: relative;
	margin-inline: auto;
}

/* Image stage: the only area where media, mullion and moving leaves live. */
.ew-reveal__stage {
	position: relative;
	overflow: hidden;
	border-radius: var(--ew-radius);
	background-color: var(--ew-stone);
}

/* Variant sizing ----------------------------------------------------------- */

.ew-reveal--cinematic {
	width: min(1480px, calc(100vw - 48px));
	height: clamp(34rem, 78svh, 52rem);
	margin-block-start: var(--ew-space-sm);
}

.ew-reveal--cinematic .ew-reveal__stage {
	position: absolute;
	inset: 0;
}

/* Split editorial hero: copy column beside the media stage. Text never
   covers the photograph; the aperture reveal still plays on the stage. */
.ew-reveal--split {
	width: 100%;
	max-width: var(--ew-container-max);
	padding-inline: var(--ew-gutter);
	margin-inline: auto;
	margin-block-start: var(--ew-space-xs);
	display: grid;
	grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
	gap: clamp(2rem, 4vw, 4.5rem);
	align-items: start;
}

.ew-reveal--split .ew-reveal__stage {
	position: relative;
	inset: auto;
	aspect-ratio: 16 / 9;
	height: auto;
	/* The photograph owns the wide column; copy sits beside it. */
	grid-column: 2;
	grid-row: 1;
}

.ew-reveal--split .ew-reveal__content {
	position: static;
	padding: 0;
	pointer-events: auto;
	grid-column: 1;
	grid-row: 1;
}

/* Square catalogue sources keep their full composition at every width. */
.ew-reveal--split.ew-page-hero--square .ew-reveal__stage {
	aspect-ratio: 1 / 1;
}

@media (max-width: 64em) {
	.ew-reveal--split {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--ew-space-sm);
		width: 100%;
	}

	/* Copy reads first; the photograph follows at full column width. */
	.ew-reveal--split .ew-reveal__content {
		order: -1;
		grid-column: 1;
		grid-row: auto;
	}

	.ew-reveal--split .ew-reveal__stage {
		grid-column: 1;
		grid-row: auto;
	}

	/* Intent copy is server-rendered before the stage, so its mobile reading and
	   focus order follows the source without CSS order or a JS relocation. */
	.ew-intent-hero .ew-reveal__content {
		margin-block-end: var(--ew-space-xs);
	}
}

/* Keep the complete mobile action group clear of the fixed dock on very short
   screens. The source order stays unchanged and the dock remains usable. */
@media (max-width: 64em) and (max-height: 40em) {
	.ew-intent-hero .ew-reveal__content {
		margin-block-start: -1.75rem;
	}
}

.ew-reveal--calm {
	/* Nearly edge-to-edge architectural shell; width determines height
	   through the 16:9 stage so the full composition stays visible. */
	width: min(1720px, calc(100vw - clamp(3rem, 4vw, 4rem)));
	margin-block: clamp(2.75rem, 2rem + 2vw, 4.75rem);
}

.ew-reveal--calm .ew-reveal__stage {
	aspect-ratio: 16 / 9;
}

@media (max-width: 64em) {
	.ew-reveal--cinematic {
		width: calc(100vw - 32px);
		height: auto;
		aspect-ratio: auto;
		margin-block-start: var(--ew-space-xs);
	}

	/* Mobile cinematic: the copy returns to the flow and owns the scene
	   height, while the stage becomes an absolutely-positioned backdrop so
	   plates are never clipped by a fixed ratio and never cross the image
	   boundary logic. */
	.ew-reveal--cinematic .ew-reveal__stage {
		position: absolute;
		inset: 0;
		min-height: calc((100vw - 32px) * 5 / 4);
	}

	.ew-reveal--cinematic .ew-reveal__content {
		position: relative;
		inset: auto;
		display: flex;
		flex-direction: column;
		align-items: stretch;
		justify-content: flex-end;
		min-height: calc((100vw - 32px) * 5 / 4);
	}

	.ew-reveal--cinematic .ew-hero__plate {
		margin-top: auto;
		align-self: flex-end;
	}

	.ew-reveal--calm .ew-reveal__content {
		padding-top: var(--ew-space-xs);
	}
}

/* Media --------------------------------------------------------------------- */

.ew-reveal__media,
.ew-reveal__media source,
.ew-reveal__image {
	display: block;
}

.ew-reveal__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Calm scenes never crop: the stage ratio matches the source exactly and
   contain guarantees the complete composition stays visible. */
.ew-reveal--calm .ew-reveal__image {
	object-fit: contain;
}

/* Copy layer ---------------------------------------------------------------- */
/* Overlay copy (cinematic/intent heroes) anchors to the reveal root, which
   sits outside the stage wrapper; calm scenes override it into a caption
   rail below the image. */

.ew-reveal__content {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: flex;
	align-items: center;
	padding: clamp(1rem, 0.5rem + 2vw, 3rem);
	pointer-events: none;
}

[data-align="right"] .ew-reveal__content {
	justify-content: flex-end;
}

.ew-reveal__content a,
.ew-reveal__content button {
	pointer-events: auto;
}

/* While JS holds the scene closed, copy stays out of the tab order and view;
   the decorative panels cover the same area, so nothing appears to flicker. */
.ew-reveal[data-reveal-live="false"] .ew-reveal__content {
	visibility: hidden;
}

/* Split heroes place copy beside, not beneath, the animated media stage.
   Keep that editorial column available from first paint while only the
   decorative leaves wait for the viewport trigger. */
.ew-reveal[data-variant="split"] .ew-reveal__content {
	visibility: visible;
}

/* Calm scenes: copy joins during the opening instead of waiting for the
   final frame. The rise starts ~260ms after the leaves and runs 700ms;
   visibility flips inside the keyframes so nothing is focusable while
   still invisible. */
.ew-reveal[data-variant="calm"][data-state="entering"] .ew-reveal__content {
	visibility: visible;
	animation: ew-calm-content-rise 450ms cubic-bezier(0.22, 1, 0.36, 1) 60ms
		both;
}

/* Split copy is already present at first paint; only the media stage opens. */
.ew-reveal[data-variant="split"][data-state="entering"] .ew-reveal__content {
	visibility: visible;
	animation: none;
}

@keyframes ew-calm-content-rise {
	from {
		opacity: 0;
		transform: translateY(12px);
		visibility: hidden;
	}

	to {
		opacity: 1;
		transform: none;
		visibility: visible;
	}
}

.ew-hero__plate,
.ew-scene-caption {
	max-width: 46rem;
}

.ew-hero__plate {
	background-color: var(--ew-surface);
	border: var(--ew-line-width) solid var(--ew-border);
	border-radius: calc(var(--ew-radius) * 2);
	padding: clamp(1.25rem, 0.9rem + 1.6vw, 2.25rem);
	box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
	pointer-events: auto;
}

/* Split-hero copy block: pure typography on the themed background — no
   card, no overlay surface, no shadow. */
.ew-hero__intro {
	max-width: 30rem;
	pointer-events: auto;
}

.ew-hero__intro h1 {
	margin-bottom: var(--ew-space-xs);
}

.ew-hero__intro .ew-lede {
	margin-bottom: var(--ew-space-sm);
}

/* Calm caption rail: pure editorial typography below the image stage —
   no card, no overlay, no blur, no border, no shadow. */
.ew-reveal--calm .ew-reveal__content {
	position: static;
	display: block;
	padding: clamp(1rem, 0.75rem + 1vw, 1.5rem) 0 0;
	pointer-events: auto;
}

.ew-scene-caption {
	max-width: none;
	color: var(--ew-text);
}

.ew-hero__plate > *:last-child,
.ew-scene-caption > *:last-child {
	margin-bottom: 0;
}

.ew-hero__plate h1 {
	font-size: clamp(2rem, 1.35rem + 2.6vw, 3.125rem);
	max-width: none;
}

.ew-scene-caption h2 {
	font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.5rem);
	margin-bottom: 0.75rem;
}

.ew-scene-caption p {
	font-size: 1rem;
	margin-bottom: 1rem;
	max-width: none;
	color: var(--ew-text-muted);
}

/* Scene onward link: quiet editorial arrow, matching .ew-link-more. */
.ew-scene-caption a {
	display: inline-flex;
	align-items: baseline;
	gap: 0.5rem;
	font-weight: 600;
	font-size: 0.9375rem;
	color: var(--ew-deep-green);
	text-decoration: none;
}

.ew-scene-caption a::after {
	content: "\2192";
	font-weight: 400;
	transition: transform var(--ew-motion-fast) var(--ew-motion-ease);
}

.ew-scene-caption a:hover {
	color: var(--ew-action);
}

.ew-scene-caption a:hover::after {
	transform: translateX(0.25rem);
}

@media (min-width: 64em) {
	/* Editorial rail: eyebrow + heading left, description + link right. */
	.ew-reveal--calm .ew-scene-caption {
		display: grid;
		grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
		column-gap: clamp(2rem, 4vw, 4rem);
		align-items: start;
	}

	.ew-reveal--calm .ew-scene-caption .ew-eyebrow {
		grid-column: 1;
		grid-row: 1;
	}

	.ew-reveal--calm .ew-scene-caption h2 {
		grid-column: 1;
		grid-row: 2;
		margin-bottom: 0;
	}

	.ew-reveal--calm .ew-scene-caption p {
		grid-column: 2;
		grid-row: 1 / span 2;
		margin-bottom: 0.75rem;
	}

	.ew-reveal--calm .ew-scene-caption a {
		grid-column: 2;
		grid-row: 3;
		justify-self: start;
	}
}

@media (max-width: 64em) {
	.ew-reveal__content {
		align-items: flex-end;
	}

	.ew-hero__plate {
		max-width: none;
	}
}

/* Decorative leaves ---------------------------------------------------------- */

.ew-reveal__panel {
	position: absolute;
	top: 0;
	bottom: 0;
	width: 50.6%;
	z-index: 4;
	display: none;
	visibility: hidden;
	pointer-events: none;
	/* A glazed sash: the view remains behind the glass, with a slim
	   aluminium profile and a restrained diagonal reflection. */
	border: 1px solid #222925;
	background:
		var(--ew-frame-metal-y) center top / 100% 6px no-repeat,
		var(--ew-frame-metal-y) center bottom / 100% 10px no-repeat,
		var(--ew-frame-metal-x) left center / 6px 100% no-repeat,
		var(--ew-frame-metal-x) right center / 6px 100% no-repeat,
		linear-gradient(116deg, transparent 12%, rgb(255 255 255 / 0.38) 26%, rgb(255 255 255 / 0.03) 47%, transparent 68%),
		linear-gradient(155deg, rgb(226 233 228 / 0.4), rgb(127 145 135 / 0.12));
	backdrop-filter: blur(3px) saturate(0.86);
	box-shadow: inset 0 0 0 7px rgb(20 28 24 / 0.25), inset 0 9px 18px rgb(15 23 19 / 0.12), 5px 0 18px rgb(8 15 11 / 0.22);
}

.ew-reveal__panel--left {
	left: 0;
	transform-origin: left center;
}

.ew-reveal__panel--right {
	right: 0;
	transform-origin: right center;
}

/* Centre stiles: each leaf carries half of the meeting mullion. */
.ew-reveal__panel::before {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 10px;
	background: var(--ew-frame-metal-x);
	box-shadow: 1px 0 0 rgb(221 226 210 / 0.5), 3px 0 6px rgb(16 23 19 / 0.18);
}

.ew-reveal__panel--left::before {
	right: 0;
}

.ew-reveal__panel--right::before {
	left: 0;
}

/* Recessed pulls travel with the two sashes, never over the copy. */
.ew-reveal__panel::after {
	content: "";
	position: absolute;
	top: calc(50% - 25px);
	width: 8px;
	height: 50px;
	border-radius: 2px;
	border: 1px solid #1c231e;
	background: var(--ew-frame-pull);
	box-shadow: 1px 0 0 rgb(239 237 218 / 0.4), 3px 3px 4px rgb(0 0 0 / 0.28);
}

.ew-reveal__panel--left::after { right: 8px; }
.ew-reveal__panel--right::after { left: 8px; }

.ew-reveal__stage::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 5;
	pointer-events: none;
	border: 1px solid rgb(226 224 209 / 0.45);
	background: var(--ew-frame-metal-y) center bottom / 100% 5px no-repeat;
	opacity: 0;
}

.ew-reveal[data-state="ready"] .ew-reveal__stage::after,
.ew-reveal[data-state="entering"] .ew-reveal__stage::after {
	opacity: 1;
}

/* Persistent identity mullion once the scene is open. */
.ew-reveal__mullion {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 50%;
	width: 8px;
	transform: translateX(-50%);
	z-index: 2;
	background-image: linear-gradient(180deg, rgb(36 82 63 / 0.55), rgb(20 53 40 / 0.55));
	opacity: 0;
	pointer-events: none;
	transition: opacity 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* States ---------------------------------------------------------------------- */

.ew-reveal[data-state="ready"] .ew-reveal__panel,
.ew-reveal[data-state="entering"] .ew-reveal__panel {
	will-change: transform;
	display: block;
	visibility: visible;
}

.ew-reveal[data-state="entering"] .ew-reveal__panel {
	transition: transform 750ms cubic-bezier(0.22, 1, 0.36, 1);
	pointer-events: none;
}

.ew-reveal[data-state="entering"][data-variant="calm"] .ew-reveal__panel {
	/* Physical opening: two leaves travelling ~51% each in 850ms. */
	transition-duration: 850ms;
	transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.ew-reveal[data-state="entering"] .ew-reveal__panel--left {
	transform: translate3d(-102%, 0, 0);
}

.ew-reveal[data-state="entering"] .ew-reveal__panel--right {
	transform: translate3d(102%, 0, 0);
}

.ew-reveal[data-state="open"] .ew-reveal__mullion,
.ew-reveal[data-state="reduced"] .ew-reveal__mullion,
.ew-reveal[data-state="image-error"] .ew-reveal__mullion {
	/* The centre bar fades fully away: the finished photograph stands alone
	   with no residual vertical element over it. */
	opacity: 0;
}

/* Home editorial sequence. Full photographs alternate with reading columns,
   so each opening and its explanation share one viewport on desktop. */
body.home .ew-reveal--calm {
	width: min(1440px, calc(100% - 2 * var(--ew-gutter)));
	margin: clamp(3.5rem, 7vw, 7rem) auto;
}

body.home .ew-reveal--calm[data-state] .ew-reveal__content {
	visibility: visible;
	animation: none;
}

body.home .ew-reveal--calm .ew-scene-caption h2 {
	font-size: clamp(2rem, 3.1vw, 3.25rem);
	line-height: 1.08;
	text-wrap: balance;
}

body.home .ew-reveal--calm .ew-scene-caption p:not(.ew-eyebrow) {
	max-width: 42ch;
	line-height: 1.65;
}

body.home .ew-reveal--calm .ew-scene-caption a {
	min-height: 44px;
	align-items: center;
	text-underline-offset: 0.3em;
}

@media (min-width: 64em) {
	body.home .ew-reveal--calm {
		display: grid;
		grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
		align-items: center;
		gap: clamp(2rem, 5vw, 5rem);
	}

	body.home .ew-reveal--calm .ew-reveal__content { padding: 0; }
	body.home .ew-reveal--calm .ew-scene-caption { display: block; }
	body.home .ew-reveal--calm .ew-scene-caption h2 { margin-bottom: 1.25rem; }
	body.home .ew-reveal--calm .ew-scene-caption .ew-eyebrow { margin-bottom: 1rem; }

	body.home .ew-scene-warm.ew-reveal--calm {
		grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
	}

	body.home .ew-scene-warm .ew-reveal__stage { grid-column: 2; grid-row: 1; }
	body.home .ew-scene-warm .ew-reveal__content { grid-column: 1; grid-row: 1; }
}
