/*
 * RRPS Posts Grid — [rrps_posts] / [rrps_blog] / [rrps_related_posts] cards.
 *
 * News card from the Figma design: light card with an 8px inset image,
 * category chip top-right, hover overlay with a "Read More" pill, headline,
 * excerpt, date and the brand gradient bar along the bottom edge. Pure CSS.
 * --rrps-pg-cols is set inline by the shortcode's columns attribute.
 */

.rrps-posts {
	display: grid;
	grid-template-columns: repeat(var(--rrps-pg-cols, 3), minmax(0, 1fr));
	gap: 24px;
}

.rrps-posts__card {
	position: relative;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	padding: 8px 8px 20px;
	border: 1px solid var(--rrps-gray-100);
	border-radius: var(--rrps-radius-card, 16px);
	background: var(--rrps-gray-50);
	overflow: hidden;
}

/* Brand gradient bar along the bottom edge. */
.rrps-posts__card::after {
	content: "";
	position: absolute;
	right: -1px;
	bottom: -1px;
	left: -1px;
	height: 12px;
	background: var(--rrps-gradient-bar);
}

/* ---- Media ---- */

.rrps-posts__media {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 381 / 242; /* reserves space before the lazy image loads: zero CLS */
	border-radius: 12px;
	overflow: hidden;
	background: var(--rrps-gray-100);
}

.rrps-posts__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.5s ease;
}

.rrps-posts__card:hover .rrps-posts__media img,
.rrps-posts__card:focus-within .rrps-posts__media img {
	transform: scale(1.04);
}

.rrps-posts__badge {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	align-items: center;
	box-sizing: border-box;
	min-height: 32px;
	padding: 4px 20px;
	border: 1px solid rgba(14, 43, 71, 0.1);
	border-radius: 12px;
	background: rgba(14, 43, 71, 0.4);
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	z-index: 2;
}

/* Hover overlay + centred "Read More" pill. */
.rrps-posts__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.3);
	opacity: 0;
	transition: opacity 0.3s ease;
	z-index: 1;
	pointer-events: none; /* decorative: clicks go through to the card-wide title link */
}

.rrps-posts__card:hover .rrps-posts__overlay,
.rrps-posts__card:focus-within .rrps-posts__overlay {
	opacity: 1;
}

.rrps-posts__more {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	box-sizing: border-box;
	min-height: 32px;
	padding: 4px 20px;
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.2);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
	color: #fff;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.5;
	backdrop-filter: blur(25px);
	-webkit-backdrop-filter: blur(25px);
	transform: translateY(6px);
	transition: transform 0.3s ease;
}

.rrps-posts__card:hover .rrps-posts__more,
.rrps-posts__card:focus-within .rrps-posts__more {
	transform: none;
}

/* ---- Text ---- */

.rrps-posts__body {
	display: flex;
	flex-direction: column;
	gap: 32px;
	flex: 1 1 auto;
	padding: 20px 10px 25px;
}

.rrps-posts .rrps-posts__title {
	margin: 0 0 8px;
	font-family: inherit;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--rrps-blue);
}

.rrps-posts .rrps-posts__title a {
	color: inherit;
	text-decoration: none;
}

.rrps-posts__badge {
	pointer-events: none; /* decorative: clicks go through to the card-wide title link */
}

.rrps-posts__title a::after {
	/* Make the whole card the click target for the title link. */
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
}

.rrps-posts .rrps-posts__title a:hover,
.rrps-posts .rrps-posts__title a:focus-visible {
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.rrps-posts__title a:focus-visible {
	outline: none;
}

.rrps-posts__card:focus-within {
	outline: 2px solid var(--rrps-teal-light);
	outline-offset: 2px;
}

.rrps-posts__excerpt {
	margin: 0;
	font-size: 16px;
	line-height: 1.5;
	color: var(--rrps-gray-900);
}

/* Date and the "Read More" pill share the card's last row. */
.rrps-posts__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-top: auto;
}

.rrps-posts__date {
	display: block;
	font-size: 14px;
	line-height: 1.5;
	color: var(--rrps-gray-400);
}

/* Shown only where a layout opts in (the News archive below 1025px, blog.css). */
.rrps-posts__cta.rrps-btn {
	display: none;
}

/* ---- Responsive: 3 → 2 → 1 (capped by the columns attribute) ---- */

@media (max-width: 1024px) {
	.rrps-posts {
		grid-template-columns: repeat(min(var(--rrps-pg-cols, 3), 2), minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.rrps-posts {
		grid-template-columns: 1fr;
		gap: 16px;
	}
}

/* Touch devices: the hover overlay can't be reached, keep the card clean. */
@media (hover: none) {
	.rrps-posts__overlay {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rrps-posts__media img,
	.rrps-posts__overlay,
	.rrps-posts__more {
		transition: none;
	}

	.rrps-posts__card:hover .rrps-posts__media img {
		transform: none;
	}
}

/* ---- [rrps_posts slider="tablet"]: swipe row with dots ----
 * Two cards per view on tablet, one on phones; the row bleeds to the section
 * edge so cards scroll off screen instead of being clipped. */
@media (max-width: 1024px) {
	.rrps-posts--slider {
	display: flex;
	gap: 16px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
		margin-inline: -32px;
		padding-inline: 32px;
		scroll-padding-inline: 32px;
	}

	.rrps-posts--slider::-webkit-scrollbar {
		display: none;
	}

	.rrps-posts--slider .rrps-posts__card {
		flex: 0 0 calc((100% - 16px) / 2);
		scroll-snap-align: start;
	}

	.rrps-posts--slider .rrps-posts__body {
		gap: 24px;
		padding: 16px 8px 20px;
	}

	.rrps-posts--slider .rrps-posts__title {
		font-size: 18px;
	}

	.rrps-posts--slider .rrps-posts__excerpt {
		font-size: 14px;
	}
}

@media (max-width: 767px) {
	.rrps-posts--slider {
		margin-inline: -16px;
		padding-inline: 16px;
		scroll-padding-inline: 16px;
	}

	.rrps-posts--slider .rrps-posts__card {
		flex-basis: 100%;
	}
}

/* ---- Related Articles ([rrps_related_posts]) ---- */

.rrps-related {
	display: flex;
	flex-direction: column;
	gap: 40px;
}

.rrps-related__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px;
}

.rrps-related .rrps-related__title {
	margin: 0;
	font-family: inherit;
	font-size: 40px;
	font-weight: 700;
	line-height: 1.2;
	color: var(--rrps-teal-dark);
}

.rrps-related .rrps-related__title em {
	font-style: normal;
	color: var(--rrps-navy);
}

/* Tablet and mobile (Figma News Single): heading and "View All News" stay on one row. */
@media (max-width: 1024px) {
	.rrps-related {
		gap: 32px;
	}

	.rrps-related__head {
		align-items: center;
		gap: 16px;
	}

	.rrps-related .rrps-related__title {
		font-size: 26px;
	}

	.rrps-related__head .rrps-btn.rrps-btn {
		flex: 0 0 auto;
		min-height: 42px;
		padding: 8px 16px;
		font-size: 14px;
	}
}

@media (max-width: 767px) {
	.rrps-related {
		gap: 24px;
	}
}
