/*
 * WonderTale House — cinematic hero (v0.2), markup from wondertale-core render_hero().
 *
 * Depth is built from: the approved illustration (one flattened plate, never cut apart),
 * CSS light layers aligned to the door, windows and moon, CSS fireflies, three dimensional
 * floating books in front, and a gentle pointer parallax (hero.js, desktop pointer only).
 *
 * Desktop ≥1025px: copy on the left over a night scrim; the house sits right of centre with
 *   the glowing door kept clear; books float bottom-right.
 * Tablet 768–1024px and mobile <768px: stacked. Copy first, then the house panel (mobile uses
 *   a portrait crop centred on the door), then the books overlapping the panel's lower edge.
 * Reduced motion: no float, glow breathing, fireflies drift or parallax.
 */

.wt-hero {
	--wt-hero-h: clamp(620px, calc(100svh - var(--wt-header-h, 76px)), 860px);
	--wt-art-ratio: 1.7768; /* 1672 / 941 */
	--wt-door-at: 0.51;     /* door centre, fraction of the illustration width */
	--wt-door-x: 58%;       /* where the door lands across the hero (desktop) */
	position: relative;
	isolation: isolate;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	background: var(--wt-night);
	color: var(--wt-ivory);
}

/* ---------- Stage: illustration, light, fireflies, scrim ---------- */
.wt-hero__stage { position: relative; }
.wt-hero__art { position: relative; }
.wt-hero__plate,
.wt-hero__plate img { display: block; width: 100%; height: 100%; }
.wt-hero__plate img { object-fit: cover; object-position: 50% 50%; }

.wt-hero__light { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: screen; }
.wt-hero__glow {
	position: absolute;
	left: var(--x);
	top: var(--y);
	width: var(--s);
	aspect-ratio: 1;
	translate: -50% -50%;
	border-radius: 50%;
	background: radial-gradient(closest-side, rgb(255 196 110 / var(--a, 0.55)), rgb(255 170 70 / 0.18) 55%, transparent 100%);
	opacity: 0.85;
}
.wt-hero__glow--door { --x: 51%; --y: 64%; --s: 12%; --a: 0.6; }
.wt-hero__glow--windows { --x: 36%; --y: 58%; --s: 15%; --a: 0.42; }
.wt-hero__glow--moon { --x: 77.3%; --y: 23%; --s: 26%; --a: 0.32; background: radial-gradient(closest-side, rgb(255 236 180 / 0.34), rgb(255 220 150 / 0.1) 60%, transparent 100%); }

.wt-hero__fireflies { position: absolute; inset: 0; pointer-events: none; }
.wt-firefly {
	position: absolute;
	left: var(--x);
	top: var(--y);
	width: var(--d, 4px);
	aspect-ratio: 1;
	border-radius: 50%;
	background: #FFE7A3;
	box-shadow: 0 0 6px 2px rgb(255 214 120 / 0.75), 0 0 16px 6px rgb(255 190 80 / 0.28);
	opacity: 0.75;
}
.wt-firefly--1  { --x: 46%; --y: 34%; --t: 9s;  --dl: -1s; }
.wt-firefly--2  { --x: 53%; --y: 48%; --t: 11s; --dl: -4s; --d: 3px; }
.wt-firefly--3  { --x: 61%; --y: 28%; --t: 8s;  --dl: -2s; }
.wt-firefly--4  { --x: 67%; --y: 56%; --t: 12s; --dl: -7s; --d: 5px; }
.wt-firefly--5  { --x: 72%; --y: 40%; --t: 10s; --dl: -3s; --d: 3px; }
.wt-firefly--6  { --x: 79%; --y: 62%; --t: 9s;  --dl: -6s; }
.wt-firefly--7  { --x: 85%; --y: 46%; --t: 13s; --dl: -2s; --d: 3px; }
.wt-firefly--8  { --x: 90%; --y: 70%; --t: 10s; --dl: -8s; }
.wt-firefly--9  { --x: 50%; --y: 78%; --t: 11s; --dl: -5s; --d: 3px; }
.wt-firefly--10 { --x: 41%; --y: 66%; --t: 9s;  --dl: -9s; }
.wt-firefly--11 { --x: 64%; --y: 82%; --t: 12s; --dl: -1s; --d: 5px; }
.wt-firefly--12 { --x: 95%; --y: 30%; --t: 10s; --dl: -3s; --d: 3px; }
.wt-firefly--13 { --x: 57%; --y: 18%; --t: 14s; --dl: -6s; --d: 2px; }
.wt-firefly--14 { --x: 75%; --y: 84%; --t: 9s;  --dl: -4s; }

.wt-hero__shade { position: absolute; inset: 0; pointer-events: none; }

/* ---------- Copy ---------- */
.wt-hero__inner {
	position: relative;
	z-index: 2;
	width: 100%;
	max-width: calc(var(--wt-content-max) + 2 * var(--wt-gutter));
	margin-inline: auto;
	padding-inline: var(--wt-gutter);
}
.wt-hero__copy { max-width: 36rem; pointer-events: auto; }
.wt-site .wt-hero__eyebrow {
	margin: 0 0 var(--wt-space-4);
	font: 800 var(--wt-fs-eyebrow)/1.3 var(--wt-font-body);
	letter-spacing: var(--wt-tracking-eyebrow);
	text-transform: uppercase;
	color: var(--wt-gold);
}
.wt-site .wt-hero__title {
	margin: 0 0 var(--wt-space-5);
	font-family: var(--wt-font-display);
	font-weight: 600;
	font-size: clamp(2.4rem, 1.35rem + 4.1vw, 4.75rem);
	line-height: 1.02;
	letter-spacing: -0.02em;
	color: var(--wt-ivory);
	text-wrap: balance;
	font-variation-settings: "opsz" 144;
}
.wt-hero__title-line,
.wt-hero__title-accent { display: block; }
.wt-hero__title-accent { color: var(--wt-gold); }
.wt-site .wt-hero__lead {
	max-width: 33rem;
	margin: 0 0 var(--wt-space-6);
	font-size: var(--wt-fs-lead);
	line-height: 1.6;
	color: rgb(255 247 238 / 0.9);
}
.wt-hero__actions { display: flex; flex-wrap: wrap; gap: var(--wt-space-4); }
.wt-site .wt-hero .wt-btn:focus-visible { outline: 3px solid var(--wt-ivory); outline-offset: 3px; box-shadow: none; }
.wt-site .wt-hero .wt-btn--primary { box-shadow: 0 10px 28px -10px rgb(233 162 59 / 0.7); }

.wt-hero__editor-note {
	position: relative;
	z-index: 3;
	margin: 0;
	padding: 6px var(--wt-gutter) 52px;
	font-size: 0.8125rem;
	color: rgb(255 247 238 / 0.7);
	text-align: center;
}

/* ---------- Floating books ---------- */
.wt-site .wt-hero__books {
	position: absolute;
	z-index: 3;
	display: flex;
	align-items: flex-end;
	margin: 0;
	padding: 0;
	list-style: none;
	perspective: 1100px;
}
.wt-hero__book { position: relative; margin: 0; flex: none; width: var(--w); }
.wt-hero__book--1 { --w: 30%; --ry: 16deg;  --rz: -5deg; --tz: 0px;  z-index: 1; margin-right: -6%; }
.wt-hero__book--2 { --w: 36%; --ry: 0deg;   --rz: 0deg;  --tz: 40px; z-index: 2; margin-bottom: 7%; }
.wt-hero__book--3 { --w: 30%; --ry: -16deg; --rz: 5deg;  --tz: 0px;  z-index: 1; margin-left: -6%; }
.wt-hero__book::after { /* soft ground shadow */
	content: "";
	position: absolute;
	left: 10%;
	right: 10%;
	bottom: -14%;
	height: 12%;
	border-radius: 50%;
	background: radial-gradient(closest-side, rgb(0 0 0 / 0.55), transparent);
	filter: blur(2px);
	z-index: -1;
}
.wt-site .wt-hbook {
	display: block;
	transform: rotateY(var(--ry)) rotateZ(var(--rz)) translateZ(var(--tz));
	transform-style: preserve-3d;
	transition: transform var(--wt-dur-slow) var(--wt-ease-out);
	border-radius: 4px 8px 8px 4px;
	text-decoration: none;
}
.wt-hbook__float {
	position: relative;
	display: block;
	border-radius: 3px 7px 7px 3px;
	box-shadow:
		3px 3px 0 -1px #F2E5CC,
		6px 6px 0 -2px #E4D2B2,
		9px 9px 0 -3px #D9C4A0,
		0 28px 40px -16px rgb(0 0 0 / 0.75),
		0 0 0 1px rgb(0 0 0 / 0.15);
	transition: box-shadow var(--wt-dur-slow) var(--wt-ease-out), transform var(--wt-dur-slow) var(--wt-ease-out);
}
.wt-hbook__float::before { /* spine crease and gloss */
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: inherit;
	background:
		linear-gradient(90deg, rgb(0 0 0 / 0.38) 0, rgb(255 255 255 / 0.22) 2.2%, rgb(0 0 0 / 0.12) 4%, transparent 9%),
		linear-gradient(115deg, rgb(255 255 255 / 0.16) 0%, transparent 32%);
	pointer-events: none;
}
.wt-hbook__cover { display: block; width: 100%; height: auto; border-radius: inherit; }
.wt-site .wt-hbook:hover,
.wt-site .wt-hbook:focus-visible { transform: rotateY(calc(var(--ry) * 0.35)) rotateZ(0deg) translateZ(calc(var(--tz) + 30px)) translateY(-8px); }
.wt-hbook:hover .wt-hbook__float,
.wt-hbook:focus-visible .wt-hbook__float { box-shadow: 3px 3px 0 -1px #F2E5CC, 6px 6px 0 -2px #E4D2B2, 9px 9px 0 -3px #D9C4A0, 0 40px 50px -18px rgb(0 0 0 / 0.8), 0 0 0 1px rgb(0 0 0 / 0.15), 0 0 34px rgb(233 162 59 / 0.35); }
.wt-site .wt-hero .wt-hbook:focus-visible { outline: 3px solid var(--wt-ivory); outline-offset: 6px; border-radius: 8px; box-shadow: none; }

/* ---------- Desktop ≥1024px: cinematic overlay layout ---------- */
@media (min-width: 1024px) {
	.wt-hero { height: var(--wt-hero-h); justify-content: center; }
	.wt-hero__stage { position: absolute; inset: 0; z-index: 0; }
	.wt-hero__art {
		position: absolute;
		top: 0;
		height: 100%;
		width: calc(var(--wt-hero-h) * var(--wt-art-ratio));
		left: calc(var(--wt-door-x) - var(--wt-door-at) * var(--wt-hero-h) * var(--wt-art-ratio));
	}
	.wt-hero__fireflies { left: 30%; }
	.wt-hero__shade {
		background:
			linear-gradient(90deg, var(--wt-night) 0%, rgb(11 36 51 / 0.95) 26%, rgb(11 36 51 / 0.86) 38%, rgb(11 36 51 / 0.45) 49%, rgb(11 36 51 / 0.1) 57%, transparent 63%),
			linear-gradient(0deg, rgb(11 36 51 / 0.85) 0%, transparent 16%),
			linear-gradient(180deg, rgb(11 36 51 / 0.45) 0%, transparent 14%);
	}
	.wt-site .wt-hero__books { right: max(2.5vw, calc((100vw - var(--wt-content-max)) / 2 - 3vw)); bottom: 7%; width: min(37vw, 620px); }
	.wt-hero__inner { pointer-events: none; }
	.wt-hero__copy { padding-block: var(--wt-space-7); }
	.wt-hero__editor-note { position: absolute; left: 0; bottom: 48px; text-align: left; } /* clear of the next section's wave edge */
}
@media (min-width: 1024px) and (max-width: 1279px) {
	.wt-hero { --wt-door-x: 61%; }
	.wt-hero__copy { max-width: 28rem; }
	.wt-site .wt-hero__title { font-size: clamp(2.6rem, 0.6rem + 4vw, 4rem); }
	.wt-site .wt-hero__books { width: 34vw; right: 2vw; }
}

/* ---------- Tablet and mobile: stacked composition ---------- */
@media (max-width: 1023px) {
	.wt-hero__inner { padding-block: clamp(2.25rem, 6vw, 4rem) clamp(1.75rem, 4vw, 2.5rem); }
	.wt-hero__art { aspect-ratio: 1672 / 941; }
	.wt-hero__stage::before { /* blend the panel's top edge into the night background */
		content: "";
		position: absolute;
		inset: 0 0 auto;
		height: 22%;
		z-index: 1;
		background: linear-gradient(180deg, var(--wt-night), transparent);
		pointer-events: none;
	}
	.wt-hero__shade { background: linear-gradient(0deg, var(--wt-night) 0%, rgb(11 36 51 / 0.55) 16%, transparent 34%); }
	.wt-hero { --wt-books-w: min(78vw, 470px); }
	/* Books sit mostly below the panel (only their tops overlap it), so the door stays clear. */
	.wt-site .wt-hero__books { left: 50%; translate: -50% 70%; bottom: 0; width: var(--wt-books-w); }
	.wt-hero__stage { margin-bottom: calc(var(--wt-books-w) * 0.31 + var(--wt-space-6)); }
	.wt-hero__copy { max-width: 38rem; }
}

@media (max-width: 767px) {
	/* Portrait crop centred on the door (x 430–1150 of the 1672 px illustration). */
	.wt-hero__art { aspect-ratio: 720 / 941; }
	.wt-hero__glow--door { --x: 58.6%; --y: 64%; --s: 26%; }
	.wt-hero__glow--windows { --x: 22%; --y: 58%; --s: 30%; }
	.wt-hero__glow--moon { display: none; }
	.wt-firefly:nth-child(n+7) { display: none; }
	.wt-hero { --wt-books-w: min(92vw, 400px); }
	.wt-hero__actions { flex-direction: column; align-items: stretch; }
	.wt-hero__actions .wt-btn { width: 100%; justify-content: center; }
	.wt-site .wt-hero__title { font-size: clamp(2.25rem, 1.5rem + 3.8vw, 2.9rem); }
}

/* ---------- Motion (only when the visitor has not asked for less) ---------- */
@media (prefers-reduced-motion: no-preference) {
	.wt-hero__copy > * { animation: wt-hero-rise 0.8s var(--wt-ease-out) both; }
	.wt-hero__copy > :nth-child(2) { animation-delay: 0.08s; }
	.wt-hero__copy > :nth-child(3) { animation-delay: 0.16s; }
	.wt-hero__copy > :nth-child(4) { animation-delay: 0.24s; }
	.wt-hero__books { animation: wt-hero-fade 1.1s 0.2s var(--wt-ease-out) both; }
	.wt-hbook__float { animation: wt-hero-bob 6.5s var(--wt-ease-in-out) infinite alternate; }
	.wt-hero__book--2 .wt-hbook__float { animation-duration: 7.5s; animation-delay: -2s; }
	.wt-hero__book--3 .wt-hbook__float { animation-duration: 7s; animation-delay: -4.5s; }
	.wt-hbook:hover .wt-hbook__float,
	.wt-hbook:focus-visible .wt-hbook__float { animation-play-state: paused; }
	.wt-hero__glow { animation: wt-hero-breathe 7s var(--wt-ease-in-out) infinite alternate; }
	.wt-hero__glow--windows { animation-delay: -3s; }
	.wt-hero__glow--moon { animation-duration: 11s; }
	.wt-firefly { animation: wt-firefly-drift var(--t, 10s) ease-in-out var(--dl, 0s) infinite alternate, wt-firefly-blink calc(var(--t, 10s) * 0.37) ease-in-out var(--dl, 0s) infinite alternate; }
	.wt-hero[data-paused] .wt-firefly,
	.wt-hero[data-paused] .wt-hbook__float,
	.wt-hero[data-paused] .wt-hero__glow { animation-play-state: paused; }
}
@keyframes wt-hero-rise { from { opacity: 0; transform: translate3d(0, 18px, 0); } to { opacity: 1; transform: none; } }
@keyframes wt-hero-fade { from { opacity: 0; transform: translate3d(0, 24px, 0) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes wt-hero-bob { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(0, -9px, 0); } }
@keyframes wt-hero-breathe { from { opacity: 0.6; } to { opacity: 1; } }
@keyframes wt-firefly-drift { from { transform: translate3d(0, 0, 0); } 50% { transform: translate3d(14px, -18px, 0); } to { transform: translate3d(-10px, -34px, 0); } }
@keyframes wt-firefly-blink { from { opacity: 0.15; } to { opacity: 0.95; } }

@media (prefers-reduced-motion: reduce) {
	.wt-hero [data-wt-depth] { transform: none !important; }
	.wt-firefly { opacity: 0.6; }
}
