/*
 * Based on stagit's stock style.css and shared by the blog and the git pages.
 * The top half is stagit's original rules; the bottom half adds what the blog needs.
 */

body {
	color: #000;
	background-color: #fff;
	/* Prefer well-hinted system monospace fonts; Windows falls back to Consolas, not Courier New. */
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
	font-size: 14px;
	line-height: 1.5;
	max-width: 880px;
	margin: 0 auto;
	padding: 16px;
}

h1, h2, h3, h4, h5, h6 {
	font-size: 1em;
	margin: 0;
}

img, h1, h2 {
	vertical-align: middle;
}

img {
	border: 0;
}

a:target {
	background-color: #ccc;
}

a.d,
a.h,
a.i,
a.line {
	text-decoration: none;
}

#blob a {
	color: #555;
}

#blob a:hover {
	color: blue;
	text-decoration: none;
}

table thead td {
	font-weight: bold;
}

table td {
	padding: 0.15em 0.6em;
}

#content {
	overflow-x: auto;
}

#content table td {
	vertical-align: top;
	white-space: nowrap;
}

#branches tr:hover td,
#tags tr:hover td,
#index tr:hover td,
#log tr:hover td,
#files tr:hover td,
#posts tr:hover td {
	background-color: #eee;
}

#index tr td:nth-child(2),
#tags tr td:nth-child(3),
#branches tr td:nth-child(3),
#log tr td:nth-child(2),
#posts tr td:nth-child(2) {
	white-space: normal;
}

td.num {
	text-align: right;
}

.desc {
	color: #555;
}

hr {
	border: 0;
	border-top: 1px solid #555;
	height: 1px;
	margin: 1.2em 0;
}

pre {
	font-family: inherit;
	line-height: 1.4;
	tab-size: 4;
}

pre a.h {
	color: #00a;
}

.A,
span.i,
pre a.i {
	color: #070;
}

.D,
span.d,
pre a.d {
	color: #e00;
}

pre a.h:hover,
pre a.i:hover,
pre a.d:hover {
	text-decoration: none;
}

/* ---- Blog-only rules ---- */

/* Keep the footer at the bottom of the window on short pages. */
body.site {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	min-height: 100vh;
	min-height: 100dvh;
}

body.site #content {
	flex: 1;
}

body.site #head {
	align-self: flex-start;
}

img.avatar {
	display: block;
	filter: grayscale(1);
}

#head td {
	vertical-align: middle;
	padding: 0.1em 0.6em;
}

#head td[rowspan] {
	padding-left: 0;
	padding-right: 1.5ch;
}

#head h1 {
	font-size: 1.3em;
	letter-spacing: 0.05em;
}

#cols {
	display: flex;
	gap: 6ch;
	align-items: flex-start;
}

#main {
	flex: 1;
	min-width: 0;
}

#side {
	flex: none;
	width: 40ch;
}

#side section + section {
	margin-top: 2em;
}

#main h2,
#side h2 {
	border-bottom: 1px dotted #555;
	padding-bottom: 0.2em;
	margin-bottom: 0.6em;
}

#side p {
	margin: 0;
}

#posts td:first-child {
	padding-left: 0;
}

#side table {
	border-collapse: collapse;
}

#side table td:first-child {
	padding-left: 0;
}

#side #recent td:last-child,
#side table td:last-child {
	white-space: normal;
}

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

ul.links li + li {
	margin-top: 0.3em;
}

/* Small monochrome icons that follow the link colour. */
svg.icon {
	width: 1em;
	height: 1em;
	margin-right: 1ch;
	vertical-align: -0.125em;
	fill: currentColor;
}

svg.icon.stroke {
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linejoin: round;
}

#main p {
	margin: 0;
}

.meta {
	margin: 0;
}

.post {
	max-width: 80ch;
	line-height: 1.6;
}

/* The post title outranks the headings inside the post. */
#main > h2 {
	font-size: 1.4em;
}

/* Heading scale inside a post: h1 1.28em with a solid rule, h2 1.16em with
   a dotted rule, h3 1.06em, h4-h6 body size in grey. */
.post h1,
#main .post h1 {
	font-size: 1.28em;
	margin: 2em 0 0.6em;
	border-bottom: 1px solid #555;
	padding-bottom: 0.2em;
}

.post h2,
#main .post h2,
#side .post h2 {
	font-size: 1.16em;
	margin: 1.8em 0 0.5em;
	border-bottom: 1px dotted #555;
	padding-bottom: 0.15em;
}

.post h3,
.post h4,
.post h5,
.post h6 {
	margin: 1.5em 0 0.4em;
}

.post h3 {
	font-size: 1.06em;
}

.post h4,
.post h5,
.post h6 {
	color: #555;
}

.post > :first-child {
	margin-top: 0;
}

.post img {
	max-width: 100%;
	height: auto;
}

.post table {
	border-collapse: collapse;
	margin: 1em 0;
}

.post th,
.post td {
	border: 1px solid #ccc;
	padding: 0.2em 0.8ch;
}

.post hr {
	border: 0;
	border-top: 1px dotted #555;
	margin: 2em 0;
}

.post pre {
	margin: 1em 0;
	padding: 0.7em 1.5ch;
	line-height: 1.45;
	overflow-x: auto;
	background-color: #f6f6f6;
	border-left: 2px solid #ccc;
}

/* Code colours (Pygments classes, written at publish time by the editor);
   same palette as the Git pages. */
.hl .k, .hl .kc, .hl .kd, .hl .kn, .hl .kp, .hl .kr, .hl .ow { color: #7433a8; }
.hl .kt, .hl .nc, .hl .nn, .hl .ne, .hl .nv, .hl .vi, .hl .vg, .hl .vc { color: #09647d; }
.hl .nf, .hl .fm, .hl .nb, .hl .bp, .hl .na, .hl .nt { color: #1455a2; }
.hl .s, .hl .s1, .hl .s2, .hl .sa, .hl .sb, .hl .sc, .hl .sd, .hl .se,
.hl .sh, .hl .si, .hl .sx, .hl .sr, .hl .ss, .hl .dl { color: #986000; }
.hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .mo, .hl .mb, .hl .il { color: #176b62; }
.hl .c, .hl .c1, .hl .cm, .hl .ch, .hl .cs, .hl .cpf { color: #697074; font-style: italic; }
.hl .cp, .hl .nd { color: #9d354b; }
.hl .gi { color: #00a000; }
.hl .gd { color: #b00000; }
.hl .gh, .hl .gu { color: #555; font-weight: bold; }

.post p code,
.post li code {
	background-color: #eee;
	padding: 0 0.2em;
}

.post blockquote {
	margin: 1em 0;
	padding-left: 2ch;
	border-left: 1px solid #555;
	color: #555;
}

.post ul,
.post ol {
	padding-left: 3ch;
}

/* ---- Post body typography ----
   Prose in posts is set in IBM Plex Sans (OFL, self-hosted under /fonts);
   headings, bylines, navigation and code keep the monospace look. */
@font-face {
	font-family: "IBM Plex Sans";
	font-style: normal;
	font-weight: 100 700;
	font-display: swap;
	src: url("/fonts/ibm-plex-sans-latin-wght-normal.woff2") format("woff2");
}

@font-face {
	font-family: "IBM Plex Sans";
	font-style: italic;
	font-weight: 100 700;
	font-display: swap;
	src: url("/fonts/ibm-plex-sans-latin-wght-italic.woff2") format("woff2");
}

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

.post {
	font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
	font-size: 15px;
	line-height: 1.7;
	overflow-wrap: break-word;
}

/* Code and headings stay monospace inside the sans prose. */
.post code,
.post pre,
.post kbd,
.post h1,
.post h2,
.post h3,
.post h4,
.post h5,
.post h6 {
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
}

.post code {
	font-size: 0.9em;
}

.post pre code {
	font-size: inherit;
}

.post pre {
	font-size: 13px;
}

#main .post p {
	margin: 0 0 1em;
}

.post ul,
.post ol {
	margin: 0 0 1em;
}

.post li + li {
	margin-top: 0.3em;
}

.post strong {
	font-weight: 600;
}

#main > p.desc {
	margin-bottom: 1.4em;
}

#footer {
	color: #555;
	text-align: center;
}

@media (max-width: 720px) {
	#cols {
		flex-direction: column;
		align-items: stretch;
	}
	#side {
		width: auto;
	}
}

@media (max-width: 600px) {
	#posts td:nth-child(3) {
		display: none;
	}
}

/* Phones: a little more room at the edges, a calmer title, bigger prose. */
@media (max-width: 600px) {
	body {
		padding: 14px 18px;
	}
	#main > h2 {
		font-size: 1.2em;
		line-height: 1.35;
	}
	.post {
		font-size: 16.5px;
		line-height: 1.65;
	}
	.post pre {
		font-size: 12.5px;
		margin-left: -18px;
		margin-right: -18px;
		padding-left: 18px;
		padding-right: 18px;
		border-left: 0;
	}
}

@media (prefers-color-scheme: dark) {
	body {
		background-color: #000;
		color: #bdbdbd;
	}
	hr {
		border-color: #222;
	}
	a {
		color: #56c8ff;
	}
	a:target {
		background-color: #222;
	}
	.desc,
	#footer,
	.post blockquote,
	.post h4,
	.post h5,
	.post h6 {
		color: #888;
	}
	.post h1,
	#main .post h1,
	.post h2,
	#main .post h2,
	#side .post h2,
	.post hr {
		border-color: #444;
	}
	.post th,
	.post td {
		border-color: #333;
	}
	.post pre {
		background-color: #0d0d0d;
		border-left-color: #333;
	}
	.post {
		color: #cfcfcf;
	}
	.hl .k, .hl .kc, .hl .kd, .hl .kn, .hl .kp, .hl .kr, .hl .ow { color: #c792ea; }
	.hl .kt, .hl .nc, .hl .nn, .hl .ne, .hl .nv, .hl .vi, .hl .vg, .hl .vc { color: #89c8f5; }
	.hl .nf, .hl .fm, .hl .nb, .hl .bp, .hl .na, .hl .nt { color: #82aaff; }
	.hl .s, .hl .s1, .hl .s2, .hl .sa, .hl .sb, .hl .sc, .hl .sd, .hl .se,
	.hl .sh, .hl .si, .hl .sx, .hl .sr, .hl .ss, .hl .dl { color: #d5c28f; }
	.hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .mo, .hl .mb, .hl .il { color: #89d0be; }
	.hl .c, .hl .c1, .hl .cm, .hl .ch, .hl .cs, .hl .cpf { color: #92999d; }
	.hl .cp, .hl .nd { color: #f08c8c; }
	.hl .gi { color: #00cd00; }
	.hl .gd { color: #cd0000; }
	.hl .gh, .hl .gu { color: #888; }
	#blob a {
		color: #555;
	}
	#blob a:target {
		color: #eee;
	}
	#blob a:hover {
		color: #56c8ff;
	}
	pre a.h {
		color: #00cdcd;
	}
	.A,
	span.i,
	pre a.i {
		color: #00cd00;
	}
	.D,
	span.d,
	pre a.d {
		color: #cd0000;
	}
	#branches tr:hover td,
	#tags tr:hover td,
	#index tr:hover td,
	#log tr:hover td,
	#files tr:hover td,
	#posts tr:hover td,
	.post p code,
	.post li code {
		background-color: #111;
	}
	.post blockquote {
		border-color: #444;
	}
}

/* ---- Git-site layout ---- */
/* Git pages share the blog header, typography and footer. */
/* Shared scrollbars also keep the blog and Git pages visually consistent. */
:root {
	--scrollbar-thumb: #aaa;
	--scrollbar-hover: #777;
}

::-webkit-scrollbar {
	width: 10px;
	height: 10px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
	background: transparent;
}

::-webkit-scrollbar-button {
	display: none;
}

::-webkit-scrollbar-thumb {
	background-color: var(--scrollbar-thumb);
	border: 2px solid transparent;
	border-radius: 6px;
	background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
	background-color: var(--scrollbar-hover);
}

@supports not selector(::-webkit-scrollbar) {
	html, #content, pre {
		scrollbar-width: thin;
		scrollbar-color: var(--scrollbar-thumb) transparent;
	}
}

@media (prefers-color-scheme: dark) {
	:root {
		--scrollbar-thumb: #444;
		--scrollbar-hover: #777;
	}
}

@media (forced-colors: active) {
	:root {
		--scrollbar-thumb: CanvasText;
		--scrollbar-hover: Highlight;
	}
}

.git-site a:focus-visible {
	outline: 1px dotted currentColor;
	outline-offset: 3px;
}

/* Syntax colours stay inside repository source and diffs. */
.git-site .syn-keyword { color: #7433a8; }
.git-site .syn-type { color: #09647d; }
.git-site .syn-function { color: #1455a2; }
.git-site .syn-string { color: #986000; }
.git-site .syn-number { color: #176b62; }
.git-site .syn-comment { color: #697074; }
.git-site .syn-preproc { color: #9d354b; }

.git-site pre a.i:has(.diff-code) { background-color: #edf8ef; }
.git-site pre a.d:has(.diff-code) { background-color: #fff0f0; }
.git-site .diff-code { color: #000; }

@media (prefers-color-scheme: dark) {
	.git-site .syn-keyword { color: #c792ea; }
	.git-site .syn-type { color: #89c8f5; }
	.git-site .syn-function { color: #82aaff; }
	.git-site .syn-string { color: #d5c28f; }
	.git-site .syn-number { color: #89d0be; }
	.git-site .syn-comment { color: #92999d; }
	.git-site .syn-preproc { color: #f08c8c; }
	.git-site pre a.i:has(.diff-code) { background-color: #102218; }
	.git-site pre a.d:has(.diff-code) { background-color: #291515; }
	.git-site .diff-code { color: #bdbdbd; }
}

.git-site #head nav {
	display: inline;
}

.git-site .git-section-title,
.git-site .repo-heading h2 {
	border-bottom: 1px dotted #555;
	padding-bottom: 0.2em;
	margin-bottom: 0.6em;
}

.git-site .repo-heading {
	margin-bottom: 1.5em;
}

.git-site .repo-heading p {
	margin: 0 0 0.6em;
}

.git-site .repo-nav a[aria-current="page"] {
	color: inherit;
	font-weight: bold;
	text-decoration: none;
}

.git-site .clone {
	margin: 1em 0 0;
	padding-left: 1.5ch;
	border-left: 1px solid #555;
	white-space: pre-wrap;
	overflow-wrap: anywhere;
	color: #555;
}

.git-site .clone .copy {
	float: right;
	margin-left: 1ch;
	padding: 0 1ch;
	border: 1px solid #555;
	background: transparent;
	color: inherit;
	font: inherit;
	cursor: pointer;
}

.git-site .snapshot,
.git-site a.raw,
.git-site a.dl {
	color: #555;
}

.git-site .snapshot a,
.git-site a.raw,
.git-site a.dl {
	color: inherit;
}

.git-site .snapshot {
	margin: 0 0 1.5em;
}

.git-site #content > h2 {
	margin: 1.5em 0 0.6em;
}

.git-site .readme {
	margin-bottom: 2em;
}

.git-site pre.readme {
	white-space: pre-wrap;
}

.git-site #index,
.git-site #log,
.git-site #files,
.git-site #branches,
.git-site #tags {
	border-collapse: collapse;
	width: 100%;
}

.git-site #content table td:first-child {
	padding-left: 0;
}

.git-site #content table td:last-child {
	padding-right: 0;
}

.git-site #content table thead td {
	padding-bottom: 0.65em;
	border-bottom: 1px dotted #555;
}

.git-site #content table tbody td {
	padding-top: 0.5em;
	padding-bottom: 0.5em;
}

.git-site #index td:nth-child(2) {
	width: 100%;
	color: #555;
}

@media (max-width: 600px) {
	.git-site #index td:nth-child(3),
	.git-site #log td:nth-child(n + 3) {
		display: none;
	}
	.git-site #index td:nth-child(4) {
		white-space: normal;
		min-width: 10ch;
	}
}

@media (prefers-color-scheme: dark) {
	.git-site .git-section-title,
	.git-site .repo-heading h2,
	.git-site #content table thead td,
	.git-site .clone {
		border-color: #444;
	}

	.git-site .clone .copy {
		border-color: #444;
	}

	.git-site .snapshot,
	.git-site a.raw,
	.git-site a.dl,
	.git-site .clone,
	.git-site #index td:nth-child(2) {
		color: #888;
	}
}
