/*
 * TP WP Tools → Related topics: square cards in a row that scrolls sideways.
 * Themes can restyle through the custom properties below.
 */
.tpwt-related {
	--tpwt-related-gap: 16px;
	--tpwt-related-radius: 10px;
	--tpwt-related-bg: #1d2327;       /* Card without an image. */
	--tpwt-related-fg: #fff;          /* Text on the cards. */
	--tpwt-related-chip-bg: #fff;     /* Kind label. */
	--tpwt-related-chip-fg: #1d2327;
	--tpwt-related-cols: var(--tpwt-related-visible, 3);
	margin-block: 3rem 1rem;
	clear: both;
}
@media (max-width: 600px) {
	.tpwt-related { --tpwt-related-cols: min(var(--tpwt-related-visible, 3), 2); }
}
@media (max-width: 380px) {
	.tpwt-related { --tpwt-related-cols: 1; }
}
.tpwt-related__heading { margin: 0 0 1rem; }

.tpwt-related__viewport {
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: thin;
	padding-bottom: 6px;
}
.tpwt-related__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	column-gap: var(--tpwt-related-gap);
}
.tpwt-related__item {
	flex: 0 0 calc((100% - (var(--tpwt-related-cols) - 1) * var(--tpwt-related-gap)) / var(--tpwt-related-cols));
	scroll-snap-align: start;
	margin: 0;
	padding: 0;
}
.tpwt-related__card {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: var(--tpwt-related-radius);
	background: var(--tpwt-related-bg);
	color: var(--tpwt-related-fg);
	text-decoration: none;
	isolation: isolate;
}
.tpwt-related__image {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: -2;
	transition: transform 200ms ease-out;
}
/* Shade under the title so it stays readable on any photo. */
.tpwt-related__card::after {
	content: "";
	position: absolute;
	inset: 40% 0 0;
	z-index: -1;
	background: linear-gradient(to top, rgba(0, 0, 0, .72), rgba(0, 0, 0, 0));
}
.tpwt-related__kind {
	position: absolute;
	top: 12px;
	left: 12px;
	padding: 3px 8px;
	border-radius: 4px;
	background: var(--tpwt-related-chip-bg);
	color: var(--tpwt-related-chip-fg);
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: .02em;
}
.tpwt-related__title {
	padding: 16px;
	font-weight: 700;
	font-size: clamp(1rem, 1.6vw, 1.25rem);
	line-height: 1.2;
	overflow-wrap: anywhere;
}
@media (hover: hover) {
	.tpwt-related__card:hover .tpwt-related__image { transform: scale(1.04); }
}
.tpwt-related__card:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

.tpwt-related__nav { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.tpwt-related__nav[hidden] { display: none; }
.tpwt-related__nav button {
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}
.tpwt-related__nav button:disabled { opacity: .35; cursor: default; }
@media (prefers-reduced-motion: reduce) {
	.tpwt-related__viewport { scroll-behavior: auto; }
	.tpwt-related__image { transition: none; }
}
