/*
 * Articles (ADR 0061): a grid (or carousel) of article cards. Each card is a Service card
 * (service-card/style.css, "requires": ["service-card"]); this file adds the grid, the category
 * buttons, the details line, the link text and the page links.
 */
.sv-posts {
	display: grid;
	gap: var(--sv-space-sm);
}

.sv-posts__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--sv-space-md);
	/* Space between columns (ADR 0054). */
	column-gap: var(--sv-colgap, var(--sv-space-md));
}

.sv-posts--columns-1 .sv-posts__grid {
	grid-template-columns: minmax(0, 1fr);
}

.sv-posts--columns-2 .sv-posts__grid {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sv-posts--columns-4 .sv-posts__grid {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1024px) {
	:is(.sv-posts--columns-3, .sv-posts--columns-4) .sv-posts__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.sv-posts .sv-posts__grid[class] {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Carousel (ADR 0047): as many cards in view as the columns; on phones one and a glimpse of the next. */
.sv-posts .sv-carousel {
	--sv-carousel-per: 3;
}

.sv-posts--columns-1 .sv-carousel {
	--sv-carousel-per: 1;
}

.sv-posts--columns-2 .sv-carousel {
	--sv-carousel-per: 2;
}

.sv-posts--columns-4 .sv-carousel {
	--sv-carousel-per: 4;
}

@media (max-width: 1024px) {
	:is(.sv-posts--columns-3, .sv-posts--columns-4) .sv-carousel {
		--sv-carousel-per: 2;
	}
}

@media (max-width: 767px) {
	.sv-posts .sv-carousel[class] {
		--sv-carousel-per: 1.15;
	}

	.sv-posts--columns-1 .sv-carousel[class] {
		--sv-carousel-per: 1;
	}
}

/* An article without a featured picture: a soft block in the Accent's tint, so the cards line up. */
.sv-posts__nophoto {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	min-block-size: 8rem;
	background:
		radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--sv-color-primary) 22%, transparent), transparent 60%),
		color-mix(in srgb, var(--sv-color-primary) 10%, var(--sv-color-surface));
}

.sv-service-card--look-text .sv-service-card__media:has(.sv-posts__nophoto) {
	display: none;
}

/* The details line: category · date · reading time, small, the category in the accent. */
.sv-posts__meta {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.5rem;
	align-items: center;
	margin: 0;
	margin-block-end: 0.4rem;
	color: var(--sv-color-muted);
	font-size: var(--sv-size-small);
	line-height: 1.4;
}

.sv-posts__meta:empty {
	display: none;
}

.sv-posts__meta > * + *::before {
	content: "·";
	margin-inline-end: 0.5rem;
	color: var(--sv-color-muted);
	font-weight: 400;
}

.sv-posts__category {
	color: var(--sv-accent, var(--sv-color-link));
	font-weight: 600;
}

/*
 * On a dark card or the photo, the details follow the card's light text, a little softer; on an accent-color card
 * at full strength, since the card's text color only just reads on it (ADR 0102).
 */
:is(.sv-card-dark, .sv-card-primary, .sv-service-card--look-overlay-shade) .sv-posts__meta,
:is(.sv-card-dark, .sv-card-primary, .sv-service-card--look-overlay-shade) .sv-posts__meta > * + *::before {
	color: inherit;
	opacity: 0.85;
}

.sv-card-primary .sv-posts__meta,
.sv-card-primary .sv-posts__meta > * + *::before {
	opacity: 1;
}

:is(.sv-card-dark, .sv-card-primary, .sv-service-card--look-overlay-shade) .sv-posts__category {
	color: inherit;
}

.sv-posts__author {
	margin: 0;
	margin-block-start: 0.5rem;
	color: var(--sv-color-muted);
	font-size: var(--sv-size-small);
}

/* The link text: the accent, with an arrow that moves when the card is pointed at. */
.sv-posts__more {
	display: inline-flex;
	gap: 0.35em;
	align-items: center;
	margin-block-start: 0.75rem;
	color: var(--sv-accent, var(--sv-color-link));
	font-size: var(--sv-size-small);
	font-weight: 600;
}

.sv-posts__more::after {
	content: "→";
	transition: translate 0.2s ease;
}

:where([dir="rtl"]) .sv-posts__more::after {
	content: "←";
}

.sv-posts__item:is(:hover, :focus-within) .sv-posts__more::after {
	translate: 3px 0;
}

:where([dir="rtl"]) .sv-posts__item:is(:hover, :focus-within) .sv-posts__more::after {
	translate: -3px 0;
}

:is(.sv-card-dark, .sv-card-primary, .sv-service-card--look-overlay-shade) .sv-posts__more {
	color: inherit;
}

/*
 * Cards in a row are as tall as the tallest: the text fills the card and the author and link text go
 * to its foot, so they line up whatever the title's length (not on the photo, where the text is a box).
 */
.sv-posts__item:is(.sv-service-card--look-text, .sv-service-card--look-top-open, .sv-service-card--look-top-card) {
	grid-template-rows: auto 1fr;
}

.sv-posts__item:not(.sv-service-card--look-overlay-box, .sv-service-card--look-overlay-shade) .sv-service-card__body {
	display: flex;
	flex-direction: column;
}

.sv-posts__item:not(.sv-service-card--look-overlay-box, .sv-service-card--look-overlay-shade) .sv-posts__author {
	margin-block-start: auto;
	padding-block-start: 0.5rem;
}

.sv-posts__item:not(.sv-service-card--look-overlay-box, .sv-service-card--look-overlay-shade) .sv-posts__more {
	align-self: flex-start;
	margin-block-start: auto;
	padding-block-start: 0.75rem;
}

.sv-posts__item:not(.sv-service-card--look-overlay-box, .sv-service-card--look-overlay-shade) .sv-posts__author ~ .sv-posts__more {
	margin-block-start: 0;
}

/*
 * On the photo the text shares the photo's height: three lines of the article at most, and on the
 * shade a deeper fade, so the details at the top of the text stay readable on a light photo.
 */
.sv-posts__item:is(.sv-service-card--look-overlay-box, .sv-service-card--look-overlay-shade) .sv-service-card__text {
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
}

/* The details and the link text follow the shade's white text. */
.sv-posts__item.sv-service-card--look-overlay-shade .sv-service-card__body {
	color: var(--sv-color-text);
}

/* Side by side: room above and below the text when it is taller than the photo (phones: photo on top). */
@media (min-width: 768px) {
	.sv-posts__item.sv-service-card--look-side .sv-service-card__body {
		padding-block: 0.85rem;
	}
}

.sv-posts__item.sv-service-card--look-overlay-shade .sv-service-card__media::before {
	background: linear-gradient(to top, rgb(0 0 0 / 86%) 0%, rgb(0 0 0 / 62%) 45%, rgb(0 0 0 / 0%) 82%);
}

/* Category buttons (All, with pages): pills, the chosen one in the accent. */
.sv-posts__filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-block-end: var(--sv-space-sm);
}

.sv-align-center .sv-posts__filters {
	justify-content: center;
}

.sv-posts__filter {
	display: inline-block;
	padding-block: 0.45rem;
	padding-inline: 1rem;
	border: 1px solid var(--sv-color-border);
	border-radius: 999px;
	color: var(--sv-color-text);
	font-size: var(--sv-size-small);
	font-weight: 500;
	line-height: 1.3;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.sv-posts__filter:is(:hover, :focus-visible) {
	border-color: var(--sv-accent, var(--sv-color-primary));
	color: var(--sv-accent, var(--sv-color-link));
}

.sv-posts__filter[aria-current="page"] {
	border-color: var(--sv-color-primary);
	background: var(--sv-color-primary);
	color: var(--sv-color-on-primary);
}

/* Newer · page x of y · Older. */
.sv-posts__pages {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem 1.5rem;
	align-items: center;
	justify-content: center;
	margin-block-start: var(--sv-space-sm);
	font-size: var(--sv-size-small);
}

.sv-posts__page {
	padding-block: 0.55rem;
	padding-inline: 1.1rem;
	border: 1px solid var(--sv-color-border);
	border-radius: var(--sv-radius-button, 10px);
	color: var(--sv-color-text);
	font-weight: 600;
	text-decoration: none;
	transition: border-color 0.15s ease, color 0.15s ease;
}

.sv-posts__page:is(:hover, :focus-visible) {
	border-color: var(--sv-accent, var(--sv-color-primary));
	color: var(--sv-accent, var(--sv-color-link));
}

.sv-posts__page-count {
	color: var(--sv-color-muted);
}

/* One article a row with the photo beside (the Simple list design): the photo keeps to a quarter of the row. */
@media (min-width: 768px) {
	.sv-posts--columns-1 .sv-service-card.sv-service-card--look-side[class]:not(:has(.sv-service-card__number)) {
		grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
	}
}

/*
 * A section whose one element has nothing to show — the Featured article or a list that the blog
 * page's category view leaves out (ADR 0063) — takes no room.
 */
.sv-section:has(> .sv-container > .sv-column:only-child > :is(.sv-posts, .sv-posts-section, .sv-post-featured):only-child:empty) {
	display: none;
}

/* Latest articles (the ready-made section): the heading, the cards, then the button. */
.sv-posts-section {
	display: grid;
	gap: var(--sv-space-md);
}

.sv-posts__action {
	display: flex;
	justify-content: center;
}

.sv-posts__action--start {
	justify-content: flex-start;
}

.sv-posts__action--end {
	justify-content: flex-end;
}

@media (prefers-reduced-motion: reduce) {
	.sv-posts__more::after,
	.sv-posts__filter,
	.sv-posts__page {
		transition: none;
	}
}
