/* ============================================================
   Blog - listing, cards, pagination and single post.
   Design refs: designs/Support & Advice (Blog).png
                designs/Blog Post.png

   The blog is NOT an ACF flexible page: WordPress routes it via
   home.php / archive.php / single.php, so it gets real pagination
   and category archives. These styles keep it looking like the
   rest of the site anyway.
   ============================================================ */

/* ---- Intro band (shared by the index and the archives) ---- */

.blog-intro {
	background: var(--color-cream-light);
	padding-block: var(--section-padding);
	text-align: center;
}

.blog-intro__heading {
	margin-bottom: var(--space-sm);
}

/* 940px, not the 800px reading column: the design's intro paragraph wraps at
   925px on its first line, so a 50rem clamp would add a line. */
.blog-intro__text {
	max-width: 58.75rem;
	margin-inline: auto;
	color: var(--color-text);
	line-height: 1.55;
}

.blog-intro__text p:last-child {
	margin-bottom: 0;
}

/* ---- Listing ---- */

.blog-list {
	background: var(--color-light-grey);
	padding-block: var(--section-padding);
}

/* Card column measures 1164px centred, ~18px narrower each side than the
   theme's usual 1200px content column. Gap between cards is 57px. */
.blog-list__items {
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
	max-width: 72.75rem;
	margin-inline: auto;
}

.blog-list__empty {
	max-width: 40rem;
	margin-inline: auto;
	padding-block: var(--space-lg);
	text-align: center;
	color: var(--color-text);
}

.blog-list__empty .btn {
	margin-top: var(--space-sm);
}

/* ============================================================
   Search + category filters
   Every state is a real URL (category archives, ?s= searches), so it is
   shareable, crawlable and works with JavaScript off.
   ============================================================ */

.blog-filters {
	max-width: 72.75rem;
	margin: 0 auto var(--space-lg);
}

/* ---- Search ---- */

.blog-search {
	margin-bottom: var(--space-md);
}

.blog-search__field {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	gap: 0.625rem;
}

.blog-search__icon {
	position: absolute;
	top: 50%;
	left: 1rem;
	width: 20px;
	height: 20px;
	transform: translateY(-50%);
	color: var(--color-text-muted);
	pointer-events: none;
}

.blog-search__field:focus-within .blog-search__icon {
	color: var(--color-teal);
}

.blog-search__icon svg {
	display: block;
	width: 100%;
	height: 100%;
}

.blog-search__input {
	flex: 1 1 14rem;
	min-width: 0;
	height: 3.25rem;
	padding: 0 1rem 0 3rem;
	font-family: var(--font-body);
	font-size: 1rem;
	color: var(--color-text);
	background: var(--color-cream-light);
	border: 1px solid var(--color-input-border);
	border-radius: var(--radius-xs);
}

.blog-search__input::placeholder {
	color: var(--color-placeholder);
}

.blog-search__input:focus-visible {
	outline: 2px solid var(--color-caramel);
	outline-offset: 2px;
	border-color: var(--color-teal);
}

/* Cancel the search input's own clear button so it does not fight the icon */
.blog-search__input::-webkit-search-cancel-button {
	margin-right: 0.25rem;
}

.blog-search__submit {
	flex: 0 0 auto;
	height: 3.25rem;
	padding-inline: 1.75rem;
}

/* ---- Category chips ---- */

.blog-filters__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.blog-chip {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	min-height: 2.25rem;
	padding: 0.375rem 0.9375rem;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.2;
	color: var(--color-teal-dark);
	text-decoration: none;
	background: transparent;
	border: 1px solid var(--color-input-border);
	border-radius: 999px;
	transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.blog-chip:hover {
	color: var(--color-teal);
	border-color: var(--color-teal);
}

.blog-chip.is-active {
	color: var(--color-text-on-dark);
	background: var(--color-teal-dark);
	border-color: var(--color-teal-dark);
}

.blog-chip.is-active:hover {
	color: var(--color-text-on-dark);
}

.blog-chip:focus-visible {
	outline: 2px solid var(--color-caramel);
	outline-offset: 2px;
}

.blog-chip__count {
	font-size: 0.75rem;
	opacity: 0.65;
}

@media (min-width: 768px) {
	.blog-search__input {
		flex: 0 1 26rem;
	}
}

/* ---- Listing card: image left, content right ----
   30px of padding measured off the design, so the photo sits inset from the
   card edge rather than bleeding to it. */

/* The resting shadow is measured, not a hover effect - all six cards in the
   design carry it, symmetric with no offset. */
.blog-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
	padding: 1.25rem;
	background: var(--color-cream-light);
	border-radius: var(--radius-sm);
	box-shadow: 0 0 9px rgb(20 51 59 / 0.15);
	transition: box-shadow 0.3s ease;
}

/* Caramel bar along the bottom edge on hover, matching the design's first
   card and the article-cards pattern used elsewhere. */
.blog-card::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 3px;
	background: var(--color-accent);
	border-radius: 0 0 var(--radius-xs) var(--radius-xs);
	transform: scaleX(0);
	transform-origin: left center;
	transition: transform 0.4s ease;
}

.blog-card:hover,
.blog-card:focus-within {
	box-shadow: 0 6px 20px rgb(20 51 59 / 0.18);
}

.blog-card:hover::after,
.blog-card:focus-within::after {
	transform: scaleX(1);
}

.blog-card__media {
	flex-shrink: 0;
}

.blog-card__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: var(--radius-xs);
}

.blog-card__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.blog-card__title {
	margin: 0 0 0.625rem;
	font-size: 1.25rem;
	line-height: 1.3;
}

/* Stretched link - the whole card is one target, and the tag/date stay
   selectable text rather than becoming part of a giant anchor. */
.blog-card__link {
	color: var(--color-heading);
	text-decoration: none;
}

.blog-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: var(--radius-xs);
}

.blog-card__link:hover {
	color: var(--color-heading);
}

.blog-card__link:focus-visible {
	outline: none;
}

.blog-card__link:focus-visible::after {
	outline: 2px solid var(--color-caramel);
	outline-offset: -2px;
}

.blog-card__excerpt {
	margin: 0 0 0.875rem;
	font-size: 1rem;
	line-height: 1.5;
	color: var(--color-text);
}

/* measured #41484A - the design does NOT mute the date */
.blog-card__date {
	margin: 0 0 1.125rem;
	font-size: 0.875rem;
	color: var(--color-text);
}

/* Category chip: --color-accent #DF9D63 (the lighter caramel), NOT --color-cta,
   and square corners - both measured off the design. */
.blog-card__tag {
	margin: 0 0 1.25rem;
	padding: 0.4375rem 0.3125rem;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: var(--tracking-eyebrow);
	text-transform: uppercase;
	color: var(--color-cream-light);
	background: var(--color-accent);
	border-radius: 0;
}

.blog-card__more {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-weight: 600;
	font-size: 0.9375rem;
	color: var(--color-heading);
}

.blog-card__arrow {
	display: inline-flex;
	width: 17px;
	height: 12px;
	transition: transform 0.3s ease, color var(--transition);
}

.blog-card__arrow svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* Warms to caramel AND nudges, matching the article-cards pattern used for
   every other "Read More" on the site. */
.blog-card:hover .blog-card__more,
.blog-card:focus-within .blog-card__more {
	color: var(--color-caramel-dark);
}

.blog-card:hover .blog-card__arrow,
.blog-card:focus-within .blog-card__arrow {
	color: var(--color-caramel-light);
	transform: translateX(3px);
}

.blog-card__more {
	transition: color var(--transition);
}

/* ---- Pagination ---- */

.blog-list .pagination {
	margin-top: var(--space-xl);
}

.blog-list .nav-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.375rem;
}

.blog-list .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.25rem;
	height: 2.25rem;
	padding-inline: 0.5rem;
	font-size: 0.9375rem;
	color: var(--color-teal-dark);
	text-decoration: none;
	border-radius: var(--radius-xs);
	transition: background-color var(--transition), color var(--transition);
}

.blog-list a.page-numbers:hover {
	background: var(--color-cream-light);
	color: var(--color-caramel-dark);
}

.blog-list .page-numbers.current {
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 4px;
}

.blog-list .page-numbers.dots {
	min-width: 1.25rem;
}

/* prev / next chevrons, drawn from the shared arrow mask */
.blog-list .page-numbers.prev,
.blog-list .page-numbers.next {
	position: relative;
}

.blog-list .page-numbers.prev::before,
.blog-list .page-numbers.next::before {
	content: "";
	width: 12px;
	height: 9px;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 12' fill='none'%3E%3Cpath d='M1 6h14.4M11.2 1.4L15.8 6l-4.6 4.6' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 17 12' fill='none'%3E%3Cpath d='M1 6h14.4M11.2 1.4L15.8 6l-4.6 4.6' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
}

.blog-list .page-numbers.prev::before {
	transform: rotate(180deg);
}

/* ============================================================
   Single post
   ============================================================ */

.blog-post__hero {
	background: var(--color-cream-light);
	padding-block: var(--section-padding);
}

.blog-post__intro {
	margin-bottom: var(--space-lg);
}

/* Caramel chip, same shape as the listing card's */
/* Same chip as the listing card: --color-accent, square corners, 12px Onest
   700 uppercase with the eyebrow tracking. All measured. */
.blog-post__tag {
	display: inline-block;
	margin: 0 0 1.5rem;
	padding: 0.4375rem 0.3125rem;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: var(--tracking-eyebrow);
	text-transform: uppercase;
	background: var(--color-accent);
	border-radius: 0;
}

.blog-post__tag a {
	color: var(--color-cream-light);
	text-decoration: none;
}

.blog-post__tag a:hover {
	color: var(--color-cream-light);
	text-decoration: underline;
}

/* 32px / line-height 1.25, measured */
.blog-post__title {
	margin-bottom: 1rem;
	line-height: 1.25;
}

/* Onest 600 at body size, in --color-text (not a heading colour) */
.blog-post__standfirst {
	margin-bottom: 1.875rem;
	font-weight: 600;
	line-height: 1.55;
	color: var(--color-text);
}

.blog-post__date {
	margin: 0;
	font-size: 0.875rem;
	color: var(--color-text);
}

/* 597 x 438 measured = 1.363, close to 15/11 */
.blog-post__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 15 / 11;
	object-fit: cover;
	border-radius: var(--radius-xs);
}

/* ---- Body ----
   Same 800px reading column as the policy pages (.legal__prose), because both
   designs measure the same and long-form reading should not drift between
   them. Styles generic tags, since this is client-authored editor content. */

.blog-post__body {
	background: var(--color-light-grey);
	padding-block: var(--section-padding);
}

.blog-post__prose {
	max-width: 50rem;
	margin-inline: auto;
	color: var(--color-text);
}

.blog-post__prose > :first-child {
	margin-top: 0;
}

/* ---- "In short" callout ----
   The posts carry a key takeaway in their frontmatter; the author's upload
   notes ask for it as a callout near the top. Cream card on the grey band,
   matching the Urgent Help card elsewhere on the site. */

.blog-post__takeaway {
	margin: 0 0 var(--space-lg);
	padding: var(--space-md);
	background: var(--color-cream);
	border-left: 3px solid var(--color-accent);
	border-radius: var(--radius-sm);
}

.blog-post__takeaway-label {
	margin: 0 0 0.5rem;
	font-size: var(--text-eyebrow);
	font-weight: 700;
	letter-spacing: var(--tracking-eyebrow);
	text-transform: uppercase;
	color: var(--color-caramel-dark);
}

.blog-post__takeaway p:last-child {
	margin-bottom: 0;
}

/* ---- Crisis strip ----
   Each post closes with the 999 / Samaritans line. Set apart so it reads as
   safety information rather than another paragraph. */

.blog-post__crisis {
	padding: var(--space-sm) var(--space-md);
	background: var(--color-cream);
	border-radius: var(--radius-sm);
	font-size: 1rem;
}

/* ---- Contents jump list ----
   The first list in a post is its table of contents. */

.blog-post__prose h2#contents {
	font-size: 1.125rem;
	letter-spacing: var(--tracking-eyebrow);
	text-transform: uppercase;
}

.blog-post__prose h2#contents + ul {
	margin-bottom: var(--space-lg);
	padding-left: 1.125rem;
}

.blog-post__prose h2#contents + ul li {
	margin-bottom: 0.25rem;
}

/* Jump targets must clear the fixed header */
.blog-post__prose h2,
.blog-post__prose h3 {
	scroll-margin-top: calc(var(--header-height) + 1rem);
}

.blog-post__prose > :last-child {
	margin-bottom: 0;
}

.blog-post__prose h2,
.blog-post__prose h3 {
	margin-top: var(--space-lg);
	margin-bottom: var(--space-sm);
	color: var(--color-heading);
}

.blog-post__prose h2 {
	font-size: 1.5rem;
}

.blog-post__prose h3 {
	font-size: 1.25rem;
}

.blog-post__prose p {
	margin-bottom: 1.75rem;
	line-height: 1.55;
}

.blog-post__prose strong {
	color: var(--color-heading);
}

.blog-post__prose a {
	color: var(--color-teal);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.blog-post__prose a:hover {
	color: var(--color-caramel);
}

.blog-post__prose ul,
.blog-post__prose ol {
	margin: 0 0 1.75rem;
	padding-left: 1.25rem;
}

.blog-post__prose li {
	margin-bottom: 0.375rem;
	line-height: 1.55;
}

/* Inline images run the full width of the reading column */
.blog-post__prose img,
.blog-post__prose .wp-block-image img {
	width: 100%;
	height: auto;
	border-radius: var(--radius-xs);
}

.blog-post__prose figure {
	margin: var(--space-lg) 0;
}

.blog-post__prose figcaption {
	margin-top: var(--space-xs);
	font-size: 0.875rem;
	color: var(--color-text-muted);
}

/* ---- Tablet (768-1023): the mandatory deliberate middle treatment ---- */

@media (min-width: 768px) {
	.blog-list__items {
		gap: 2.5rem;
	}

	/* 30px padding measured; the square image is vertically centred in the card */
	.blog-card {
		flex-direction: row;
		align-items: center;
		gap: var(--space-lg);
		padding: 1.875rem;
	}

	.blog-card__media {
		flex: 0 0 42%;
	}

	.blog-post__hero-inner {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		gap: var(--space-lg);
		align-items: center;
	}

	/* No featured image yet - one column, so the hero does not leave a void
	   where the picture will go. Remove nothing when images arrive; the
	   modifier simply stops being applied. */
	.blog-post__hero-inner--no-image {
		grid-template-columns: minmax(0, 1fr);
		max-width: 50rem;
	}

	.blog-post__intro {
		margin-bottom: 0;
	}
}

@media (min-width: 1024px) {
	.blog-list__items {
		gap: 3.5625rem; /* 57px measured */
	}

	/* 400px square image, 60px gutter, 30px card padding - all measured */
	.blog-card {
		gap: 3.75rem;
	}

	.blog-card__media {
		flex: 0 0 400px;
	}

	/* The content column measures 587-599px in the design. Without this cap the
	   excerpts break at different words than the mockup. */
	.blog-card__body {
		max-width: 37rem;
	}

	.blog-card__title {
		font-size: 1.25rem;
	}

	/* Measured: text column 565px, image 597px, 25px between them. Equal
	   columns would shrink the image ~30px below the design. */
	.blog-post__hero-inner {
		grid-template-columns: minmax(0, 565fr) minmax(0, 597fr);
		gap: 1.5625rem;
	}

	.blog-post__hero-inner--no-image {
		grid-template-columns: minmax(0, 1fr);
	}

	.blog-post__prose h2 {
		font-size: 1.75rem;
	}

	.blog-post__prose h2:not(:first-child) {
		margin-top: 2.75rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.blog-card,
	.blog-card::after,
	.blog-card__arrow,
	.blog-list .page-numbers {
		transition: none;
	}
}
