/**
 * Related posts / “Related articles” — ONLY singular blog posts, main column (#primary).
 * Enqueued only when is_singular( 'post' ).
 * Disable: add_filter( 'forageplus_post_meta_enable_related_posts_css', '__return_false' );
 *
 * Targets common theme/plugin wrappers; scoped to avoid shop/archives/widgets.
 */

body.forageplus-post-meta-active.single-post #primary .related-posts,
body.forageplus-post-meta-active.single-post #primary section.related-posts,
body.forageplus-post-meta-active.single-post #primary .related-articles,
body.forageplus-post-meta-active.single-post #primary section[class*="related-articles"],
body.forageplus-post-meta-active.single-post #primary .shoptimizer-related-posts,
body.forageplus-post-meta-active.single-post #primary .post-related,
body.forageplus-post-meta-active.single-post #primary .entry-related {
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid #e8e8e8;
	box-sizing: border-box;
}

/* Section title + intro line */
body.forageplus-post-meta-active.single-post #primary .related-posts > h2,
body.forageplus-post-meta-active.single-post #primary .related-posts > h3,
body.forageplus-post-meta-active.single-post #primary .related-articles > h2,
body.forageplus-post-meta-active.single-post #primary .related-articles > h3,
body.forageplus-post-meta-active.single-post #primary section.related-posts > h2,
body.forageplus-post-meta-active.single-post #primary section[class*="related"] > h2:first-of-type {
	margin: 0 0 0.5rem;
	font-size: clamp(1.35rem, 1.1rem + 1vw, 1.6rem);
	line-height: 1.25;
	color: #1d2327;
}

body.forageplus-post-meta-active.single-post #primary .related-posts > p:first-of-type,
body.forageplus-post-meta-active.single-post #primary .related-articles > p:first-of-type,
body.forageplus-post-meta-active.single-post #primary .related-posts .related-posts__intro,
body.forageplus-post-meta-active.single-post #primary .related-posts .related-intro {
	margin: 0 0 1.35rem;
	font-size: 0.95rem;
	line-height: 1.5;
	color: #646970;
}

/* Grid: lists or flex rows of items */
body.forageplus-post-meta-active.single-post #primary .related-posts ul,
body.forageplus-post-meta-active.single-post #primary .related-posts ol,
body.forageplus-post-meta-active.single-post #primary .related-articles ul,
body.forageplus-post-meta-active.single-post #primary section.related-posts ul {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1.25rem;
	list-style: none;
	margin: 0;
	padding: 0;
	align-items: stretch;
}

body.forageplus-post-meta-active.single-post #primary .related-posts li,
body.forageplus-post-meta-active.single-post #primary .related-articles li,
body.forageplus-post-meta-active.single-post #primary section.related-posts li {
	margin: 0;
	padding: 0;
	min-width: 0;
}

/* Card: theme may output li > a > img + span, or nested divs */
body.forageplus-post-meta-active.single-post #primary .related-posts li > a,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a,
body.forageplus-post-meta-active.single-post #primary .related-posts .related-post,
body.forageplus-post-meta-active.single-post #primary .related-posts .related-post-item {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	height: 100%;
	padding: 0;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
	text-decoration: none;
	color: inherit;
	transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

body.forageplus-post-meta-active.single-post #primary .related-posts li > a:hover,
body.forageplus-post-meta-active.single-post #primary .related-posts li > a:focus,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a:hover,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a:focus,
body.forageplus-post-meta-active.single-post #primary .related-posts .related-post:hover {
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
	border-color: #cfe2f8;
	transform: translateY(-2px);
}

/* Image area */
body.forageplus-post-meta-active.single-post #primary .related-posts img,
body.forageplus-post-meta-active.single-post #primary .related-articles img,
body.forageplus-post-meta-active.single-post #primary section.related-posts img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	margin: 0;
	border-radius: 0;
	transition: transform 0.35s ease;
}

body.forageplus-post-meta-active.single-post #primary .related-posts li > a:hover img,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a:hover img {
	transform: scale(1.04);
}

body.forageplus-post-meta-active.single-post #primary .related-posts li > a,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a {
	padding-bottom: 0;
}

/* Title / text under image: tight vertical gap, centered */
body.forageplus-post-meta-active.single-post #primary .related-posts li > a > *:last-child:not(img):not(.wp-post-image),
body.forageplus-post-meta-active.single-post #primary .related-articles li > a > *:last-child:not(img),
body.forageplus-post-meta-active.single-post #primary .related-posts li > a img + *,
body.forageplus-post-meta-active.single-post #primary .related-articles li > a img + * {
	margin-top: 0;
	padding: 0.65rem 0.85rem 0.95rem;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.35;
	text-align: center;
	color: #0066cc;
	flex: 1 1 auto;
}

/* Jetpack related posts */
body.forageplus-post-meta-active.single-post #primary #jp-relatedposts.jp-relatedposts {
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid #e8e8e8;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts h3.jp-relatedposts-headline {
	font-size: clamp(1.35rem, 1.1rem + 1vw, 1.6rem);
	margin-bottom: 0.5rem;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-items-visual {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1.25rem;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-post {
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	overflow: hidden;
	background: #fff;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-post:hover {
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
	transform: translateY(-2px);
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-post .jp-relatedposts-post-a {
	padding: 0 0.85rem 0.95rem;
	text-align: center;
	font-weight: 600;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-post img {
	border-radius: 0;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	width: 100%;
	height: auto;
	transition: transform 0.35s ease;
}

body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-post:hover img {
	transform: scale(1.04);
}

/* YARPP */
body.forageplus-post-meta-active.single-post #primary .yarpp-related {
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid #e8e8e8;
}

body.forageplus-post-meta-active.single-post #primary .yarpp-related .yarpp-thumbnail {
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid #e5e7eb;
	background: #fff;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* Responsive */
@media screen and (max-width: 900px) {
	body.forageplus-post-meta-active.single-post #primary .related-posts ul,
	body.forageplus-post-meta-active.single-post #primary .related-posts ol,
	body.forageplus-post-meta-active.single-post #primary .related-articles ul,
	body.forageplus-post-meta-active.single-post #primary section.related-posts ul,
	body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-items-visual {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media screen and (max-width: 600px) {
	body.forageplus-post-meta-active.single-post #primary .related-posts ul,
	body.forageplus-post-meta-active.single-post #primary .related-posts ol,
	body.forageplus-post-meta-active.single-post #primary .related-articles ul,
	body.forageplus-post-meta-active.single-post #primary section.related-posts ul,
	body.forageplus-post-meta-active.single-post #primary #jp-relatedposts .jp-relatedposts-items-visual {
		grid-template-columns: 1fr;
		gap: 1rem;
	}
}

/* -------------------------------------------------------------------------
   Link Whisper — Related Posts (lwrp)
   Plugin inserts <br> between image and title; that creates a large visual gap.
   ------------------------------------------------------------------------- */
body.forageplus-post-meta-active.single-post #primary .link-whisper-related-posts.lwrp,
body.forageplus-post-meta-active.single-post .link-whisper-related-posts.lwrp {
	margin-top: 2.5rem;
	padding-top: 2rem;
	border-top: 1px solid #e8e8e8;
	box-sizing: border-box;
	clear: both;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-title {
	margin: 0 0 0.5rem;
	font-size: clamp(1.35rem, 1.1rem + 1vw, 1.6rem);
	line-height: 1.25;
	color: #1d2327;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-description {
	margin: 0 0 1.15rem;
	font-size: 0.95rem;
	line-height: 1.5;
	color: #646970;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-container {
	margin: 0;
	padding: 0;
}

/* Row: CSS grid (overrides plugin row/float quirks) */
body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list.lwrp-list-row-container {
	display: grid !important;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 1.25rem;
	width: 100% !important;
	max-width: 100%;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-item {
	float: none !important;
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
	min-width: 0;
	box-sizing: border-box;
}

/* Card link: flex column — no reliance on <br> */
body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link {
	display: flex !important;
	flex-direction: column;
	align-items: stretch;
	justify-content: flex-start;
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: #fff;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
	text-decoration: none !important;
	transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
	box-sizing: border-box;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link:hover,
body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link:focus {
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
	border-color: #cfe2f8;
	transform: translateY(-2px);
}

/* Remove line-break gap between image and title */
body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link br {
	display: none !important;
	height: 0;
	line-height: 0;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0 !important;
	padding: 0;
	vertical-align: bottom;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 0;
	transition: transform 0.35s ease;
	flex-shrink: 0;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link:hover img {
	transform: scale(1.03);
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link-title-text {
	display: block;
	margin: 0;
	padding: 0.65rem 0.85rem 0.95rem;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.35;
	text-align: center;
	color: #0066cc;
	flex: 1 1 auto;
}

body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list-link:hover .lwrp-list-link-title-text {
	text-decoration: underline;
}

@media screen and (max-width: 900px) {
	body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list.lwrp-list-row-container {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}

@media screen and (max-width: 600px) {
	body.forageplus-post-meta-active.single-post .link-whisper-related-posts .lwrp-list.lwrp-list-row-container {
		grid-template-columns: 1fr !important;
		gap: 1rem;
	}
}
