/*
 * NORTIA hero: "The Nail of Years" (front page only).
 *
 * One screen tall: the owner's film plays once over it (hero.js) and rests on
 * its last frame, the NORTIA sign. One line of text and one button (D41).
 * Mobile is composed first; the desktop composition is its own block below,
 * not a stretched phone.
 *
 * --p is the film's progress, 0 (start) to 1 (end). hero.js writes it while
 * the film plays; without it (no JS, reduced motion, no video) it stays 1,
 * the final state.
 *
 * Two ink states: the film starts in a dark cave (light ink) and turns
 * light from the hand-in-light shot on (dark ink, .hero--light).
 */

/* The header stays fixed on this page: in-page jumps (#koleksiyon) and
   keyboard focus must not land underneath it. */
html {
	scroll-padding-block-start: var(--header-height);
}

/* While the dark hero is under the header (hero.js), the page ground outside
   the content is dark too, so a phone's bounce past the top shows no light
   strip. Once the film turns light, the ground follows (no dark strip). */
html.in-hero:not(.in-hero--light) {
	background-color: var(--color-hero-bg);
}

/* Inside the hero, the theme's color roles flip to the dark film ground,
   so the focus ring and text stay legible. Values come from tokens.css. */
.hero {
	--p: 1;
	--ink: var(--color-hero-ink);
	--ink-dim: var(--color-hero-ink-dim);
	--ground: var(--color-hero-bg);
	--color-bg: var(--ground);
	--color-text: var(--ink);
	--color-text-muted: var(--color-hero-ink-muted);
	--color-focus: var(--ink);

	position: relative;
	background: var(--color-hero-bg);
	color: var(--ink);
}

/* Light film (from the hand in the light to the sign): dark ink. Uses the
   theme's own text color (tokens.css), no new color. The dim part of the
   line is the same ink, see-through. */
.hero--light {
	--ink: var(--color-hero-bg); /* #1E1B17, the theme's own text color (tokens.css) */
	--ink-dim: color-mix(in srgb, var(--color-hero-bg) 50%, transparent);
	--ground: var(--color-hero-ink);
	--color-text-muted: color-mix(in srgb, var(--color-hero-bg) 70%, transparent);
}

/* Reduced motion: the poster is the film's last frame (light), so the hero
   starts in its light state. Only when that poster exists (inc/hero-media.php). */
@media (prefers-reduced-motion: reduce) {
	.hero--has-end-poster {
		--ink: var(--color-hero-bg);
		--ink-dim: color-mix(in srgb, var(--color-hero-bg) 50%, transparent);
		--ground: var(--color-hero-ink);
		--color-text-muted: color-mix(in srgb, var(--color-hero-bg) 70%, transparent);
	}
}

/* No transitions while the hero sets itself up: hero.js puts the starting
   look in place (calm button, dim line) without animating it, then adds
   .hero--ready one frame later. Later changes (light film, ending) animate. */
.hero:not(.hero--ready) *,
.hero:not(.hero--ready) *::before,
.hero:not(.hero--ready) *::after {
	transition: none !important;
}

.hero__stage {
	position: relative;
	min-height: 100svh;
	overflow: hidden;
}

/* Marker for the header switch (hero.js): one header height above the
   hero's bottom edge. */
.hero__end-marker {
	position: absolute;
	inset-inline: 0;
	inset-block-start: calc(100% - var(--header-height));
	height: 1px;
	pointer-events: none;
}

/* ---- Media: poster and film ------------------------------------------- */

.hero__media {
	position: absolute;
	inset: 0;
}

/* Poster (LCP image) and film fill the stage, centered. */
.hero__poster,
.hero__poster img,
.hero__video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* The film stays invisible until it is actually playing (hero.js), so the
   poster never gives way to an empty or black frame. The poster is the
   film's first frame, so the switch is not seen. */
.hero__video {
	opacity: 0;
	transition: opacity 160ms linear;
}

.hero--video-on .hero__video {
	opacity: 1;
}

/* Reduced motion: no film at all, the last-frame poster stays. */
@media (prefers-reduced-motion: reduce) {
	.hero__video {
		display: none;
	}
}

/* Soft shade under the line and the button, so they stay readable on every
   frame: dark on the dark film, light on the light film. The two layers
   cross-fade (opacity only) when the ink changes. */
.hero__media::before,
.hero__media::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	transition: opacity 500ms var(--ease-in-out);
}

.hero__media::before {
	background: linear-gradient(to top, color-mix(in srgb, var(--color-hero-bg) 55%, transparent) 0%, color-mix(in srgb, var(--color-hero-bg) 25%, transparent) 30%, transparent 55%);
	opacity: 1;
}

.hero__media::after {
	background: linear-gradient(to top, color-mix(in srgb, var(--color-hero-ink) 60%, transparent) 0%, color-mix(in srgb, var(--color-hero-ink) 25%, transparent) 30%, transparent 55%);
	opacity: 0;
}

.hero--light .hero__media::before {
	opacity: 0;
}

.hero--light .hero__media::after {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.hero--has-end-poster .hero__media::before {
		opacity: 0;
	}

	.hero--has-end-poster .hero__media::after {
		opacity: 1;
	}
}

/* ---- The line --------------------------------------------------------- */
/* Phone: lower left, above the button, so the frame's center stays free for
   the film. */
.hero__line {
	position: absolute;
	z-index: 1;
	/* Gutter, or more where a phone's notch / rounded corner needs it (landscape). */
	inset-inline:
		max(var(--gutter), env(safe-area-inset-left, 0px))
		max(var(--gutter), env(safe-area-inset-right, 0px));
	inset-block-end: calc(var(--hero-cta-bottom) + var(--hero-cta-height) + var(--space-l));
	max-width: 18ch;
	margin: 0;
	font-family: var(--font-display);
	font-size: var(--text-2xl);
	font-weight: 300;
	line-height: var(--leading-snug);
	letter-spacing: var(--tracking-display);
	text-wrap: balance;
	transition: color 500ms var(--ease-in-out);
}

/* The line is visible from start to end (D44). While the film plays,
   hero.js splits it into its rendered lines; the ink then fills each line
   in reading order as the film runs (the "thread"), complete well before
   the end. Shown in dim ink, the line stays readable at every moment.
   --fp: fill progress of the whole line (starts at 2 %, complete at 75 %).
   --lp: fill progress of one line, from its index --i of --n lines. */
.hero__line.is-split {
	--fp: clamp(0, (var(--p) - 0.02) / 0.73, 1);
}

/* One rendered line. nowrap: the split already fixed the line breaks. */
.hero-line {
	position: relative;
	display: block;
	white-space: nowrap;
}

.hero-line__base {
	color: var(--ink-dim);
	transition: color 500ms var(--ease-in-out);
}

.hero-line__fill {
	--lp: clamp(0, var(--fp) * var(--n) - var(--i), 1);
	position: absolute;
	inset: 0;
	color: var(--ink);
	white-space: nowrap;
	transition: color 500ms var(--ease-in-out);
	/* Soft leading edge: 20 % of the line width fades in ahead of the fill. */
	-webkit-mask-image: linear-gradient(90deg, #000 calc(var(--lp) * 120% - 20%), transparent calc(var(--lp) * 120%));
	mask-image: linear-gradient(90deg, #000 calc(var(--lp) * 120% - 20%), transparent calc(var(--lp) * 120%));
}

/* ---- Hero button (D41) ------------------------------------------------ */
/* One button, one fixed spot for the whole hero.
   Phone: horizontally centered, near the bottom (thumb zone), clear of the
   iPhone home bar. Desktop: see the media query below.
   The button's look is set here for every menu style, so the hero always
   shows the same calm-then-emphasized button. */
.hero {
	--hero-cta-height: 3.25rem; /* 52px: well above the 44px minimum */
	--hero-cta-bottom: calc(var(--space-l) + env(safe-area-inset-bottom, 0px));
}

.hero__cta {
	position: absolute;
	z-index: 2;
	inset-inline: 0;
	inset-block-end: var(--hero-cta-bottom);
	display: flex;
	justify-content: center;
	padding-inline:
		max(var(--gutter), env(safe-area-inset-left, 0px))
		max(var(--gutter), env(safe-area-inset-right, 0px));
	pointer-events: none; /* only the button itself takes taps */
}

.hero__cta .button-area {
	justify-content: center;
	width: 100%;
}

/* Final, emphasized state: solid ink button. This is also the state without
   JS, with reduced motion and once the film has ended. */
.hero__cta .button {
	width: min(100%, 22rem);
	min-height: var(--hero-cta-height);
	padding-inline: var(--space-l);
	border: 1px solid var(--ink);
	background: var(--ink);
	color: var(--ground);
	font-size: var(--text-base);
	pointer-events: auto;
	transition:
		background-color var(--duration-slow) var(--ease-out),
		color var(--duration-slow) var(--ease-out),
		border-color var(--duration-slow) var(--ease-out),
		transform var(--duration-fast) var(--ease-out);
}

.hero__cta .button:hover {
	border-color: var(--color-accent);
	background: var(--color-accent);
	color: var(--color-on-accent);
}

/* While the film plays: calm outline. A faint ground keeps the label
   readable over bright frames. hero.js adds .hero--ended when the film
   reaches the sign, which returns the button to the emphasized state. */
.hero--film:not(.hero--ended) .hero__cta .button {
	background: color-mix(in srgb, var(--ground) 40%, transparent);
	color: var(--ink);
}

.hero--film:not(.hero--ended) .hero__cta .button:hover {
	background: var(--ink);
	color: var(--ground);
}

/* The quiet underline of .button--quiet is not used on the hero button. */
.hero__cta .button::after {
	content: none;
}

/* ---- Desktop and tablet composition ----------------------------------- */

@media (min-width: 48rem) {
	.hero {
		--hero-cta-height: 3.5rem;
		/* + home-bar inset: phones in landscape are this wide too. */
		--hero-cta-bottom: calc(clamp(2.5rem, 9svh, 6rem) + env(safe-area-inset-bottom, 0px));
	}

	/* Line: lower left, leaving the center of the frame to the film. */
	.hero__line {
		inset-inline-end: auto;
		inset-block-end: calc(var(--hero-cta-bottom) + var(--hero-cta-height) + var(--space-xl));
		max-width: 16ch;
		font-size: var(--text-3xl);
		line-height: var(--leading-tight);
	}

	/* Button: horizontally centered, in the lower part of the frame. */
	.hero__cta .button {
		width: auto;
		min-width: 17rem;
	}
}

/* ---- Short screens: phones in landscape (step 6) ---------------------- */
/* About 320-430px of height: the header, the line and the button must all
   fit without touching. The button keeps its centered spot, gets closer to
   the bottom and stays at the 44px minimum; the line gets smaller and wider
   so it needs fewer rows. Comes last, so it also overrides the desktop
   block (landscape phones are often 768px+ wide). */
@media (orientation: landscape) and (max-height: 30rem) {
	.hero {
		--hero-cta-height: var(--tap-target);
		--hero-cta-bottom: calc(var(--space-s) + env(safe-area-inset-bottom, 0px));
	}

	.hero__line {
		inset-block-end: calc(var(--hero-cta-bottom) + var(--hero-cta-height) + var(--space-s));
		max-width: 26ch;
		font-size: var(--text-xl);
		line-height: var(--leading-snug);
	}

	.hero__cta .button {
		min-width: 15rem;
		font-size: var(--text-sm);
	}
}
