/*
 * Loading and feedback. Nothing here changes how a page looks once it has loaded; it only fills the
 * gaps where the visitor would otherwise wait and see nothing.
 *
 *   - Moving to a page. Listing pages and every listing are built from the CRM, so a click can take a
 *     second or two. A thin bar at the top, and a spinner on the card that was chosen, say it was received.
 *   - Photos. Listing cards and the listing gallery show a quiet shimmer until each photo arrives, then
 *     the photo fades in rather than appearing in pieces.
 *   - Load more. The cards that are revealed rise in, a few at a time.
 *   - Forms. The Send button says it is sending (assets/loading.js).
 *
 * Every state is added by assets/loading.js. Without the script none of them exists and nothing is hidden.
 */

:root {
	--pcp-load-blue: #00a3da;
	--pcp-load-navy: #102330;
	--pcp-load-ease: cubic-bezier(0.44, 0, 0.56, 1);
}

/* 1. The bar across the top while a page is on its way. */

.pcp-progress {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 100000;
	width: 100%;
	height: 3px;
	background: var(--pcp-load-blue);
	box-shadow: 0 0 8px rgba(0, 163, 218, 0.55);
	transform: scaleX(0);
	transform-origin: 0 50%;
	opacity: 0;
	pointer-events: none;
}

.pcp-progress.is-active {
	opacity: 1;
	/* Most of the way across quickly, then a slow creep: it never claims to be finished. */
	transform: scaleX(0.82);
	transition: transform 9s cubic-bezier(0.08, 0.7, 0.2, 1), opacity 0.15s ease;
}

/* 2. The card that was chosen. */

@keyframes pcp-spin {
	to {
		transform: rotate(360deg);
	}
}

.rpl-res__card.pcp-opening {
	cursor: progress;
}

.rpl-res__card.pcp-opening .rpl-res__thumb {
	position: relative;
}

.rpl-res__card.pcp-opening .rpl-res__thumb::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	background: rgba(16, 35, 48, 0.45);
	border-radius: inherit;
}

.rpl-res__card.pcp-opening .rpl-res__thumb::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 3;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: pcp-spin 0.8s linear infinite;
	pointer-events: none;
}

/* 3. Photos on their way. */

@keyframes pcp-shimmer {
	from {
		background-position: 150% 0;
	}
	to {
		background-position: -50% 0;
	}
}

@keyframes pcp-photo-in {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.pcp-loading {
	position: relative;
	background-color: #e4eaee;
}

.pcp-loading img {
	opacity: 0;
}

.pcp-loading::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(100deg, rgba(255, 255, 255, 0) 25%, rgba(255, 255, 255, 0.65) 50%, rgba(255, 255, 255, 0) 75%);
	background-size: 200% 100%;
	animation: pcp-shimmer 1.4s ease-in-out infinite;
	pointer-events: none;
}

.pcp-loaded img {
	animation: pcp-photo-in 0.4s var(--pcp-load-ease) both;
}

/* 4. Load more: the cards that appear rise in, a few at a time. */

@keyframes pcp-card-in {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

.rpl-res__card.pcp-new,
.rpl-card.pcp-new {
	animation: pcp-card-in 0.4s var(--pcp-load-ease) both;
	animation-delay: calc(var(--pcp-i, 0) * 35ms);
}

/* 5. A form that is being sent (the label is changed by assets/loading.js). */

.wpcf7 form.submitting .wpcf7-submit {
	cursor: progress;
	background-color: var(--pcp-load-navy);
}

.wpcf7 form.submitting .wpcf7-spinner {
	background-color: var(--pcp-load-blue);
	opacity: 1;
}

.pcp-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.pcp-progress.is-active {
		transition: opacity 0.15s ease;
		transform: scaleX(1);
	}

	.pcp-loading::after,
	.pcp-loaded img,
	.rpl-res__card.pcp-new,
	.rpl-card.pcp-new {
		animation: none;
	}

	.rpl-res__card.pcp-opening .rpl-res__thumb::after {
		animation-duration: 2s;
	}
}
