.tdev-carousel {
	--carousel-control-size: 48px;
	--carousel-control-gutter: calc(var(--carousel-control-size) + 1.5rem);

	/* The gap is declared once and the slide width is derived from it, so
	   changing one can no longer leave the other behind. */
	--carousel-gap: 3rem;
	--carousel-per-view: 4;

	position: relative;
}

.tdev-carousel__track {
	display: flex;
	gap: var(--carousel-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.tdev-carousel__track::-webkit-scrollbar {
	display: none;
}

.tdev-carousel__slide {
	flex: 0 0 calc(
		(100% - (var(--carousel-per-view) - 1) * var(--carousel-gap)) /
			var(--carousel-per-view)
	);
	scroll-snap-align: start;
}

@media (max-width: 999px) {
	.tdev-carousel {
		--carousel-per-view: 2;
	}
}

@media (max-width: 599px) {
	.tdev-carousel__slide {
		flex-basis: 85%;
	}
}

/* The controls sit in the carousel's own side padding, so they never cover a
   slide. Their appearance comes from the shared .tdev-arrow component; only
   the placement belongs here. */
.tdev-carousel {
	padding-left: var(--carousel-control-gutter);
	padding-right: var(--carousel-control-gutter);
}

.tdev-carousel__prev,
.tdev-carousel__next {
	--arrow-size: var(--carousel-control-size);

	position: absolute;
	top: 50%;
	transform: translateY(-50%);
}

.tdev-carousel__prev {
	left: 0;
}

.tdev-carousel__next {
	right: 0;
}

/* Below this width the two gutters cost more than they are worth: they were
   eating 186px of a 390px screen, leaving the slides a sliver. The controls
   drop under the track instead and the padding goes away, so a slide gets the
   full width. Laying the wrapper out as a wrapping flex row is enough to move
   them -- the track claims a whole line, the buttons fall onto the next one --
   which avoids hand-positioning them against the carousel's own height. */
@media (max-width: 781px) {
	.tdev-carousel {
		display: flex;
		flex-wrap: wrap;
		justify-content: center;
		gap: 1.25rem;
		padding-left: 0;
		padding-right: 0;
	}

	.tdev-carousel__track {
		flex: 0 0 100%;
	}

	.tdev-carousel__prev,
	.tdev-carousel__next {
		position: static;
		transform: none;
	}
}

.wp-block-terradev-carousel-articles.tdev-carousel {
	--carousel-gap: 1.5rem;
	--carousel-per-view: 4;
}

.wp-block-terradev-carousel-articles .tdev-carousel__track {
	align-items: flex-start;
}

@media (max-width: 1199px) {
	.wp-block-terradev-carousel-articles.tdev-carousel {
		--carousel-per-view: 3;
	}
}

@media (max-width: 781px) {
	.wp-block-terradev-carousel-articles.tdev-carousel {
		--carousel-per-view: 2;
	}
}

@media (max-width: 599px) {
	.wp-block-terradev-carousel-articles.tdev-carousel {
		--carousel-per-view: 1;
	}
}

.tdev-article-card {
	display: flex;
	flex-direction: column;
	min-height: 397px;
	background-color: #f7fafc;
}

.tdev-article-card__thumb,
.tdev-article-card--no-thumb::before {
	display: block;
	flex: 0 0 49%;
	min-height: 195px;
	background-color: #a0aec0;
}

.tdev-article-card--no-thumb::before {
	content: "";
}

/* The thumbnail is sized by the card, not by the picture: anchoring the image
   to the frame makes it fill the whole thing. Left to `height: 100%`, it
   resolved against the link's auto height and the picture stopped short, baking
   a grey band under it. */
.tdev-article-card__thumb {
	position: relative;
}

.tdev-article-card__thumb img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.tdev-article-card__date {
	margin: 12px 12px 0;
}

.tdev-article-card__title {
	font-family: var(--wp--preset--font-family--lunchbox);
	font-size: 16px;
	line-height: 1;
	text-transform: uppercase;
	margin: 12px 12px 18px;
	color: var(--wp--preset--color--terracotta);
}

.tdev-article-card__title a,
.tdev-article-card__link {
	color: inherit;
	text-decoration: none;
}

.tdev-article-card__excerpt {
	margin: 0 12px 18px;
	color: var(--wp--preset--color--noir);
	font-size: 16px;
	line-height: 1.5;
}

.tdev-article-card__link {
	align-self: flex-start;
	margin: auto 0 10px 11px;
	padding: 7px 25px 6px;
	background-color: var(--wp--preset--color--terracotta);
	color: var(--wp--preset--color--blanc);
	font-family: var(--wp--preset--font-family--lunchbox);
	font-size: 13px;
	line-height: 1;
	text-transform: uppercase;
}

.tdev-article-card__link:hover,
.tdev-article-card__link:focus {
	background-color: var(--wp--preset--color--noir);
	color: var(--wp--preset--color--blanc);
}

/* Phone adjustments last, so they win the cascade over the base rules above --
   these selectors carry the same specificity, so source order is what decides. */
@media (max-width: 599px) {
	/* The full 20-word excerpt stacked to 446px and turned the card into a
	   column of single words. Clamping keeps the teaser to a glance. */
	.tdev-article-card__excerpt {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 3;
		line-clamp: 3;
		overflow: hidden;
	}

	/* 13px of condensed uppercase is hard to read at arm's length. The label
	   grows to 16px -- matching the excerpt -- and the link is laid out around
	   it so it also clears a 44px touch target instead of a 26px sliver. */
	.tdev-article-card__link {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: 44px;
		padding: 0 28px;
		font-size: 16px;
	}
}
