/* Reading Extras — uses Materia's colour tokens, with fallbacks for other themes. */
.mre-toc,
.mre-related {
	--mre-primary: var(--primary, #1a73e8);
	--mre-tint: var(--primary-tint, #e8f0fe);
	--mre-line: var(--line, #dadce0);
	--mre-text: var(--text, #202124);
	--mre-text-2: var(--text-2, #5f6368);
	--mre-surface: var(--surface, #fff);
	--mre-surface-2: var(--surface-2, #f8f9fa);
	--mre-radius: var(--radius-card, 12px);
	--mre-elev: var(--elev-1, 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15));
	font-family: var(--font, inherit);
}

/* ---------- Table of contents ---------- */
.mre-toc {
	margin: 8px auto 32px;
	border: 1px solid var(--mre-line);
	border-radius: var(--mre-radius);
	background: var(--mre-surface-2);
}

.mre-toc summary {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 14px 20px;
	cursor: pointer;
	list-style: none;
	user-select: none;
}

.mre-toc summary::-webkit-details-marker { display: none; }

.mre-toc summary::after {
	content: "";
	width: 8px;
	height: 8px;
	margin-left: 4px;
	border-right: 2px solid var(--mre-text-2);
	border-bottom: 2px solid var(--mre-text-2);
	transform: rotate(45deg) translateY(-2px);
	transition: transform .2s var(--ease, ease);
}

.mre-toc details[open] summary::after { transform: rotate(-135deg) translateY(-2px); }

.mre-toc__title {
	font-size: 1rem;
	font-weight: 500;
	color: var(--mre-text);
}

.mre-toc__count {
	margin-left: auto;
	font-size: .8125rem;
	color: var(--mre-text-2);
}

.mre-toc__list,
.mre-toc__list ol {
	margin: 0;
	padding: 0;
	list-style: none;
}

.mre-toc__list {
	padding: 0 12px 14px;
	counter-reset: mre-toc;
}

.mre-toc__list > li { counter-increment: mre-toc; }
.mre-toc__list ol { counter-reset: mre-sub; padding-left: 28px; }
.mre-toc__list ol > li { counter-increment: mre-sub; }

.mre-toc a,
.entry-content .mre-toc a {
	display: flex;
	gap: 10px;
	padding: 6px 10px;
	border-radius: 8px;
	font-size: .9375rem;
	line-height: 1.45;
	color: var(--mre-text);
	text-decoration: none;
}

.mre-toc__list > li > a::before {
	content: counter(mre-toc) ".";
	min-width: 1.4em;
	color: var(--mre-text-2);
	font-variant-numeric: tabular-nums;
}

.mre-toc__list ol a { font-size: .875rem; color: var(--mre-text-2); }

.mre-toc__list ol a::before {
	content: counter(mre-toc) "." counter(mre-sub);
	min-width: 2.2em;
	font-variant-numeric: tabular-nums;
}

.mre-toc a:hover {
	background: var(--hover, #f1f3f4);
	text-decoration: none;
}

.mre-toc a.is-active {
	background: var(--mre-tint);
	color: var(--mre-primary);
	font-weight: 500;
}

.mre-toc a.is-active::before { color: var(--mre-primary); }

@media (prefers-reduced-motion: no-preference) {
	html:has(.mre-toc) { scroll-behavior: smooth; }
}

/* ---------- Related posts ---------- */
.mre-related {
	margin: 56px auto 8px;
	padding-top: 32px;
	border-top: 1px solid var(--mre-line);
}


.mre-related__title {
	margin: 0 0 20px;
	font-size: 1.375rem;
	font-weight: 400;
	color: var(--mre-text);
}

.mre-related__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 16px;
}

.mre-card {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--mre-line);
	border-radius: var(--mre-radius);
	background: var(--mre-surface);
	color: var(--mre-text);
	text-decoration: none !important;
	transition: box-shadow .2s var(--ease, ease), border-color .2s var(--ease, ease);
}

.mre-card:hover,
.mre-card:focus-visible {
	border-color: transparent;
	box-shadow: var(--mre-elev);
}

.mre-card__media {
	display: block;
	aspect-ratio: 16 / 9;
	overflow: hidden;
	background: var(--mre-tint);
}

.mre-card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 0 !important;
	display: block;
}

.mre-card__letter {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	font-size: 2.5rem;
	font-weight: 500;
	color: var(--mre-primary);
	text-transform: uppercase;
}

.mre-card__body {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 14px 16px 16px;
	flex: 1;
}

.mre-card__cat {
	font-size: .75rem;
	font-weight: 500;
	color: var(--mre-primary);
}

.mre-card__title {
	font-size: 1rem;
	font-weight: 500;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.mre-card__meta {
	margin-top: auto;
	padding-top: 4px;
	font-size: .8125rem;
	color: var(--mre-text-2);
}

.mre-card:hover .mre-card__title { color: var(--mre-primary); }

@media (max-width: 600px) {
	.mre-related__grid { grid-template-columns: 1fr; }
	.mre-card { flex-direction: row; }
	.mre-card__media { flex: 0 0 112px; aspect-ratio: auto; }
	.mre-related__grid.no-images .mre-card { flex-direction: column; }
}
