/**
 * 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;
}

/* transform has no logical equivalent, so the nudge is mirrored by hand. */
[dir="rtl"] .side-card-list .msm-icon {
	transform: translateX(4px);
}

.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;
}

/* --------------------------------------------------------------------------
   Table of contents
   -------------------------------------------------------------------------- */

/*
 * Two copies are printed: one in the sticky sidebar for wide screens, one
 * inside the article for narrow ones, where the sidebar has dropped below the
 * content. Exactly one is ever displayed.
 */
.post-toc-inline {
	display: none;
}

.post-toc {
	overflow: hidden;
	background: var(--bg-surface-alt);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
}

.post-toc-rail {
	background: var(--card-solid);
}

.post-toc-head {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 14px 20px;
	background: none;
	border: 0;
	cursor: pointer;
	font-family: var(--msm-font-display);
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--text-primary);
	text-align: start;
	transition: color 0.2s;
}

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

.post-toc-head:focus-visible {
	outline: 2px solid var(--msm-brand);
	outline-offset: -2px;
}

.post-toc-icon {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--msm-brand);
}

.post-toc-label {
	flex: 1;
	min-width: 0;
}

.post-toc-count {
	font-family: var(--msm-font-body);
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--text-muted);
}

.post-toc-caret {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	color: var(--text-muted);
	transition: transform 0.25s ease;
}

.post-toc[data-open="false"] .post-toc-caret {
	transform: rotate(-90deg);
}

.post-toc[data-open="false"] .post-toc-body {
	display: none;
}

.post-toc-body {
	padding: 0 20px 16px;
}

.post-toc-rail .post-toc-body {
	max-height: 58vh;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.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;
	counter-reset: msm-toc-sub;
}

.post-toc-h3 {
	counter-increment: msm-toc-sub;
	counter-reset: msm-toc-sub2;
	padding-inline-start: 20px;
}

.post-toc-h4 {
	counter-increment: msm-toc-sub2;
	padding-inline-start: 40px;
}

.post-toc a {
	display: block;
	padding: 5px 0;
	padding-inline-start: 10px;
	border-inline-start: 2px solid transparent;
	font-size: 0.92rem;
	color: var(--text-secondary);
	text-decoration: none;
	transition: color 0.2s, border-color 0.2s, background 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;
}

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

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

.post-toc a.is-active {
	background: var(--msm-brand-soft);
	border-inline-start-color: var(--msm-brand);
	border-radius: 0 6px 6px 0;
	color: var(--msm-brand);
	font-weight: 600;
}

/* An anchored heading must clear the fixed header when the list jumps to it,
   and must not draw a focus ring simply for having been jumped to. */
.entry-content h2[id],
.entry-content h3[id],
.entry-content h4[id] {
	scroll-margin-top: 96px;
}

.entry-content h2[id]:focus,
.entry-content h3[id]:focus,
.entry-content h4[id]:focus {
	outline: none;
}

/* --------------------------------------------------------------------------
   Tool guide bar (rendered by the MSM Tools plugin above a guide's content)

   Quieter than the callout below the article: this one sits between the
   byline and the first sentence, so it has to be skippable. A bordered row
   rather than a filled panel, and the only saturated thing in it is the
   button.
   -------------------------------------------------------------------------- */
.msm-guide-tool {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	margin: 0 0 30px;
	padding: 12px 16px;
	background: var(--card-solid);
	border: 1px solid var(--card-border);
	border-radius: 12px;
}

.msm-guide-tool .msm-icon {
	width: 17px;
	height: 17px;
	flex: 0 0 auto;
	color: var(--msm-brand);
}

.msm-guide-tool p {
	margin: 0;
	font-size: 0.9rem;
	color: var(--text-secondary);
}

.msm-guide-tool-go {
	margin-inline-start: auto;
	padding: 7px 15px;
	border-radius: 40px;
	background: var(--msm-brand);
	color: var(--msm-on-brand);
	font-weight: 600;
	font-size: 0.85rem;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.2s;
}

.msm-guide-tool-go:hover,
.msm-guide-tool-go:focus-visible {
	background: var(--msm-brand-hover);
	color: var(--msm-on-brand);
}

/* --------------------------------------------------------------------------
   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-inline-start: 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;
	}

	.post-toc-inline {
		display: block;
		margin: 26px 0;
	}

	.post-toc-rail {
		display: none;
	}

	.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;
	}

	/*
	 * The button loses its auto margin and the row becomes two lines. Left
	 * to itself the flex row keeps the button on the same line as the
	 * sentence and squeezes the sentence to two words a line.
	 */
	.msm-guide-tool-go {
		margin-inline-start: 0;
	}
}

/* --------------------------------------------------------------------------
   Comments
   -------------------------------------------------------------------------- */
.msm-comments {
	margin-top: 44px;
	padding-top: 32px;
	border-top: 1px solid var(--card-border);
}

.msm-comments-title {
	margin-bottom: 24px;
	font-size: 1.25rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.msm-comments-title span {
	color: var(--text-muted);
	font-weight: 500;
}

.comment-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.comment-list li {
	list-style: none;
}

.comment-list > li + li {
	margin-top: 8px;
}

.comment-list ol.children {
	margin: 0;
	padding-inline-start: 26px;
	list-style: none;
	border-inline-start: 2px solid var(--card-border);
}

.comment-list ol.children > li {
	padding-inline-start: 18px;
}

.comment-body {
	margin-bottom: 8px;
	padding: 18px 20px;
	background: var(--card-solid);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
}

/* A reply from the person who wrote the article carries more weight than the
   rest of the thread, so it is tinted rather than just badged. */
.comment-body.bypostauthor {
	background: var(--msm-brand-soft);
	border-color: rgba(var(--msm-brand-rgb), 0.35);
}

.comment-head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 10px;
}

.comment-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.8rem;
	font-weight: 700;
}

.comment-avatar img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: 50%;
}

.comment-meta {
	min-width: 0;
}

.comment-author {
	display: flex;
	align-items: center;
	gap: 8px;
	font-family: var(--msm-font-display);
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.3;
}

.comment-author a {
	color: inherit;
}

.comment-author a:hover {
	color: var(--msm-brand);
}

.comment-badge {
	padding: 2px 8px;
	border-radius: 40px;
	background: var(--msm-brand);
	color: var(--msm-on-brand);
	font-family: var(--msm-font-body);
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.comment-date {
	font-size: 0.8rem;
	color: var(--text-muted);
}

.comment-date a {
	color: inherit;
}

.comment-date a:hover {
	text-decoration: underline;
}

.comment-content {
	color: var(--text-secondary);
	overflow-wrap: break-word;
}

.comment-content p {
	margin-bottom: 12px;
}

.comment-content p:last-child {
	margin-bottom: 0;
}

.comment-content img {
	max-width: 100%;
	height: auto;
}

.comment-actions {
	display: flex;
	gap: 14px;
	margin-top: 12px;
}

.comment-actions a {
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--msm-brand);
}

.comment-actions a:hover {
	text-decoration: underline;
}

.comment-awaiting-moderation {
	display: inline-block;
	margin-top: 10px;
	padding: 4px 12px;
	border-radius: 40px;
	background: var(--bg-surface-alt);
	font-size: 0.8rem;
	color: var(--text-muted);
}

.comment-ping {
	padding: 10px 0;
	font-size: 0.88rem;
	color: var(--text-muted);
}

.comment-nav {
	display: flex;
	justify-content: space-between;
	gap: 12px;
	margin-top: 20px;
	font-size: 0.9rem;
}

.comment-nav a {
	font-weight: 600;
	color: var(--msm-brand);
}

/* --- reply form --------------------------------------------------------- */
.comment-respond {
	margin-top: 32px;
	padding: 26px;
	background: var(--bg-surface-alt);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
}

/* Nested under a comment the form is a reply to that comment, so it sits
   inside the thread rather than restarting the section. */
.comment-list .comment-respond {
	margin: 0 0 8px;
}

.comment-reply-title {
	margin-bottom: 6px;
	font-size: 1.1rem;
	font-weight: 700;
	letter-spacing: -0.02em;
}

.comment-reply-title small {
	font-size: 0.8rem;
	font-weight: 500;
}

.comment-reply-title small a {
	margin-inline-start: 10px;
	color: var(--msm-brand);
}

.comment-notes,
.logged-in-as {
	margin-bottom: 18px;
	font-size: 0.86rem;
	color: var(--text-muted);
}

.logged-in-as a {
	color: var(--msm-brand);
}

.comment-form .required {
	color: var(--msm-danger);
}

.comment-form-fields {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
	margin-bottom: 14px;
}

.comment-form p {
	margin-bottom: 14px;
}

.comment-form-fields p {
	margin-bottom: 0;
}

.comment-form label {
	display: block;
	margin-bottom: 6px;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--text-muted);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
	width: 100%;
	padding: 11px 14px;
	background: var(--input-bg);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-sm);
	color: var(--text-primary);
	font-family: inherit;
	font-size: 0.95rem;
	line-height: 1.5;
	transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-form textarea {
	min-height: 140px;
	resize: vertical;
}

.comment-form input[type="text"]:focus,
.comment-form input[type="email"]:focus,
.comment-form input[type="url"]:focus,
.comment-form textarea:focus {
	outline: none;
	border-color: var(--msm-brand);
	box-shadow: 0 0 0 3px var(--msm-brand-soft);
}

.comment-form-cookies-consent {
	display: flex;
	align-items: flex-start;
	gap: 10px;
}

.comment-form-cookies-consent input {
	flex-shrink: 0;
	margin-top: 4px;
	accent-color: var(--msm-brand);
}

.comment-form-cookies-consent label {
	margin: 0;
	font-size: 0.86rem;
	font-weight: 400;
	letter-spacing: 0;
	text-transform: none;
	color: var(--text-secondary);
}

.comment-form .form-submit {
	margin-bottom: 0;
}

.comment-form input[type="submit"] {
	padding: 12px 28px;
	border: 0;
	border-radius: 40px;
	background: var(--msm-brand);
	color: var(--msm-on-brand);
	font-family: inherit;
	font-size: 0.95rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.2s, transform 0.2s;
}

.comment-form input[type="submit"]:hover {
	background: var(--msm-brand-hover);
	transform: translateY(-1px);
}

.comments-closed {
	margin-top: 28px;
	padding: 16px 20px;
	background: var(--bg-surface-alt);
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
	font-size: 0.9rem;
	color: var(--text-muted);
	text-align: center;
}

@media (max-width: 600px) {
	.comment-form-fields {
		grid-template-columns: 1fr;
	}

	.comment-list ol.children {
		padding-inline-start: 12px;
	}

	.comment-list ol.children > li {
		padding-inline-start: 12px;
	}

	.comment-respond {
		padding: 20px 18px;
	}
}

/* --------------------------------------------------------------------------
   Related tools at the end of a tool guide (MSM Tools plugin)
   -------------------------------------------------------------------------- */
.msm-guide-related {
	margin-top: 40px;
	padding-top: 28px;
	border-top: 1px solid var(--card-border);
}

.msm-guide-related h2 {
	margin: 0 0 6px;
	font-family: var(--msm-font-display);
	font-size: 1.35rem;
}

.msm-guide-related-lede {
	margin: 0 0 18px;
	font-size: 0.9rem;
	color: var(--text-secondary);
}

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

.msm-guide-related-card {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 16px 18px;
	border: 1px solid var(--card-border);
	border-radius: var(--radius-md);
	background: var(--card-solid);
	text-decoration: none;
	transition: border-color var(--transition), transform var(--transition);
}

.msm-guide-related-card:hover,
.msm-guide-related-card:focus-visible {
	border-color: var(--msm-brand);
	transform: translateY(-1px);
}

.msm-guide-related-card:focus-visible {
	outline: 2px solid var(--msm-brand);
	outline-offset: 2px;
}

.msm-guide-related-name {
	font-family: var(--msm-font-display);
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--text-primary);
}

.msm-guide-related-desc {
	font-size: 0.82rem;
	line-height: 1.5;
	color: var(--text-secondary);
}

.msm-guide-related-go {
	margin-top: auto;
	padding-top: 4px;
	font-size: 0.82rem;
	font-weight: 600;
	color: var(--msm-brand);
}

@media (max-width: 760px) {
	.msm-guide-related-grid {
		grid-template-columns: minmax(0, 1fr);
	}
}

@media (prefers-reduced-motion: reduce) {
	.msm-guide-related-card {
		transition: none;
	}

	.msm-guide-related-card:hover {
		transform: none;
	}
}
