/* aaronwells.me: "The Clipping". Tokens first, then layers. */

@layer reset, tokens, base, layout, components, utilities;

@layer tokens {
	:root {
		color-scheme: light dark;

		--paper: oklch(97.5% 0.008 85);
		--paper-2: oklch(94.5% 0.012 85);
		--ink: oklch(22% 0.012 60);
		--ink-2: oklch(42% 0.014 60);
		--rule: oklch(84% 0.012 80);
		--accent: oklch(50% 0.17 264);
		--signal: oklch(66% 0.16 48);
		--card: oklch(98.5% 0.006 85);

		--font-text: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
		--font-display: "Gambetta", "Newsreader", "Iowan Old Style", Georgia, serif;
		--font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

		--fs-body: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
		--fs-small: clamp(0.95rem, 0.9rem + 0.2vw, 1.05rem);
		--fs-label: clamp(0.72rem, 0.68rem + 0.15vw, 0.8rem);
		--fs-h1: clamp(2.5rem, 1.6rem + 4vw, 4.25rem);
		--fs-dek: clamp(1.2rem, 1.05rem + 0.7vw, 1.55rem);
		--fs-quote: clamp(1.3rem, 1.1rem + 0.9vw, 1.9rem);
		--fs-h2: clamp(1.5rem, 1.3rem + 0.9vw, 2rem);

		--measure: 62ch;
		--lh: 1.55;

		--s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.5rem;
		--s-6: 2rem; --s-7: 3rem; --s-8: 4rem; --s-9: 6rem; --s-10: 8rem;

		--radius: 2px;
		--dur-fast: 160ms;
		--dur-entry: 600ms;
		--ease: cubic-bezier(.2, .7, .2, 1);
		--gutter: clamp(1rem, 4vw, 3rem);
	}

	@media (prefers-color-scheme: dark) {
		:root:not([data-theme="light"]) {
			--paper: oklch(21% 0.012 70);
			--paper-2: oklch(26% 0.012 70);
			--ink: oklch(91% 0.01 85);
			--ink-2: oklch(72% 0.012 85);
			--rule: oklch(36% 0.012 70);
			--accent: oklch(74% 0.12 264);
			--signal: oklch(74% 0.14 48);
			--card: oklch(97.5% 0.008 85);
		}
	}
	:root[data-theme="light"] { color-scheme: light; }
	:root[data-theme="dark"] {
		color-scheme: dark;
		--paper: oklch(21% 0.012 70);
		--paper-2: oklch(26% 0.012 70);
		--ink: oklch(91% 0.01 85);
		--ink-2: oklch(72% 0.012 85);
		--rule: oklch(36% 0.012 70);
		--accent: oklch(74% 0.12 264);
		--signal: oklch(74% 0.14 48);
		--card: oklch(97.5% 0.008 85);
	}
}

@layer reset {
	*, *::before, *::after { box-sizing: border-box; }
	* { margin: 0; }
	html { -webkit-text-size-adjust: 100%; hanging-punctuation: first last; }
	img, picture, svg { display: block; max-width: 100%; height: auto; }
	h1, h2, h3, p, blockquote, figure, dl, dd { overflow-wrap: break-word; }
	button { font: inherit; }
}

@font-face {
	font-family: "Newsreader";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url("../fonts/newsreader-normal-400-700.c6082d41da.woff2") format("woff2");
}
@font-face {
	font-family: "Newsreader";
	font-style: italic;
	font-weight: 400 700;
	font-display: swap;
	src: url("../fonts/newsreader-italic-400-700.c3586e7c5b.woff2") format("woff2");
}
@font-face {
	font-family: "Gambetta";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("../fonts/gambetta-normal-500.e55e2245cb.woff2") format("woff2");
}
@font-face {
	font-family: "Gambetta";
	font-style: italic;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/gambetta-italic-400.64846263db.woff2") format("woff2");
}
@font-face {
	font-family: "IBM Plex Mono";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url("../fonts/plexmono-normal-400.08949f728d.woff2") format("woff2");
}
@font-face {
	font-family: "IBM Plex Mono";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url("../fonts/plexmono-normal-500.01d2854474.woff2") format("woff2");
}

@layer base {
	html { background: var(--paper); }
	body {
		background: var(--paper);
		color: var(--ink);
		font-family: var(--font-text);
		font-size: var(--fs-body);
		line-height: var(--lh);
		font-optical-sizing: auto;
		font-kerning: normal;
		font-variant-numeric: oldstyle-nums proportional-nums;
		text-rendering: optimizeLegibility;
		min-height: 100svh;
	}
	::selection { background: var(--signal); color: var(--paper); }

	h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.08; letter-spacing: -0.012em; text-wrap: balance; }
	h1 { font-size: var(--fs-h1); }
	h2 { font-size: var(--fs-h2); }
	p { text-wrap: pretty; max-width: var(--measure); }
	p + p { margin-block-start: 1em; }

	a {
		color: var(--accent);
		text-decoration: underline;
		text-decoration-thickness: 1px;
		text-underline-offset: 0.16em;
		text-decoration-color: color-mix(in oklch, var(--accent) 55%, transparent);
		transition: text-decoration-color var(--dur-fast) var(--ease), text-decoration-thickness var(--dur-fast) var(--ease);
	}
	a:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
	a:focus-visible, button:focus-visible {
		outline: 2px solid var(--signal);
		outline-offset: 3px;
		border-radius: var(--radius);
	}

	.skip {
		position: absolute; inset-inline-start: var(--s-4); top: -100%;
		background: var(--ink); color: var(--paper); padding: var(--s-2) var(--s-4);
		font-family: var(--font-mono); font-size: var(--fs-label); z-index: 10;
	}
	.skip:focus { top: var(--s-4); }

	.label {
		font-family: var(--font-mono);
		font-size: var(--fs-label);
		font-weight: 500;
		letter-spacing: 0.08em;
		text-transform: uppercase;
		color: var(--ink-2);
		font-variant-numeric: lining-nums;
	}
	.small { font-size: var(--fs-small); color: var(--ink-2); }
	.mono { font-family: var(--font-mono); font-variant-numeric: lining-nums; }
}

@layer layout {
	.page { padding-inline: var(--gutter); max-width: 96rem; margin-inline: auto; }

	.folio {
		display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4);
		padding-block: var(--s-4);
		border-block-end: 1px solid var(--ink);
	}
	.folio a { color: inherit; text-decoration: none; }
	.folio a:hover { text-decoration: underline; }
	.folio { flex-wrap: wrap; }
	.nav { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-5); }
	.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.35em; text-decoration-thickness: 1px; }
	/* theme switch: shown only when the script is running */
	.theme { display: none; gap: 0; border: 1px solid var(--rule); border-radius: var(--radius); }
	.js .theme { display: inline-flex; }
	.theme button {
		font: inherit; font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase;
		background: none; border: 0; color: var(--ink-2); padding: 0.35em 0.7em; cursor: pointer;
	}
	.theme button + button { border-inline-start: 1px solid var(--rule); }
	.theme button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
	.theme button:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; position: relative; z-index: 1; }
	.folio-right { display: flex; flex-wrap: wrap; gap: var(--s-4) var(--s-6); align-items: center; }
	@media (max-width: 55.99rem) {
		.folio-right { display: contents; }
		.folio .theme { order: 2; margin-inline-start: auto; }
		.folio .nav { order: 3; flex-basis: 100%; gap: var(--s-3) var(--s-4); }
	}
	.theme-switching * { transition: none !important; }
	@view-transition { navigation: auto; }

	.grid {
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		column-gap: var(--s-6);
	}
	.grid > * { grid-column: 1 / -1; }
	main.grid { padding-block-end: var(--s-9); }

	/* Wide: 12 columns, marginalia in 1 to 3, text in 4 to 10 */
	@media (min-width: 56rem) {
		.grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
		.grid > .text { grid-column: 4 / 11; }
		.grid > .margin { grid-column: 1 / 4; }
		.grid > .full { grid-column: 1 / -1; }
	}
	@media (min-width: 80rem) {
		.grid > .text { grid-column: 4 / 10; }
	}

	.hero { padding-block: var(--s-7) var(--s-6); }
	.hero .kicker { margin-block-end: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
	.hero h1 { max-width: 16ch; }
	.hero .dek {
		margin-block-start: var(--s-5);
		font-family: var(--font-display);
		font-size: var(--fs-dek);
		line-height: 1.3;
		font-style: italic;
		font-weight: 400;
		color: var(--ink-2);
		max-width: 38ch;
		text-wrap: balance;
	}

	@media (min-width: 56rem) {
		.hero { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--s-6); align-items: center; }
		.hero .portrait { margin-block: 0; }
		.hero .intro { grid-column: 1 / 9; }
		.hero .portrait { grid-column: 9 / 13; }
	}

	section.part {
		border-block-start: 1px solid var(--rule);
		padding-block: var(--s-7);
	}
	/* newspaper column rule between marginalia and text on wide screens */
	@media (min-width: 56rem) {
		section.part > .text { border-inline-start: 1px solid var(--rule); padding-inline-start: var(--s-6); margin-inline-start: calc(-1 * var(--s-6)); }
	}
	section.part > .margin { margin-block-end: var(--s-5); }
	@media (min-width: 56rem) {
		section.part > .margin { margin-block-end: 0; position: sticky; top: var(--s-6); align-self: start; }
	}

	footer.colophon {
		border-block-start: 1px solid var(--ink);
		padding-block: var(--s-6) var(--s-8);
		display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-4);
		font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2);
		letter-spacing: 0.02em;
	}
	footer.colophon a { color: inherit; }
}

@layer components {
	/* Portrait: a paper disc with a hairline ring, both modes */
	.portrait {
		margin-block: var(--s-6) 0;
		max-width: min(15rem, 50vw);
	}
	.portrait figure { display: grid; justify-items: start; }
	.portrait img {
		width: 100%;
		aspect-ratio: 1;
		object-fit: cover;
		border-radius: 50%;
		background: var(--card);
		box-shadow: 0 0 0 1px var(--rule), 0 0 0 5px var(--paper), 0 0 0 6px var(--rule);
	}
	.portrait figcaption {
		font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2);
		margin-block-start: var(--s-4); letter-spacing: 0.02em;
	}

	@media (prefers-reduced-motion: no-preference) {
		.portrait img {
			transition: opacity var(--dur-entry) var(--ease), translate var(--dur-entry) var(--ease);
			@starting-style { opacity: 0; translate: 0 0.5rem; }
		}
	}

	/* Drop cap on the opener */
	.opener > p:first-of-type::first-letter {
		float: left;
		font-size: 4.6em;
		line-height: 0.78;
		padding-inline-end: 0.08em;
		padding-block-start: 0.06em;
		font-weight: 500;
		font-family: var(--font-text);
	}
	@supports (initial-letter: 3) {
		.opener > p:first-of-type::first-letter {
			float: none; font-size: inherit; line-height: inherit; padding: 0;
			initial-letter: 3;
			margin-inline-end: 0.1em;
		}
	}

	/* Section label in the margin */
	.part-label { display: flex; flex-direction: column; gap: var(--s-2); }
	.part-label .num { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2); }

	/* Pull quote in the margin */
	.pull {
		margin-block: var(--s-6) 0;
		padding-block-start: var(--s-4);
		border-block-start: 2px solid var(--ink);
		border-block-end: 1px solid var(--rule);
		padding-block-end: var(--s-4);
		font-family: var(--font-display);
		font-size: var(--fs-quote);
		line-height: 1.2;
		font-style: italic;
		font-weight: 400;
		text-wrap: balance;
		max-width: 20ch;
	}
	.pull cite {
		display: block; margin-block-start: var(--s-3);
		font-style: normal; font-family: var(--font-mono); font-size: var(--fs-label);
		color: var(--ink-2); letter-spacing: 0.04em; text-transform: uppercase;
	}

	/* Contact */
	.contact dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-3) var(--s-5); max-width: var(--measure); }
	.contact dt { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding-block-start: 0.35em; }
	.contact dd { margin: 0; }

	.button {
		display: inline-block;
		margin-block-start: var(--s-5);
		padding: 0.6em 1.1em;
		background: var(--ink);
		color: var(--paper);
		text-decoration: none;
		border-radius: var(--radius);
		font-family: var(--font-mono);
		font-size: var(--fs-label);
		letter-spacing: 0.08em;
		text-transform: uppercase;
		transition: background var(--dur-fast) var(--ease);
	}
	.button:hover { background: var(--accent); color: var(--paper); text-decoration: none; }
	.button:active { translate: 0 1px; }

	/* Inline list (cities, outlets) */
	.inline-list { display: inline; }
	.inline-list li { display: inline; }
	.inline-list li:not(:last-child)::after { content: ", "; }

	/* Prose block */
	.prose > * + * { margin-block-start: 1em; }
	.prose h2 { margin-block-start: var(--s-6); margin-block-end: var(--s-3); }

	/* Not-found */
	.notfound { padding-block: var(--s-10) var(--s-9); }
	.notfound h1 { max-width: 14ch; }
	.notfound p { margin-block-start: var(--s-5); }

	/* Figures: three textures. Wide (full width), boxed (in the text column), pair (two up) */
	.figure { margin: 0; }
	.figure figcaption {
		font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2); letter-spacing: 0.02em;
		margin-block-start: var(--s-3); max-width: 70ch; line-height: 1.5;
	}
	.figure img { width: 100%; height: auto; background: var(--paper-2); }
	.figure-row { padding-block: var(--s-6) var(--s-8); }
	.figure-wide img { aspect-ratio: 3 / 2; object-fit: cover; }
	.figure-boxed { margin-block: var(--s-7); max-width: 34rem; background: var(--card); border: 1px solid var(--rule); padding: var(--s-4); }
	.figure-boxed img { background: var(--card); }
	.figure-boxed figcaption { color: oklch(42% 0.014 60); }
	.figure-pair { display: grid; gap: var(--s-4); margin-block: var(--s-7) var(--s-4); }
	@media (min-width: 40rem) { .figure-pair { grid-template-columns: 1fr 1fr; } .figure-pair figcaption { grid-column: 1 / -1; } }
	.figure-pair img { aspect-ratio: 3 / 2; object-fit: cover; }

	/* The map: a data graphic in the margin */
	.map { margin-block-start: var(--s-7); max-width: 20rem; }
	.map svg { width: 100%; height: auto; font-family: var(--font-mono); font-size: 24px; }
	.map .cities circle { r: 5; }
	.map .cities circle.far { r: 4; }
	.map .counties path { fill: var(--paper-2); stroke: var(--paper); stroke-width: 1.2; }
	.map .counties path.served { fill: color-mix(in oklch, var(--ink) 18%, var(--paper)); }
	.map .cities circle.near { fill: var(--ink); }
	.map .cities circle.far { fill: none; stroke: var(--ink); stroke-width: 1.2; }
	.map .cities text { fill: var(--ink-2); letter-spacing: 0.04em; }
	.map figcaption { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2); margin-block-start: var(--s-3); line-height: 1.5; }

	/* Secondary pages */
	.doc h1 { margin-block-end: var(--s-5); }
	.doc h2 { margin-block-start: var(--s-7); }
	.doc h3 { font-family: var(--font-text); font-size: var(--fs-body); font-weight: 600; margin-block-start: var(--s-5); margin-block-end: var(--s-2); }
	.doc ul, .doc ol { padding-inline-start: 1.25em; max-width: var(--measure); }
	.doc li + li { margin-block-start: 0.4em; }
	.doc dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-2) var(--s-5); max-width: var(--measure); }
	.doc dl.facts dt { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); padding-block-start: 0.4em; }
	.doc dl.facts dd { margin: 0; }
	.doc .byline { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); margin-block-end: var(--s-5); }
	.doc blockquote.spec { border-inline-start: 2px solid var(--ink); padding-inline-start: var(--s-4); margin-block: var(--s-5); font-style: italic; }
	.posts { list-style: none; padding: 0; max-width: var(--measure); }
	.posts li { border-block-start: 1px solid var(--rule); padding-block: var(--s-5); }
	.posts h2 { margin: 0 0 var(--s-2); font-size: var(--fs-h2); font-family: var(--font-display); }
	.posts .meta { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
	.now-date { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
	.downloads { list-style: none; padding: 0; display: grid; gap: var(--s-3); max-width: var(--measure); }
	.downloads li { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: baseline; }
	.downloads .small { color: var(--ink-2); }
	.bio-block { background: var(--paper-2); border-inline-start: 2px solid var(--rule); padding: var(--s-4) var(--s-5); margin-block: var(--s-4); max-width: var(--measure); }
	.bio-block .label { margin-block-end: var(--s-2); }

	/* Contact form */
	.form { display: grid; gap: var(--s-5); max-width: var(--measure); margin-block-start: var(--s-5); }
	.field { display: grid; gap: var(--s-2); }
	.field label { font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
	.field input, .field textarea {
		font: inherit; color: var(--ink); background: var(--paper-2);
		border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.6em 0.75em; width: 100%;
	}
	.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-color: var(--ink); }
	.field textarea { min-height: 10rem; resize: vertical; }
	.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
	.notice { border-inline-start: 2px solid var(--signal); padding: var(--s-3) var(--s-4); background: var(--paper-2); max-width: var(--measure); }
	button.button { border: 0; cursor: pointer; }

	/* Style guide bits */
	.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s-4); list-style: none; padding: 0; }
	.swatches li { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
	.swatches .chip { height: 4rem; }
	.swatches .meta { padding: var(--s-2) var(--s-3); font-family: var(--font-mono); font-size: var(--fs-label); }
	.specimen { border-block-start: 1px solid var(--rule); padding-block: var(--s-4); }
	.specimen + .specimen { margin-block-start: var(--s-4); }
	.states { display: flex; flex-wrap: wrap; gap: var(--s-4); align-items: center; }
	.button[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
}

@layer utilities {
	.visually-hidden {
		position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
		overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
	}
	.mt-0 { margin-block-start: 0; }
	.m-0 { margin: 0; }
	.mt-section { margin-block-start: var(--s-7); }
	.c-paper { background: var(--paper); } .c-paper-2 { background: var(--paper-2); } .c-ink { background: var(--ink); }
	.c-ink-2 { background: var(--ink-2); } .c-rule { background: var(--rule); } .c-accent { background: var(--accent); }
	.c-signal { background: var(--signal); } .c-card { background: var(--card); }
	.button.is-hover { background: var(--accent); }
	.button.is-focus { outline: 2px solid var(--signal); outline-offset: 3px; }
	.dek-specimen { font-family: var(--font-display); font-size: var(--fs-dek); font-style: italic; color: var(--ink-2); }
}

@media print {
	.folio, .button, .skip { display: none; }
	body { background: #fff; color: #000; }
}
