/* =========================================================
   ANIMATIONS
   Loaded last, outside the three breakpoint bundles.

   HOW THE SEO GUARANTEE WORKS
   ---------------------------
   Every hidden start state below is nested under `.js-motion`,
   a class added by a tiny inline script in <head> that only
   fires when JS is on AND the visitor has not asked for reduced
   motion. No JS -> no class -> nothing is ever hidden, and
   `display: none` is not used anywhere in this file.
   ========================================================= */

:root {
	--ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--ease-soft: cubic-bezier(0.16, 1, 0.3, 1);
	--rv-dur: 0.9s;
}

/* =========================================================
   1. BACKDROP PARALLAX
   ========================================================= */

.has-bg-layer body {
	background-image: none;
}

.bg-parallax {
	position: fixed;
	inset: -20px;
	z-index: -1;
	pointer-events: none;
	background-image: radial-gradient(
		rgba(14, 14, 14, 0.1) 1px,
		transparent 1px
	);
	background-size: 10px 10px;
	will-change: transform;
}

/* =========================================================
   2. REVEAL TARGETS
   Mirrors the GROUPS list in assets/js/animations/reveal.js.
   Change one, change the other.
   ========================================================= */

.js-motion .education-info,
.js-motion .skill-group,
.js-motion .contact-content p,
.js-motion .contact-cta-mobile p,
.js-motion .footer-brand,
.js-motion .footer-column {
	opacity: 0;
	transform: translateY(1.6rem);
	filter: blur(5px);
	transition:
		opacity var(--rv-dur) var(--ease-out) var(--rv-delay, 0ms),
		transform var(--rv-dur) var(--ease-out) var(--rv-delay, 0ms),
		filter var(--rv-dur) var(--ease-out) var(--rv-delay, 0ms);
}

.js-motion .education-info.is-inview,
.js-motion .skill-group.is-inview,
.js-motion .contact-content p.is-inview,
.js-motion .contact-cta-mobile p.is-inview,
.js-motion .footer-brand.is-inview,
.js-motion .footer-column.is-inview {
	opacity: 1;
	transform: none;
	filter: none;
}

.js-motion .profile-card {
	opacity: 0;
	transform: translateY(1.6rem);
	transition:
		opacity var(--rv-dur) var(--ease-out),
		transform var(--rv-dur) var(--ease-out);
}

.js-motion .profile-card.is-inview {
	opacity: 1;
	transform: none;
}

/* ---- section headings drop in from above ---- */

.js-motion .about-card > h3,
.js-motion .education-card > h3,
.js-motion .skills-card > h3,
.js-motion .connect-card > h3 {
	opacity: 0;
	transform: translateY(-1.2rem);
	filter: blur(5px);
	transition:
		opacity var(--rv-dur) var(--ease-out),
		transform var(--rv-dur) var(--ease-out),
		filter var(--rv-dur) var(--ease-out);
}

.js-motion .about-card > h3.is-inview,
.js-motion .education-card > h3.is-inview,
.js-motion .skills-card > h3.is-inview,
.js-motion .connect-card > h3.is-inview {
	opacity: 1;
	transform: none;
	filter: none;
}

/* ---- About paragraphs: word by word ----
   The <p> opacity is only an anti-flash guard for the moment
   between stylesheet and script. If split-words.js ever fails,
   the paragraph still reveals here as ordinary prose. */

.js-motion .about-text p {
	opacity: 0;
	transition: opacity 0.01s linear var(--rv-delay, 0ms);
}

.js-motion .about-text p.is-inview {
	opacity: 1;
}

.js-motion .about-text .w {
	display: inline-block;
	overflow: hidden;
	/* an inline-block with overflow:hidden takes its bottom edge as
	   the baseline, which would shove every word off the line */
	vertical-align: bottom;
	/* room for the tails of g, y, p so the clip does not cut them */
	padding-bottom: 0.18em;
	margin-bottom: -0.18em;
}

.js-motion .about-text .w-i {
	display: inline-block;
	opacity: 0;
	transform: translateY(110%);
	transition:
		opacity 0.62s var(--ease-out)
			calc(var(--rv-delay, 0ms) + var(--w-delay, 0ms)),
		transform 0.72s var(--ease-out)
			calc(var(--rv-delay, 0ms) + var(--w-delay, 0ms));
}

.js-motion .about-text p.is-inview .w-i {
	opacity: 1;
	transform: none;
}

/* ---- headline wipe: the expensive-looking one ---- */

.js-motion .projects h2,
.js-motion .contact-content h2,
.js-motion .contact-cta-mobile h2 {
	/* The wipe uses mask-size, NOT clip-path. Chrome's
	   IntersectionObserver refuses to report an element whose own
	   clip-path has collapsed it, so a clip-path wipe would leave
	   the heading permanently invisible. A mask has no such effect. */
	opacity: 0;
	transform: translateY(0.9rem);
	-webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent);
	mask-image: linear-gradient(to bottom, #000 62%, transparent);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: top;
	mask-position: top;
	-webkit-mask-size: 100% 0%;
	mask-size: 100% 0%;
	transition:
		opacity 0.8s var(--ease-out),
		transform 1.05s var(--ease-out),
		-webkit-mask-size 1.05s var(--ease-out),
		mask-size 1.05s var(--ease-out);
}

.js-motion .projects h2.is-inview,
.js-motion .contact-content h2.is-inview,
.js-motion .contact-cta-mobile h2.is-inview {
	opacity: 1;
	transform: none;
	/* past 100% so the gradient's soft tail clears the bottom edge */
	-webkit-mask-size: 100% 260%;
	mask-size: 100% 260%;
}

/* ---- section labels + their rules drawing outward ---- */

.js-motion .projects > span {
	opacity: 0;
	transition: opacity 0.8s ease var(--rv-delay, 0ms);
}

.js-motion .projects > span.is-inview {
	opacity: 1;
}

.js-motion .projects > span::before,
.js-motion .projects > span::after {
	transform: translateY(-50%) scaleX(0);
	transition: transform 1s var(--ease-out) 140ms;
}

.js-motion .projects > span::before {
	transform-origin: right center;
}

.js-motion .projects > span::after {
	transform-origin: left center;
}

.js-motion .projects > span.is-inview::before,
.js-motion .projects > span.is-inview::after {
	transform: translateY(-50%) scaleX(1);
}

/* ---- vertical divider grows downward ---- */

.js-motion .vertical-divider {
	transform-origin: top center;
	transition: transform 1.1s var(--ease-out);
}

@media screen and (min-width: 1025px) {
	.js-motion .vertical-divider {
		transform: translateY(1%) scaleY(0);
	}
	.js-motion .vertical-divider.is-inview {
		transform: translateY(1%) scaleY(1);
	}
}

@media screen and (max-width: 1024px) {
	.js-motion .vertical-divider {
		transform: scaleY(0);
	}
	.js-motion .vertical-divider.is-inview {
		transform: scaleY(1);
	}
}

/* =========================================================
   3. HERO
   The base transform of each element is rebuilt here with
   CSS variables folded in, so JS never overwrites the
   stylesheet's own positioning.
   ========================================================= */

/* ---- hold the entrance until the page is actually looked at ----
   Set from the inline script in <head> when the document loads
   hidden (a tab opened in the background). Paused, not withheld:
   without the class everything runs exactly as before. */

.js-motion.motion-hold .hero-image,
.js-motion.motion-hold .hero h1,
.js-motion.motion-hold .hero h2,
.js-motion.motion-hold .hero-card {
	animation-play-state: paused;
}

/* ---- image frame: pendulum + slow scroll layer ---- */

.js-motion .hero-image {
	will-change: transform;
	animation: curtain 1.15s var(--ease-out) 0.15s both;
}

@keyframes curtain {
	from {
		clip-path: inset(0 0 100% 0);
	}
	to {
		clip-path: inset(0 0 0 0);
	}
}

@media screen and (min-width: 1025px) {
	.js-motion .hero-image {
		transform: translateX(-4%)
			translate(var(--fx, 0px), calc(var(--shift, 0px) + var(--fy, 0px)))
			rotate(calc(1deg + var(--swing, 0deg)));
		-webkit-mask-image: linear-gradient(
			to bottom,
			#000 84%,
			transparent 100%
		);
		mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
	}
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
	.js-motion .hero-image {
		transform: translateX(0%)
			translate(var(--fx, 0px), calc(var(--shift, 0px) + var(--fy, 0px)))
			rotate(calc(2deg + var(--swing, 0deg)));
		-webkit-mask-image: linear-gradient(
			to bottom,
			#000 70%,
			transparent 100%
		);
		mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
	}
}

@media screen and (max-width: 767px) {
	.js-motion .hero-image {
		transform: translateX(-3%)
			translate(var(--fx, 0px), calc(var(--shift, 0px) + var(--fy, 0px)))
			rotate(calc(2deg + var(--swing, 0deg)));
		-webkit-mask-image: linear-gradient(
			to bottom,
			#000 70%,
			transparent 100%
		);
		mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
	}
}

/* ---- the picture drifts INSIDE the frame ---- */

.js-motion .hero-image img {
	/* scale() zooms the ALREADY-CROPPED result of object-fit, so a large
	   value pushes the photo's baked-in bottom fade out of the frame.
	   1.02 is just enough to cover the corners the tilt exposes and
	   leaves the original framing intact. */
	transform: perspective(1000px) rotateY(var(--tilt-y, 0deg))
		rotateX(var(--tilt-x, 0deg)) scale(1.02);
	will-change: transform;
}

/* ---- headline layers move at their own rate ---- */

.js-motion .hero h2 {
	animation: heroTextIn 1s var(--ease-out) both;
}

.js-motion .hero h1 {
	animation: heroTextIn 1.1s var(--ease-out) 0.08s both;
}

@keyframes heroTextIn {
	from {
		opacity: 0;
		clip-path: inset(0 0 110% 0);
	}
	to {
		opacity: 1;
		clip-path: inset(-30% -30% -30% -30%);
	}
}

@media screen and (min-width: 768px) {
	.js-motion .hero h1,
	.js-motion .hero h2 {
		transform: translateX(-50%) translateY(var(--shift, 0px));
	}
}

@media screen and (max-width: 767px) {
	.js-motion .hero h2 {
		transform: translateX(-50%) translateY(var(--shift, 0px));
	}
	.js-motion .hero h1 {
		transform: translateX(-50%) translateY(calc(-3px + var(--shift, 0px)));
	}
}

/* ---- floating cards ---- */

.js-motion .hero-card {
	transform: translate3d(var(--cx, 0px), var(--cy, 0px), 0);
	opacity: 0;
	filter: blur(10px);
	animation: heroCardIn 1s var(--ease-out) both;
}

.js-motion .hero-cards-container > :nth-child(1) {
	animation-delay: 0.45s;
}
.js-motion .hero-cards-container > :nth-child(2) {
	animation-delay: 0.3s;
}
.js-motion .hero-cards-container > :nth-child(3) {
	animation-delay: 0.6s;
}

@keyframes heroCardIn {
	from {
		opacity: 0;
		filter: blur(10px);
	}
	to {
		opacity: 1;
		filter: blur(0);
	}
}

/* only promote to their own layer where they actually move */
@media (hover: hover) and (pointer: fine) {
	.js-motion .hero-card {
		will-change: transform;
	}
}

/* =========================================================
   4. PROJECTS — folders rise out of the page
   ========================================================= */

.js-motion .folder {
	--rv-y: 3.5rem;
	--rv-rot: 20deg;
	--rv-s: 0.94;
	--hv-y: 0rem;

	opacity: 0;
	transform-origin: 50% 100%;
	transform: perspective(1400px) translateY(calc(var(--rv-y) + var(--hv-y)))
		rotateX(var(--rv-rot)) scale(var(--rv-s));
	transition:
		opacity 0.95s var(--ease-out) var(--rv-delay, 0ms),
		transform 0.95s var(--ease-out) var(--rv-delay, 0ms);
}

.js-motion .folder.is-inview {
	--rv-y: 0rem;
	--rv-rot: 0deg;
	--rv-s: 1;
	opacity: 1;
}

/* once the entrance is done, hand the element back to the
   short snappy transition the component was designed with */
.js-motion .folder.is-settled {
	transition: transform 0.35s ease;
	transform-origin: 50% 50%;
	transform: none;
}

.js-motion .folder.is-settled:hover {
	transform: translateY(-1rem);
}

/* =========================================================
   5. CONTACT
   ========================================================= */

.js-motion .contact-cta.has-spotlight::after {
	content: "";
	position: absolute;
	z-index: 0;
	top: 0;
	left: 0;
	width: 34rem;
	height: 34rem;
	margin: -17rem 0 0 -17rem;
	background: radial-gradient(
		circle,
		rgba(169, 255, 191, 0.16),
		transparent 62%
	);
	pointer-events: none;
	opacity: 0;
	transform: translate3d(var(--lx, 0px), var(--ly, 0px), 0);
	transition: opacity 0.6s ease;
}

.js-motion .contact-cta.has-spotlight.is-lit::after {
	opacity: 1;
}

/* ---- magnetic CTA ---- */

.js-motion .contact-button {
	opacity: 0;
	transform: translate3d(var(--mx, 0px), var(--my, 0px), 0) translateY(1.4rem);
	transition:
		opacity var(--rv-dur) var(--ease-out),
		transform var(--rv-dur) var(--ease-out);
}

.js-motion .contact-button.is-inview {
	opacity: 1;
	transform: translate3d(var(--mx, 0px), var(--my, 0px), 0);
}

/* drop transform from the transition list so the magnet is
   driven by the rAF lerp instead of fighting a 0.35s ease */
.js-motion .contact-button.is-settled {
	transition:
		background 0.35s ease-in-out,
		scale 0.35s ease-in-out,
		opacity 0.3s ease;
}

/* =========================================================
   6. REDUCED MOTION — second line of defence
   (the inline script already withholds .js-motion, this
    covers anything that slips through)
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
	.js-motion .hero-image,
	.js-motion .hero h1,
	.js-motion .hero h2,
	.js-motion .hero-card {
		animation: none !important;
		opacity: 1 !important;
		filter: none !important;
		-webkit-mask-image: none !important;
		mask-image: none !important;
	}
}
