/**
 * Arranges the selected-work grid and its category filter.
 *
 * A staggered three-column "gallery wall" of video boxes (the box surface
 * itself lives in components/cards.css); the filter fades cards out without
 * reshuffling the columns.
 */

.work-section {
	padding-block: var(--inv-sect);
	background: var(--inv-paper);
}

.work-section__inner {
	display: grid;
	gap: var(--inv-space-xl);
}

.work-filter {
	display: flex;
	flex-wrap: wrap;
	gap: var(--inv-space-xs);
}

.work-filter__button {
	padding: 0.65rem 0.85rem;
	border: 1px solid var(--inv-line);
	border-radius: var(--inv-radius-pill);
	background: transparent;
	color: var(--inv-muted);
	font-family: var(--inv-font-mono);
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
	transition: color var(--inv-duration-fast) var(--inv-ease), background var(--inv-duration-fast) var(--inv-ease), border-color var(--inv-duration-fast) var(--inv-ease);
}

.work-filter__button:hover,
.work-filter__button.is-active {
	border-color: var(--inv-ink);
	background: var(--inv-ink);
	color: var(--inv-text-inv);
}

.work-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--inv-space-xl) var(--inv-space-lg);
}

.work-card.is-filtered-out {
	display: none;
}

@media (min-width: 58rem) {
	.work-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	/* Offset "gallery" rhythm: nudge the 2nd card down and pull the 5th up so the
	   three columns read as a staggered wall, not a flat grid. The pattern repeats
	   every SIX cards (two rows) so every row keeps the rhythm — it used to be a
	   one-off on cards 2 and 5, which left everything below the sixth box flat. */
	.work-grid .work-card:nth-child(6n + 2) {
		margin-top: var(--inv-space-xl);
	}

	.work-grid .work-card:nth-child(6n + 5) {
		margin-top: calc(var(--inv-space-xl) * -1);
	}

	/* The category filter hides cards with display:none, but :nth-child still
	   counts them — so a filtered view would inherit the wrong offsets (usually
	   none at all, i.e. flat). Re-count over the VISIBLE cards only, resetting
	   the four positions that should sit flush. Browsers without `of` support
	   drop these rules and keep the DOM-order rhythm above. */
	.work-grid .work-card:nth-child(6n + 1 of :not(.is-filtered-out)),
	.work-grid .work-card:nth-child(6n + 3 of :not(.is-filtered-out)),
	.work-grid .work-card:nth-child(6n + 4 of :not(.is-filtered-out)),
	.work-grid .work-card:nth-child(6n + 6 of :not(.is-filtered-out)) {
		margin-top: 0;
	}

	.work-grid .work-card:nth-child(6n + 2 of :not(.is-filtered-out)) {
		margin-top: var(--inv-space-xl);
	}

	.work-grid .work-card:nth-child(6n + 5 of :not(.is-filtered-out)) {
		margin-top: calc(var(--inv-space-xl) * -1);
	}
}

@media (max-width: 36rem) {
	.work-grid {
		grid-template-columns: 1fr;
	}
}
