/*
 * archive.css — the archive listing and its cards.
 *
 * Sibling of header.css and footer.css: the markup lives in template parts, so
 * the owner of its styles has to be declared somewhere, and this is it.
 *
 * Deliberately NOT a block stylesheet. blocks/archive-listing/style.css would
 * only load where that block is on the page, and the same cards render on the
 * topic, category, tag, date and author archives, where the block never
 * appears. Deliberately not css/content.css either: that file owns the core
 * blocks and excludes [class*="wp-block-sws-theme-"] on purpose.
 *
 * Enqueued conditionally from functions.php (is_home / is_archive / is_search)
 * and not passed to add_editor_style(): the block draws a static placeholder in
 * the editor, so there are no cards to style there.
 */

/*--------------------------------------------------------------
# Listing
--------------------------------------------------------------*/

.sws-archive-listing,
.sws-archive-listing *,
.sws-archive-listing *::before,
.sws-archive-listing *::after {
	box-sizing: border-box;
}

.sws-archive-listing {
	/* The rail formula from base.css: no padding, so the box model stays out of it. */
	max-width: min(var(--sws-content, 1116px), 100% - 2 * var(--sws-gutter, 0.75rem));
	margin-inline: auto;
	/*
	 * The block carries a wp-block-sws-theme-* class, which keeps content.css
	 * and its vertical rhythm off this section — so the section brings its own.
	 */
	padding-block: clamp(2rem, 6vw, 4rem);
}

.sws-archive-listing__grid {
	display: grid;
	/*
	 * Intrinsic tracks rather than a container query: the same grid has to work
	 * inside the block on /projects/ and inside the plain listing on
	 * /topic/<term>/, and auto-fill needs no container declared on either.
	 */
	grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
	gap: 1.875rem;
}

.sws-archive-listing__empty {
	margin: 0;
	color: var(--wp--preset--color--text, #4a6f8a);
	font-size: var(--wp--preset--font-size--large, 1.375rem);
	text-align: center;
}

/*--------------------------------------------------------------
# Card
--------------------------------------------------------------*/

.sws-card,
.sws-card *,
.sws-card *::before,
.sws-card *::after {
	box-sizing: border-box;
}

.sws-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--line, #dbeefd);
	border-radius: var(--sws-radius-lg, 5px);
	background-color: var(--wp--preset--color--surface, #fff);
	transition: box-shadow var(--sws-transition, 0.3s ease), transform var(--sws-transition, 0.3s ease);
}

.sws-card:hover,
.sws-card:focus-within {
	box-shadow: var(--sws-shadow-dropdown, 0 0 30px 0 rgb(0 0 0 / 5%));
	transform: translateY(-3px);
}

/*--------------------------------------------------------------
# Card media
--------------------------------------------------------------*/

.sws-card__media {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	aspect-ratio: 16 / 10;
	background-color: var(--wp--preset--color--surface-alt, #f7fafd);
}

.sws-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/*
 * The stand-in for a missing featured image. It is the common case while the
 * media library is nearly empty, so it is styled as a first-class state rather
 * than a fallback: a schematic symbol from the theme's own icon set, on the
 * alternate surface.
 */
.sws-card__media--placeholder {
	border-bottom: 1px solid var(--wp--preset--color--line, #dbeefd);
	color: var(--wp--preset--color--accent, #44ce6f);
}

.sws-card__icon {
	width: 3.5rem;
	height: 3.5rem;
	opacity: 0.55;
}

/*--------------------------------------------------------------
# Card body
--------------------------------------------------------------*/

.sws-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 0.625rem;
	padding: 1.5rem;
}

.sws-card__title {
	/*
	 * Not the x-large h2 from theme.json: that size is set for prose, and a
	 * card heading sits in a 17.5rem track.
	 */
	margin: 0;
	color: var(--wp--preset--color--heading, #0e314c);
	font-size: 1.25rem;
	font-weight: 700;
	line-height: 1.4;
}

.sws-card__link {
	color: inherit;
	text-decoration: none;
	transition: color var(--sws-transition, 0.3s ease);
}

.sws-card__link:hover,
.sws-card__link:focus {
	color: var(--wp--preset--color--accent, #44ce6f);
}

.sws-card__date {
	color: var(--wp--preset--color--text, #4a6f8a);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.sws-card__excerpt {
	/*
	 * Clamped rather than shortened in PHP. An excerpt WordPress generated for
	 * itself runs 55 words, which is fine on a feed and far too long in a
	 * 17.5rem track — one verbose entry would set the height of its whole grid
	 * row. A filter on excerpt_length would change the excerpt everywhere,
	 * including the RSS feed and search results; this only changes how many
	 * lines the card shows.
	 */
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 4;
	line-clamp: 4;
	margin: 0;
	color: var(--wp--preset--color--text, #4a6f8a);
	line-height: 1.7;
}

/*--------------------------------------------------------------
# Card topics
--------------------------------------------------------------*/

.sws-card__topics {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	/* Pushed to the bottom so cards of unequal height still line up. */
	margin: auto 0 0;
	padding: 0;
	list-style: none;
}

.sws-card__topic {
	margin: 0;
}

.sws-card__topic-link {
	display: inline-block;
	padding: 0.25rem 0.625rem;
	border-radius: var(--sws-radius, 4px);
	background-color: var(--wp--preset--color--surface-alt, #f7fafd);
	color: var(--wp--preset--color--text, #4a6f8a);
	font-size: var(--wp--preset--font-size--small, 0.875rem);
	text-decoration: none;
	transition: background-color var(--sws-transition, 0.3s ease), color var(--sws-transition, 0.3s ease);
}

.sws-card__topic-link:hover,
.sws-card__topic-link:focus {
	background-color: var(--wp--preset--color--accent-soft, #cdf1d8);
	color: var(--wp--preset--color--heading, #0e314c);
}

/*--------------------------------------------------------------
# Pagination
--------------------------------------------------------------*/

/*
 * .page-numbers and .nav-links are core class names. They are styled here only
 * because they are nested inside our own root — the same exception css/content.css
 * documents for the dynamic core blocks.
 */
.sws-pagination {
	margin-block-start: 2.5rem;
}

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

.sws-pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding-inline: 0.5rem;
	border: 1px solid var(--wp--preset--color--line, #dbeefd);
	border-radius: var(--sws-radius, 4px);
	color: var(--wp--preset--color--heading, #0e314c);
	text-decoration: none;
	transition: background-color var(--sws-transition, 0.3s ease), color var(--sws-transition, 0.3s ease), border-color var(--sws-transition, 0.3s ease);
}

.sws-pagination .page-numbers:hover,
.sws-pagination .page-numbers:focus,
.sws-pagination .page-numbers.current {
	border-color: var(--wp--preset--color--accent, #44ce6f);
	background-color: var(--wp--preset--color--accent, #44ce6f);
	color: var(--wp--preset--color--surface, #fff);
}

.sws-pagination .page-numbers.dots {
	border-color: transparent;
}

.sws-pagination .page-numbers.dots:hover {
	background-color: transparent;
	color: var(--wp--preset--color--heading, #0e314c);
}
