/*
 * Projects archive. Figma frame BSGV-projecten-1a:
 * filter right-aligned at y207 (Eudoxus Medium 14, active Bold, 25px gaps),
 * grid starts 88px below; two columns of 586 with a 124 gap,
 * right column 99px lower, every fifth card 1296 wide.
 */

body.post-type-archive-project,
body.tax-project_category {
	background: var(--wp--preset--color--cream);
}

.project-archive {
	--stagger: 99px;

	padding-top: 34px;
	padding-bottom: var(--wp--preset--spacing--60);
}

/* Filter */

.project-filter__list {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px 25px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.project-filter__link {
	display: inline-block;
	color: var(--wp--preset--color--black);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	line-height: 1;
	padding-block: 4px;

	@media (hover: hover) {
		&:hover {
			text-decoration: underline;
			text-underline-offset: 4px;
		}
	}

	&[aria-current="page"] {
		font-weight: 700;
	}
}

@media (max-width: 767px) {
	/* Single scrollable row instead of wrapping onto many lines. */
	.project-filter {
		margin-inline: calc(-1 * var(--wp--custom--gutter));
		overflow-x: auto;
		scrollbar-width: none;
	}

	.project-filter__list {
		flex-wrap: nowrap;
		justify-content: flex-start;
		padding-inline: var(--wp--custom--gutter);
		white-space: nowrap;
	}
}

/* Grid */

.project-grid {
	display: grid;
	gap: 48px;
	margin-top: clamp(40px, 4.37vw, 66px);

	@media (min-width: 768px) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: 9.57%;
		row-gap: clamp(48px, 6.5vw, 98px);
		padding-bottom: var(--stagger);
	}
}

/*
 * Pattern per block of five *visible* cards: 1 left, 2 right (lower),
 * 3 left, 4 right (lower), 5 full width. Counting with "of :not([hidden])"
 * keeps the pattern intact after filtering.
 */
@media (min-width: 768px) {
	.project-grid > .project-card:nth-child(5n + 2 of :not([hidden])),
	.project-grid > .project-card:nth-child(5n + 4 of :not([hidden])) {
		transform: translateY(var(--stagger));
	}

	.project-grid > .project-card:nth-child(5n of :not([hidden])) {
		grid-column: 1 / -1;
		margin-top: var(--stagger);

		& .project-card__media {
			aspect-ratio: 1296 / 689;
		}
	}
}

/* Filter animation: cards morph to their new place (view transitions). */
::view-transition-group(*) {
	animation-duration: 0.5s;
	animation-timing-function: cubic-bezier(0.2, 0.6, 0.2, 1);
}

::view-transition-old(*),
::view-transition-new(*) {
	animation-duration: 0.35s;
}

/* Fallback for browsers without view transitions. */
.project-grid {
	transition: opacity 0.2s;

	&.is-fading {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.project-grid {
		transition: none;
	}
}

.project-archive__empty {
	margin-top: var(--wp--preset--spacing--50);
}
