/* Panel Cards */

/*
 * Hero + Panel Cards without the featured post: the filter, then the card
 * grid from the first post. The template's header says "Featured post: none",
 * which is what makes the feature turn the hero off for this design, so the
 * newest post is a card here rather than vanishing.
 *
 * Every setting on the Posts screen that this design has a place for arrives
 * as a variable read with its own value as the fallback. Layout follows the
 * listing's own width through container queries. Fonts are the theme's.
 */

.srd-posts {
	container-type: inline-size;
	margin-block: 0 2em;
}

/* --- Archive heading --------------------------------------------------- */

/*
 * The theme's own h2 styling stands until a setting says otherwise: each
 * property is declared only under the modifier class PHP adds when that
 * setting is set. Only the spacing is the design's, so the heading sits with
 * the filter rather than wherever the theme's h2 margins put it.
 */
.srd-posts-heading {
	margin: var(--srd-posts-heading-margin, 0 0 16px);
}

.srd-posts-heading--size {
	font-size: var(--srd-posts-heading-font-size);
}

.srd-posts-heading--weight {
	font-weight: var(--srd-posts-heading-font-weight);
}

.srd-posts-heading--align {
	text-align: var(--srd-posts-heading-text-align);
}

.srd-posts-heading--transform {
	text-transform: var(--srd-posts-heading-text-transform);
}

/* --- Category filter --------------------------------------------------- */

.srd-posts-filter {
	margin-bottom: 20px;
	scroll-margin-top: 120px;
}

.srd-posts-filter__list {
	display: flex;
	flex-wrap: wrap;
	justify-content: var(--srd-posts-filter-justify, flex-start);
	gap: 4px 8px;
	margin: 0;
	padding: 0;
}

.srd-posts-filter__list li {
	margin: 0;
	padding: 0;
}

/*
 * List style and pill colour carry two IDs of weight, as the nav link colours
 * do: a theme's `#content ul` / `.entry-content ul li` / `.entry-content a`
 * otherwise wins, which is the bullet beside every pill. Nothing else here is
 * raised, so a site can still override the layout at ordinary weight.
 */
.srd-posts-filter__list:not(#srd-id-weight):not(#srd-id-weight),
.srd-posts-filter__list:not(#srd-id-weight):not(#srd-id-weight) > li {
	list-style: var(--srd-posts-filter-list-style, none);
	/* A flex item stays a list item and draws its marker; outside, the
	   marker would hang into the gap and over the pill before it. */
	list-style-position: inside;
}

/* A theme's decorative bullet, drawn as a pseudo-element rather than a marker. */
.srd-posts-filter__list:not(#srd-id-weight):not(#srd-id-weight) > li::before {
	content: none;
}

.srd-posts-filter__pill {
	display: inline-flex;
	align-items: baseline;
	justify-content: center;
	gap: 3px;
	min-width: var(--srd-posts-filter-pill-min-width, auto);
	padding: var(--srd-posts-filter-pill-padding, 5px 12px);
	font-size: var(--srd-posts-filter-pill-font-size, 0.875rem);
	font-weight: var(--srd-posts-filter-pill-font-weight, inherit);
	text-transform: var(--srd-posts-filter-pill-text-transform, none);
	letter-spacing: var(--srd-posts-filter-pill-letter-spacing, normal);
	line-height: 1.4;
	text-decoration: none;
	border: var(--srd-posts-filter-pill-border-width, 0) var(--srd-posts-filter-pill-border-style, solid) var(--srd-posts-filter-pill-border-color, currentColor);
	border-radius: var(--srd-posts-filter-pill-radius, 999px);
	opacity: 0.75;
	transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.srd-posts--pill-color .srd-posts-filter__pill {
	opacity: 1;
}

.srd-posts-filter__pill:not(#srd-id-weight):not(#srd-id-weight) {
	color: var(--srd-posts-filter-pill-color, inherit);
	background: var(--srd-posts-filter-pill-bg, transparent);
}

.srd-posts-filter__pill:hover,
.srd-posts-filter__pill:focus-visible {
	opacity: 1;
}

.srd-posts-filter__pill:not(#srd-id-weight):not(#srd-id-weight):hover,
.srd-posts-filter__pill:not(#srd-id-weight):not(#srd-id-weight):focus-visible {
	color: var(--srd-posts-filter-pill-color-hover, var(--srd-posts-filter-pill-color, inherit));
	background: var(--srd-posts-filter-pill-bg-hover, rgba(0, 0, 0, 0.05));
	border-color: var(--srd-posts-filter-pill-border-color-hover, var(--srd-posts-filter-pill-border-color, currentColor));
}

.srd-posts-filter__pill--current,
.srd-posts-filter__pill--current:hover {
	opacity: 1;
}

/* Written after the hover rule it ties with at (2,2,0), so the current pill
   keeps its own pair on hover rather than taking the ordinary pill's. */
.srd-posts-filter__pill--current:not(#srd-id-weight):not(#srd-id-weight) {
	color: var(--srd-posts-filter-active-color, var(--srd-posts-filter-pill-color, inherit));
	background: var(--srd-posts-filter-active-bg, #dcebbd);
	border-color: var(--srd-posts-filter-active-border-color, var(--srd-posts-filter-pill-border-color, currentColor));
}

.srd-posts-filter__pill--current:not(#srd-id-weight):not(#srd-id-weight):hover,
.srd-posts-filter__pill--current:not(#srd-id-weight):not(#srd-id-weight):focus-visible {
	color: var(--srd-posts-filter-active-color-hover, var(--srd-posts-filter-active-color, var(--srd-posts-filter-pill-color-hover, var(--srd-posts-filter-pill-color, inherit))));
	background: var(--srd-posts-filter-active-bg-hover, var(--srd-posts-filter-active-bg, #dcebbd));
	/* Active Hover, then Active, then the ordinary hover border — the same
	   chain the active pill's text colour follows. */
	border-color: var(--srd-posts-filter-active-border-color-hover, var(--srd-posts-filter-active-border-color, var(--srd-posts-filter-pill-border-color-hover, var(--srd-posts-filter-pill-border-color, currentColor))));
}

.srd-posts-filter__count {
	font-size: 0.65em;
	position: relative;
	top: -0.5em;
}

/* --- Panel cards ------------------------------------------------------- */

.srd-posts-grid {
	display: grid;
	grid-template-columns: repeat(var(--srd-posts-columns, 3), minmax(0, 1fr));
	gap: var(--srd-posts-gap, 24px);
}

/* Each card is its own container, so its padding and title scale with the
   card rather than with the whole listing: four abreast and one alone both
   read right. Flex, so every card in a row stretches to the tallest. */
.srd-posts-item {
	display: flex;
	margin: 0;
	min-width: 0;
	container-type: inline-size;
}

.srd-posts-tile {
	display: flex;
	flex: 1;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	text-decoration: none;
	background: var(--srd-posts-card-bg, #416f6b);
	border-radius: var(--srd-posts-card-radius, 0);
}

.srd-posts-tile:hover,
.srd-posts-tile:focus {
	text-decoration: none;
}

/* The whole card is a link. Its colour carries two IDs of weight, as the
   featured title's does: a theme's `.entry-content a` would otherwise paint
   the title and the date its link colour. */
.srd-posts-tile:not(#srd-id-weight):not(#srd-id-weight),
.srd-posts-tile:not(#srd-id-weight):not(#srd-id-weight):hover,
.srd-posts-tile:not(#srd-id-weight):not(#srd-id-weight):focus {
	color: var(--srd-posts-card-text, #ffffff);
}

.srd-posts-tile:focus-visible {
	outline: 2px solid var(--srd-posts-card-bg, #416f6b);
	outline-offset: 3px;
}

.srd-posts-tile__media {
	position: relative;
	display: block;
	flex: none;
	aspect-ratio: var(--srd-posts-card-aspect, 3 / 2);
	overflow: hidden;
}

.srd-posts-tile__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	transition: scale 0.6s ease;
}

/* A tint over the whole picture, nothing when Card Overlay Color is blank.
   ::before, because ::after belongs to the link hover animations. */
.srd-posts-tile__media::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: var(--srd-posts-card-overlay, transparent);
	pointer-events: none;
}

.srd-posts-tile__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 32px;
	padding: clamp(20px, 7cqi, 44px);
}

.srd-posts-tile__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: var(--srd-posts-tile-title-lines, none);
	line-clamp: var(--srd-posts-tile-title-lines, none);
	overflow: hidden;
	margin: 0;
	padding: 0;
	font-size: var(--srd-posts-card-title-size, clamp(1.125rem, 0.7rem + 3.4cqi, 1.875rem));
	font-weight: var(--srd-posts-tile-title-font-weight, 500);
	line-height: 1.3;
	color: inherit;
}

/* Pinned to the bottom of the panel, so the tags and dates of a row line up
   whatever length each title runs to. */
.srd-posts-tile__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 22px;
	margin-top: auto;
	line-height: 1.3;
}

/*
 * The category tag and the date each take their own type settings, so the
 * Card Category and Card Date tabs move one without the other.
 *
 * The tag's default colours are the panel's own two swapped, so it stays
 * legible whatever pair Card Background Color and Card Text Color are set to.
 * A colour set here is declared on the span itself, which beats the colour it
 * would inherit from the weighted card link without needing weight of its own.
 */
.srd-posts-tile__tag {
	padding: var(--srd-posts-tile-tag-padding, 0.55em 1.4em);
	font-size: var(--srd-posts-tile-tag-font-size, 0.9375rem);
	font-weight: var(--srd-posts-tile-tag-font-weight, 500);
	text-transform: var(--srd-posts-tile-tag-text-transform, none);
	letter-spacing: var(--srd-posts-tile-tag-letter-spacing, normal);
	color: var(--srd-posts-tile-tag-color, var(--srd-posts-card-bg, #416f6b));
	background: var(--srd-posts-tile-tag-bg, var(--srd-posts-card-text, #ffffff));
	border-radius: var(--srd-posts-tile-tag-radius, 0);
}

/* "April 19, 2026" wraps as a whole beside the tag, never mid-date. */
.srd-posts-tile__date {
	font-size: var(--srd-posts-tile-date-font-size, 0.9375rem);
	font-weight: var(--srd-posts-tile-date-font-weight, 500);
	text-transform: var(--srd-posts-tile-date-text-transform, none);
	letter-spacing: var(--srd-posts-tile-date-letter-spacing, normal);
	color: var(--srd-posts-tile-date-color, inherit);
	white-space: nowrap;
}


.srd-posts-tile:hover .srd-posts-tile__media img {
	scale: 1.04;
}

/* --- Card hover: Fill with color --------------------------------------- */

/*
 * Card Hover Effect = Fill with color puts srd-posts--tile-hover-fill on the
 * root. A layer then fades in over the whole card, image included, with the
 * border on it, and an arrow box appears at the top. The card's own box and
 * its text never move, so nothing beside it reflows on hover.
 *
 * The layer is the card's ::before, because ::after belongs to the link hover
 * animations. Stacking, inside the card's own isolated context: the image and
 * its tint at 1, the layer at 2, the text and the arrow at 3.
 */
.srd-posts-tile {
	position: relative;
	isolation: isolate;
	transition: border-radius 0.25s ease;
}

.srd-posts-tile__body {
	position: relative;
	z-index: 3;
}

.srd-posts-tile__icon {
	display: none;
}

.srd-posts--tile-hover-fill .srd-posts-tile::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
	box-sizing: border-box;
	background: var(--srd-posts-tile-hover-bg, var(--srd-posts-card-bg, #416f6b));
	border: var(--srd-posts-tile-hover-border-width, 0) solid var(--srd-posts-tile-hover-border-color, currentColor);
	border-radius: inherit;
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
}

.srd-posts--tile-hover-fill .srd-posts-tile__icon {
	position: absolute;
	top: clamp(20px, 7cqi, 44px);
	left: clamp(20px, 7cqi, 44px);
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--srd-posts-tile-hover-icon-size, 3.75em);
	height: var(--srd-posts-tile-hover-icon-size, 3.75em);
	color: var(--srd-posts-tile-hover-icon-color, #1a1a1a);
	background: var(--srd-posts-tile-hover-icon-bg, #ffffff);
	border-radius: var(--srd-posts-tile-hover-icon-radius, 0);
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
}

/* The shared arrow points right; the card's points up and out. */
.srd-posts-tile__icon svg {
	width: var(--srd-posts-tile-hover-arrow-size, 55%);
	height: var(--srd-posts-tile-hover-arrow-size, 55%);
	rotate: -45deg;
}

.srd-posts--tile-hover-fill .srd-posts-tile:is(:hover, :focus-visible) {
	border-radius: var(--srd-posts-tile-hover-radius, var(--srd-posts-card-radius, 0));
}

.srd-posts--tile-hover-fill .srd-posts-tile:is(:hover, :focus-visible)::before,
.srd-posts--tile-hover-fill .srd-posts-tile:is(:hover, :focus-visible) .srd-posts-tile__icon {
	opacity: 1;
}

/* Two IDs of weight, to outrank the card's own weighted colour rule. */
.srd-posts--tile-hover-fill .srd-posts-tile:not(#srd-id-weight):not(#srd-id-weight):is(:hover, :focus-visible) {
	color: var(--srd-posts-tile-hover-color, var(--srd-posts-card-text, #ffffff));
}

/* The date declares its own colour, so it has to be told to follow. Blank
   Hover Text Color leaves a Card Date Color as it was. */
.srd-posts--tile-hover-fill .srd-posts-tile:is(:hover, :focus-visible) .srd-posts-tile__date {
	color: var(--srd-posts-tile-hover-color, var(--srd-posts-tile-date-color, inherit));
}

/* The image is covered; zooming it underneath would only cost paint. */
.srd-posts--tile-hover-fill .srd-posts-tile:hover .srd-posts-tile__media img {
	scale: none;
}

@media (prefers-reduced-motion: reduce) {
	.srd-posts-tile,
	.srd-posts--tile-hover-fill .srd-posts-tile::before,
	.srd-posts--tile-hover-fill .srd-posts-tile__icon {
		transition: none;
	}
}

/* --- Load more --------------------------------------------------------- */

.srd-posts-more {
	margin-top: 32px;
	text-align: center;
}

.srd-posts-more__link--loading {
	opacity: 0.6;
	pointer-events: none;
}

/* Announced, not shown. */
.srd-posts-status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.srd-posts-empty {
	padding: 32px 0;
	text-align: center;
	opacity: 0.7;
}

/* --- Narrower containers ----------------------------------------------- */

@container (max-width: 860px) {
	.srd-posts-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (max-width: 540px) {
	.srd-posts-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.srd-posts-tile__media img {
		transition: none;
	}

	.srd-posts-tile:hover .srd-posts-tile__media img {
		scale: none;
	}
}
