/* ==========================================================================
   Motion
   Quiet and slow: text and entries settle in with a soft fade and at most
   6px of movement, photos settle from a 1.03 scale, hairlines draw from the
   left. No wipes, masks or clip-path reveals.

   Everything is visible in plain CSS. Hidden start states hang off
   html.ph-motion, which is only present when JavaScript runs and the visitor
   has not asked for reduced motion; motion.js and the head script both
   remove it again if anything goes wrong. Only transform and opacity are
   animated.
   ========================================================================== */

:root {
	--ph-ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
	--ph-dur-reveal: 1.1s;
	--ph-dur-draw: 1.2s;
}

@keyframes ph-soft-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Header and hero
   ========================================================================== */

.ph-motion .site-branding,
.ph-motion .nav-toggle {
	animation: ph-soft-in var(--ph-dur-reveal) var(--ph-ease-soft) 0.2s backwards;
}

@media (min-width: 68rem) {
	.ph-motion .primary-menu li {
		animation: ph-soft-in var(--ph-dur-reveal) var(--ph-ease-soft) backwards;
		animation-delay: calc(0.3s + var(--ph-n, 0) * 0.05s);
	}

	.ph-motion .primary-menu li:nth-child(2) { --ph-n: 1; }
	.ph-motion .primary-menu li:nth-child(3) { --ph-n: 2; }
	.ph-motion .primary-menu li:nth-child(4) { --ph-n: 3; }
	.ph-motion .primary-menu li:nth-child(n + 5) { --ph-n: 4; }

	/* Underline grows from the left, unhurried. */
	.primary-menu a::after {
		transition:
			transform 0.7s var(--ph-ease-soft),
			background-color var(--ph-dur-base) var(--ph-ease-out);
	}
}

/* The photo drifts slowly on scroll (see motion.js). */
.ph-motion .hero__media {
	transform: translate3d(0, var(--ph-drift, 0px), 0);
	will-change: transform;
}

/* Shared reveal: a soft fade with a 6px settle
   motion.js marks each target with data-reveal and adds .is-inview once.
   ========================================================================== */

.ph-motion [data-reveal] {
	opacity: 0;
	transform: translateY(6px);
	transition:
		opacity var(--ph-dur-reveal) var(--ph-ease-soft) var(--ph-delay, 0ms),
		transform var(--ph-dur-reveal) var(--ph-ease-soft) var(--ph-delay, 0ms);
}

.ph-motion [data-reveal].is-inview {
	opacity: 1;
	transform: none;
}

/* Photos settle from a slight scale while their entry fades in. The scale
   property leaves transform free for the hover zoom. */
.ph-motion [data-reveal] .ph-src__photo img,
.ph-motion [data-reveal] .ph-apps__media img {
	scale: 1.03;
	transition:
		scale 1.4s var(--ph-ease-soft) var(--ph-delay, 0ms),
		transform 1.2s var(--ph-ease-soft);
}

.ph-motion [data-reveal].is-inview .ph-src__photo img,
.ph-motion [data-reveal].is-inview .ph-apps__media img {
	scale: 1;
}

/* Hairlines draw from the left
   The border is hidden and redrawn as a line that grows with the entry.
   ========================================================================== */

.ph-motion .ph-iso__item[data-reveal],
.ph-motion .ph-why__item[data-reveal] {
	border-top-color: transparent;
}

.ph-motion .ph-iso__item[data-reveal]::after,
.ph-motion .ph-why__item[data-reveal]::after,
.ph-motion .ph-apps__item[data-reveal] .ph-apps__body::before {
	content: "";
	position: absolute;
	left: 0;
	width: 100%;
	height: 1px;
	background: var(--ph-sec-line);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform var(--ph-dur-draw) var(--ph-ease-soft) var(--ph-delay, 0ms);
	pointer-events: none;
}

.ph-motion .ph-iso__item[data-reveal]::after,
.ph-motion .ph-why__item[data-reveal]::after,
.ph-motion .ph-apps__item[data-reveal] .ph-apps__body::before {
	top: -1px;
}

.ph-motion .ph-apps__item[data-reveal] .ph-apps__body {
	position: relative;
	border-top-color: transparent;
}

.ph-motion .is-inview.ph-iso__item::after,
.ph-motion .is-inview.ph-why__item::after,
.ph-motion .ph-apps__item.is-inview .ph-apps__body::before {
	transform: scaleX(1);
}

/* Micro-interactions: links and buttons only
   ========================================================================== */

.ph-button {
	transition:
		background-color var(--ph-dur-base) var(--ph-ease-out),
		border-color var(--ph-dur-base) var(--ph-ease-out),
		color var(--ph-dur-base) var(--ph-ease-out),
		translate 0.6s var(--ph-ease-soft);
}

.ph-button:hover,
.ph-button:focus-visible {
	translate: 0 -1px;
}

/* Reduced motion: no entrances, no drift, no lift. Everything is shown. */
@media (prefers-reduced-motion: reduce) {
	[data-reveal] {
		opacity: 1 !important;
		transform: none !important;
	}

	.ph-button:hover,
	.ph-button:focus-visible {
		translate: none;
	}
}
