/*
 * Blog index (/blog/): featured row, card grid, numbered pagination.
 * Loaded only on the posts index (see inc/blog-index.php).
 * Selectors are scoped to .blog-index so they override the theme's
 * ".site-content article" rules without touching single posts.
 */

/* Full-width content area (the index has no sidebar) */
body.blog-index-page .site-content.blog-index {
	float: none;
	width: 100%;
	margin-top: 24px;
}

/* Side gutter when the viewport is narrower than the 960px page wrapper */
@media (max-width: 999px) {
	body.blog-index-page .site-content.blog-index {
		box-sizing: border-box;
		padding-left: 16px;
		padding-right: 16px;
	}
}

/* On phones the theme sets the nav box to calc(100% - 400px), a negative width, so the menu button spills past the edge */
@media (max-width: 991px) {
	body.blog-index-page .headNav .main-navigation {
		width: auto;
	}
}

/* The theme's off-screen "Skip to content" link is wider than a phone and causes sideways scrolling */
body.blog-index-page .assistive-text:not(:focus) {
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Heading + intro */
.blog-index__header {
	margin: 0 0 28px;
}
.blog-index__title {
	margin: 0 0 10px;
	font-size: 30px;
	line-height: 1.25;
	font-weight: 700;
	color: #222;
	text-align: left;
}
.blog-index__intro {
	margin: 0;
	font-size: 16px;
	line-height: 1.6;
	color: #555;
}

/* Card */
.blog-index .blog-card {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	border: 1px solid #e3e6ea;
	border-radius: 6px;
	background: #fff;
	overflow: hidden;
	-webkit-hyphens: manual;
	-moz-hyphens: manual;
	hyphens: manual;
	transition: transform .2s ease, box-shadow .2s ease;
}
.blog-index .blog-card:hover,
.blog-index .blog-card:focus-within {
	transform: translateY(-3px);
	box-shadow: 0 8px 22px rgba(0, 0, 0, .12);
}

.blog-card__media {
	display: block;
	aspect-ratio: 3 / 2;
	overflow: hidden;
	background: #eef2f7;
}
.blog-card__media .blog-card__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	margin: 0;
	padding: 0;
	border: 0;
	box-shadow: none;
}

.blog-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 16px 18px 18px;
}
.blog-card__title {
	margin: 0 0 6px;
	font-size: 18px;
	line-height: 1.35;
	font-weight: 700;
}
/* Title: the original design's colours (dark with a soft grey shadow, blue on hover).
   Hover also underlines the title, as the client's hover spec asks. */
.blog-card__title a {
	color: rgb(45, 45, 45);
	text-decoration: none;
	text-shadow: 1px 1px 0 rgb(223, 223, 223), 2px 2px 0 rgb(185, 185, 185);
}
.blog-index .blog-card:hover .blog-card__title a,
.blog-card__title a:hover,
.blog-card__title a:focus {
	color: rgb(26, 103, 235);
	text-decoration: underline;
	text-shadow: 1px 1px 0 rgb(223, 223, 223), 2px 2px 0 rgb(185, 185, 185);
}
/* Keyboard users still get a visible focus ring (the theme turns off the browser default) */
.blog-card__title a:focus-visible,
.blog-card__more:focus-visible {
	outline: 2px solid rgb(26, 103, 235);
	outline-offset: 2px;
}
.blog-card__date {
	display: block;
	margin: 0 0 10px;
	font-size: 13px;
	color: #757575;
}
.blog-card__excerpt {
	margin: 0 0 14px;
	font-size: 14px;
	line-height: 1.6;
	color: #555;
}
.blog-card__more {
	margin-top: auto;
	align-self: flex-start;
	font-size: 14px;
	font-weight: 700;
	color: rgb(26, 103, 235);
	text-decoration: none;
}
.blog-card__more:hover,
.blog-card__more:focus {
	text-decoration: underline;
}

/* Featured row: stacked on mobile, lead card ~2/3 + two stacked cards on desktop */
.blog-featured {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
	margin: 0 0 36px;
}
.blog-card--lead .blog-card__title {
	font-size: 24px;
}
.blog-card--lead .blog-card__excerpt {
	font-size: 15px;
}

@media (min-width: 768px) {
	.blog-featured {
		grid-template-columns: 2fr 1fr;
		grid-template-rows: 1fr 1fr;
	}
	.blog-featured .blog-card--lead {
		grid-row: 1 / span 2;
	}
	/* Keep the two small cards compact so the right column matches the lead card's height. */
	.blog-featured .blog-card:not(.blog-card--lead) .blog-card__excerpt {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}
}

/* Fewer than 3 featured posts: no empty space where the missing cards would be */
@media (min-width: 768px) {
	/* 2 posts: two equal cards side by side (the lead keeps its larger title) */
	.blog-featured--2 {
		grid-template-columns: 1fr 1fr;
		grid-template-rows: auto;
	}
	.blog-featured--2 .blog-card--lead {
		grid-row: auto;
	}

	/* 1 post: one full-width card with the image beside the text */
	.blog-featured--1 {
		grid-template-columns: 1fr;
		grid-template-rows: auto;
	}
	.blog-featured--1 .blog-card--lead {
		grid-row: auto;
		flex-direction: row;
	}
	.blog-featured--1 .blog-card--lead .blog-card__media {
		flex: 0 0 60%;
		align-self: stretch; /* the image always fills the card height, so no blank space under it */
	}
	.blog-featured--1 .blog-card--lead .blog-card__body {
		justify-content: flex-start;
		min-height: 0;
		padding: 24px;
	}
	.blog-featured--1 .blog-card--lead .blog-card__more {
		margin-top: 12px;
	}
}

/* Latest posts grid: 1 column (< 640px), 2 columns (640-1023px), 3 columns (1024px+) */
.blog-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
	margin: 0 0 36px;
}
@media (min-width: 640px) {
	.blog-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}
@media (min-width: 1024px) {
	.blog-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

/* Numbered pagination */
.blog-index .navigation.pagination {
	clear: both;
	overflow: visible;
	margin: 0 0 24px;
}
.blog-index .navigation.pagination .nav-links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
}
.blog-index .pagination .page-numbers {
	display: inline-block;
	min-width: 40px;
	padding: 8px 12px;
	border: 1px solid #d5dae0;
	border-radius: 4px;
	background: #fff;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
	color: #333;
	text-decoration: none;
}
.blog-index .pagination a.page-numbers:hover,
.blog-index .pagination a.page-numbers:focus {
	border-color: rgb(26, 103, 235);
	color: rgb(26, 103, 235);
}
.blog-index .pagination .page-numbers.current {
	border-color: rgb(26, 103, 235);
	background: rgb(26, 103, 235);
	color: #fff;
	font-weight: 700;
}
.blog-index .pagination .page-numbers.dots {
	border-color: transparent;
	background: transparent;
}
.blog-index .pagination .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (prefers-reduced-motion: reduce) {
	.blog-index .blog-card {
		transition: none;
	}
	.blog-index .blog-card:hover,
	.blog-index .blog-card:focus-within {
		transform: none;
	}
}

/* More than 3 featured posts: the lead card on the left and the other featured posts in a
   scrollable column on the right, exactly as tall as the lead card (desktop and tablet).
   On phones there is no inner scroll; the cards simply follow each other. */
.blog-featured__label {
	display: none;
}
.blog-featured__scroll {
	display: grid;
	grid-template-columns: 1fr;
	/* Rows keep their natural height, so a fixed-height box overflows (and scrolls) instead of squeezing the cards. */
	grid-auto-rows: max-content;
	align-content: start;
	gap: 24px;
}

@media (min-width: 768px) {
	.blog-featured--scroll {
		grid-template-columns: 2fr 1fr;
		grid-template-rows: auto;
	}
	.blog-featured--scroll .blog-card--lead {
		grid-row: auto;
	}
	/* The column adds no height of its own, so the lead card decides the row height. */
	.blog-featured__more {
		position: relative;
		min-height: 0;
	}
	.blog-featured__label {
		display: block;
		margin: 0;
		padding: 0 0 8px;
		font-size: 13px;
		font-weight: 700;
		line-height: 1.3;
		color: #444;
	}
	.blog-featured__scroll {
		position: absolute;
		top: 30px;
		right: 0;
		bottom: 0;
		left: 0;
		overflow-y: scroll;
		overscroll-behavior: contain;
		padding: 6px 8px 6px 6px;
		margin: -6px 0 0 -6px;
		border: 1px solid #e3e6ea;
		border-radius: 6px;
		background: #fafbfc;
		scrollbar-width: thin;
		scrollbar-color: rgb(26, 103, 235) #e9eef5;
	}
	.blog-featured__scroll::-webkit-scrollbar {
		width: 10px;
	}
	.blog-featured__scroll::-webkit-scrollbar-track {
		background: #e9eef5;
		border-radius: 5px;
	}
	.blog-featured__scroll::-webkit-scrollbar-thumb {
		background: rgb(26, 103, 235);
		border-radius: 5px;
	}
	.blog-featured__scroll:focus-visible {
		outline: 2px solid rgb(26, 103, 235);
		outline-offset: 2px;
	}
}

/* Exactly 3 featured posts: the lead card is as tall as the two stacked cards beside it, which
   left white space under its excerpt. The lead card gets a longer excerpt that fills that space
   and fades out at the bottom. The excerpt takes no height of its own, so it never makes the row
   taller. On phones it is kept short. */
.blog-featured--3 .blog-card--lead .blog-card__excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
@media (min-width: 768px) {
	.blog-featured--3 .blog-card--lead .blog-card__body {
		min-height: 0;
	}
	.blog-featured--3 .blog-card--lead .blog-card__excerpt {
		display: block;
		-webkit-line-clamp: unset;
		flex: 1 1 0;
		min-height: 0;
		margin-bottom: 10px;
		-webkit-mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
		mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
	}
}

/* Exactly 2 featured posts: two equal cards side by side. Whichever card has the shorter text
   used to be left with blank space above Read More, so both cards get a longer excerpt that fills
   the row height and fades out at the bottom. The excerpt reserves at least 3 lines, then takes
   whatever space is left, so the row is as tall as its taller card needs. Phones keep it short. */
.blog-featured.blog-featured--2 .blog-card .blog-card__excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
@media (min-width: 768px) {
	.blog-featured.blog-featured--2 .blog-card .blog-card__body {
		min-height: 0;
	}
	.blog-featured.blog-featured--2 .blog-card .blog-card__excerpt {
		display: block;
		-webkit-line-clamp: unset;
		flex: 1 1 0;
		min-height: 4.8em;
		margin-bottom: 10px;
		-webkit-mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
		mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
	}
}

/* Exactly 1 featured post: image on the left, text on the right. The excerpt is longer and fills
   the free space beside the image (fading out at the bottom) instead of leaving the text block
   floating in white space. It reserves at least 3 lines, so the card is never shorter than its
   text needs. Phones keep a short 3-line excerpt. */
.blog-featured--1 .blog-card--lead .blog-card__excerpt {
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
@media (min-width: 768px) {
	.blog-featured--1 .blog-card--lead .blog-card__excerpt {
		display: block;
		-webkit-line-clamp: unset;
		flex: 1 1 0;
		min-height: 4.8em;
		margin-bottom: 10px;
		-webkit-mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
		mask-image: linear-gradient(#000 calc(100% - 30px), transparent);
	}
}
