/* The site's theme: a light page in the look of a tokenizer view. Plain rules and
   thin lines, mint tokens for emphasis, and markdown marks on the headings. Tag
   selectors do most of the work; classes are for reusable components. */
:root {
	--font-main: ui-sans-serif, system-ui, sans-serif;
	--font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;

	--color-page: #fbfefc;
	--color-card: #fff;
	--color-ink: #10201a;
	--color-muted: #50645b;
	--color-rule: #dfeee6;
	--color-link: #0b6b48;
	--color-accent: #c9f2dc;
	--color-accent-strong: #0f8a5f;
	--color-code-bg: #f5faf7;

	--token-1: #c9f2dc;
	--token-2: #d3ecff;
	--token-3: #f4efb1;
	--token-4: #e4dcff;

	--space-xs: 0.25rem;
	--space-s: 0.5rem;
	--space-m: 1rem;
	--space-l: 1.5rem;
	--space-xl: 3rem;

	--page-width: 42rem;
	--border-card: 1px solid var(--color-rule);
	--shadow-card: none;
}

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

body {
	margin: 0;
	padding: 0 1.25rem;
	background: var(--color-page);
	color: var(--color-ink);
	font-family: var(--font-main);
	font-size: 1.0625rem;
	line-height: 1.7;
	overflow-wrap: break-word;
}

.site-header, main, .site-footer, .admin-banner {
	max-width: var(--page-width);
	margin-inline: auto;
}

h1, h2, h3, h4, h5, h6 {
	margin: 2rem 0 var(--space-s);
	color: var(--color-ink);
	font-weight: 700;
	letter-spacing: -0.025em;
	line-height: 1.15;
}

h1 { font-size: clamp(2.25rem, 6vw, 3rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.1875rem; }
h4, h5, h6 { font-size: 1.0625rem; }

/* Each heading shows its markdown mark. */
h1::before, h2::before, h3::before {
	color: var(--color-accent-strong);
	font-family: var(--font-mono);
	font-size: 0.6em;
	font-weight: 400;
	letter-spacing: 0;
	vertical-align: 0.12em;
}

h1::before { content: "# "; }
h2::before { content: "## "; }
h3::before { content: "### "; }

a {
	color: var(--color-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

a:hover {
	text-decoration-thickness: 2px;
}

img, video {
	max-width: 100%;
	height: auto;
}

code, pre, kbd {
	font-family: var(--font-mono);
}

/* Sections are separated by a rule, not boxed. */
main > article, main > section {
	margin-top: var(--space-xl);
}

main > * + section, main > * + article {
	padding-top: var(--space-xl);
	border-top: 1px solid var(--color-rule);
}

main > :first-child {
	margin-top: 2rem;
}

/* The title of a page, as opposed to a heading inside its text. */
.page-title, .entry-title {
	margin: 0 0 var(--space-m);
}

/* The home page's greeting, with a cursor waiting after it. */
main > section:first-child > .prose > h1 {
	margin-top: 0;
	font-size: clamp(2.75rem, 8vw, 4rem);
}

main > section:first-child > .prose > h1::after {
	content: "";
	display: inline-block;
	width: 0.09em;
	height: 0.9em;
	margin-left: 0.15em;
	background: var(--color-accent-strong);
	vertical-align: -0.08em;
	animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
	50% { opacity: 0; }
}

main > section:first-child > .prose > ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.1rem;
	padding: 0;
	font-family: var(--font-mono);
	font-size: 1rem;
	list-style: none;
}

main > section:first-child > .prose > ul li {
	padding: 0.05rem 0.4rem;
	border-radius: 0.25rem;
	background: var(--token-1);
}

main > section:first-child > .prose > ul li:nth-child(4n + 2) { background: var(--token-2); }
main > section:first-child > .prose > ul li:nth-child(4n + 3) { background: var(--token-3); }
main > section:first-child > .prose > ul li:nth-child(4n) { background: var(--token-4); }

/* Site header */
.site-header {
	position: relative;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-s);
	padding-top: var(--space-l);
}

.site-title {
	color: var(--color-ink);
	font-family: var(--font-mono);
	font-size: 0.9375rem;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
}

.site-title::before {
	content: "> ";
	color: var(--color-accent-strong);
}

.site-header ul {
	display: flex;
	align-items: center;
	gap: 0.15rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.nav-link {
	display: block;
	padding: 0.1rem var(--space-s);
	border-radius: 0.3rem;
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-size: 0.875rem;
	text-decoration: none;
}

.nav-link:hover {
	background: var(--token-2);
	color: var(--color-ink);
}

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

/* One menu for wide screens, and one that opens with no script for narrow ones. */
.nav-wide {
	display: none;
}

.nav-menu summary {
	display: block;
	line-height: 0;
	cursor: pointer;
	list-style: none;
}

.nav-menu summary::-webkit-details-marker {
	display: none;
}

.nav-menu svg {
	width: 1.5rem;
	height: 1.5rem;
	fill: none;
	stroke: var(--color-ink);
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2.5;
}

.nav-menu .icon-close, .nav-menu[open] .icon-open {
	display: none;
}

.nav-menu[open] .icon-close {
	display: block;
}

.nav-menu ul {
	position: absolute;
	top: 100%;
	right: 0;
	display: grid;
	gap: var(--space-xs);
	width: 12rem;
	margin-top: var(--space-s);
	padding: 0.75rem;
	border: var(--border-card);
	border-radius: var(--space-s);
	background: var(--color-card);
}

/* Text written by the author */
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote, .prose figure {
	margin-block: var(--space-m);
}

.prose ul, .prose ol, main > section > ul:not([class]) {
	padding-left: 1.5em;
}

.prose li {
	padding-left: 0.25em;
}

.prose li::marker {
	color: var(--color-accent-strong);
}

.prose img {
	display: block;
	width: auto;
	max-height: 33vh;
	margin-inline: auto;
	border-radius: 0.5rem;
	cursor: zoom-in;
}

.prose blockquote {
	margin-inline: 0;
	padding-left: var(--space-m);
	border-left: 2px solid var(--color-accent-strong);
	color: var(--color-muted);
}

.prose hr {
	margin-block: var(--space-xl);
	border: 0;
	border-top: 1px solid var(--color-rule);
}

.prose :not(pre) > code {
	padding: 0.05em 0.3em;
	border-radius: 0.25rem;
	background: var(--token-3);
	font-size: 0.875em;
	overflow-wrap: anywhere;
}

.prose pre {
	position: relative;
	padding: var(--space-m);
	overflow-x: auto;
	border: var(--border-card);
	border-radius: var(--space-s);
	font-size: 0.8125rem;
	line-height: 1.65;
}

.prose pre, .chroma {
	background: var(--color-code-bg) !important;
}

.prose table {
	display: block;
	max-width: 100%;
	overflow-x: auto;
	border-collapse: collapse;
	font-size: 1rem;
}

.prose th, .prose td {
	padding: var(--space-s) 0.75rem;
	border-bottom: 1px solid var(--color-rule);
	text-align: left;
}

.prose del, .prose s {
	color: var(--color-muted);
}

/* A post's header */
.entry-header {
	display: flex;
	flex-direction: column;
	gap: var(--space-l);
	align-items: flex-start;
}

.entry-dates, .book-authors {
	margin: 0.75rem 0 0;
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-size: 0.8125rem;
}

.book-cover {
	display: block;
	width: auto;
	max-height: 250px;
	border-radius: var(--space-xs);
}

.now-credit {
	margin-top: var(--space-l);
	padding-top: var(--space-m);
	border-top: 1px solid var(--color-rule);
	color: var(--color-muted);
	font-size: 0.875rem;
}

.now-credit p {
	margin: 0;
}

/* Tags */
.tag-list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.15rem;
	margin: var(--space-s) 0;
	padding: 0;
	list-style: none;
}

.tag {
	display: inline-block;
	padding: 0.05rem 0.4rem;
	border-radius: 0.25rem;
	background: var(--token-1);
	color: var(--color-ink);
	font-family: var(--font-mono);
	font-size: 0.8125rem;
	text-decoration: none;
}

.tag:hover {
	outline: 1.5px solid var(--color-accent-strong);
}

.tag-list li:nth-child(4n + 2) .tag { background: var(--token-2); }
.tag-list li:nth-child(4n + 3) .tag { background: var(--token-3); }
.tag-list li:nth-child(4n) .tag { background: var(--token-4); }

/* Rows of posts and links */
.post-list, .link-list, .search-hits {
	margin: 0;
	padding: 0;
	list-style: none;
}

.post-list {
	container-type: inline-size;
}

.post-list a {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: var(--space-xs);
	padding: 0.4rem var(--space-s);
	border-radius: 0.35rem;
	color: var(--color-ink);
	text-decoration: none;
}

.post-list a:hover { background: var(--token-1); }
.post-list li:nth-child(4n + 2) a:hover { background: var(--token-2); }
.post-list li:nth-child(4n + 3) a:hover { background: var(--token-3); }
.post-list li:nth-child(4n) a:hover { background: var(--token-4); }

.post-list time, .search-hits small, .link-author {
	flex-shrink: 0;
	color: var(--color-muted);
	font-family: var(--font-mono);
	font-size: 0.8125rem;
}

.post-list a:hover time {
	color: var(--color-ink);
}

@container (min-width: 32rem) {
	.post-list a {
		flex-direction: row;
		align-items: baseline;
		gap: var(--space-m);
	}
}

.link-list > li, .search-hits li {
	scroll-margin-top: var(--space-m);
	padding: 0.75rem 0;
}

.link-list > li + li, .search-hits li + li {
	border-top: 1px solid var(--color-rule);
}

.link-list > li:target {
	margin-inline: calc(-1 * var(--space-s));
	padding-inline: var(--space-s);
	border-radius: 0.35rem;
	background: var(--color-accent);
}

.link-list > li > a, .search-hits a {
	font-weight: 600;
}

.link-author {
	display: block;
}

/* Journal prompts */
figure {
	margin: var(--space-l) 0;
}

figure blockquote {
	margin: 0;
	padding-left: var(--space-m);
	border-left: 2px solid var(--color-accent-strong);
}

figure blockquote ol {
	margin: 0;
	padding-left: 1.25em;
}

figure blockquote p {
	margin: 0;
}

figcaption {
	margin-top: var(--space-s);
	color: var(--color-muted);
	font-size: 0.875rem;
}

/* Explore */
.card-grid {
	display: grid;
	gap: var(--space-s);
	margin: 0;
	padding: 0;
	list-style: none;
}

.card-grid a {
	display: block;
	height: 100%;
	padding: 0.75rem var(--space-m);
	border: var(--border-card);
	border-radius: var(--space-s);
	color: var(--color-ink);
	text-decoration: none;
}

.card-grid a:hover {
	border-color: var(--color-accent-strong);
	background: var(--color-accent);
}

.card-grid strong {
	display: block;
	font-weight: 600;
}

.card-grid span {
	display: block;
	color: var(--color-muted);
	font-size: 0.875rem;
}

/* Forms */
.contact-form, .search-form {
	display: grid;
	gap: var(--space-m);
	margin-block: var(--space-m);
}

.contact-form label, .search-form label {
	display: grid;
	gap: var(--space-xs);
	font-weight: 600;
}

/* 16px or more, so iOS does not zoom on focus. */
.contact-form input, .contact-form textarea, .search-form input {
	width: 100%;
	padding: var(--space-s);
	border: 1px solid var(--color-muted);
	border-radius: 0.35rem;
	background: var(--color-card);
	font: inherit;
	font-size: 1rem;
	font-weight: 400;
}

.contact-form textarea {
	min-height: 10rem;
}

.contact-form button, .search-form button {
	justify-self: start;
	padding: 0.35rem var(--space-m);
	border: 1px solid var(--color-accent-strong);
	border-radius: 0.35rem;
	background: var(--color-accent);
	color: var(--color-ink);
	font-family: var(--font-mono);
	font-size: 1rem;
	cursor: pointer;
}

.contact-form button:hover, .search-form button:hover {
	background: var(--token-3);
}

.field-error {
	color: #a30000;
	font-size: 0.875rem;
	font-weight: 600;
}

/* Hidden from people, who never see or fill the honeypot field. Bots that fill
   every field get the same answer, with nothing stored. */
.contact-hp {
	position: absolute;
	left: -10000px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* Search results */
.search-hits small {
	display: block;
}

.search-hits p {
	margin: var(--space-xs) 0 0;
}

/* Footer */
.site-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-top: 4rem;
	padding-block: var(--space-l) var(--space-xl);
	border-top: 1px solid var(--color-rule);
}

.site-footer p {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 0.875rem;
}

.site-footer p::after {
	content: " ▍";
	color: var(--color-accent-strong);
}

.site-footer ul {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-footer img {
	display: block;
	width: 88px;
	height: 31px;
	image-rendering: pixelated;
}

/* Shown only to a logged-in admin */
.admin-banner {
	margin-top: var(--space-s);
	padding: var(--space-xs) var(--space-s);
	border-radius: 0.35rem;
	background: var(--color-accent);
	font-size: 0.875rem;
}

/* A message body wraps rather than scrolling sideways. */
.message-body {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}

/* Error pages */
.error-page {
	margin-top: var(--space-l);
}

/* Copy buttons on code blocks, added by site.js */
.copy-btn {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	display: flex;
	align-items: center;
	padding: 5px;
	border: 1px solid transparent;
	border-radius: 4px;
	background: transparent;
	color: currentcolor;
	opacity: 0.3;
	cursor: pointer;
	transition: all 200ms ease;
}

.copy-btn:hover, .copy-btn:focus-visible {
	border-color: rgb(0 0 0 / 10%);
	background: rgb(0 0 0 / 5%);
	opacity: 1;
}

.copy-btn.copied {
	color: var(--color-accent-strong);
	opacity: 1;
}

/* Image lightbox, added by site.js */
#lightbox {
	position: fixed;
	inset: 0;
	z-index: 1000;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgb(0 0 0 / 85%);
	cursor: zoom-out;
	backdrop-filter: blur(4px);
}

#lightbox.open {
	display: flex;
}

#lightbox img {
	max-width: calc(100dvw - 32px);
	max-height: calc(100dvh - 32px);
	border-radius: 4px;
	object-fit: contain;
}

body:has(#lightbox.open) {
	overflow: hidden;
}

@media (min-width: 40rem) {
	.entry-header:has(.book-cover) {
		flex-direction: row;
	}

	.card-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 48rem) {
	.nav-wide {
		display: block;
	}

	.nav-menu {
		display: none;
	}
}

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

	main > section:first-child > .prose > h1::after {
		animation: none;
	}
}
