/**
 * Ajax Filter Search: Editorial Grid items (image cards). Builds on afs-discovery.css.
 *
 * Per feed, the plugin sets --afs-cols (1 to 4) and --afs-ratio (the image aspect ratio) on the root element. The grid
 * never goes below 15rem per card, so the column count is a maximum that drops on narrow screens without media queries.
 */

.afs-design-editorial .afs-items {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(max(15rem, calc((100% - (var(--afs-cols, 3) - 1) * var(--afs-gap)) / var(--afs-cols, 3))), 1fr));
	gap: var(--afs-gap);
	margin: 0;
}

/* One card. These selectors beat the base item rules (a grid row with a bottom border) without !important. */
.afs-design-editorial .afs-items .afs-item.afs-card {
	display: flex;
	flex-direction: column;
	gap: 0;
	padding: 0;
	overflow: hidden;
	border: 1px solid var(--afs-border);
	border-radius: var(--afs-radius);
}

.afs-design-editorial .afs-img {
	display: block;
	aspect-ratio: var(--afs-ratio, 16 / 10);
	overflow: hidden;
	background: var(--afs-soft);
	color: inherit;
}

.afs-design-editorial .afs-img__el {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* No image: a soft tinted tile with a faint dot pattern and a monogram badge (the category's first letter). */
.afs-design-editorial .afs-img--none {
	position: relative;
	display: grid;
	place-items: center;
	background: linear-gradient(135deg, var(--afs-tint), transparent 75%);
	background-color: var(--afs-soft);
}

.afs-design-editorial .afs-img--none::before {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(circle, var(--afs-border) 1.2px, transparent 1.7px) 0 0 / 14px 14px;
	-webkit-mask-image: linear-gradient(135deg, transparent 30%, #000);
	mask-image: linear-gradient(135deg, transparent 30%, #000);
}

.afs-design-editorial .afs-img__mono {
	position: relative;
	display: grid;
	place-items: center;
	width: 4.2rem;
	height: 4.2rem;
	border: 1px solid var(--afs-border);
	border-radius: 18px;
	background: var(--afs-soft);
	font-size: 1.8rem;
	font-weight: 700;
	letter-spacing: -0.02em;
	box-shadow: 0 8px 20px -12px rgba(0, 0, 0, 0.35);
}

.afs-design-editorial .afs-card__body {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.5rem;
	padding: 1rem 1.1rem 1.15rem;
}

.afs-design-editorial .afs-badge {
	padding: 0.15rem 0.55rem;
	border-radius: 6px;
	background: var(--afs-tint);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.afs-design-editorial .afs-card h3 {
	margin: 0;
	font-size: 1.15em;
	font-weight: 650;
	letter-spacing: -0.01em;
	line-height: 1.3;
}

.afs-design-editorial .afs-card h3 a {
	color: inherit;
	text-decoration: none;
}

.afs-design-editorial .afs-card h3 a:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.15em;
}

.afs-design-editorial .afs-excerpt {
	display: -webkit-box;
	margin: 0;
	overflow: hidden;
	color: var(--afs-muted);
	font-size: 0.92em;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
}

.afs-design-editorial .afs-meta {
	display: flex;
	gap: 0.5rem;
	margin: auto 0 0;
	padding-top: 0.25rem;
	color: var(--afs-muted);
	font-size: 0.8125em;
}

/* List layout: the same card, image on the left. */
.afs-design-editorial.afs-layout-list .afs-items {
	grid-template-columns: minmax(0, 1fr);
}

.afs-design-editorial.afs-layout-list .afs-items .afs-item.afs-card {
	flex-direction: row;
}

.afs-design-editorial.afs-layout-list .afs-img {
	flex: 0 0 min(15rem, 38%);
	align-self: stretch;
	aspect-ratio: auto;
	min-height: 9rem;
}

@media (max-width: 640px) {
	.afs-design-editorial.afs-layout-list .afs-items .afs-item.afs-card {
		flex-direction: column;
	}

	.afs-design-editorial.afs-layout-list .afs-img {
		flex-basis: auto;
		aspect-ratio: var(--afs-ratio, 16 / 10);
		min-height: 0;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.afs-design-editorial .afs-items .afs-item.afs-card {
		transition: box-shadow 0.18s ease, border-color 0.18s ease;
	}
}

/* Hover: a firmer border and a soft shadow. */
.afs-design-editorial .afs-items .afs-item.afs-card:hover {
	border-color: var(--afs-muted);
	box-shadow: 0 14px 30px -18px rgba(0, 0, 0, 0.4);
}

/* Keyboard focus: a clear ring around the whole card where the browser supports :has(), else around the link. */
.afs-design-editorial .afs-items .afs-item.afs-card:focus-within {
	border-color: var(--afs-muted);
}

@supports selector(:has(*)) {
	.afs-design-editorial .afs-card:has(a:focus-visible) {
		outline: 2px solid currentColor;
		outline-offset: 3px;
	}

	.afs-design-editorial .afs-card a:focus-visible {
		outline: none;
	}
}
