/* jacobsaunders.xyz — editorial/print-inspired, deliberately not the usual
   flat-card look. No external fonts, no JS, no frameworks.

   To restyle, change the custom properties in :root. Everything else derives
   from them. Layout is a two-column rail + column on wide screens, stacking
   to one column on narrow ones.

   NOTE: the CSP forbids inline styles (style-src 'self'), so all styling
   must live in this file — do not add style="" attributes to the HTML. */

:root {
	--paper: #fcf9f1;
	--ink: #191714;
	--muted: #6d675e;
	--rule: #d6cfc2;
	--accent: #9c4a24;
	--accent-soft: #b8683f;

	--serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
		"Times New Roman", serif;
	--sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;

	--measure: 34rem;
	--rail: 13rem;
	--gap: 3.5rem;
}

@media (prefers-color-scheme: dark) {
	:root {
		--paper: #14130f;
		--ink: #e9e4d8;
		--muted: #9c9485;
		--rule: #33302a;
		--accent: #d9895a;
		--accent-soft: #e8a179;
	}
}

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

html {
	font-size: 17px;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background-color: var(--paper);
	/* Very faint paper grain. Inline SVG so there is no external request. */
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
	color: var(--ink);
	font-family: var(--serif);
	line-height: 1.62;
	text-rendering: optimizeLegibility;
}

.page {
	max-width: 62rem;
	margin: 0 auto;
	padding: 3.5rem 1.6rem 5rem;
	display: grid;
	grid-template-columns: var(--rail) minmax(0, 1fr);
	gap: var(--gap);
	align-items: start;
}

/* ---------- left rail ---------- */

.rail {
	position: sticky;
	top: 3.5rem;
}

.wordmark {
	display: block;
	font-size: 1.32rem;
	line-height: 1.25;
	letter-spacing: -0.015em;
	color: var(--ink);
	text-decoration: none;
	font-weight: 600;
}

.wordmark:hover {
	color: var(--accent);
}

.wordmark::after {
	content: "";
	display: block;
	width: 2.4rem;
	height: 2px;
	margin-top: 0.85rem;
	background: var(--accent);
}

.tagline {
	margin: 0.85rem 0 0;
	font-family: var(--sans);
	font-size: 0.76rem;
	letter-spacing: 0.02em;
	color: var(--muted);
	max-width: 11rem;
}

.nav {
	margin-top: 2.2rem;
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
}

.nav a {
	font-family: var(--sans);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.13em;
	color: var(--muted);
	text-decoration: none;
	width: fit-content;
	padding-bottom: 2px;
	border-bottom: 1px solid transparent;
	transition: color 0.15s ease, border-color 0.15s ease;
}

.nav a:hover,
.nav a:focus-visible {
	color: var(--ink);
	border-bottom-color: var(--accent);
}

.nav a[aria-current="page"] {
	color: var(--ink);
	border-bottom-color: var(--accent);
}

/* External links (the map) get a small mark rather than an emoji. */
.nav a.ext::after {
	content: " ↗";
	color: var(--accent);
	letter-spacing: 0;
}

/* ---------- content ---------- */

.content {
	max-width: var(--measure);
	border-left: 1px solid var(--rule);
	padding-left: var(--gap);
	margin-left: calc(var(--gap) * -1 + var(--gap));
}

.lede {
	font-size: 1.28rem;
	line-height: 1.5;
	margin: 0 0 2.6rem;
	color: var(--ink);
}

section {
	margin: 0 0 3rem;
}

/* Margin markers: a numbered label sitting to the left of each heading.
   This is what stops the page reading like a generic template. */
section > h2 {
	font-family: var(--sans);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.14em;
	color: var(--muted);
	font-weight: 600;
	margin: 0 0 0.9rem;
	padding-top: 0.9rem;
	border-top: 1px solid var(--rule);
	position: relative;
}

section > h2::before {
	content: counter(sec, decimal-leading-zero);
	counter-increment: sec;
	position: absolute;
	top: 0.9rem;
	left: -3.1rem;
	color: var(--accent);
	letter-spacing: 0;
}

.content {
	counter-reset: sec;
}

h3 {
	font-size: 1.06rem;
	margin: 0 0 0.3rem;
	font-weight: 600;
}

p {
	margin: 0 0 1.1rem;
}

a {
	color: var(--accent);
	text-underline-offset: 0.18em;
	text-decoration-thickness: 1px;
}

a:hover {
	color: var(--accent-soft);
}

.placeholder {
	color: var(--muted);
	font-style: italic;
}

/* Simple list of entries — projects, clips, posts. Add <li> items. */
.entries {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Rules BETWEEN entries only. The section's own rule is the one above its
   heading (section > h2 border-top); a first-child top border would double
   it, and a last-child bottom border would fence off anything after the
   list ("All projects →") and leave a stray rule at the end of a page. */
.entries li {
	padding: 0.9rem 0;
	border-bottom: 1px solid var(--rule);
}

.entries li:first-child {
	padding-top: 0;
}

.entries li:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.entries .meta {
	font-family: var(--sans);
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	color: var(--muted);
}

/* Embedded video player (the Music page's YouTube clips). The wrapper owns
   the 16:9 box so the iframe can be styled without inline attributes —
   the CSP forbids style="". */
.video {
	aspect-ratio: 16 / 9;
	margin: 0.2rem 0 0.4rem;
}

.video iframe {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: var(--rule);
}

/* File list on the docs.jacobsaunders.xyz home page. That page is GENERATED
   by site-admin's pages_api.py (see its DOCS_HOME_TMPL) — keep the class
   names here and there in sync. */
.doclist-wrap {
	overflow-x: auto;
}

.doclist {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.94rem;
}

.doclist th {
	font-family: var(--sans);
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--muted);
	font-weight: 600;
	text-align: left;
	padding: 0 1.1rem 0.45rem 0;
	border-bottom: 1px solid var(--rule);
}

.doclist td {
	padding: 0.55rem 1.1rem 0.55rem 0;
	border-bottom: 1px solid var(--rule);
	vertical-align: top;
}

.doclist tr:last-child td {
	border-bottom: 0;
}

.doclist .tags {
	font-family: var(--sans);
	font-size: 0.74rem;
	color: var(--muted);
	padding-top: 0.72rem;
}

.foot {
	grid-column: 2;
	margin-top: 1rem;
	padding-left: var(--gap);
	font-family: var(--sans);
	font-size: 0.72rem;
	color: var(--muted);
}

/* ---------- narrow screens ---------- */

@media (max-width: 44rem) {
	.page {
		grid-template-columns: 1fr;
		gap: 2.4rem;
		padding: 2.4rem 1.3rem 3.5rem;
	}

	.rail {
		position: static;
	}

	.nav {
		margin-top: 1.4rem;
		flex-direction: row;
		flex-wrap: wrap;
		gap: 0.9rem 1.4rem;
	}

	.content {
		border-left: 0;
		padding-left: 0;
		margin-left: 0;
	}

	section > h2::before {
		position: static;
		display: inline;
		margin-right: 0.6rem;
	}

	.foot {
		grid-column: 1;
		padding-left: 0;
	}
}

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

/* ==========================================================================
   Long-form posts (body.post)
   ==========================================================================

   Added when the first project write-up went up. Everything below is scoped to
   `body.post` or to classes no other page uses, so index/projects/music render
   exactly as they did before.

   Generated by tools/mdpost.py — see that file before changing a class name.

   REMINDER: the CSP is `style-src 'self'`. There are no style="" attributes
   anywhere in the generated HTML and there must not be; per-figure widths are
   the .fig-450 / .fig-650 / .fig-750 classes below. */

/* The site grid gives the content column ~719px, which is narrower than the
   650-750px figures a build post needs. Posts widen the whole grid rather than
   letting figures spill out of it. */
body.post .page {
	max-width: 72rem;
}

body.post .content {
	max-width: 44rem;
}

/* ---------- post header ---------- */

.post-header {
	margin: 0 0 2.6rem;
}

.post-kicker {
	margin: 0 0 1.4rem;
	font-family: var(--sans);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.13em;
}

.post-kicker a,
.post-foot a {
	color: var(--muted);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	padding-bottom: 2px;
}

.post-kicker a:hover,
.post-foot a:hover {
	color: var(--ink);
	border-bottom-color: var(--accent);
}

.post-header h1 {
	font-size: 2.15rem;
	line-height: 1.16;
	letter-spacing: -0.018em;
	font-weight: 600;
	margin: 0 0 0.9rem;
	text-wrap: balance;
}

.post-meta {
	margin: 0;
	padding-top: 0.85rem;
	border-top: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	color: var(--muted);
}

.post-meta .sep {
	color: var(--rule);
	margin: 0 0.2rem;
}

/* ---------- article body ---------- */

/* The site's section > h2 rule turns headings into small uppercase labels with
   a counter in the margin. A post's own headings are already numbered in the
   prose ("2. From a rough sketch to CISPR 25"), so that treatment would print
   a second number. Posts get real serif subheads instead. */
body.post article h2 {
	font-family: var(--serif);
	font-size: 1.42rem;
	line-height: 1.25;
	letter-spacing: -0.01em;
	text-transform: none;
	font-weight: 600;
	color: var(--ink);
	margin: 2.9rem 0 0.9rem;
	padding-top: 0;
	border-top: 0;
	counter-increment: none;
}

body.post article h2::before {
	content: none;
}

body.post article h3 {
	font-size: 1.08rem;
	margin: 2rem 0 0.5rem;
}

/* Reports converted from deep Obsidian outlines reach one level further. */
body.post article h4 {
	font-size: 0.98rem;
	font-weight: 600;
	margin: 1.6rem 0 0.4rem;
}

body.post article p {
	margin: 0 0 1.25rem;
}

body.post article ul {
	margin: 0 0 1.25rem;
	padding-left: 1.15rem;
}

body.post article li {
	margin: 0 0 0.55rem;
}

body.post article li::marker {
	color: var(--accent);
}

body.post article hr {
	border: 0;
	border-top: 1px solid var(--rule);
	margin: 2.9rem 0;
}

body.post code {
	font-size: 0.88em;
	background: color-mix(in srgb, var(--rule) 45%, transparent);
	padding: 0.1em 0.32em;
	border-radius: 2px;
}

/* ---------- figures ---------- */

/* Widths come from the source post's embed syntax and are classes, not inline
   styles, because of the CSP. Add a new one here if a post needs it. */
.fig-350 { max-width: 350px; }
.fig-400 { max-width: 400px; }
.fig-450 { max-width: 450px; }
.fig-500 { max-width: 500px; }
.fig-550 { max-width: 550px; }
.fig-650 { max-width: 650px; }
.fig-750 { max-width: 750px; }

.fig {
	margin: 2.2rem 0;
	width: 100%;
}

.fig img {
	display: block;
	width: 100%;
	height: auto;
	border: 1px solid var(--rule);
}

/* The schematic is an SVG with an opaque white background. Against the dark
   theme's near-black paper that would read as a glare panel, so it gets a
   deliberate white plate and reads as a printed sheet instead. */
.fig-svg img {
	background: #fff;
	padding: 0.7rem;
}

.fig figcaption {
	margin-top: 0.7rem;
	font-family: var(--sans);
	font-size: 0.72rem;
	line-height: 1.5;
	letter-spacing: 0.02em;
	color: var(--muted);
	border-left: 2px solid var(--accent);
	padding-left: 0.7rem;
}

/* ---------- tables ---------- */

.table-wrap {
	margin: 1.9rem 0;
	overflow-x: auto;
}

.table-wrap table {
	border-collapse: collapse;
	width: 100%;
	font-size: 0.92rem;
}

.table-wrap th {
	font-family: var(--sans);
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	font-weight: 600;
	color: var(--muted);
	text-align: left;
	padding: 0 0.8rem 0.6rem 0;
	border-bottom: 1px solid var(--ink);
	white-space: nowrap;
}

.table-wrap td {
	padding: 0.62rem 0.8rem 0.62rem 0;
	border-bottom: 1px solid var(--rule);
	vertical-align: top;
}

/* Cost column: right-aligned so the figures line up and the total reads. */
.table-wrap th:last-child,
.table-wrap td:last-child {
	text-align: right;
	padding-right: 0;
	white-space: nowrap;
}

.table-wrap tr:last-child td {
	border-bottom: 0;
	border-top: 1px solid var(--ink);
}

/* ---------- footnotes ---------- */

.fnref {
	font-size: 0.68em;
	line-height: 0;
	margin-left: 0.1em;
}

.fnref a {
	text-decoration: none;
	padding: 0 0.15em;
}

.footnotes {
	margin: 3rem 0 0;
	padding-top: 1.4rem;
	border-top: 1px solid var(--rule);
}

.footnotes h2 {
	font-family: var(--sans) !important;
	font-size: 0.7rem !important;
	text-transform: uppercase !important;
	letter-spacing: 0.14em !important;
	color: var(--muted) !important;
	margin: 0 0 1rem !important;
}

.footnotes ol {
	margin: 0;
	padding-left: 1.2rem;
	font-size: 0.92rem;
	color: var(--muted);
}

.footnotes li {
	margin: 0 0 0.8rem;
	padding-left: 0.2rem;
}

.footnotes li::marker {
	color: var(--accent);
	font-family: var(--sans);
	font-size: 0.8rem;
}

/* Jumping to a footnote should show you where you landed. */
.footnotes li:target,
sup.fnref:target {
	background: color-mix(in srgb, var(--accent) 16%, transparent);
	border-radius: 2px;
}

.fn-back {
	text-decoration: none;
	margin-left: 0.2em;
}

.post-foot {
	margin: 3rem 0 0;
	padding-top: 1.4rem;
	border-top: 1px solid var(--rule);
	font-family: var(--sans);
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.13em;
}

/* A reference to a post that does not exist yet. Deliberately renders as plain
   prose — a link to nowhere is worse than no link, for readers and for screen
   readers alike. `grep -rn 'class="pending"' site/` finds every one when the
   target finally goes up. */
.pending {
	color: inherit;
}

/* ---------- unlisted report pages (served at /r/<slug>/) ---------- */

/* The expiry line under the post meta. Small, but deliberately in the accent
   colour: a reader must be able to tell the page is temporary. The date sits
   inside <span id="page-expiry"> so the pages API can rewrite it. */
.expiry-note {
	margin: 0.9rem 0 0;
	font-family: var(--sans);
	font-size: 0.72rem;
	letter-spacing: 0.04em;
	color: var(--accent);
}

/* An image with its summary bullets beside it — the report "lead box".
   Rebuilt from the source's raw flex div by mdpost.py; widths and gaps live
   here, never in a style="" attribute (the CSP drops those silently). */
.lead-box {
	display: flex;
	gap: 1.4rem;
	align-items: flex-start;
	margin: 0 0 1.25rem;
}

.lead-box .fig {
	margin: 0;
	flex: 0 1 auto;
}

.lead-box ul {
	margin: 0;
	flex: 1 1 12rem;
}

/* ---------- entry lists that link somewhere ---------- */

.entries h3 a {
	text-decoration: none;
	color: var(--ink);
	border-bottom: 1px solid var(--rule);
	padding-bottom: 1px;
}

.entries h3 a:hover {
	color: var(--accent);
	border-bottom-color: var(--accent);
}

/* ---------- narrow screens ---------- */

@media (max-width: 44rem) {
	body.post .page {
		max-width: none;
	}

	body.post .content {
		max-width: none;
	}

	.post-header h1 {
		font-size: 1.72rem;
	}

	body.post article h2 {
		font-size: 1.24rem;
		margin-top: 2.3rem;
	}

	/* Figures go full width; the max-width classes would otherwise leave a
	   650px figure overflowing a 380px screen. */
	.fig-350,
	.fig-400,
	.fig-450,
	.fig-500,
	.fig-550,
	.fig-650,
	.fig-750 {
		max-width: 100%;
	}

	/* The lead box stacks: image above, bullets below. */
	.lead-box {
		flex-direction: column;
	}

	.table-wrap {
		font-size: 0.86rem;
	}
}
