/* ---------------------------------------------------------------------------
   Blog styles - shared by blog.php (index) and blog_post.php (article).

   Two things about the surrounding site shape everything below:

   1. style.css sets a global `a { font-size:15px; letter-spacing:3px }`, which
      is fine for nav but wrecks links inside running prose. Everything under
      .blog-scope resets link typography back to inherit.
   2. header.php's mobile script bolts .mobile-text-large / .mobile-link-large
      (20-22px, grey, display:block, !important) onto paragraphs and links on
      phones. Blog pages opt out via .no-mobile-restyle; the resets near the
      bottom of this file are a second line of defence if that script changes.
--------------------------------------------------------------------------- */

.blog-scope {
	--blog-ink: #23282d;
	--blog-ink-soft: #4a5560;
	--blog-muted: #646d78;   /* 5.2:1 on white - readable at the 13px byline size */
	/* The brand blue (#60b5da) only reaches 2.3:1 against white, so link text and
	   anything carrying a white label uses this darker shade of the same hue,
	   which clears 4.5:1. The bright brand blue stays for decorative accents. */
	--blog-accent: #25799d;
	--blog-accent-bright: #60b5da;
	--blog-line: #e3e7ea;
	--blog-surface: #f7f9fa;
	--blog-max: 760px;

	max-width: var(--blog-max);
	margin: 0 auto;
	padding: 24px 20px 56px;
	box-sizing: border-box;
	color: var(--blog-ink);
	font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	/* 17px on phones up to ~19px on desktop: comfortable without a media query. */
	font-size: clamp(17px, 0.95rem + 0.25vw, 19px);
	line-height: 1.75;
	-webkit-text-size-adjust: 100%;
	text-rendering: optimizeLegibility;
}

.blog-scope * {
	box-sizing: border-box;
}

/* style.css turns every h1 into a centred grid with decorative rules either
   side, and uppercases h2/h3. That is the look for product pages; an article
   headline needs to read as a headline, so the blog resets it. */
.blog-scope h1 {
	display: block;
	width: auto;
	text-align: left;
	grid-template-columns: none;
	grid-gap: 0;
	text-transform: none;
	color: inherit;
}

.blog-scope h1::before,
.blog-scope h1::after {
	content: none;
	border: 0;
}

.blog-scope h2,
.blog-scope h3,
.blog-scope h4,
.blog-scope h5,
.blog-scope h6 {
	text-transform: none;
	color: inherit;
}

/* style.css also fixes p at 16px with 1px letter-spacing, li at 16px and td at
   12px. Those sizes are set on the element, so they beat anything the blog
   inherits from .blog-scope - which left body copy small, grey and tracked out
   on exactly the pages this file is meant to make readable. Everything below
   hands sizing back to the cascade; the component rules that follow are all
   more specific, so they still win where they set a size deliberately. */
.blog-scope p,
.blog-scope li,
.blog-scope td,
.blog-scope th,
.blog-scope dd,
.blog-scope dt,
.blog-scope blockquote,
.blog-scope figcaption,
.blog-scope small {
	font-size: inherit;
	letter-spacing: normal;
	color: inherit;
}

/* Undo the site-wide letter-spaced 15px link style inside blog content. */
.blog-scope a {
	color: var(--blog-accent);
	font-size: inherit;
	letter-spacing: normal;
	text-decoration: none;
}

.blog-scope a:hover,
.blog-scope a:focus {
	color: var(--blog-accent);
	text-decoration: underline;
}

.blog-scope a:focus-visible {
	outline: 2px solid var(--blog-accent);
	outline-offset: 3px;
	border-radius: 3px;
}

.blog-scope img {
	max-width: 100%;
	height: auto;
}

/* --- Breadcrumb ---------------------------------------------------------- */

.blog-crumbs {
	margin: 0 0 18px;
	font-size: 0.8em;
	letter-spacing: 0.02em;
	color: var(--blog-muted);
}

.blog-crumbs ol {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin: 0;
	padding: 0;
}

.blog-crumbs li {
	display: flex;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.blog-crumbs li + li::before {
	content: "\203A";
	color: #b9c0c7;
}

.blog-crumbs [aria-current] {
	color: var(--blog-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 60vw;
}

/* --- Page header --------------------------------------------------------- */

.blog-masthead {
	margin: 0 0 32px;
	padding-bottom: 24px;
	border-bottom: 1px solid var(--blog-line);
}

.blog-masthead h1 {
	margin: 0 0 12px;
	font-size: clamp(1.7rem, 1.25rem + 2.2vw, 2.4rem);
	line-height: 1.2;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--blog-ink);
}

.blog-masthead .blog-standfirst {
	margin: 0;
	max-width: 60ch;
	color: var(--blog-ink-soft);
	font-size: 0.95em;
}

/* --- Index: post cards --------------------------------------------------- */

.blog-list {
	display: grid;
	gap: 28px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.blog-card {
	display: grid;
	grid-template-columns: 220px minmax(0, 1fr);
	gap: 22px;
	align-items: start;
	padding-bottom: 28px;
	border-bottom: 1px solid var(--blog-line);
}

.blog-list > li:last-child .blog-card {
	border-bottom: 0;
	padding-bottom: 0;
}

.blog-card-media {
	display: block;
	overflow: hidden;
	border-radius: 10px;
	background: var(--blog-surface);
	/* Fixed ratio box: the thumbnail never shifts the text as it loads. */
	aspect-ratio: 3 / 2;
}

.blog-card-media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}

.blog-card-media:hover img,
.blog-card-media:focus-visible img {
	transform: scale(1.04);
}

.blog-card-body {
	min-width: 0;
}

.blog-card h2 {
	margin: 0 0 8px;
	font-size: 1.15em;
	line-height: 1.35;
	font-weight: 700;
}

.blog-card h2 a {
	color: var(--blog-ink);
}

.blog-card h2 a:hover,
.blog-card h2 a:focus {
	color: var(--blog-accent);
	text-decoration: none;
}

.blog-card p {
	margin: 0 0 12px;
	font-size: 0.92em;
	line-height: 1.7;
	color: var(--blog-ink-soft);
}

.blog-scope .blog-byline {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 14px;
	margin: 0 0 10px;
	font-size: 0.78em;
	line-height: 1.5;
	color: var(--blog-muted);
	letter-spacing: 0.02em;
}

.blog-scope .blog-byline i {
	margin-right: 5px;
	color: var(--blog-accent-bright);
}

.blog-scope .blog-more {
	display: inline-block;
	font-weight: 700;
	font-size: 0.85em;
	letter-spacing: 0.04em;
}

.blog-more::after {
	content: " \2192";
}

.blog-scope .blog-empty {
	padding: 40px 0;
	color: var(--blog-muted);
	text-align: center;
}

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

.blog-pagination {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 8px;
	margin-top: 40px;
	padding-top: 24px;
	border-top: 1px solid var(--blog-line);
}

.blog-pagination a,
.blog-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--blog-line);
	border-radius: 8px;
	font-size: 0.85em;
	font-weight: 700;
	color: var(--blog-ink-soft);
}

.blog-pagination a:hover {
	border-color: var(--blog-accent-bright);
	color: var(--blog-accent);
	text-decoration: none;
}

.blog-pagination [aria-current="page"] {
	background: var(--blog-accent);
	border-color: var(--blog-accent);
	color: #fff;
}

/* --- Article ------------------------------------------------------------- */

.blog-article-head h1 {
	margin: 0 0 14px;
	font-size: clamp(1.65rem, 1.15rem + 2.4vw, 2.35rem);
	line-height: 1.22;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--blog-ink);
	/* Keeps long AI-generated headlines from overflowing narrow phones. */
	overflow-wrap: break-word;
}

.blog-scope .blog-article-head .blog-byline {
	margin-bottom: 22px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--blog-line);
}

.blog-hero {
	margin: 0 0 28px;
}

.blog-hero img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: 12px;
}

.blog-hero figcaption {
	margin-top: 8px;
	font-size: 0.78em;
	color: var(--blog-muted);
	text-align: center;
}

/* --- Prose: the admin/AI-authored HTML body ------------------------------ */

.blog-prose {
	font-size: 1em;
	line-height: 1.8;
	color: var(--blog-ink);
	overflow-wrap: break-word;
}

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

.blog-prose p {
	margin: 0 0 1.35em;
}

/* The first paragraph reads as a lead-in. */
.blog-prose > p:first-of-type {
	font-size: 1.06em;
	color: var(--blog-ink);
}

.blog-prose h2,
.blog-prose h3,
.blog-prose h4 {
	margin: 1.9em 0 0.6em;
	line-height: 1.3;
	font-weight: 700;
	color: var(--blog-ink);
	letter-spacing: -0.005em;
	scroll-margin-top: 24px;
}

.blog-prose h2 { font-size: 1.32em; }
.blog-prose h3 { font-size: 1.13em; }
.blog-prose h4 { font-size: 1em; }

.blog-prose ul,
.blog-prose ol {
	margin: 0 0 1.35em;
	padding-left: 1.35em;
}

.blog-prose li {
	margin-bottom: 0.5em;
}

.blog-prose li > ul,
.blog-prose li > ol {
	margin: 0.5em 0 0;
}

.blog-prose a {
	text-decoration: underline;
	text-underline-offset: 2px;
	text-decoration-thickness: 1px;
	font-weight: 500;
}

.blog-prose strong,
.blog-prose b {
	font-weight: 700;
	color: var(--blog-ink);
}

.blog-prose img {
	display: block;
	height: auto;
	margin: 1.6em auto;
	border-radius: 10px;
}

.blog-prose blockquote {
	margin: 1.6em 0;
	padding: 4px 0 4px 20px;
	border-left: 3px solid var(--blog-accent-bright);
	color: var(--blog-ink-soft);
	font-style: italic;
}

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

.blog-prose hr {
	margin: 2em 0;
	border: 0;
	border-top: 1px solid var(--blog-line);
}

/* Wide tables scroll on their own instead of stretching the page sideways. */
.blog-prose .blog-table-scroll {
	overflow-x: auto;
	margin: 0 0 1.35em;
	-webkit-overflow-scrolling: touch;
}

.blog-prose table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9em;
}

.blog-prose th,
.blog-prose td {
	padding: 10px 12px;
	border: 1px solid var(--blog-line);
	text-align: left;
}

.blog-prose th {
	background: var(--blog-surface);
	font-weight: 700;
	/* style.css paints every th blue with white text; in a prose table that
	   leaves the heading invisible on this pale background. */
	color: var(--blog-ink);
	text-transform: none;
	text-align: left;
	height: auto;
	border-radius: 0;
}

.blog-prose pre {
	overflow-x: auto;
	padding: 14px;
	background: var(--blog-surface);
	border-radius: 8px;
	font-size: 0.85em;
}

/* --- Call to action ------------------------------------------------------ */

.blog-cta {
	margin: 40px 0 32px;
	padding: 26px 24px;
	background: var(--blog-surface);
	border: 1px solid var(--blog-line);
	border-radius: 14px;
	text-align: center;
}

.blog-cta h2 {
	margin: 0 0 6px;
	font-size: 1.2em;
	line-height: 1.3;
	font-weight: 700;
	color: var(--blog-ink);
}

.blog-cta p {
	margin: 0 0 18px;
	font-size: 0.9em;
	color: var(--blog-ink-soft);
}

.blog-cta-buttons {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
}

.blog-scope .blog-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px; /* comfortable touch target */
	padding: 12px 26px;
	border-radius: 8px;
	font-size: 0.85em;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.blog-scope .blog-btn-primary {
	background: var(--blog-accent);
	color: #fff;
	box-shadow: 0 4px 14px rgba(37, 121, 157, 0.3);
}

.blog-scope .blog-btn-primary:hover,
.blog-scope .blog-btn-primary:focus {
	background: #1d5f7c;
	color: #fff;
	text-decoration: none;
	transform: translateY(-2px);
	box-shadow: 0 6px 18px rgba(37, 121, 157, 0.4);
}

.blog-scope .blog-btn-secondary {
	background: #fff;
	color: var(--blog-ink);
	border: 1px solid #cfd6db;
}

.blog-scope .blog-btn-secondary:hover,
.blog-scope .blog-btn-secondary:focus {
	border-color: var(--blog-accent-bright);
	color: var(--blog-accent);
	text-decoration: none;
	transform: translateY(-2px);
}

/* --- Tags ---------------------------------------------------------------- */

.blog-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 28px 0 0;
	padding-top: 22px;
	border-top: 1px solid var(--blog-line);
}

.blog-scope .blog-tags-label {
	width: 100%;
	margin: 0 0 4px;
	font-size: 0.75em;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--blog-muted);
}

.blog-scope .blog-tag {
	display: inline-block;
	padding: 6px 14px;
	border-radius: 20px;
	background: var(--blog-surface);
	border: 1px solid var(--blog-line);
	font-size: 0.75em;
	font-weight: 500;
	letter-spacing: 0.04em;
	color: var(--blog-ink-soft);
}

/* --- Related posts ------------------------------------------------------- */

.blog-related {
	margin-top: 44px;
	padding-top: 28px;
	border-top: 1px solid var(--blog-line);
}

.blog-related h2 {
	margin: 0 0 20px;
	font-size: 1.15em;
	font-weight: 700;
	color: var(--blog-ink);
}

.blog-related-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.blog-related-card {
	display: block;
	height: 100%;
}

.blog-related-card .blog-card-media {
	margin-bottom: 10px;
}

.blog-related-card h3 {
	margin: 0;
	font-size: 0.92em;
	line-height: 1.45;
	font-weight: 700;
	color: var(--blog-ink);
}

.blog-related-card:hover h3 {
	color: var(--blog-accent);
}

/* --- Back link ----------------------------------------------------------- */

.blog-scope .blog-back {
	margin-top: 36px;
	font-size: 0.85em;
	font-weight: 700;
}

/* --- Narrow screens ------------------------------------------------------ */

@media (max-width: 640px) {
	.blog-scope {
		padding: 18px 18px 44px;
	}

	.blog-card {
		grid-template-columns: 1fr;
		gap: 14px;
	}

	.blog-card-media {
		aspect-ratio: 16 / 9;
	}

	.blog-masthead {
		margin-bottom: 26px;
		padding-bottom: 20px;
	}

	.blog-hero img {
		border-radius: 10px;
	}

	.blog-cta {
		padding: 22px 18px;
	}

	.blog-cta-buttons {
		flex-direction: column;
	}

	.blog-btn {
		width: 100%;
	}

	.blog-prose .blog-table-scroll table {
		min-width: 480px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.blog-scope * {
		transition: none !important;
	}
}

/* --- Defensive resets against header.php's mobile restyle script ---------- */

.blog-scope .mobile-text-large,
.blog-scope .mobile-link-large,
.blog-scope .mobile-label-large {
	font-size: inherit !important;
	line-height: inherit !important;
	color: inherit !important;
	margin: revert !important;
	padding: revert !important;
	display: revert !important;
	font-weight: revert !important;
	text-decoration: revert !important;
}

.blog-scope .blog-prose .mobile-link-large {
	color: var(--blog-accent) !important;
	text-decoration: underline !important;
	font-weight: 500 !important;
}

/* --- Print --------------------------------------------------------------- */

@media print {
	.blog-cta,
	.blog-related,
	.blog-back,
	.blog-pagination {
		display: none;
	}

	.blog-scope {
		max-width: none;
		font-size: 12pt;
	}
}
