/**
 * Teb Open — Tebkadeh Emerald Reveal (v2.0.08).
 * Signature page transition: one unified choreography for the whole site.
 *
 * Architecture (see inc/page-transition.php + assets/js/page-transition.js):
 * - Phase B (outgoing document): html.to-pt-out recedes #to-main + footer
 *   with a barely-there scale/opacity change while #to-pt-cover — an
 *   emerald layer — expands from the interaction origin via clip-path.
 *   The header/announcement stay visually stable (wayfinding preserved).
 * - Phase C (incoming document): the head boot creates #to-pt-veil BEFORE
 *   first paint so the new document never flashes beneath; the reveal then
 *   unmasks the page through an expanding circular hole anchored at the
 *   same origin (JS-driven mask radius, see page-transition.js).
 * - Failsafe: #to-pt-veil carries a CSS-only auto-fade at 1.7s (armed while
 *   .is-covered, cancelled when the orchestrator claims it), so a failed
 *   script load can never trap the page. Without page-transition.css the
 *   veil is an empty unstyled div — invisible, harmless.
 * - Reduced motion: the boot never creates a veil and the orchestrator
 *   never intercepts navigation; these rules are the belt-and-braces layer.
 *
 * Colors come exclusively from tokens.css (--to-pt-* family); no raw hex
 * outside the token file. transform/opacity/clip-path/mask only — no
 * layout properties, no CLS.
 */

/* ---------- Transition layers ---------- */
.to-pt-layer {
	position: fixed;
	inset: 0;
	z-index: var(--to-z-transition);
	pointer-events: none;
	/* Origin is owned by JS via --to-pt-x / --to-pt-y (px values). */
	background:
		radial-gradient(
			circle at var(--to-pt-x, 50%) var(--to-pt-y, 38%),
			var(--to-pt-glow-core) 0px,
			var(--to-pt-glow-mid) min(23vw, 220px),
			transparent min(48vw, 470px)
		),
		var(--to-pt-veil);
}

/* Outgoing emerald layer: forms from the interaction origin. */
#to-pt-cover {
	will-change: clip-path;
}

/* Incoming veil: covers the new document at first paint. */
#to-pt-veil.is-covered {
	/* CSS-only failsafe: if the orchestrator never claims the veil, it
	 * fades itself away 1.7s after first paint. Claim (.is-claimed) cancels. */
	animation: to-pt-veil-failsafe 10ms linear 1.7s forwards;
}

#to-pt-veil.is-claimed {
	animation: none;
}

@keyframes to-pt-veil-failsafe {
	to {
		opacity: 0;
		visibility: hidden;
	}
}

/* ---------- Outgoing content recede (Phase B) ----------
 * Only #to-main, the footer wave and the footer recede — the header and
 * announcement bar stay stable so navigation never loses its wayfinding.
 * The transition declaration lives INSIDE the destination state so the
 * animation runs when html.to-pt-out is added and reverses cleanly when
 * the abort paths remove it. */
html.to-pt-out #to-main,
html.to-pt-out .to-footer-wave,
html.to-pt-out .to-footer {
	transform: scale(var(--to-pt-scale-out));
	opacity: var(--to-pt-fade-out);
	transition:
		transform var(--to-pt-dur-out) var(--to-pt-ease),
		opacity var(--to-pt-dur-out) var(--to-pt-ease);
	will-change: transform, opacity;
}

/* ---------- Reduced motion ----------
 * The boot snippet never arms the system under reduced motion; if a veil
 * ever exists anyway (e.g. the OS preference flips mid-flight), it is
 * removed instantly and the recede is neutralized. */
@media (prefers-reduced-motion: reduce) {
	#to-pt-cover,
	#to-pt-veil {
		display: none !important;
	}

	html.to-pt-out #to-main,
	html.to-pt-out .to-footer-wave,
	html.to-pt-out .to-footer {
		transform: none;
		opacity: 1;
		transition: none;
	}
}

/* ---------- Mobile refinement ----------
 * One system, not a second design: on small viewports the ember glow is
 * physically smaller (smaller min() caps) so the composition keeps the
 * same proportions instead of a scaled-up desktop effect. Durations and
 * geometry come from the same tokens. */
@media (max-width: 767px) {
	.to-pt-layer {
		background:
			radial-gradient(
				circle at var(--to-pt-x, 50%) var(--to-pt-y, 38%),
				var(--to-pt-glow-core) 0px,
				var(--to-pt-glow-mid) min(30vw, 150px),
				transparent min(62vw, 320px)
			),
			var(--to-pt-veil);
	}
}
