/**
 * DELIAN — cinematic layer.
 *
 * The "flagship demo" tier on top of the motion layer: an opening plate, a live
 * process visualisation in the hero, a scroll-driven process sequence, word-by-
 * word headline reveals, 3D card tilt, a technical cursor and a rolling label
 * band.
 *
 * Everything is additive, gated behind `dl-js`, non-blocking (the opening plate
 * removes itself even if JavaScript dies), and switched off for
 * `prefers-reduced-motion`.
 *
 *  1. Opening plate       5. 3D cards
 *  2. Hero visualisation  6. Cursor
 *  3. Process sequence    7. Rolling band
 *  4. Word reveals        8. Fallbacks
 */

/* 1. Opening plate --------------------------------------------------------- */
.dl-curtain,
.dl-cursor,
.dl-hero__viz,
.dl-hero__grain,
.dl-hero__scan {
	display: none;
}

.dl-motion--full .dl-curtain {
	display: grid;
}

.dl-motion--full .dl-cursor {
	display: grid;
}

.dl-motion--subtle .dl-hero__viz,
.dl-motion--full .dl-hero__viz {
	display: block;
}

/* The default level keeps the flow read subtle; full lets it lead the hero. */
.dl-motion--subtle .dl-hero__viz {
	opacity: 0.5;
}

.dl-motion--full .dl-hero__grain,
.dl-motion--full .dl-hero__scan {
	display: block;
}

.dl-curtain {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: grid;
	place-items: center;
	background: #101010;
	color: #ffffff;
	animation: dl-curtain-out 700ms cubic-bezier(0.76, 0, 0.24, 1) 900ms forwards;
}

.dl-motion--full:not(.dl-js) .dl-curtain,
.dl-curtain.is-done {
	display: none;
}

.dl-curtain__inner {
	display: grid;
	gap: 1rem;
	justify-items: center;
	width: min(22rem, 70vw);
	text-align: center;
}

.dl-curtain__mark {
	font-family: var(--dl-font-display, "Arial Narrow", Impact, sans-serif);
	font-size: clamp(2rem, 6vw, 3.4rem);
	font-weight: 700;
	letter-spacing: 0.22em;
	text-transform: uppercase;
}

.dl-curtain__line {
	position: relative;
	width: 100%;
	height: 3px;
	background: rgba(255, 255, 255, 0.18);
	overflow: hidden;
}

.dl-curtain__line::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--dl-accent, #7db713);
	transform-origin: left center;
	transform: scaleX(var(--dl-load, 0.12));
	transition: transform 300ms ease-out;
}

.dl-curtain__label {
	font-family: var(--dl-font-mono, ui-monospace, monospace);
	font-size: 0.6875rem;
	letter-spacing: 0.28em;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.65);
}

@keyframes dl-curtain-out {
	to {
		opacity: 0;
		visibility: hidden;
	}
}

/* 2. Hero visualisation ---------------------------------------------------- */
.dl-hero__viz {
	position: absolute;
	inset: 0;
	z-index: 1;
	width: 100%;
	height: 100%;
	pointer-events: none;
	opacity: 0.85;
	mix-blend-mode: screen;
}

.dl-hero > .dl-container {
	position: relative;
	z-index: 2;
}

.dl-hero__grain {
	position: absolute;
	inset: 0;
	z-index: 3;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
	opacity: 0.06;
	mix-blend-mode: overlay;
	pointer-events: none;
}

.dl-hero__scan {
	position: absolute;
	left: 0;
	right: 0;
	height: 35%;
	z-index: 3;
	background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0) 100%);
	animation: dl-scan 7s cubic-bezier(0.45, 0, 0.55, 1) infinite;
	pointer-events: none;
}

@keyframes dl-scan {
	0% {
		transform: translateY(-40%);
	}
	55%,
	100% {
		transform: translateY(320%);
	}
}

/* 3. Process sequence ------------------------------------------------------ */
/*
 * From 760 px up the stages sit in a horizontal rail, and that is where the
 * visitor can pick one: the selected stage reads green, the others recede. The
 * selection is a click (see initProcessSequence in cinematic.js), so nothing
 * here depends on the scroll position any more.
 */
@media (min-width: 760px) {
	.dl-js .dl-flow__fill {
		position: absolute;
		top: 0;
		left: 0;
		height: 3px;
		width: 100%;
		background: linear-gradient(90deg, var(--dl-accent, #7db713), rgba(125, 183, 19, 0.35));
		transform: scaleX(var(--dl-flow-progress, 0));
		transform-origin: left center;
		transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
		pointer-events: none;
	}

	/* Focus mode: the active stage reads bright, the rest recede. */
	.dl-js .dl-flow__stage {
		transition: opacity 400ms ease, filter 400ms ease, transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
	}

	.dl-js .dl-flow.is-sequencing .dl-flow__stage {
		opacity: 0.78;
		filter: saturate(0.4);
	}

	.dl-motion--full.dl-js .dl-flow.is-sequencing .dl-flow__stage {
		opacity: 0.5;
	}

	.dl-js .dl-flow.is-sequencing .dl-flow__stage.is-active {
		opacity: 1;
		filter: none;
	}

	.dl-js .dl-flow__stage.is-active .dl-flow__icon {
		background: var(--dl-accent, #7db713);
		color: #ffffff;
		transform: translateY(-3px) rotate(-4deg);
	}

	.dl-js .dl-flow__stage.is-active .dl-flow__title {
		color: var(--dl-ind-black, #181818);
	}
}

.dl-flow__counter {
	display: none;
}

@media (min-width: 760px) {
	.dl-js .dl-flow__counter {
		position: absolute;
		top: -0.4rem;
		right: 0;
		display: flex;
		gap: 0.6rem;
		align-items: baseline;
		font-family: var(--dl-font-mono, ui-monospace, monospace);
		font-size: 0.6875rem;
		letter-spacing: 0.24em;
		text-transform: uppercase;
	}

	.dl-js .dl-flow__counter-current {
		font-size: 1.6rem;
		font-weight: 700;
		letter-spacing: 0.06em;
		color: var(--dl-accent, #7db713);
	}

	.dl-js .dl-flow__counter-total {
		color: var(--dl-muted, #5c5c5c);
	}
}

/* 4. Word reveals ---------------------------------------------------------- */
.dl-js .dl-word {
	display: inline-block;
	overflow: hidden;
	vertical-align: bottom;
}

.dl-motion--subtle.dl-js .dl-word__inner,
.dl-motion--full.dl-js .dl-word__inner {
	display: inline-block;
	transform: translateY(105%);
	/* A transition, not a keyframe animation: the browser pauses animation clocks in
	   background tabs and for off-screen blocks, which used to strand the words below
	   their mask — the headline then simply never appeared. The rise is triggered by
	   the same entrance/reveal class the rest of the choreography uses. */
	transition: transform 780ms cubic-bezier(0.22, 1, 0.36, 1) var(--dl-word-delay, 0ms);
}

.dl-js .dl-hero.is-entered .dl-word__inner,
.dl-motion--subtle.dl-js .is-revealed .dl-word__inner,
.dl-motion--full.dl-js .is-revealed .dl-word__inner,
.dl-js .dl-word__inner.is-in {
	transform: none;
}

/* When the hero headline is split, the sheen moves to the word inner spans so
   the background-clip still paints on every word. */
.dl-js .dl-hero__title.is-split {
	background-image: none;
	color: #ffffff;
	animation: none;
}

.dl-motion--full.dl-js .dl-hero__title.is-split .dl-word__inner {
	background-image:
		linear-gradient(100deg, rgba(255, 255, 255, 0) 42%, rgba(223, 242, 194, 0.95) 50%, rgba(255, 255, 255, 0) 58%),
		linear-gradient(#ffffff, #ffffff);
	background-size: 220% 100%, 100% 100%;
	background-repeat: no-repeat, no-repeat;
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	animation: dl-sheen 9s linear infinite;
}

/* Subtle and off keep the split words plain white. */
.dl-motion--subtle.dl-js .dl-hero__title.is-split .dl-word__inner,
.dl-motion--off.dl-js .dl-hero__title.is-split .dl-word__inner {
	background-image: none;
	color: #ffffff;
	animation: none;
}

/* A slide that takes the ink treatment (a light photograph, see
   industrial-reference.css) keeps its headline in charcoal at every motion
   level, including the split-word markup and the "full" level's sheen, which
   paints the type through a background-clip and would otherwise force white.
   The rules above and below this one out-specify the plain hero title rule, so
   the override has to be matched selector for selector. */
.dl-body--industrial .dl-hero__slide--ink .dl-hero__title,
.dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split,
.dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split .dl-word__inner,
.dl-motion--subtle .dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split .dl-word__inner,
.dl-motion--full .dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split .dl-word__inner,
.dl-motion--off .dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split .dl-word__inner,
.dl-js .dl-body--industrial .dl-hero__slide--ink .dl-hero__title.is-split .dl-word__inner {
	background-image: none;
	color: var(--dl-ind-black, #181818);
	animation: none;
}

/* 5. 3D cards (full motion only) ------------------------------------------- */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
	.dl-js .dl-card {
		transform-style: preserve-3d;
		perspective: 900px;
	}

	.dl-js .dl-card.is-tilting {
		transition: transform 120ms linear, box-shadow 320ms ease;
		transform: perspective(900px) rotateX(var(--dl-tilt-x, 0deg)) rotateY(var(--dl-tilt-y, 0deg)) translate3d(0, -6px, 0);
		will-change: transform;
	}

	.dl-js .dl-card::before {
		content: "";
		position: absolute;
		inset: 0;
		z-index: 5;
		background: radial-gradient(340px circle at var(--dl-tx, 50%) var(--dl-ty, 50%), rgba(255, 255, 255, 0.16), transparent 62%);
		opacity: 0;
		transition: opacity 260ms linear;
		pointer-events: none;
	}

	.dl-js .dl-card.is-tilting::before {
		opacity: 1;
	}
}

/* 6. Cursor ---------------------------------------------------------------- */
.dl-cursor {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 125;
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border: 1.5px solid var(--dl-accent, #7db713);
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.72);
	color: #181818;
	font-family: var(--dl-font-mono, ui-monospace, monospace);
	font-size: 0.5625rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85), 0 6px 18px -8px rgba(0, 0, 0, 0.45);
	transform: translate3d(var(--dl-cx, -100px), var(--dl-cy, -100px), 0) translate(-50%, -50%);
	transition: width 200ms ease, height 200ms ease, background 200ms ease, border-radius 200ms ease, opacity 200ms ease;
	pointer-events: none;
	opacity: 0;
}

.dl-cursor.is-on {
	opacity: 1;
}

.dl-cursor.is-hot {
	width: 72px;
	height: 72px;
	background: rgba(255, 255, 255, 0.9);
	border-color: var(--dl-accent, #7db713);
	border-radius: 50%;
}

.dl-cursor__label {
	position: absolute;
	bottom: -1.6rem;
	left: 50%;
	padding: 0.15rem 0.45rem;
	background: #181818;
	border-radius: 999px;
	color: #ffffff;
	line-height: 1.4;
	transform: translateX(-50%);
	white-space: nowrap;
	opacity: 0;
	transition: opacity 180ms ease;
}

.dl-cursor.is-hot .dl-cursor__label {
	opacity: 1;
}

/* 8. Fallbacks ------------------------------------------------------------- */
.dl-paused *,
.dl-paused *::before,
.dl-paused *::after {
	animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
	.dl-curtain {
		display: none;
	}

	.dl-hero__viz,
	.dl-hero__scan,
	.dl-cursor {
		display: none;
	}

	.dl-js .dl-word__inner {
		transform: none;
		transition: none;
	}

	.dl-js .dl-hero__title.is-split .dl-word__inner {
		background-image: none;
		color: #ffffff;
	}

	.dl-js .dl-flow.is-sequencing .dl-flow__stage {
		opacity: 1;
		filter: none;
	}
}

@media (max-width: 900px) {
	.dl-hero__viz,
	.dl-hero__scan,
	.dl-cursor {
		display: none;
	}
}
