/*
 * Masonry feed.
 *
 * CSS Grid. feed.js gives each card a row span equal to its measured
 * height, so cards interlock while reading order stays newest-first
 * across each row. Without JS the grid still works, on even rows.
 *
 * Every spacing number below is a default. Blog Tuner prints the
 * saved values straight after this file, so tune there, not here.
 * All sizes are fixed: identical on phone and desktop.
 */

.stage {
	--top-space:  5px;   /* screen top to the first card */
	--post-space: 72px;  /* bottom of one card to top of the next */
	--col-space:  24px;  /* between columns (desktop) */
	--frame:      16px;  /* black either side of image and tablet */
	--card-gap:   8px;   /* image to text tablet */
	--excerpt-h:  4cm;   /* how much excerpt shows */

	/* The safe-area inset is zero in a normal browser tab; it only
	   adds space where a notch would otherwise cover the cards. */
	padding-top: calc(var(--top-space) + env(safe-area-inset-top));
}

.masonry {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
	gap: var(--post-space) var(--col-space);
	align-items: start;
	max-width: 96rem;
	margin: 0 auto;
}

/* Measured: 1px rows, no row gap. Each card carries the space below
   it as padding, and feed.js spans each card over its full height —
   so changing --post-space resizes the cards, the script sees it,
   and the grid re-flows by itself. */
.masonry.is-measured {
	grid-auto-rows: 1px;
	row-gap: 0;
}

.masonry.is-measured .card { padding-bottom: var(--post-space); }

/* ---------------------------------------------------------------
   Card
   --------------------------------------------------------------- */

.card { min-width: 0; }

.card-link {
	display: flex;
	flex-direction: column;
	gap: var(--card-gap);
	color: inherit;
	text-decoration: none;
}

/* Natural proportions, never cropped: the ragged edge is the layout.
   Side padding only, so --post-space and --card-gap own the vertical. */
.card-media { padding-inline: var(--frame); }

/* One post, one object: the image and its tablet meet at square
   corners, so they read as two halves of a single piece. Rounded on
   the outside only. A post with no image keeps all four corners. */
.card-media img {
	width: 100%;
	border-radius: var(--radius) var(--radius) 0 0;
	transition: opacity 200ms ease;
}

.card-link:hover img,
.card-link:focus-visible img { opacity: 0.86; }

.card-tablet {
	margin-inline: var(--frame);
	padding: 1.25rem 1.375rem 1.5rem;
	background: var(--tablet);
	color: var(--ink);
	border-radius: var(--radius);
}

.card-media + .card-tablet {
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.card-title {
	font-size: 1.125rem;
	line-height: 1.25;
	font-weight: 600;
	letter-spacing: -0.015em;

	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
}

/* Date, then category, each on its own line, in the same small
   typewriter type as the date on a post. Plain text, not links: the
   whole card is already one. */
.card-date,
.card-cat {
	font-family: var(--mono);
	font-size: 0.8125rem;
}

.card-date {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin-top: 0.375rem;
	letter-spacing: 0.02em;
	color: var(--ink-soft);
}

/* Author photo beside the date. Fetched at 48px, shown at 24px, so it
   stays sharp on high-density screens. */
.card-avatar {
	flex: none;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	object-fit: cover;
}

.card-cat {
	margin-top: 0.125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #9A7212;
}

/* Cut by height; the fade stops the last line looking sliced. */
.card-excerpt {
	margin-top: 0.5rem;
	font-size: 0.9375rem;
	line-height: 1.5;
	color: var(--ink-soft);

	max-height: var(--excerpt-h);
	overflow: hidden;
	-webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
	mask-image: linear-gradient(to bottom, #000 75%, transparent);
}

/* ---------------------------------------------------------------
   Head tablet (archive and search) and empty state

   Centred at the reading measure, never closer to the screen edge
   than --frame, so it lines up with the cards. Sits one --post-space
   above the first card, as if it were a post.
   --------------------------------------------------------------- */

.stage > .tablet-solo {
	width: min(var(--measure), 100% - 2 * var(--frame));
	margin: 0 auto var(--post-space);
}

/* ---------------------------------------------------------------
   Pagination
   --------------------------------------------------------------- */

.pager {
	max-width: 96rem;
	margin: calc(var(--gap) * 2) auto;
	font-family: var(--mono);
	font-size: 0.875rem;
}

.pager .nav-links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
}

.pager a,
.pager .current {
	display: inline-block;
	padding: 0.45rem 0.85rem;
	border: 1px solid #262626;
	border-radius: 999px;
	color: #bbb;
	text-decoration: none;
}

.pager .current {
	background: var(--tablet);
	border-color: var(--tablet);
	color: var(--ink);
}

.pager a:hover { color: #fff; border-color: #555; }