/*
 * Masonry feed.
 *
 * CSS Grid with row spans set by JS from measured card heights.
 * Reading order stays newest-first across each row, which CSS
 * columns cannot do. Without JS the grid still renders — cards
 * just sit on a uniform row rhythm instead of interlocking.
 */

.masonry {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
	gap: var(--gap);
	align-items: start;
	max-width: 96rem;
	margin: 0 auto;
}

/* Once JS has measured, cards span a computed number of 1px rows
   and the gutter is handled by grid-auto-rows arithmetic. */
.masonry.is-measured {
	grid-auto-rows: 1px;
	row-gap: 0;
	align-items: stretch;
}

.masonry.is-measured .card { padding-bottom: var(--gap); }

.card { min-width: 0; }

.card-link {
	display: flex;
	flex-direction: column;
	gap: var(--gap);
	text-decoration: none;
	color: inherit;
	height: 100%;
}

/* ---------------------------------------------------------------
   Card image — no fixed aspect ratio. The natural proportions of
   each featured image are what make the grid ragged, so cropping
   them to a uniform box would defeat the whole layout.
   --------------------------------------------------------------- */

.card-media {
	border-radius: var(--radius);
	overflow: hidden;
	background: #0d0d0d;
	line-height: 0;
}

.card-media img {
	width: 100%;
	height: auto;
	transition: opacity 200ms ease;
}

.card-link:hover .card-media img,
.card-link:focus-visible .card-media img { opacity: 0.86; }

/* ---------------------------------------------------------------
   Card tablet
   --------------------------------------------------------------- */

.card-tablet {
	background: var(--tablet);
	color: var(--ink);
	border-radius: var(--radius);
	padding: 1.25rem 1.375rem 1.5rem;
	flex: 1;
}

.card-title {
	font-size: 1.125rem;
	line-height: 1.25;
	font-weight: 600;
	letter-spacing: -0.015em;
	color: var(--ink);

	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.card-excerpt {
	margin-top: 0.5rem;
	font-size: 0.9375rem;
	line-height: 1.5;
	color: var(--ink-soft);

	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ---------------------------------------------------------------
   Head block and pagination
   --------------------------------------------------------------- */

.stage-head { margin-bottom: var(--gap); }

.pager {
	max-width: 96rem;
	margin: calc(var(--gap) * 2) auto 0;
	font-family: var(--mono);
	font-size: 0.875rem;
}

.pager .nav-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	justify-content: center;
}

.pager a,
.pager .current {
	display: inline-block;
	padding: 0.45rem 0.85rem;
	border-radius: 999px;
	text-decoration: none;
	color: #bbb;
	border: 1px solid #262626;
}

.pager .current {
	background: var(--tablet);
	color: var(--ink);
	border-color: var(--tablet);
}

.pager a:hover { color: #fff; border-color: #555; }
