/* ------------------------------------------------------------------ tokens */

:root {
	--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

	--bg: #faf9f7;
	--text: #1c2126;
	--muted: #647079;
	--accent: #0e7a67;
	--border: #e5e2dc;
	--code-bg: #f1efeb;
	--tag-bg: #e9f2ef;

	--tok-comment: #8a939b;
	--tok-keyword: #a4366f;
	--tok-string: #276f4e;
	--tok-function: #205ea6;
	--tok-number: #a35200;

	color-scheme: light;
}

[data-theme="dark"] {
	--bg: #0e1216;
	--text: #d9e0e6;
	--muted: #8b96a0;
	--accent: #35d0ad;
	--border: #242c34;
	--code-bg: #151b21;
	--tag-bg: #16241f;

	--tok-comment: #6b7681;
	--tok-keyword: #e083b0;
	--tok-string: #7fc79c;
	--tok-function: #7fb3e8;
	--tok-number: #e0a468;

	color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0e1216;
		--text: #d9e0e6;
		--muted: #8b96a0;
		--accent: #35d0ad;
		--border: #242c34;
		--code-bg: #151b21;
		--tag-bg: #16241f;

		--tok-comment: #6b7681;
		--tok-keyword: #e083b0;
		--tok-string: #7fc79c;
		--tok-function: #7fb3e8;
		--tok-number: #e0a468;

		color-scheme: dark;
	}
}

/* -------------------------------------------------------------------- base */

* {
	box-sizing: border-box;
}

body {
	margin: 0 auto;
	padding: 0 1.25rem;
	max-width: 44rem;
	font-family: var(--font-body);
	font-size: 1.0625rem;
	line-height: 1.65;
	background: var(--bg);
	color: var(--text);
}

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

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

h1, h2, h3, h4 {
	line-height: 1.25;
	margin: 2em 0 0.5em;
}

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

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

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

.site-header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.75rem 1.5rem;
	padding: 2rem 0 2.5rem;
}

.wordmark {
	font-family: var(--font-mono);
	font-size: 1.2rem;
	font-weight: 700;
	color: var(--text);
	text-decoration: none;
}

.wordmark .cursor {
	display: inline-block;
	width: 0.55em;
	height: 1.05em;
	margin-left: 0.15em;
	vertical-align: text-bottom;
	background: var(--accent);
	animation: blink 1.2s steps(2, start) infinite;
}

@keyframes blink {
	to { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
	.wordmark .cursor { animation: none; }
}

.site-nav {
	display: flex;
	align-items: baseline;
	gap: 1rem;
	margin-left: auto;
	font-family: var(--font-mono);
	font-size: 0.85rem;
}

.site-nav a {
	color: var(--muted);
	text-decoration: none;
}

.site-nav a:hover {
	color: var(--accent);
	text-decoration: underline;
}

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

#nav-toggle {
	display: none;
	border: 0;
	padding: 0;
	background: none;
	margin-left: auto;
	font-family: var(--font-mono);
	font-size: 0.85rem;
	color: var(--muted);
	cursor: pointer;
}

#nav-toggle:hover {
	color: var(--accent);
}

#nav-toggle::before { content: "["; }
#nav-toggle::after { content: "]"; }

.nav-label-close { display: none; }

#nav-toggle[aria-expanded="true"] .nav-label-open { display: none; }
#nav-toggle[aria-expanded="true"] .nav-label-close { display: inline; }

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

/* Collapse the nav behind the [menu] toggle on narrow screens.
   Gated on .js so the plain wrapped nav remains without JavaScript. */
@media (max-width: 38rem) {
	.js #nav-toggle {
		display: block;
	}

	.js .site-nav {
		display: none;
		flex-basis: 100%;
		flex-direction: column;
		align-items: flex-start;
		gap: 0.9rem;
		margin: 0.75rem 0 0;
		padding-top: 1rem;
		border-top: 1px solid var(--border);
		font-size: 0.95rem;
	}

	.js .site-nav.open {
		display: flex;
	}
}

#theme-toggle {
	border: 0;
	padding: 0;
	background: none;
	font: inherit;
	color: var(--muted);
	cursor: pointer;
}

#theme-toggle:hover {
	color: var(--accent);
}

#theme-toggle::before { content: "["; }
#theme-toggle::after { content: "]"; }

/* Button names the theme you'd switch to */
.theme-icon-light { display: none; }
.theme-icon-dark { display: inline; }

[data-theme="dark"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: none; }

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .theme-icon-light { display: inline; }
	:root:not([data-theme="light"]) .theme-icon-dark { display: none; }
}

/* --------------------------------------------------------------- post list */

.post-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.post-list li {
	display: grid;
	grid-template-columns: 8.5rem 1fr;
	gap: 0.2rem 1.25rem;
	padding: 1.1rem 0;
	border-top: 1px solid var(--border);
}

.post-list li:last-child {
	border-bottom: 1px solid var(--border);
}

.post-list-meta {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
	font-family: var(--font-mono);
	font-size: 0.8rem;
	color: var(--muted);
	padding-top: 0.3rem;
}

.post-list-title {
	font-size: 1.15rem;
	font-weight: 650;
	color: var(--text);
	text-decoration: none;
}

.post-list-title:hover {
	color: var(--accent);
	text-decoration: underline;
}

.post-list-description {
	margin: 0.25rem 0 0;
	color: var(--muted);
	font-size: 0.95rem;
}

.post-list-tags {
	margin: 0.5rem 0 0;
}

@media (max-width: 38rem) {
	.post-list li {
		grid-template-columns: 1fr;
	}
	.post-list-meta {
		flex-direction: row;
		gap: 0.75rem;
		padding-top: 0;
	}
}

.tag {
	font-family: var(--font-mono);
	font-size: 0.78rem;
	color: var(--accent);
	background: var(--tag-bg);
	padding: 0.1em 0.5em;
	border-radius: 3px;
	text-decoration: none;
	margin-right: 0.35rem;
}

.tag:hover {
	text-decoration: underline;
}

/* ---------------------------------------------------------- featured cards */

.featured-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin-bottom: 1rem;
}

.featured-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
	text-decoration: none;
	color: var(--text);
	background: var(--code-bg);
}

.featured-card:hover {
	border-color: var(--accent);
}

.featured-card img {
	width: 100%;
	aspect-ratio: 2 / 1;
	object-fit: cover;
	border-radius: 0;
	display: block;
}

.featured-card-body {
	display: flex;
	flex-direction: column;
	flex: 1;
	gap: 0.35rem;
	padding: 0.9rem 1rem 1rem;
}

.featured-card-title {
	font-weight: 650;
	line-height: 1.35;
}

.featured-card:hover .featured-card-title {
	color: var(--accent);
}

.featured-card-description {
	font-size: 0.88rem;
	color: var(--muted);
}

.featured-card-meta {
	font-family: var(--font-mono);
	font-size: 0.75rem;
	color: var(--muted);
	margin-top: auto;
	padding-top: 0.35rem;
}

@media (max-width: 38rem) {
	.featured-grid {
		grid-template-columns: 1fr;
	}
}

/* ---------------------------------------------------------- section titles */

.section-title {
	font-family: var(--font-mono);
	font-size: 1rem;
	font-weight: 700;
	color: var(--muted);
	margin: 2.5rem 0 1rem;
}

.section-title::before {
	content: "## ";
	color: var(--accent);
}

.more-link {
	font-family: var(--font-mono);
	font-size: 0.85rem;
	display: inline-block;
	margin-top: 1.25rem;
}

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

.post-header h1 {
	margin: 0 0 0.5rem;
	font-size: 2rem;
	letter-spacing: -0.015em;
}

.post-meta {
	font-family: var(--font-mono);
	font-size: 0.82rem;
	color: var(--muted);
	margin: 0 0 2.5rem;
}

.post-banner {
	margin: 0 0 2.5rem;
}

.post-banner img {
	width: 100%;
	border-radius: 8px;
	display: block;
}

.post-banner figcaption {
	font-family: var(--font-mono);
	font-size: 0.75rem;
	color: var(--muted);
	margin-top: 0.5rem;
}

.post h2::before,
.post h3::before {
	font-family: var(--font-mono);
	color: var(--accent);
	font-weight: 700;
}

.post h2::before { content: "## "; }
.post h3::before { content: "### "; }

.post blockquote {
	margin: 1.5rem 0;
	padding: 0.1rem 1.25rem;
	border-left: 3px solid var(--accent);
	background: var(--code-bg);
	border-radius: 0 4px 4px 0;
	color: var(--muted);
}

.post table {
	border-collapse: collapse;
	width: 100%;
	font-size: 0.95rem;
	margin: 1.5rem 0;
}

.post th, .post td {
	border: 1px solid var(--border);
	padding: 0.4rem 0.75rem;
	text-align: left;
}

.post th {
	font-family: var(--font-mono);
	font-size: 0.82rem;
	background: var(--code-bg);
}

/* -------------------------------------------------------------------- code */

code {
	font-family: var(--font-mono);
	font-size: 0.86em;
	background: var(--code-bg);
	border: 1px solid var(--border);
	border-radius: 3px;
	padding: 0.1em 0.35em;
}

pre {
	background: var(--code-bg);
	border: 1px solid var(--border);
	border-radius: 6px;
	padding: 1rem 1.25rem;
	overflow-x: auto;
	line-height: 1.55;
	margin: 1.5rem 0;
}

pre code {
	background: none;
	border: 0;
	padding: 0;
	font-size: 0.85rem;
}

.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--tok-comment); }
.token.keyword, .token.tag, .token.selector, .token.important, .token.atrule { color: var(--tok-keyword); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.inserted { color: var(--tok-string); }
.token.function, .token.class-name, .token.attr-name, .token.property { color: var(--tok-function); }
.token.number, .token.boolean, .token.constant, .token.symbol, .token.deleted { color: var(--tok-number); }
.token.operator, .token.punctuation { color: var(--muted); }

/* -------------------------------------------------------------- pagination */

.post-pagination {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	margin: 3rem 0;
}

.post-pagination a {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	padding: 0.85rem 1rem;
	border: 1px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	text-decoration: none;
	font-size: 0.92rem;
}

.post-pagination a:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.post-pagination a span {
	font-family: var(--font-mono);
	font-size: 0.75rem;
	color: var(--muted);
}

.post-pagination .newer {
	text-align: right;
	grid-column: 2;
}

@media (max-width: 38rem) {
	.post-pagination {
		grid-template-columns: 1fr;
	}
	.post-pagination .newer {
		grid-column: 1;
		text-align: left;
	}
}

/* ----------------------------------------------------------------- archive */

.archive-year {
	font-family: var(--font-mono);
	font-size: 1.05rem;
	color: var(--muted);
	margin: 2.5rem 0 0.5rem;
}

.archive-year::before {
	content: "## ";
	color: var(--accent);
}

.tag-cloud {
	list-style: none;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
}

.tag-cloud .tag {
	font-size: 0.9rem;
	margin: 0;
}

.tag-cloud .count {
	color: var(--muted);
}

/* ---------------------------------------------------------------- portrait */

.portrait,
.portrait img {
	width: 9.5rem;
	height: 9.5rem;
	border-radius: 50%;
	object-fit: cover;
}

picture:has(> .portrait),
img.portrait {
	float: right;
	margin: 0.25rem 0 1rem 1.5rem;
	shape-outside: circle(50%);
}

/* On phones, skip the picture and keep just the text */
@media (max-width: 38rem) {
	picture:has(> .portrait),
	img.portrait {
		display: none;
	}
}

/* ------------------------------------------------------------------ footer */

.site-footer {
	margin-top: 4rem;
	padding: 1.5rem 0 2.5rem;
	border-top: 1px solid var(--border);
	font-family: var(--font-mono);
	font-size: 0.8rem;
	color: var(--muted);
}

.site-footer a {
	color: var(--muted);
}

.site-footer a:hover {
	color: var(--accent);
}
