/**
 * Blog archive and single post.
 *
 * Loaded only on the blog index, archives, search results and single posts.
 * Everything shared with the rest of the site — cards, the lead card, the
 * category rail, prose styling — lives in components.css; this file adds the
 * two-column shell, the sidebar and the article furniture.
 */

/* --------------------------------------------------------------------------
   Two-column shell
   -------------------------------------------------------------------------- */
.blog-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 300px;
	gap: 40px;
	align-items: start;
}

.blog-main {
	min-width: 0;
}

.blog-side {
	display: grid;
	gap: 20px;
	min-width: 0;
}

/*
 * The article sidebar rides along with the read. `align-self` matters: a grid
 * item stretches to the row height by default, and a sticky box inside a
 * full-height item has nothing left to stick against.
 */
.blog-side-sticky {
	position: sticky;
	top: 96px;
	align-self: start;
}

.blog-side .msm-ad {
	margin: 0;
}

/* --------------------------------------------------------------------------
   Sidebar cards
   -------------------------------------------------------------------------- */
.side-card {
	padding: 20px 22px;
	background: var(--card-solid);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
}

.side-card h2 {
	margin-bottom: 12px;
	font-size: 0.74rem;
	font-weight: 700;
	letter-spacing: 0.13em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.side-card-list {
	display: flex;
	flex-direction: column;
	margin: 0;
	padding: 0;
	list-style: none;
}

.side-card-list li + li {
	border-top: 1px solid var(--card-border);
}

.side-card-list a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 0;
	font-size: 0.92rem;
	font-weight: 500;
	color: var(--text-secondary);
	transition: color 0.2s;
}

.side-card-list a:hover {
	color: var(--msm-brand);
}

.side-card-list a > span {
	flex: 1;
	min-width: 0;
}

.side-card-list .msm-icon {
	width: 0.75em;
	height: 0.75em;
	opacity: 0;
	transform: translateX(-4px);
	transition: opacity 0.2s, transform 0.2s;
}

.side-card-list a:hover .msm-icon {
	opacity: 1;
	transform: translateX(0);
}

.side-card-topics a b {
	flex-shrink: 0;
	font-size: 0.78rem;
	font-weight: 700;
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Single post header
   -------------------------------------------------------------------------- */
.section-post {
	padding-top: 36px;
}

.section-post .msm-breadcrumbs {
	margin-bottom: 18px;
}

.post-kicker {
	margin-bottom: 12px;
	font-size: 0.78rem;
	font-weight: 600;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--msm-brand);
}

.post-kicker a {
	color: inherit;
}

.post-kicker a:hover {
	text-decoration: underline;
}

.post-title {
	max-width: 22ch;
	font-size: clamp(1.9rem, 4vw, 2.7rem);
	font-weight: 800;
	line-height: 1.14;
	letter-spacing: -0.03em;
}

.post-byline {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 18px;
	font-size: 0.88rem;
	color: var(--text-muted);
}

.post-avatar {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	flex-shrink: 0;
	border-radius: 50%;
	background: var(--msm-brand-soft);
	color: var(--msm-brand);
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.02em;
}

.post-byline-text b {
	font-weight: 600;
	color: var(--text-primary);
}

.post-hero {
	margin: 28px 0 32px;
	overflow: hidden;
	border-radius: var(--radius-md);
	background: var(--bg-surface-alt);
}

.post-hero img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
	object-fit: cover;
}

.post-hero figcaption {
	padding: 10px 4px 0;
	font-size: 0.82rem;
	color: var(--text-muted);
}

/*
 * Inside the two-column shell the prose column is already the right width, so
 * the centring the standalone article layout applies would only push the text
 * away from the sidebar it is paired with.
 */
.blog-main .entry-content {
	max-width: none;
	margin: 0;
}

/* Anchored headings must clear the fixed header when the TOC jumps to them. */
.entry-content h2[id],
.entry-content h3[id] {
	scroll-margin-top: 96px;
}

/* --------------------------------------------------------------------------
   Table of contents
   -------------------------------------------------------------------------- */
.post-toc {
	margin: 26px 0;
	padding: 18px 22px;
	background: var(--bg-surface-alt);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
}

.post-toc-title {
	margin-bottom: 10px;
	font-family: var(--msm-font-display);
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--text-primary);
}

.post-toc ol {
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: msm-toc;
}

.post-toc li {
	list-style: none;
}

.post-toc-h2 {
	counter-increment: msm-toc;
}

.post-toc-h3 {
	padding-left: 18px;
}

.post-toc a {
	display: block;
	padding: 4px 0;
	font-size: 0.92rem;
	color: var(--text-secondary);
	text-decoration: none;
	transition: color 0.2s;
}

.post-toc a:hover {
	color: var(--msm-brand);
}

.post-toc-h2 > a::before {
	content: counter(msm-toc) ". ";
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Callout (rendered by the MSM Tools plugin, and available in the editor)
   -------------------------------------------------------------------------- */
.msm-callout {
	margin: 30px 0;
	padding: 18px 22px;
	background: var(--msm-brand-soft);
	border-left: 3px solid var(--msm-brand);
	border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.msm-callout p {
	margin: 0;
	color: var(--text-secondary);
}

.msm-callout-title {
	font-family: var(--msm-font-display);
	font-weight: 700;
	color: var(--text-primary) !important;
}

.msm-callout-links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px !important;
}

.msm-callout-links a {
	padding: 6px 14px;
	border-radius: 40px;
	background: var(--card-solid);
	border: 1px solid var(--card-border);
	font-size: 0.86rem;
	font-weight: 600;
	color: var(--msm-brand);
	text-decoration: none;
	transition: border-color 0.2s, transform 0.2s;
}

.msm-callout-links a:hover {
	border-color: var(--msm-brand);
	transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Keep reading
   -------------------------------------------------------------------------- */
.post-related {
	margin-top: 44px;
	padding-top: 32px;
	border-top: 1px solid var(--card-border);
}

.post-related > h2 {
	margin-bottom: 20px;
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.post-related-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 18px;
}

.post-related-grid .post-card h2 {
	font-size: 0.98rem;
}

.post-related-grid .post-excerpt {
	font-size: 0.84rem;
}

.post-related-grid .post-card .post-body {
	padding: 16px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
	.blog-layout {
		gap: 28px;
		grid-template-columns: minmax(0, 1fr) 280px;
	}
}

@media (max-width: 991px) {
	/*
	 * The sidebar drops below the article. It is the secondary column on a
	 * wide screen and stays secondary on a narrow one, so it follows the
	 * content rather than pushing it down the page.
	 */
	.blog-layout {
		grid-template-columns: 1fr;
		gap: 36px;
	}

	.blog-side-sticky {
		position: static;
	}

	.blog-side {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.post-title {
		max-width: none;
	}

	.post-related-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 680px) {
	.blog-side {
		grid-template-columns: 1fr;
	}

	.post-hero {
		margin: 22px 0 26px;
	}

	.post-related-grid {
		grid-template-columns: 1fr;
	}

	.post-toc,
	.msm-callout {
		padding: 16px 18px;
	}
}
