/* The blog's one stylesheet. No fonts or files from anywhere else: it has to work from a folder, offline. */

:root {
	--bg: #faf9f7;
	--panel: #f1eff4;
	--ink: #201e26;
	--soft: #5f5c6b;
	--line: #dcd8e4;
	--accent: #5544bd;
	--accent-bg: #eceafa;
	--good: #2b7449;
	--good-bg: #e8f4ec;
	--try: #8a5f00;
	--try-bg: #fbf2dc;
	--c-comment: #777385;
	--c-string: #9a4b14;
	--c-number: #1b6a9c;
	--c-keyword: #7538b0;
	--c-func: #1f6b66;
	--c-type: #855600;
	--measure: 43rem;
	--wide: 62rem;
	--clip: 82rem;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #17161c;
		--panel: #211f29;
		--ink: #dddae6;
		--soft: #a19dae;
		--line: #35323f;
		--accent: #ad9eff;
		--accent-bg: #292640;
		--good: #72cf99;
		--good-bg: #1a2a21;
		--try: #e3b552;
		--try-bg: #2a2416;
		--c-comment: #8d899c;
		--c-string: #e5a370;
		--c-number: #7fc6ef;
		--c-keyword: #c79dff;
		--c-func: #80d2c9;
		--c-type: #e3c37c;
		color-scheme: dark;
	}
}

:root[data-theme="dark"] {
	--bg: #17161c;
	--panel: #211f29;
	--ink: #dddae6;
	--soft: #a19dae;
	--line: #35323f;
	--accent: #ad9eff;
	--accent-bg: #292640;
	--good: #72cf99;
	--good-bg: #1a2a21;
	--try: #e3b552;
	--try-bg: #2a2416;
	--c-comment: #8d899c;
	--c-string: #e5a370;
	--c-number: #7fc6ef;
	--c-keyword: #c79dff;
	--c-func: #80d2c9;
	--c-type: #e3c37c;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}

html {
	font-size: 106.25%;
	scroll-padding-top: 1rem;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	line-height: 1.65;
	-webkit-text-size-adjust: 100%;
}

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

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

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

code, pre, .file {
	font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---- the bar at the top */

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.7rem 1.5rem;
	border-bottom: 1px solid var(--line);
}

.site {
	color: var(--ink);
	font-weight: 650;
	text-decoration: none;
}

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

#theme {
	padding: 0.25rem 0.8rem;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: var(--panel);
	color: var(--ink);
	font: inherit;
	font-size: 0.82rem;
	cursor: pointer;
}

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

/* ---- the page: the list of posts beside the post */

.frame {
	display: grid;
	grid-template-columns: 16.5rem minmax(0, 1fr);
	gap: 3rem;
	max-width: 104rem;
	margin: 0 auto;
	padding: 0 1.5rem;
}

.home .frame {
	display: block;
	max-width: 49rem;
}

main {
	min-width: 0;
	padding: 2rem 0 4rem;
}

.series ol, .series ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.series.side {
	position: sticky;
	top: 0;
	align-self: start;
	max-height: 100vh;
	overflow-y: auto;
	padding: 2rem 0.4rem 2rem 0;
	font-size: 0.88rem;
	line-height: 1.35;
}

.series.small {
	display: none;
	margin-bottom: 1.5rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	font-size: 0.92rem;
}

.series.small summary {
	padding: 0.6rem 0.9rem;
	color: var(--soft);
	cursor: pointer;
}

.series.small ol {
	padding: 0 0.5rem 0.6rem;
}

.series ol > li > a {
	display: flex;
	gap: 0.6rem;
	padding: 0.38rem 0.6rem;
	border-radius: 6px;
	color: var(--ink);
	text-decoration: none;
}

.series ol > li > a:hover {
	background: var(--panel);
}

.series .n {
	flex: none;
	width: 1.4rem;
	color: var(--soft);
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.series li.done > a {
	color: var(--soft);
}

.series li.done .n::after {
	content: " ✓";
	color: var(--good);
}

.series li.done .n {
	width: 2.2rem;
	margin-left: -0.8rem;
}

.series li.here > a {
	background: var(--accent-bg);
	font-weight: 650;
}

.series li.here .n {
	color: var(--accent);
}

.series li.about {
	margin-top: 0.7rem;
	padding-top: 0.7rem;
	border-top: 1px solid var(--line);
}

.series li ul {
	margin: 0.25rem 0 0.6rem 2.6rem;
	border-left: 1px solid var(--line);
}

.series li ul a {
	display: block;
	padding: 0.22rem 0.7rem;
	color: var(--soft);
	text-decoration: none;
}

.series li ul a:hover {
	color: var(--accent);
}

/* ---- the post */

article > * {
	max-width: var(--measure);
}

article > figure.code,
article > .table,
article > ol.wide,
article > pre.sketch {
	max-width: var(--wide);
}

article > figure.clip {
	max-width: var(--clip);
}

.where {
	margin: 0 0 0.3rem;
	color: var(--accent);
	font-size: 0.8rem;
	font-weight: 650;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

h1 {
	margin: 0 0 1.4rem;
	font-size: 2.05rem;
	line-height: 1.2;
	letter-spacing: -0.01em;
}

h2 {
	margin: 2.8rem 0 0.8rem;
	padding-top: 1.2rem;
	border-top: 1px solid var(--line);
	font-size: 1.4rem;
	line-height: 1.3;
}

h3 {
	margin: 2rem 0 0.6rem;
	font-size: 1.12rem;
}

p, ul, ol, blockquote {
	margin: 0 0 1.05rem;
}

ul, ol {
	padding-left: 1.5rem;
}

li {
	margin: 0.3rem 0;
}

li > p {
	margin: 0.5rem 0;
}

li > ul, li > ol {
	margin: 0.3rem 0;
}

strong {
	font-weight: 650;
}

blockquote {
	margin-left: 0;
	padding: 0.1rem 0 0.1rem 1.1rem;
	border-left: 3px solid var(--accent);
	color: var(--soft);
	font-size: 1.05rem;
}

blockquote p:last-child {
	margin-bottom: 0;
}

code {
	padding: 0.08em 0.32em;
	border-radius: 4px;
	background: var(--panel);
	font-size: 0.86em;
}

h1 code, h2 code, h3 code {
	font-size: 0.9em;
}

/* ---- code */

figure {
	margin: 1.5rem 0;
}

figure.code figcaption {
	margin: 0 0 0.3rem 0.1rem;
	color: var(--soft);
	font-size: 0.78rem;
}

pre {
	margin: 0;
	padding: 0.85rem 1rem;
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: var(--panel);
	font-size: 0.8rem;
	line-height: 1.55;
	-moz-tab-size: 4;
	tab-size: 4;
}

pre code {
	padding: 0;
	background: none;
	font-size: inherit;
}

pre.sketch {
	margin: 1.3rem 0;
	border-style: dashed;
	background: none;
}

pre .c { color: var(--c-comment); font-style: italic; }
pre .s { color: var(--c-string); }
pre .n { color: var(--c-number); }
pre .k, pre .a { color: var(--c-keyword); }
pre .f { color: var(--c-func); }
pre .t { color: var(--c-type); }

/* ---- tables */

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

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9rem;
	line-height: 1.5;
}

th, td {
	padding: 0.5rem 0.75rem;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

th {
	border-bottom-width: 2px;
	color: var(--soft);
	font-size: 0.78rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	white-space: nowrap;
}

td:first-child, th:first-child {
	padding-left: 0.2rem;
}

/* ---- boxes */

.box {
	--c: var(--soft);
	margin: 1.7rem 0;
	padding: 0.9rem 1.15rem;
	border-left: 4px solid var(--c);
	border-radius: 0 8px 8px 0;
	background: var(--panel);
}

.box.goal {
	--c: var(--accent);
	background: var(--accent-bg);
}

.box.checkpoint {
	--c: var(--good);
	background: var(--good-bg);
}

.box.try {
	--c: var(--try);
	background: var(--try-bg);
}

.box .label {
	margin: 0 0 0.45rem;
	color: var(--c);
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

.box > :last-child {
	margin-bottom: 0;
}

.box code {
	background: color-mix(in srgb, var(--ink) 9%, transparent);
}

.box pre {
	background: var(--bg);
}

.box pre code {
	background: none;
}

/* ---- clips */

figure.clip {
	margin: 2rem 0;
}

figure.clip video {
	display: block;
	width: 100%;
	height: auto;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #111;
}

figure.clip figcaption {
	margin-top: 0.55rem;
	color: var(--soft);
	font-size: 0.9rem;
	line-height: 1.5;
}

figure.clip .tag {
	margin-right: 0.5rem;
	padding: 0.12rem 0.5rem;
	border-radius: 999px;
	background: var(--accent-bg);
	color: var(--accent);
	font-size: 0.74rem;
	font-weight: 650;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* ---- previous and next */

.pager {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 1rem;
	max-width: var(--measure);
	margin-top: 3.5rem;
}

.pager a {
	padding: 0.8rem 1rem;
	border: 1px solid var(--line);
	border-radius: 8px;
	color: var(--ink);
	font-weight: 650;
	line-height: 1.35;
	text-decoration: none;
}

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

.pager a span {
	display: block;
	margin-bottom: 0.15rem;
	color: var(--soft);
	font-size: 0.76rem;
	font-weight: 500;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}

.pager .next {
	text-align: right;
}

/* ---- the home page's list */

ul.posts {
	padding: 0;
	list-style: none;
}

ul.posts li {
	display: grid;
	grid-template-columns: 4.6rem minmax(0, 1fr);
	column-gap: 0.8rem;
	margin: 0;
	padding: 0.75rem 0;
	border-top: 1px solid var(--line);
}

ul.posts .n {
	grid-row: 1 / span 2;
	padding-top: 0.2rem;
	color: var(--soft);
	font-size: 0.76rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

ul.posts a {
	font-weight: 650;
	text-decoration: none;
}

ul.posts a:hover {
	text-decoration: underline;
}

ul.posts .count {
	margin-left: 0.6rem;
	padding: 0.1rem 0.5rem;
	border-radius: 999px;
	background: var(--accent-bg);
	color: var(--accent);
	font-size: 0.72rem;
	font-weight: 650;
	white-space: nowrap;
}

ul.posts .summary {
	display: block;
	grid-column: 2;
	color: var(--soft);
	font-size: 0.92rem;
	line-height: 1.5;
}

ul.posts div {
	grid-column: 2;
}

footer {
	margin-top: 2rem;
	padding: 1.3rem 1.5rem 2.5rem;
	border-top: 1px solid var(--line);
	color: var(--soft);
	font-size: 0.82rem;
}

footer p {
	max-width: 60rem;
	margin: 0 auto;
}

/* ---- narrow windows: the list folds away above the post */

@media (max-width: 62rem) {
	.frame {
		display: block;
		padding: 0 1.1rem;
	}

	.series.side {
		display: none;
	}

	.series.small {
		display: block;
	}

	main {
		padding-top: 1.2rem;
	}

	h1 {
		font-size: 1.7rem;
	}
}

@media print {
	.series, .pager, #theme, video {
		display: none !important;
	}

	.frame {
		display: block;
	}
}
