/*
 * VAIDIKX Signal — first-visit intro.
 *
 * An automatic brand sequence over the live homepage. Nothing here is
 * interactive: there is no card, no field and no control, so every rule below
 * is presentation only.
 *
 * Every value resolves from the design tokens already defined in style.css;
 * this file introduces no colours, no families and no new scale. It loads only
 * on the front page, and only for a visitor who has not seen the intro.
 *
 * The whole thing lives inside one fixed, clipped container, which is what
 * guarantees the flowing type can never widen the document.
 */

/* --------------------------------------------------------------------------
   Visibility

   The overlay is inert until the head script arms the root element. That single
   attribute is what prevents both the homepage-flash and the overlay-flash.
   -------------------------------------------------------------------------- */

.mh-signal { display: none; }

/*
 * :not([hidden]) is load-bearing. An attribute selector outranks the UA
 * stylesheet's [hidden] { display: none }, so without it this rule paints the
 * overlay even when the markup is still hidden — and if signal.js never runs,
 * that is a blank dark scrim with no content until the failsafe clears it.
 * signal.js drops the attribute once it has content to show.
 */
[data-vx-signal="armed"] .mh-signal:not( [hidden] ) { display: flex; }

/*
 * Hold the page still underneath while the sequence plays.
 *
 * Both the root element and the body are locked. Locking body alone relies on
 * overflow propagating to the viewport, which only happens while the root's own
 * overflow is visible — one plugin or theme rule setting it and the page scrolls
 * again underneath the intro.
 *
 * scrollbar-gutter reserves the classic scrollbar's width for as long as the
 * lock is on, so removing and restoring the scrollbar does not shift the page
 * sideways when the intro starts or ends.
 *
 * The scroll position itself needs no bookkeeping: hiding overflow leaves the
 * document where it is, unlike the position:fixed approach, which collapses it
 * to the top and has to be put back by hand.
 */
[data-vx-signal="armed"],
[data-vx-signal="armed"] body {
	overflow: hidden;
}

[data-vx-signal="armed"] { scrollbar-gutter: stable; }

.mh-signal {
	position: fixed;
	inset: 0;
	z-index: 2000;
	overflow: hidden; /* load-bearing: clips the flowing rows to the viewport */

	/* No `display` here on purpose. Declaring it in this block would override
	   both the `display: none` default above and the UA's [hidden] rule, which
	   is what previously left a blank scrim on screen whenever signal.js failed
	   to run. The armed rule above is the only thing that turns this on. */
	align-items: center;
	justify-content: center;
	padding: var( --mh-space-md );

	/*
	 * A scrim, not a lid: the real homepage stays behind it, dimmed and blurred
	 * so it still reads as VAIDIKX.
	 */
	background: rgba( 5, 5, 5, 0.88 );
	-webkit-backdrop-filter: blur( 14px );
	backdrop-filter: blur( 14px );

	/* Nothing here can be operated, so the overlay should never intercept a
	   gesture — and a touch drag must not pan the page behind it. */
	pointer-events: none;
	touch-action: none;
	overscroll-behavior: contain;

	opacity: 1;
	transition: opacity 0.65s ease; /* keeps step with FADE_MS in signal.js */
}

/* Handing over: fade to nothing above an already-dark page, so there is no
   white flash and nothing shifts when the element is finally removed. */
.mh-signal.is-leaving { opacity: 0; }

/* Backdrop blur is the one effect here that costs the compositor anything, so
   it is dropped for anyone who has asked for less motion. */
@media ( prefers-reduced-motion: reduce ) {
	.mh-signal {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: rgba( 5, 5, 5, 0.94 );
	}
}

/* --------------------------------------------------------------------------
   Scene

   One centred stack. Each beat fades its own element in and the previous one
   out, so the sequence reads as a single object changing rather than a slide
   show of separate screens.
   -------------------------------------------------------------------------- */

.mh-signal__scene {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* --- Beat 1: the mark ---------------------------------------------------- */

.mh-signal__mark {
	position: absolute;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale( 0.96 );
	transition: opacity 0.45s ease, transform 0.45s ease;
}

.mh-signal__mark img {
	height: clamp( 2.5rem, 1.5rem + 4vw, 4rem );
	width: auto;
	max-width: none;
}

.mh-signal.is-phase-mark .mh-signal__mark { opacity: 1; transform: scale( 1 ); }

/* It recedes rather than cutting, so the wordmark feels like the same object
   resolving into type. */
.mh-signal.is-phase-word .mh-signal__mark,
.mh-signal.is-phase-domain .mh-signal__mark {
	opacity: 0;
	transform: scale( 1.15 );
}

/* --- Beats 2 and 3: the wordmark, then the domain ------------------------ */

.mh-signal__word {
	position: relative;
	z-index: 2;
	max-width: 100%;
	font-family: var( --mh-font-display );
	font-size: clamp( 2rem, 1rem + 7vw, 5rem );
	font-weight: 700;
	line-height: 1;
	letter-spacing: var( --mh-track-display );
	text-transform: uppercase;
	color: var( --mh-color-heading );
	text-align: center;
	overflow-wrap: anywhere; /* a long token wraps rather than overflowing */
	opacity: 0;
	transform: scale( 0.96 );
	transition: opacity 0.45s ease, transform 0.45s ease;
}

.mh-signal.is-phase-word .mh-signal__word,
.mh-signal.is-phase-domain .mh-signal__word {
	opacity: 1;
	transform: scale( 1 );
}

/* By the welcome line the wordmark has handed over to the stream. */
.mh-signal.is-phase-welcome .mh-signal__word,
.mh-signal.is-phase-stream .mh-signal__word {
	opacity: 0;
	transform: scale( 1.2 );
}

/* --- Beat 4: the line ---------------------------------------------------- */

.mh-signal__line {
	position: absolute;
	z-index: 2;
	left: 50%;
	transform: translateX( -50% );
	margin: 0;
	max-width: min( 92vw, 40rem );
	text-align: center;
	font-family: var( --mh-font-ui );
	font-size: var( --mh-size-meta );
	font-weight: 600;
	letter-spacing: var( --mh-track-meta );
	text-transform: uppercase;
	color: var( --mh-color-muted );
	opacity: 0;
	transition: opacity 0.5s ease;
}

/* Centred while it is the subject, then parked at the foot once the stream
   takes over behind it. */
.mh-signal.is-phase-welcome .mh-signal__line {
	opacity: 1;
	color: var( --mh-color-ink );
	font-size: 0.875rem;
}

.mh-signal.is-phase-stream .mh-signal__line {
	opacity: 1;
	bottom: var( --mh-space-xl );
}

/* --- Beat 5: the stream --------------------------------------------------
   Three rows at different scales, speeds and weights so it reads as layered
   signal rather than one marquee. Each row's content is duplicated in JS and
   translated by exactly -50%, which makes the loop seamless.
   -------------------------------------------------------------------------- */

.mh-signal__stream {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.35em;
	opacity: 0;
	transition: opacity 0.6s ease;
}

.mh-signal.is-phase-stream .mh-signal__stream { opacity: 1; }

.mh-signal__row {
	display: flex;
	flex: none;
	width: max-content;
	white-space: nowrap;
	font-family: var( --mh-font-display );
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: var( --mh-track-display );
	will-change: transform;
}

.mh-signal__row span { padding-right: 0.4em; }

.mh-signal__row--back {
	font-size: clamp( 1.5rem, 1rem + 3vw, 3rem );
	color: var( --mh-color-ink );
	opacity: 0.12;
	animation: mh-signal-drift 22s linear infinite;
}

.mh-signal__row--mid {
	font-size: clamp( 2.25rem, 1rem + 6vw, 4.5rem );
	color: var( --mh-color-ink );
	opacity: 0.3;
	animation: mh-signal-drift 14s linear infinite reverse;
}

.mh-signal__row--fore {
	font-size: clamp( 1.125rem, 0.9rem + 1.6vw, 1.875rem );
	color: var( --mh-color-muted );
	opacity: 0.45;
	animation: mh-signal-drift 9s linear infinite;
}

@keyframes mh-signal-drift {
	from { transform: translate3d( 0, 0, 0 ); }
	to   { transform: translate3d( -50%, 0, 0 ); }
}

/* --- The accent ----------------------------------------------------------
   The single piece of colour in the sequence: one thin rule crossing the frame.
   -------------------------------------------------------------------------- */

.mh-signal__trace {
	position: absolute;
	left: 0;
	top: 50%;
	width: 100%;
	height: 1px;
	background: var( --mh-color-accent );
	transform: scaleX( 0 );
	transform-origin: left center;
	opacity: 0;
}

.mh-signal.is-phase-stream .mh-signal__trace {
	animation: mh-signal-trace 1.6s ease-in-out forwards;
}

@keyframes mh-signal-trace {
	0%   { opacity: 0; transform: scaleX( 0 ); transform-origin: left center; }
	18%  { opacity: 1; }
	50%  { opacity: 1; transform: scaleX( 1 ); transform-origin: left center; }
	51%  { transform: scaleX( 1 ); transform-origin: right center; }
	100% { opacity: 0; transform: scaleX( 0 ); transform-origin: right center; }
}

/* --------------------------------------------------------------------------
   Mobile

   Same composition, tightened: the stream is the part that has to stay inside
   a 320px viewport, so its type steps down and the sequence is shorter.
   -------------------------------------------------------------------------- */

@media ( max-width: 600px ) {
	.mh-signal { padding: var( --mh-space-sm ); }

	.mh-signal.is-phase-stream .mh-signal__line { bottom: var( --mh-space-lg ); }

	.mh-signal__row--back { animation-duration: 16s; }
	.mh-signal__row--mid  { animation-duration: 10s; }
	.mh-signal__row--fore { animation-duration: 7s; }
}

/* --------------------------------------------------------------------------
   Reduced motion

   Nothing travels and nothing scales: the mark and the wordmark appear, and the
   overlay hands over. JS shortens the timeline to match and never reaches the
   streaming beat.
   -------------------------------------------------------------------------- */

@media ( prefers-reduced-motion: reduce ) {
	.mh-signal__stream,
	.mh-signal__trace { display: none; }

	.mh-signal__mark,
	.mh-signal__word {
		transform: none !important;
		transition: opacity 0.25s ease;
	}

	.mh-signal__row { animation: none; }
}
