/**
 * PencilART Scroll Story — hero styles.
 * Tokens fall back to local values so the component also works standalone.
 */

.pab-scroll-hero {
	--pab-hero-h-desktop: 420vh;
	--pab-hero-h-tablet: 340vh;
	--pab-hero-h-mobile: 280vh;
	--pab-hero-paper: #F5F2E3;
	--pab-hero-graphite: var(--pab-graphite, #252422);
	--pab-hero-grey: var(--pab-grey, #6F6B65);
	--pab-hero-honey: var(--pab-honey, #B8892F);
	--pab-hero-line: var(--pab-line, #CAC3B7);
	--pab-hero-display: var(--pab-display, 'Cormorant Garamond', Georgia, serif);
	--pab-hero-sans: var(--pab-sans, 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif);

	position: relative;
	height: var(--pab-hero-h-desktop);
	background: var(--pab-hero-paper);
	/* Deliberately NOT overflow:hidden — that would break the sticky child. */
}

/* The sticky stage is the only element that clips. */
.pab-scroll-hero__sticky {
	position: sticky;
	top: 0;
	width: 100%;
	height: 100vh;
	height: 100svh;
	overflow: hidden;
	background: var(--pab-hero-paper);
}

.pab-scroll-hero__canvas,
.pab-scroll-hero__poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
}

.pab-scroll-hero__poster {
	object-fit: contain;
	object-position: center 40%;
	background: var(--pab-hero-paper);
	transition: opacity .5s ease;
}

.pab-scroll-hero__poster.is-hidden {
	opacity: 0;
	pointer-events: none;
}

/* Canvas stays invisible until the first frame is drawn, so the poster shows through. */
.pab-scroll-hero.is-live .pab-scroll-hero__canvas { opacity: 0; transition: opacity .4s ease; }
.pab-scroll-hero.is-live.is-ready .pab-scroll-hero__canvas { opacity: 1; }

/* ---------- Story copy ---------- */

.pab-scroll-hero__story {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	padding: 0 clamp(1.5rem, 1rem + 3vw, 5.5rem);
	pointer-events: none;
	z-index: 2;
}

/* `ch` here resolves against this element's 16px sans, not the display serif, so
   a ch-only cap pins the column to ~343px at every width: squashed at 1440 and
   five lines with ~200px of wasted paper at 1920. Pair it with a vw cap that
   tracks where the drawing's ink begins. */
.pab-scroll-hero__panel {
	max-width: min(34ch, 42%);
	pointer-events: auto;
	will-change: opacity, transform;
}

/* Before JavaScript runs, show only the opening panel rather than all five stacked. */
.pab-scroll-hero:not(.is-live):not(.is-reduced-motion) .pab-scroll-hero__panel:not(:first-child) {
	display: none;
}

.pab-scroll-hero.is-live .pab-scroll-hero__panel {
	position: absolute;
	left: clamp(1.5rem, 1rem + 3vw, 5.5rem);
	right: auto;
	opacity: 0;
}

.pab-scroll-hero__eyebrow {
	font-family: var(--pab-hero-sans);
	font-size: .72rem;
	font-weight: 500;
	letter-spacing: .2em;
	text-transform: uppercase;
	color: var(--pab-hero-grey);
	margin: 0 0 1.1rem;
}

.pab-scroll-hero__heading {
	font-family: var(--pab-hero-display);
	font-weight: 400;
	font-size: clamp(2rem, 1rem + 2.4vw, 3.9rem);
	line-height: 1.04;
	letter-spacing: -.012em;
	color: var(--pab-hero-graphite);
	margin: 0 0 1.1rem;
	text-wrap: balance;
}

.pab-scroll-hero__text {
	font-family: var(--pab-hero-sans);
	font-size: clamp(1rem, .95rem + .3vw, 1.18rem);
	line-height: 1.6;
	color: var(--pab-hero-grey);
	margin: 0;
	max-width: 34ch;
}

.pab-scroll-hero__cue {
	margin: 2rem 0 0;
	font-family: var(--pab-hero-sans);
	font-size: .76rem;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--pab-hero-graphite);
}

.pab-scroll-hero__cue span {
	border-bottom: 1px solid var(--pab-hero-honey);
	padding-bottom: 3px;
}

/* ---------- Loading progress: a fine graphite line, not a spinner ---------- */

.pab-scroll-hero__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 1px;
	background: rgba(37, 36, 34, .09);
	z-index: 3;
	transition: opacity .6s ease;
}

.pab-scroll-hero__progress span {
	display: block;
	height: 100%;
	width: 100%;
	background: var(--pab-hero-graphite);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform .35s ease;
}

.pab-scroll-hero.is-loaded .pab-scroll-hero__progress { opacity: 0; }

/* ---------- Skip link ---------- */

.pab-scroll-hero__skip {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 10;
	background: var(--pab-hero-graphite);
	color: var(--pab-hero-paper);
	padding: .8rem 1.3rem;
	font-family: var(--pab-hero-sans);
	font-size: .82rem;
	text-decoration: none;
}

.pab-scroll-hero__skip:focus {
	left: 1rem;
	top: 1rem;
}

/* ---------- Static states: reduced motion, canvas failure, editor ---------- */

.pab-scroll-hero.is-reduced-motion,
.pab-scroll-hero.is-fallback,
.pab-scroll-hero.is-editor-preview {
	height: auto;
}

.pab-scroll-hero.is-reduced-motion .pab-scroll-hero__sticky,
.pab-scroll-hero.is-fallback .pab-scroll-hero__sticky,
.pab-scroll-hero.is-editor-preview .pab-scroll-hero__sticky {
	position: relative;
	height: auto;
	min-height: 100svh;
}

/* Opening headline and closing message together, middle stages omitted. */
.pab-scroll-hero.is-reduced-motion .pab-scroll-hero__panel:not(:first-child):not(:last-child) {
	display: none;
}

.pab-scroll-hero.is-reduced-motion .pab-scroll-hero__story,
.pab-scroll-hero.is-fallback .pab-scroll-hero__story {
	position: relative;
	flex-direction: column;
	justify-content: center;
	gap: 2rem;
	min-height: 100svh;
	padding-block: 4rem;
}

.pab-scroll-hero.is-reduced-motion .pab-scroll-hero__panel,
.pab-scroll-hero.is-fallback .pab-scroll-hero__panel {
	position: relative;
	opacity: 1;
	transform: none;
}

.pab-scroll-hero.is-reduced-motion .pab-scroll-hero__progress,
.pab-scroll-hero.is-fallback .pab-scroll-hero__progress {
	display: none;
}

.pab-scroll-hero.is-editor-preview .pab-scroll-hero__canvas { display: none; }

.pab-scroll-hero__editor-note {
	position: absolute;
	left: 1rem;
	bottom: 1rem;
	z-index: 5;
	margin: 0;
	padding: .5rem .9rem;
	background: rgba(37, 36, 34, .88);
	color: #F5F2E3;
	font-family: var(--pab-hero-sans);
	font-size: .74rem;
	letter-spacing: .04em;
}

.pab-scroll-hero__noscript img {
	display: block;
	width: 100%;
	height: auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
	.pab-scroll-hero { height: var(--pab-hero-h-tablet); }
	.pab-scroll-hero__panel { max-width: min(32ch, 56%); }
}

@media (min-width: 1025px) { .pab-scroll-hero__panel { max-width: min(34ch, 23vw); } }
@media (min-width: 1700px) { .pab-scroll-hero__panel { max-width: min(46ch, 25vw); } }
@media (min-width: 1900px) { .pab-scroll-hero__panel { max-width: min(46ch, 26vw); } }

@media (max-width: 767px) {
	.pab-scroll-hero { height: var(--pab-hero-h-mobile); }

	/* Portrait: the frame is contained in the upper area, copy sits below it. */
	.pab-scroll-hero__story {
		align-items: flex-start;
		padding: 50% 1.4rem 2rem;
	}

	/*
	 * Portrait: the copy sits inside the clear opening of the arch. Measured across
	 * the whole sequence, y 44%-70% carries essentially no ink (0% between 50% and
	 * 65%), with the centre columns clearest — so the panel is a fixed band there
	 * and centres its content. A fixed band rather than a translate keeps the
	 * reveal transform (set inline by the script) free to do its own job.
	 */
	.pab-scroll-hero.is-live .pab-scroll-hero__panel {
		left: 1.25rem;
		right: 1.25rem;
		top: 43%;
		bottom: auto;
		height: 30%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		text-align: center;
		max-width: none;
	}

	.pab-scroll-hero__panel {
		max-width: none;
	}

	.pab-scroll-hero__eyebrow,
	.pab-scroll-hero__heading,
	.pab-scroll-hero__text,
	.pab-scroll-hero__cue {
		text-align: center;
		margin-left: auto;
		margin-right: auto;
	}

	.pab-scroll-hero__heading {
		font-size: clamp(1.45rem, 5.4vw, 2.05rem);
		text-wrap: balance;
		margin-bottom: .7rem;
	}

	.pab-scroll-hero__text {
		font-size: .97rem;
		line-height: 1.5;
		max-width: 30ch;
	}

	.pab-scroll-hero__cue { margin-top: 1rem; }


}

@media (prefers-reduced-motion: reduce) {
	.pab-scroll-hero__panel,
	.pab-scroll-hero__poster,
	.pab-scroll-hero__canvas,
	.pab-scroll-hero__progress span {
		transition: none !important;
	}
}
