/**
 * MkSEO — Related posts.
 *
 * Colour-agnostic and low specificity: it inherits the theme's typography and
 * colours (currentColor), so it sits inside Divi without fighting it.
 *
 * Three layouts: grid, list and buttons. A grid becomes a slider when there are
 * more posts than columns; the slider is a scroll-snap track, so it scrolls with
 * a finger, a trackpad or the keyboard even if the JavaScript never loads. The
 * arrows are an enhancement, not the mechanism.
 */

.mk-seo-related {
	--mk-seo-related-gap: 1.5em;
	--mk-seo-related-cols: 3;

	box-sizing: border-box;
	margin: 2em 0;
	position: relative;
}

.mk-seo-related *,
.mk-seo-related *::before,
.mk-seo-related *::after {
	box-sizing: inherit;
}

.mk-seo-related__title {
	margin: 0 0 1em;
	padding: 0;
	font-size: 1.35em;
	line-height: 1.25;
}

.mk-seo-related__list {
	margin: 0;
	padding: 0;
	list-style: none;
	display: grid;
	gap: var(--mk-seo-related-gap);
}

.mk-seo-related__item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.mk-seo-related__card {
	height: 100%;
	display: flex;
	flex-direction: column;
	gap: 0.65em;
}

.mk-seo-related__thumb {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	line-height: 0;
}

.mk-seo-related__img {
	width: 100%;
	/*height: auto;*/
	display: block;
	transition: transform 0.3s ease;
	height: 12rem;
	object-fit: cover;
}

.mk-seo-related__thumb:hover .mk-seo-related__img {
	transform: scale(1.04);
}

.mk-seo-related__body {
	display: flex;
	flex-direction: column;
	gap: 0.35em;
}

.mk-seo-related__heading {
	margin: 0;
	padding: 0;
	font-size: 1.05em;
	line-height: 1.35;
}

.mk-seo-related__link {
	text-decoration: none;
	color: inherit;
}

.mk-seo-related__link:hover,
.mk-seo-related__link:focus-visible {
	text-decoration: underline;
}

.mk-seo-related__date {
	font-size: 0.85em;
	opacity: 0.7;
}

.mk-seo-related__excerpt {
	margin: 0;
	font-size: 0.92em;
	line-height: 1.5;
	opacity: 0.85;
}

/* ---------------------------------------------------------------- Grid ---- */

/*
 * A non-slider grid never holds more posts than columns, so auto-fit lays them
 * out on a single row and collapses them on narrow screens without any media
 * query of ours.
 */
.mk-seo-related--grid .mk-seo-related__list {
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.mk-seo-related--cols-1 .mk-seo-related__list {
	grid-template-columns: 1fr;
}

/* ---------------------------------------------------------------- List ---- */

.mk-seo-related--list .mk-seo-related__list {
	grid-template-columns: 1fr;
	gap: 1.25em;
}

.mk-seo-related--list .mk-seo-related__card {
	flex-direction: row;
	align-items: flex-start;
	gap: 1em;
}

.mk-seo-related--list .mk-seo-related__thumb {
	flex: 0 0 auto;
	width: 140px;
	max-width: 35%;
}

.mk-seo-related--list .mk-seo-related__body {
	flex: 1 1 auto;
}

/* ------------------------------------------------------------- Buttons ---- */

.mk-seo-related--buttons .mk-seo-related__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6em;
}

.mk-seo-related__button {
	display: inline-block;
	padding: 0.6em 1.15em;
	border: 1px solid currentColor;
	border-radius: 999px;
	color: inherit;
	font-size: 0.95em;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

/*
 * A tint rather than a currentColor fill: the plugin has no idea what the
 * theme's text colour is, so inverting the button would risk an unreadable
 * label. The tint reads correctly on both light and dark backgrounds.
 */
.mk-seo-related__button:hover,
.mk-seo-related__button:focus-visible {
	background-color: rgba(127, 127, 127, 0.15);
	text-decoration: none;
}

/* -------------------------------------------------------------- Slider ---- */

.mk-seo-related__viewport {
	position: relative;
	margin: 0 -2px;
	padding: 0 2px;
}

.mk-seo-related--slider .mk-seo-related__list {
	display: flex;
	grid-template-columns: none;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	-ms-overflow-style: none;
	padding-bottom: 2px;
}

.mk-seo-related--slider .mk-seo-related__list::-webkit-scrollbar {
	display: none;
}

.mk-seo-related--slider .mk-seo-related__list:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 4px;
}

.mk-seo-related--slider .mk-seo-related__item {
	flex: 0 0 calc((100% - (var(--mk-seo-related-cols) - 1) * var(--mk-seo-related-gap)) / var(--mk-seo-related-cols));
	scroll-snap-align: start;
}

.mk-seo-related__nav {
	display: flex;
	justify-content: flex-end;
	gap: 0.5em;
	margin-top: 1em;
}

/* Set by related.js when the viewport happens to fit every card anyway. */
.mk-seo-related.is-static .mk-seo-related__nav {
	display: none;
}

.mk-seo-related__arrow {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.4em;
	height: 2.4em;
	padding: 0;
	border: 1px solid currentColor;
	border-radius: 50%;
	background: none;
	color: inherit;
	font-size: 1em;
	line-height: 1;
	cursor: pointer;
	transition: opacity 0.2s ease, background-color 0.2s ease;
}

.mk-seo-related__arrow span {
	font-size: 1.6em;
	line-height: 1;
}

.mk-seo-related__arrow:hover:not( :disabled),
.mk-seo-related__arrow:focus-visible {
	background-color: rgba(0, 0, 0, 0.06);
}

.mk-seo-related__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

/* Two per view on tablets, one on phones, whatever the column setting says. */
@media (max-width: 900px) {
	.mk-seo-related--slider .mk-seo-related__item {
		flex-basis: calc((100% - var(--mk-seo-related-gap)) / 2);
	}
}

@media (max-width: 600px) {
	.mk-seo-related--slider .mk-seo-related__item {
		flex-basis: 100%;
	}

	.mk-seo-related--list .mk-seo-related__card {
		flex-direction: column;
	}

	.mk-seo-related--list .mk-seo-related__thumb {
		width: 100%;
		max-width: none;
	}
}

@media (prefers-reduced-motion: reduce) {

	.mk-seo-related__img,
	.mk-seo-related__button,
	.mk-seo-related__arrow {
		transition: none;
	}

	.mk-seo-related__thumb:hover .mk-seo-related__img {
		transform: none;
	}

	.mk-seo-related--slider .mk-seo-related__list {
		scroll-behavior: auto;
	}
}