/* ==========================================================================
   jasonsteinshouer.com
   A reading surface for a nine-year archive of working-developer notes.
   One stylesheet, no framework, no build step.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Faces — self-hosted, variable, latin + latin-ext only
   -------------------------------------------------------------------------- */

@font-face {
	font-family: "Source Serif 4";
	font-style: normal;
	font-weight: 200 900;
	font-display: swap;
	src: url("/assets/fonts/ss4-normal-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Source Serif 4";
	font-style: normal;
	font-weight: 200 900;
	font-display: swap;
	src: url("/assets/fonts/ss4-normal-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "Source Serif 4";
	font-style: italic;
	font-weight: 200 900;
	font-display: swap;
	src: url("/assets/fonts/ss4-italic-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Source Serif 4";
	font-style: italic;
	font-weight: 200 900;
	font-display: swap;
	src: url("/assets/fonts/ss4-italic-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "JetBrains Mono";
	font-style: normal;
	font-weight: 100 800;
	font-display: swap;
	src: url("/assets/fonts/jbm-normal-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "JetBrains Mono";
	font-style: normal;
	font-weight: 100 800;
	font-display: swap;
	src: url("/assets/fonts/jbm-normal-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "JetBrains Mono";
	font-style: italic;
	font-weight: 100 800;
	font-display: swap;
	src: url("/assets/fonts/jbm-italic-latin.woff2") format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --------------------------------------------------------------------------
   2. Tokens
   -------------------------------------------------------------------------- */

:root {
	color-scheme: light;

	--paper:        #fbfbfa;
	--paper-sunk:   #f2f2ef;
	--paper-raised: #ffffff;
	--ink:          #1a1c1b;
	--ink-soft:     #5c6360;
	--ink-faint:    #6a706b;
	--rule:         #e3e3de;
	--rule-strong:  #cfcfc8;
	--accent:       #0e6b54;
	--accent-deep:  #0a5140;
	--accent-wash:  #e7f1ed;
	--select:       #cfe6dd;
	--code-cue:     #767c78;

	--font-read: "Source Serif 4", Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
	--font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-code: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	--measure: 68ch;
	--page: 78rem;
	--gutter: clamp(1.25rem, 5vw, 3rem);

	--step-0: 1.125rem;
	--step-1: 1.3125rem;
	--step-2: clamp(1.5rem, 1.32rem + 0.75vw, 1.875rem);
	--step-3: clamp(1.875rem, 1.6rem + 1.2vw, 2.5rem);
	--step-4: clamp(2.125rem, 1.62rem + 2.3vw, 3.375rem);
	--step-sm: 0.9375rem;
	--step-xs: 0.8125rem;

	--ease: cubic-bezier(0.16, 1, 0.3, 1);
	--radius: 6px;
}

:root[data-theme="dark"] {
	color-scheme: dark;

	/* A blue slate rather than near-black, with warm cream ink — carried over
	   from the notebook variation, where it read better for long reading at
	   night than a near-black ground with neutral white on it. */
	--paper:        #1c2124;
	--paper-sunk:   #242a2d;
	--paper-raised: #232a2e;
	--ink:          #ece5d8;
	--ink-soft:     #a7a89e;
	--ink-faint:    #93958c;
	--rule:         #414444;
	--rule-strong:  #5f605e;
	--accent:       #59d6ae;
	--accent-deep:  #8ee7c9;
	--accent-wash:  #22322c;
	--select:       #1e4438;
	--code-cue:     #767e78;
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: 6rem;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-read);
	font-size: var(--step-0);
	line-height: 1.7;
	font-optical-sizing: auto;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* --- Browser surfaces: the parts nobody draws ---------------------------- */

::selection { background: var(--select); color: var(--ink); }

:root { accent-color: var(--accent); caret-color: var(--accent); }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
	background: var(--rule-strong);
	border-radius: 99px;
	border: 3px solid transparent;
	background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); background-clip: content-box; }

img, svg, video { max-width: 100%; height: auto; }
img { border-radius: 3px; }

hr {
	border: 0;
	border-top: 1px solid var(--rule);
	margin: 3rem 0;
}

a {
	color: var(--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
	transition: color 0.15s var(--ease), text-decoration-color 0.15s var(--ease);
}
a:hover { color: var(--accent-deep); text-decoration-color: currentColor; }

time, .tabular { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.visually-hidden {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: 1rem;
	top: -4rem;
	z-index: 100;
	background: var(--accent);
	color: var(--paper);
	padding: 0.6rem 1rem;
	border-radius: var(--radius);
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	text-decoration: none;
	transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 1rem; }
.skip-link:focus,
.skip-link:hover { color: var(--paper); }

/* --------------------------------------------------------------------------
   4. Shell
   -------------------------------------------------------------------------- */

.shell {
	width: 100%;
	max-width: var(--page);
	margin-inline: auto;
	padding-inline: var(--gutter);
}

.column {
	width: 100%;
	max-width: var(--measure);
	margin-inline: auto;
}

/* An index hangs its dates in the left margin, so it needs the reading
   measure plus that margin — not the measure minus it. */
.column--index { max-width: calc(var(--measure) + 9rem); }

/* Tag fields and archive rows are not prose. */
.column--wide { max-width: 54rem; }

.site-main {
	flex: 1 0 auto;
	padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem);
}

/* --------------------------------------------------------------------------
   5. Masthead
   -------------------------------------------------------------------------- */

.masthead {
	position: sticky;
	top: 0;
	z-index: 40;
	background: var(--paper);
	border-bottom: 1px solid transparent;
	transition: border-color 0.25s var(--ease);
}
.masthead[data-scrolled="true"] { border-bottom-color: var(--rule); }

.masthead__inner {
	display: flex;
	align-items: center;
	gap: clamp(0.75rem, 3vw, 2rem);
	min-height: 4.25rem;
}

.wordmark {
	font-family: var(--font-read);
	font-size: 1.1875rem;
	font-weight: 600;
	letter-spacing: -0.015em;
	color: var(--ink);
	text-decoration: none;
	white-space: nowrap;
	margin-right: auto;
}
.wordmark:hover { color: var(--accent); }

.site-nav {
	display: flex;
	align-items: center;
	gap: clamp(0.5rem, 2vw, 1.5rem);
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	letter-spacing: 0.01em;
}

.site-nav a {
	color: var(--ink-soft);
	text-decoration: none;
	padding: 0.35rem 0;
	position: relative;
	white-space: nowrap;
}
.site-nav a::after {
	content: "";
	position: absolute;
	left: 0; right: 0; bottom: 0;
	height: 1px;
	background: var(--accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 0.25s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.site-nav a[aria-current="page"]::after { transform: scaleX(1); background: var(--rule-strong); }

.masthead__tools {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-left: 0.25rem;
}

.icon-button {
	display: inline-grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	border: 0;
	border-radius: var(--radius);
	background: transparent;
	color: var(--ink-soft);
	cursor: pointer;
	padding: 0;
	transition: background-color 0.18s var(--ease), color 0.18s var(--ease);
}
.icon-button:hover { background: var(--paper-sunk); color: var(--ink); }
.icon-button svg { width: 1.125rem; height: 1.125rem; }

.icon-button--search {
	display: inline-flex;
	width: auto;
	gap: 0.5rem;
	padding: 0 0.6rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	border: 1px solid var(--rule);
}
.icon-button--search .kbd {
	font-family: var(--font-code);
	font-size: 0.6875rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 0.05rem 0.3rem;
	line-height: 1.4;
}
@media (max-width: 46.25em) {
	.icon-button--search { width: 2.25rem; padding: 0; border-color: transparent; }
	.icon-button--search .icon-button__label,
	.icon-button--search .kbd { display: none; }

	/* One row cannot hold the wordmark, five destinations, and two controls
	   at 390px. Give the nav its own scrollable strip instead of overflowing
	   the document. */
	.masthead__inner { flex-wrap: wrap; min-height: 0; padding-top: 0.5rem; column-gap: 0.75rem; }
	.wordmark { margin-right: auto; }
	.site-nav {
		order: 3;
		flex: 1 0 100%;
		gap: 1.15rem;
		overflow-x: auto;
		scrollbar-width: none;
		margin-inline: calc(-1 * var(--gutter));
		padding-inline: var(--gutter);
		padding-bottom: 0.4rem;
	}
	.site-nav::-webkit-scrollbar { display: none; }
	.site-nav a { padding-block: 0.15rem; }
}

.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }

/* --------------------------------------------------------------------------
   6. Page headers
   -------------------------------------------------------------------------- */

.page-head {
	margin: 0 0 clamp(2.25rem, 5vw, 3.25rem);
}

.page-head__title {
	font-size: var(--step-3);
	font-weight: 600;
	line-height: 1.1;
	letter-spacing: -0.022em;
	margin: 0;
	text-wrap: balance;
}

.page-head__note {
	font-family: var(--font-ui);
	font-size: var(--step-sm);
	color: var(--ink-soft);
	margin: 0.75rem 0 0;
	line-height: 1.6;
}

/* The home masthead block: the archive stated plainly, not a hero. */
.intro {
	margin: 0 0 clamp(2.75rem, 7vw, 4.5rem);
	padding-bottom: clamp(1.75rem, 4vw, 2.5rem);
	border-bottom: 1px solid var(--rule);
}

.intro__name {
	font-size: var(--step-4);
	font-weight: 600;
	line-height: 1.03;
	letter-spacing: -0.03em;
	margin: 0 0 0.75rem;
}

.intro__lede {
	font-size: var(--step-1);
	line-height: 1.55;
	color: var(--ink-soft);
	margin: 0 0 1.5rem;
	max-width: 46ch;
	text-wrap: pretty;
}
.intro__lede strong { color: var(--ink); font-weight: 600; }

.intro__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1.25rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
}
.intro__meta a { color: var(--ink-soft); text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; }
.intro__meta a:hover { color: var(--accent); }
.intro__meta svg { width: 0.9375rem; height: 0.9375rem; }

/* --------------------------------------------------------------------------
   7. Post list — hanging date margin
   -------------------------------------------------------------------------- */

.entries { display: flex; flex-direction: column; }

.entry {
	display: grid;
	gap: 0.35rem 2.5rem;
	padding-block: clamp(1.75rem, 4vw, 2.5rem);
	border-top: 1px solid var(--rule);
}
.entry:first-child { border-top: 0; padding-top: 0; }

.entry__date {
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	letter-spacing: 0.02em;
	white-space: nowrap;
	padding-top: 0.4rem;
}

.entry__body { min-width: 0; }

.entry__title {
	font-size: var(--step-2);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: -0.02em;
	margin: 0 0 0.5rem;
	text-wrap: balance;
}
.entry__title a {
	color: var(--ink);
	text-decoration: none;
	background-image: linear-gradient(var(--accent), var(--accent));
	background-size: 0% 1px;
	background-position: 0 100%;
	background-repeat: no-repeat;
	transition: background-size 0.35s var(--ease), color 0.2s var(--ease);
}
.entry__title a:hover { color: var(--accent); background-size: 100% 1px; }

.entry__excerpt {
	margin: 0 0 0.9rem;
	color: var(--ink-soft);
	line-height: 1.65;
	max-width: 62ch;
}
.entry__excerpt p { display: inline; margin: 0; }
.entry__excerpt a.read-more {
	color: var(--accent);
	text-decoration: none;
	font-weight: 600;
	margin-left: 0.4em;
	white-space: nowrap;
}

@media (min-width: 52em) {
	/* Align the running head with the entry bodies; the dates hang outside. */
	.column--index > .intro,
	.column--index > .page-head { padding-left: 9rem; }

	.entry { grid-template-columns: 6.5rem minmax(0, 1fr); }
	.entry__date { grid-column: 1; grid-row: 1; text-align: right; }
	.entry__body { grid-column: 2; grid-row: 1; }
}
@media (max-width: 51.99em) {
	.entry__date { order: -1; padding-top: 0; }
}

/* --------------------------------------------------------------------------
   8. Tags
   -------------------------------------------------------------------------- */

.tags {
	display: flex;
	flex-wrap: wrap;
	gap: 0.375rem;
	list-style: none;
	padding: 0;
	margin: 0;
}

.tag {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	font-family: var(--font-ui);
	font-size: 0.75rem;
	letter-spacing: 0.02em;
	line-height: 1;
	padding: 0.34rem 0.55rem;
	border: 1px solid var(--rule);
	border-radius: 4px;
	color: var(--ink-soft);
	text-decoration: none;
	background: transparent;
	transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.tag:hover {
	color: var(--accent);
	border-color: color-mix(in srgb, var(--accent) 45%, transparent);
	background: var(--accent-wash);
}
.tag__count {
	font-variant-numeric: tabular-nums;
	color: var(--ink-faint);
	font-size: 0.6875rem;
}
.tag:hover .tag__count { color: var(--accent); }

/* Tag index, weighted by how much of the archive each tag actually carries. */
.tag-index { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.tag-index .tag { font-size: 0.8125rem; padding: 0.45rem 0.7rem; }
.tag-index .tag[data-weight="1"] {
	font-size: 1.125rem;
	font-weight: 700;
	color: var(--ink);
	border-color: var(--ink-faint);
	padding: 0.6rem 0.95rem;
	letter-spacing: -0.01em;
}
.tag-index .tag[data-weight="2"] {
	font-size: 1rem;
	font-weight: 650;
	color: var(--ink);
	border-color: var(--rule-strong);
	padding: 0.55rem 0.85rem;
}
.tag-index .tag[data-weight="3"] {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--ink);
}
.tag-index .tag[data-weight="1"] .tag__count,
.tag-index .tag[data-weight="2"] .tag__count { font-size: 0.8125rem; }
.tag-index .tag:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* --------------------------------------------------------------------------
   9. Article
   -------------------------------------------------------------------------- */

.article-layout {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
}
.article-layout > .article {
	grid-column: 1;
	min-width: 0;
	width: 100%;
	max-width: var(--measure);
	margin-inline: auto;
}
.article-layout > .toc { display: none; }
.toc[hidden] { display: none !important; }

@media (min-width: 78em) {
	.article-layout {
		grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr);
		gap: 0 3rem;
	}
	.article-layout > .article { grid-column: 2; margin-inline: 0; }
	.article-layout > .toc { grid-column: 3; display: block; max-width: 15rem; }
}

.article__header {
	padding-bottom: 1.5rem;
	margin-bottom: 2.25rem;
	border-bottom: 1px solid var(--rule);
}

.article__title {
	font-size: var(--step-4);
	font-weight: 600;
	line-height: 1.06;
	letter-spacing: -0.03em;
	margin: 0;
	text-wrap: balance;
}

.article__subtitle {
	font-size: var(--step-1);
	line-height: 1.45;
	color: var(--ink-soft);
	font-style: italic;
	margin: 0.75rem 0 0;
	text-wrap: pretty;
}

.article__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.6rem 1rem;
	margin-top: 1.5rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
}
.article__meta time { letter-spacing: 0.02em; }

/* --- Prose -------------------------------------------------------------- */

.prose {
	font-size: var(--step-0);
	line-height: 1.72;
	/* Nine years of posts contain long unbreakable strings — paths, flags, class
	   names. They wrap rather than widening the document on a phone. */
	overflow-wrap: break-word;
}
.prose > * { margin-block: 0 1.4em; }
.prose > *:last-child { margin-bottom: 0; }

.prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
	font-weight: 600;
	line-height: 1.22;
	letter-spacing: -0.018em;
	margin-top: 2.4em;
	margin-bottom: 0.7em;
	scroll-margin-top: 6rem;
	text-wrap: balance;
}
.prose h2 { font-size: var(--step-2); }
.prose h3 { font-size: var(--step-1); margin-top: 2em; }
.prose h4 { font-size: var(--step-0); margin-top: 1.8em; }
.prose h5, .prose h6 {
	font-family: var(--font-ui);
	font-size: var(--step-sm);
	letter-spacing: 0.02em;
	color: var(--ink-soft);
}
.prose > h2:first-child, .prose > h3:first-child { margin-top: 0; }

/* markdown-it-anchor wraps the heading text in a link; keep it invisible
   until the reader goes looking for it. */
.prose .header-anchor {
	color: inherit;
	text-decoration: none;
	position: relative;
}
.prose .header-anchor::after {
	content: "#";
	position: absolute;
	left: -0.85em;
	top: 0;
	color: var(--accent);
	opacity: 0;
	font-weight: 400;
	transition: opacity 0.18s var(--ease);
}
.prose :is(h2, h3, h4):hover .header-anchor::after,
.prose .header-anchor:focus-visible::after { opacity: 1; }
@media (max-width: 60em) { .prose .header-anchor::after { content: none; } }

.prose strong { font-weight: 650; }
.prose em { font-style: italic; }

.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.45em; }
.prose li::marker { color: var(--ink-faint); }
.prose ul > li::marker { color: var(--accent); }

.prose blockquote {
	margin-inline: 0;
	padding-left: 1.5rem;
	border-left: 1px solid var(--accent);
	color: var(--ink-soft);
	font-style: italic;
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose table {
	width: 100%;
	border-collapse: collapse;
	font-family: var(--font-ui);
	font-size: var(--step-sm);
	font-variant-numeric: tabular-nums;
}
.prose :is(th, td) {
	text-align: left;
	padding: 0.6rem 0.9rem 0.6rem 0;
	border-bottom: 1px solid var(--rule);
	vertical-align: top;
}
.prose th { font-weight: 600; color: var(--ink); border-bottom-color: var(--rule-strong); }

.prose figure { margin-inline: 0; }
.prose figcaption {
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	margin-top: 0.6rem;
}

.prose img { display: block; margin-inline: auto; }
.prose iframe, .prose video { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 1px solid var(--rule); border-radius: var(--radius); }

/* --- Footnotes (markdown-it-footnote) ----------------------------------- */

.prose .footnotes {
	margin-top: 3.5rem;
	padding-top: 1.75rem;
	border-top: 1px solid var(--rule);
	font-size: var(--step-sm);
	color: var(--ink-soft);
}
.prose .footnotes hr { display: none; }
.prose .footnotes ol { padding-left: 1.2em; }
.prose .footnotes li { margin-bottom: 0.6em; }
.prose .footnotes p { margin-bottom: 0.4em; }
.prose .footnote-ref a {
	text-decoration: none;
	font-size: 0.8em;
	font-weight: 600;
	padding: 0 0.15em;
	vertical-align: super;
}
.prose .footnote-backref { text-decoration: none; }

/* --------------------------------------------------------------------------
   10. Code — the site's primary content, treated as such
   -------------------------------------------------------------------------- */

.prose :not(pre) > code {
	font-family: var(--font-code);
	font-size: 0.855em;
	background: var(--paper-sunk);
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 0.1em 0.34em;
	color: var(--ink);
	word-break: break-word;
}
.prose a > code { color: inherit; }

/* Code is the content here, so it is allowed a little more width than the
   prose measure once the viewport can spare it. */
.codeblock {
	margin: 1.75em 0;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	background: var(--paper-sunk);
	overflow: hidden;
	position: relative;
}

.codeblock__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.4rem 0.5rem 0.4rem 0.85rem;
	border-bottom: 1px solid var(--rule);
	background: color-mix(in srgb, var(--paper-sunk) 60%, var(--paper));
	min-height: 2.25rem;
}

.codeblock__lang {
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink-faint);
}

.codeblock__copy {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	border: 1px solid transparent;
	background: transparent;
	color: var(--ink-faint);
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	letter-spacing: 0.03em;
	padding: 0.3rem 0.5rem;
	border-radius: 4px;
	cursor: pointer;
	opacity: 0.65;
	transition: opacity 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.codeblock:hover .codeblock__copy,
.codeblock__copy:hover,
.codeblock__copy:focus-visible { opacity: 1; }
.codeblock__copy:hover { color: var(--ink); border-color: var(--rule-strong); }
.codeblock__copy[data-state="copied"] { opacity: 1; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.codeblock__copy svg { width: 0.875rem; height: 0.875rem; }
.codeblock__copy .icon-check { display: none; }
.codeblock__copy[data-state="copied"] .icon-check { display: block; }
.codeblock__copy[data-state="copied"] .icon-copy { display: none; }
@media (hover: none) { .codeblock__copy { opacity: 1; } }

.codeblock pre,
.prose pre {
	margin: 0;
	padding: 1rem 1.15rem 1.15rem;
	overflow-x: auto;
	background: transparent;
	border: 0;
	border-radius: 0;
	font-family: var(--font-code);
	font-size: 0.8125rem;
	line-height: 1.65;
	tab-size: 4;
	-moz-tab-size: 4;

	/* Two masks in the panel's own stock scroll with the content; two 2px
	   rules stay put, so a rule shows only while there is code past that
	   edge. The rules sit inside the panel's padding, where no glyph is ever
	   painted — a wash here would sit behind the code and cost it contrast
	   that a background-color audit cannot see. */
	background-image:
		linear-gradient(to right, var(--paper-sunk) 45%, rgba(0, 0, 0, 0)),
		linear-gradient(to left, var(--paper-sunk) 45%, rgba(0, 0, 0, 0)),
		linear-gradient(var(--code-cue), var(--code-cue)),
		linear-gradient(var(--code-cue), var(--code-cue));
	background-position: 0 0, 100% 0, 0 0, 100% 0;
	background-repeat: no-repeat;
	background-size: 3rem 100%, 3rem 100%, 2px 100%, 2px 100%;
	background-attachment: local, local, scroll, scroll;
}
.prose pre code {
	font-family: inherit;
	font-size: inherit;
	background: none;
	border: 0;
	padding: 0;
	color: inherit;
	white-space: pre;
}

@media (min-width: 64em) {
	.prose .codeblock,
	.prose > pre:not([class*="language-"]) { margin-inline: -2rem; }
}

/* Bare <pre> from the indented code blocks in the older posts. */
.prose > pre:not([class*="language-"]) {
	background: var(--paper-sunk);
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	color: var(--ink);
}

/* --------------------------------------------------------------------------
   11. Table of contents rail
   -------------------------------------------------------------------------- */

.toc {
	position: sticky;
	top: 6rem;
	align-self: start;
	max-height: calc(100vh - 9rem);
	overflow-y: auto;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	line-height: 1.5;
	padding-left: 1rem;
	border-left: 1px solid var(--rule);
}

.toc__label {
	font-size: 0.6875rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-faint);
	margin: 0 0 0.85rem;
	font-weight: 600;
}

.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: 0.55rem; }
.toc li[data-level="3"] { padding-left: 0.85rem; }
.toc a {
	color: var(--ink-soft);
	text-decoration: none;
	display: block;
	transition: color 0.18s var(--ease);
}
.toc a:hover { color: var(--ink); }
.toc a[aria-current="true"] { color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------------------------
   12. Article footer — who wrote this, and what to read next
   -------------------------------------------------------------------------- */

.article__footer { margin-top: clamp(3rem, 7vw, 4.5rem); }

.byline {
	display: flex;
	gap: 1.1rem;
	align-items: flex-start;
	padding-top: 2rem;
	border-top: 1px solid var(--rule);
}
.byline__avatar {
	flex: none;
	width: 3.25rem;
	height: 3.25rem;
	border-radius: 50%;
	object-fit: cover;
	filter: grayscale(1) contrast(1.05);
	border: 1px solid var(--rule);
}
.byline__body { min-width: 0; }
.byline__name {
	font-size: var(--step-0);
	font-weight: 600;
	margin: 0 0 0.2rem;
	letter-spacing: -0.012em;
}
.byline__bio {
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	line-height: 1.6;
	color: var(--ink-soft);
	margin: 0 0 0.55rem;
	max-width: 52ch;
}
.byline__links {
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
}
.byline__links a { display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none; }
.byline__links a:hover { text-decoration: underline; }
.byline__links svg { width: 0.9375rem; height: 0.9375rem; }

.section-label {
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	color: var(--ink-faint);
	font-weight: 600;
	margin: 0 0 1.1rem;
}

.related { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--rule); }
.related__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.related__item { display: grid; gap: 0.15rem; }
.related__item a {
	font-size: var(--step-sm);
	font-weight: 600;
	color: var(--ink);
	text-decoration: none;
	line-height: 1.35;
	letter-spacing: -0.01em;
}
.related__item a:hover { color: var(--accent); }
.related__item time { font-family: var(--font-ui); font-size: var(--step-xs); color: var(--ink-faint); }

.post-nav {
	display: grid;
	gap: 1.5rem;
	margin-top: 3rem;
	padding-top: 2rem;
	border-top: 1px solid var(--rule);
}
@media (min-width: 40em) { .post-nav { grid-template-columns: 1fr 1fr; gap: 2.5rem; } }

.post-nav__link { display: grid; gap: 0.3rem; text-decoration: none; }
.post-nav__dir {
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-faint);
	font-weight: 600;
}
.post-nav__title {
	font-size: var(--step-sm);
	font-weight: 600;
	color: var(--ink);
	line-height: 1.35;
	letter-spacing: -0.01em;
	transition: color 0.18s var(--ease);
}
.post-nav__link:hover .post-nav__title { color: var(--accent); }
.post-nav__link--next { text-align: right; }
@media (max-width: 39.99em) { .post-nav__link--next { text-align: left; } }

/* --------------------------------------------------------------------------
   13. Archive
   -------------------------------------------------------------------------- */

.archive-year { margin-bottom: clamp(2.5rem, 6vw, 3.5rem); }

.archive-year__heading {
	display: flex;
	align-items: baseline;
	gap: 1rem;
	margin: 0 0 1rem;
	padding-bottom: 0.6rem;
	border-bottom: 1px solid var(--rule-strong);
}
.archive-year__number {
	font-size: var(--step-2);
	font-weight: 600;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	margin: 0;
}
.archive-year__count {
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	margin-left: auto;
}

.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-item {
	display: grid;
	gap: 0.15rem 1.5rem;
	padding-block: 0.7rem;
	border-bottom: 1px solid var(--rule);
	align-items: baseline;
}
.archive-item:last-child { border-bottom: 0; }
.archive-item__date {
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	white-space: nowrap;
}
.archive-item__title {
	font-size: var(--step-sm);
	line-height: 1.4;
	color: var(--ink);
	text-decoration: none;
	font-weight: 600;
	letter-spacing: -0.008em;
}
.archive-item__title:hover { color: var(--accent); }
.archive-item__tags {
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	color: var(--ink-faint);
	letter-spacing: 0.02em;
}
@media (min-width: 46em) {
	.archive-item { grid-template-columns: 4.5rem minmax(0, 1fr) auto; }
	.archive-item__tags { text-align: right; }
}

/* --------------------------------------------------------------------------
   14. Pagination
   -------------------------------------------------------------------------- */

.pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-top: clamp(2.5rem, 6vw, 3.5rem);
	padding-top: 1.75rem;
	border-top: 1px solid var(--rule);
	font-family: var(--font-ui);
	font-size: var(--step-xs);
}
.pagination__count { color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.pagination a {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	text-decoration: none;
	padding: 0.45rem 0.75rem;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	color: var(--ink-soft);
	transition: border-color 0.18s var(--ease), color 0.18s var(--ease);
}
.pagination a:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pagination a svg { width: 0.875rem; height: 0.875rem; }
.pagination__spacer { flex: 1; }

/* --------------------------------------------------------------------------
   15. Search — the site's one authored moment
   -------------------------------------------------------------------------- */

.search-dialog {
	position: fixed;
	inset: 0;
	z-index: 90;
	border: 0;
	padding: 0;
	margin: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	background: transparent;
	overflow: hidden;
}
.search-dialog::backdrop { background: transparent; }

.search-dialog__scrim {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, var(--paper) 55%, transparent);
	backdrop-filter: blur(6px) saturate(1.2);
	-webkit-backdrop-filter: blur(6px) saturate(1.2);
	opacity: 0;
	transition: opacity 0.32s var(--ease);
}
.search-dialog[data-ready] .search-dialog__scrim { opacity: 1; }

.search-panel {
	position: relative;
	width: min(42rem, calc(100% - 2rem));
	margin: clamp(3rem, 10vh, 7rem) auto 0;
	background: var(--paper-raised);
	border: 1px solid var(--rule-strong);
	border-radius: 10px;
	display: flex;
	flex-direction: column;
	max-height: min(34rem, calc(100vh - 8rem));
	overflow: hidden;
	opacity: 0;
	transform: translateY(-0.75rem) scale(0.985);
	transition: opacity 0.3s var(--ease), transform 0.4s var(--ease);
}
.search-dialog[data-ready] .search-panel { opacity: 1; transform: none; }

.search-field {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.9rem 1rem;
	border-bottom: 1px solid var(--rule);
	flex: none;
}
/* The input hides its own ring, so the field carries it instead. */
.search-field:focus-within {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
	border-radius: 9px 9px 0 0;
}
.search-field svg { width: 1.0625rem; height: 1.0625rem; color: var(--ink-faint); flex: none; }

.search-field input {
	flex: 1;
	min-width: 0;
	border: 0;
	background: transparent;
	font-family: var(--font-ui);
	font-size: 1rem;
	color: var(--ink);
	padding: 0;
}
.search-field input::placeholder { color: var(--ink-faint); }
.search-field input::-webkit-search-cancel-button,
.search-field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-field input:focus { outline: none; }

.search-field__close {
	flex: none;
	font-family: var(--font-code);
	font-size: 0.6875rem;
	color: var(--ink-faint);
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 0.15rem 0.4rem;
	background: transparent;
	cursor: pointer;
}
.search-field__close:hover { color: var(--ink); border-color: var(--rule-strong); }

.search-results {
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 0.4rem;
	margin: 0;
	list-style: none;
	min-height: 0;
}

.search-result a {
	display: grid;
	gap: 0.2rem;
	padding: 0.65rem 0.75rem;
	border-radius: var(--radius);
	text-decoration: none;
	opacity: 0;
	transform: translateY(0.35rem);
	animation: result-in 0.42s var(--ease) forwards;
	animation-delay: calc(var(--i, 0) * 28ms);
}
.search-result a:hover,
.search-result a:focus-visible,
.search-result[data-active="true"] a { background: var(--paper-sunk); }

@keyframes result-in { to { opacity: 1; transform: none; } }

.search-result__title {
	font-family: var(--font-read);
	font-size: var(--step-sm);
	font-weight: 600;
	color: var(--ink);
	line-height: 1.35;
	letter-spacing: -0.01em;
}
.search-result[data-active="true"] .search-result__title { color: var(--accent); }
.search-result__title mark {
	background: color-mix(in srgb, var(--accent) 22%, transparent);
	color: inherit;
	border-radius: 2px;
	padding: 0 0.08em;
}
.search-result__meta {
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	color: var(--ink-faint);
	letter-spacing: 0.02em;
	display: flex;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.search-empty {
	padding: 2rem 1rem 2.25rem;
	text-align: center;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
	line-height: 1.6;
}

.search-foot {
	flex: none;
	border-top: 1px solid var(--rule);
	padding: 0.55rem 1rem;
	display: flex;
	gap: 1.1rem;
	font-family: var(--font-ui);
	font-size: 0.6875rem;
	color: var(--ink-faint);
	flex-wrap: wrap;
}
.search-foot kbd {
	font-family: var(--font-code);
	border: 1px solid var(--rule);
	border-radius: 4px;
	padding: 0 0.3rem;
	font-size: 0.6875rem;
	margin-right: 0.3rem;
}

/* --------------------------------------------------------------------------
   16. Footer
   -------------------------------------------------------------------------- */

.site-footer {
	flex: none;
	border-top: 1px solid var(--rule);
	padding-block: 2.25rem 3rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	color: var(--ink-faint);
}

.site-footer__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 1rem 2rem;
}

.site-footer__links { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-left: auto; }
.site-footer a { color: var(--ink-soft); text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; }
.site-footer a:hover { color: var(--accent); }
.site-footer svg { width: 0.9375rem; height: 0.9375rem; }

/* --------------------------------------------------------------------------
   17. Not found
   -------------------------------------------------------------------------- */

.notfound { text-align: center; padding-block: clamp(2rem, 8vh, 5rem); }
.notfound__code {
	font-family: var(--font-code);
	font-size: clamp(3rem, 12vw, 5rem);
	font-weight: 200;
	letter-spacing: 0.02em;
	color: var(--ink-faint);
	line-height: 1;
	margin: 0 0 1rem;
}
.notfound__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.75rem;
	margin-top: 2rem;
}

.button {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	padding: 0.6rem 1rem;
	border-radius: var(--radius);
	border: 1px solid var(--rule-strong);
	color: var(--ink);
	text-decoration: none;
	background: transparent;
	cursor: pointer;
	transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.button:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-wash); }
.button svg { width: 0.9375rem; height: 0.9375rem; }
.button--primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.button--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--paper); }

/* --------------------------------------------------------------------------
   18. Motion and print
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
	.search-result a { opacity: 1; transform: none; }
}

@media print {
	.masthead, .site-footer, .toc, .search-dialog, .post-nav, .related { display: none !important; }
	body { background: #fff; color: #000; font-size: 11pt; }
	.article-layout { display: block; }
	.prose a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
	.codeblock { break-inside: avoid; }
}


/* --------------------------------------------------------------------------
   19. Inline table of contents — the rail's stand-in below the rail's width
   -------------------------------------------------------------------------- */

.toc-inline {
	margin: 0 0 2.25rem;
	border: 1px solid var(--rule);
	border-radius: var(--radius);
	font-family: var(--font-ui);
	font-size: var(--step-xs);
	background: var(--paper-sunk);
}
.toc-inline[hidden] { display: none !important; }
@media (min-width: 78em) { .toc-inline { display: none !important; } }

.toc-inline summary {
	cursor: pointer;
	padding: 0.7rem 0.9rem;
	font-weight: 600;
	color: var(--ink);
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
}
.toc-inline summary::-webkit-details-marker { display: none; }
.toc-inline summary::after {
	content: "";
	flex: none;
	width: 0.45rem;
	height: 0.45rem;
	border-right: 1.5px solid var(--ink-faint);
	border-bottom: 1.5px solid var(--ink-faint);
	transform: rotate(45deg) translate(-1px, -1px);
	transition: transform 0.22s var(--ease);
}
.toc-inline[open] summary::after { transform: rotate(-135deg) translate(-1px, -1px); }
.toc-inline summary:focus-visible { border-radius: var(--radius); }

.toc-inline ul { list-style: none; margin: 0; padding: 0 0.9rem 0.9rem; }
.toc-inline li { margin-bottom: 0.5rem; line-height: 1.45; }
.toc-inline li[data-level="3"] { padding-left: 0.9rem; }
.toc-inline a { color: var(--ink-soft); text-decoration: none; }
.toc-inline a:hover { color: var(--accent); }
