/* microbook. Override anything in your own CSS linked from SUMMARY.md or a page. */

:root {
	color-scheme: light dark;
	--text: light-dark(#1f2328, #e3e6ea);
	--muted: light-dark(#59636e, #949ba4);
	--bg: light-dark(#fff, #17191d);
	--bg-alt: light-dark(#f3f5f7, #22252b);
	--border: light-dark(#d8dee4, #353a42);
	--link: light-dark(#0969da, #58a6ff);
	--note: light-dark(#0969da, #4493f8);
	--tip: light-dark(#1a7f37, #3fb950);
	--important: light-dark(#8250df, #ab7df8);
	--warning: light-dark(#9a6700, #d29922);
	--caution: light-dark(#cf222e, #f85149);
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
	--sidebar: 17rem;
	--content: 46rem;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: 1rem;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

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

/* Layout: header, toolbar, sidebar, content, footer. The page itself scrolls. */

body {
	display: grid;
	grid-template: "header header" "aside menu" "aside main" 1fr "aside footer" / var(--sidebar) minmax(0, 1fr);
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	font: 1rem/1.6 var(--font);
	color: var(--text);
	background: var(--bg);
	overflow-wrap: break-word;
}
body:not(:has(> aside)) { grid-template-columns: 0 minmax(0, 1fr); }
body > header { grid-area: header; }
body > menu { grid-area: menu; }
body > aside { grid-area: aside; }
body > main { grid-area: main; }
body > footer { grid-area: footer; }

body > header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5rem 1.5rem;
	padding: .75rem 1.5rem;
	border-bottom: 1px solid var(--border);
}
body > header > * { margin: 0; }
body > header > :is(ul, ol):last-child { margin-left: auto; }
body > header > :is(.center, :has(> .center)) { flex: 1; }
body > header :is(ul, ol) { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; padding: 0; list-style: none; }
body > header li { margin: 0; }
body > header :is(h1, h2, h3, h4, h5, h6) { margin: 0; font-size: 1.125rem; }
body > header a { color: inherit; text-decoration: none; }
body > header a:hover, body > header a[aria-current] { color: var(--link); }
body > header img { vertical-align: middle; }

body > footer {
	padding: 1.5rem;
	border-top: 1px solid var(--border);
	font-size: .875rem;
	color: var(--muted);
	text-align: center;
}
body > footer > * { margin: .25rem 0; }
body > footer a { color: inherit; }
body > footer a:hover { color: var(--link); }
body > footer :is(ul, ol) { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.25rem; padding: 0; list-style: none; }
body > footer li { margin: 0; }

/* Toolbar */

body > menu { display: flex; align-items: center; gap: .5rem; margin: 0; padding: .75rem 1rem; list-style: none; }
body > menu > li:has(search) { margin-left: auto; }
body > menu button {
	display: grid;
	padding: .375rem;
	border: 0;
	border-radius: .375rem;
	color: var(--muted);
	background: none;
	cursor: pointer;
}
body > menu button:hover { color: var(--text); background: var(--bg-alt); }
body > menu svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
search label {
	display: flex;
	align-items: center;
	gap: .375rem;
	padding: .25rem .75rem;
	border: 1px solid var(--border);
	border-radius: 1rem;
	color: var(--muted);
}
search label:focus-within { border-color: var(--link); }
search svg { flex: none; width: 1rem !important; height: 1rem !important; }
search input { width: 7rem; padding: 0; border: 0; outline: 0; font: inherit; font-size: .875rem; color: var(--text); background: none; transition: width .2s; }
search input:focus { width: 14rem; }

/* Sidebar: SUMMARY.md, usually a table of contents but any content works */

body > aside {
	position: sticky;
	top: 0;
	align-self: start;
	max-height: calc(100vh - var(--header-visible, 0px));
	max-height: calc(100dvh - var(--header-visible, 0px));
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 1.25rem 1.5rem 2rem;
	font-size: .9375rem;
	line-height: 1.45;
}
body > aside > :first-child { margin-top: 0; }
body > aside > :last-child { margin-bottom: 0; }
/* The dividing line spans the whole sidebar column, however short the sidebar is */
body:has(> aside)::before { content: ""; grid-area: aside; border-right: 1px solid var(--border); }
body > aside :is(ul, ol) { margin: 0; padding: 0; list-style: none; }
body > aside ol { padding-left: 1em; list-style: decimal; }
body > aside ol > li::marker, body > aside span[data-sidebar-number] { color: color-mix(in srgb, var(--muted) 75%, var(--bg)); font-size: .9em; font-weight: normal; }
body > aside li > :is(ul, ol) { margin: .125rem 0 .25rem; padding-left: .5rem; }
body > aside li > ol { padding-left: 1.75em; }
body > aside ol[data-sidebar-number] { padding-left: 0; }
body > aside li > ol[data-sidebar-number] { padding-left: .5rem; }
body > aside ol > li[data-sidebar-number] { list-style: none; }
body > aside span[data-sidebar-number] { white-space: pre; }
body > aside ol[data-sidebar-number] > li:has(> input[type="checkbox"]:first-child, > p:first-child > input[type="checkbox"]:first-child) { padding-left: 1.4em; }
body > aside li { margin: .0625rem 0; }
body > aside li > p { margin: 0; }
/* A table of contents entry is a link at the start of a list item; other links stay ordinary inline links */
body > aside :where(li, li > p) > a:first-child { display: block; margin: 0 -.5rem; padding: .25rem .5rem; border-radius: .375rem; color: inherit; text-decoration: none; }
body > aside ol:not([data-sidebar-number]) > li > a:first-child, body > aside ol:not([data-sidebar-number]) > li > p > a:first-child { margin-left: calc(-1em - .5rem); padding-left: calc(1em + .5rem); }
body > aside :where(li, li > p) > a:first-child:hover { color: var(--link); }
body > aside a[aria-current="page"] { color: var(--link); background: var(--bg-alt); font-weight: 500; }
/* [Chapter](): a chapter not written yet */
body > aside a:not([href]), body > aside li:has(> a:not([href]))::marker, body > aside a:not([href]) > span[data-sidebar-number] { color: color-mix(in srgb, var(--muted) 55%, var(--bg)); }
body > aside :is(h1, h2, h3, h4, h5, h6) { margin: 1.5rem 0 .375rem; font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
body > aside h1 { font-size: 1.0625rem; letter-spacing: 0; text-transform: none; color: var(--text); }
body > aside :is(h1, h2, h3, h4, h5, h6) a { color: inherit; text-decoration: none; }
body > aside :is(p, figure, blockquote, details, pre) { margin: .75rem 0; }
body > aside hr { margin: 1rem 0; }
body > aside summary { padding: .25rem 0; }
body > aside img { max-width: 100%; }

/* Content */

body > main { width: 100%; max-width: var(--content); margin: 0 auto; padding: 0 1.5rem 4rem; }
main > :first-child { margin-top: .5rem; }

h1, h2, h3, h4, h5, h6 { margin: 2.25rem 0 1rem; font-weight: normal; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; margin-top: 2rem; margin-bottom: .75rem; }
h4 { font-size: 1rem; margin-top: 1.75rem; margin-bottom: .5rem; }
h5, h6 { font-size: .875rem; margin-top: 1.5rem; margin-bottom: .5rem; }
h6 { color: var(--muted); }
:is(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6) { margin-top: 1rem; }
:is(h1, h2, h3, h4, h5, h6)[id] > a[href^="#"]:only-child { color: inherit; text-decoration: none; }
:is(h1, h2, h3, h4, h5, h6)[id] > a[href^="#"]:only-child::after { content: "#"; margin-left: .3em; color: var(--muted); opacity: 0; transition: opacity .2s; }
:is(h1, h2, h3, h4, h5, h6)[id]:hover > a[href^="#"]:only-child::after { opacity: 1; }

p, ul, ol, dl, pre, table, blockquote, figure, details { margin: 1rem 0; }
p { text-wrap: pretty; }
.center { display: block; text-align: center; }

a { color: var(--link); text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-color: currentColor; }

ul, ol { padding-left: 1.75em; }
li > :is(ul, ol) { margin: .25rem 0; }
li + li { margin-top: .25rem; }
li > p { margin: .5rem 0; }
li:has(> input[type="checkbox"]:first-child, > p:first-child > input[type="checkbox"]:first-child) { list-style: none; }
li > input[type="checkbox"]:first-child, li > p:first-child > input[type="checkbox"]:first-child { margin: 0 .3em 0 -1.4em; vertical-align: -.1em; }

dt { font-weight: 600; }
dd { margin: 0 0 .5rem 1.5em; }

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

blockquote { padding: 0 0 0 1rem; border-left: .25rem solid var(--border); color: var(--muted); }
:is(blockquote, details, li, td, th, figure) > :first-child { margin-top: 0; }
:is(blockquote, details, li, td, th, figure) > :last-child { margin-bottom: 0; }

/* Alerts: > [!NOTE] and friends, shown by color and icon only */
blockquote:is(.note, .tip, .important, .warning, .caution) {
	position: relative;
	padding: .75rem 1rem .75rem 2.75rem;
	border-left-color: var(--color);
	border-radius: 0 .375rem .375rem 0;
	color: var(--text);
	background: color-mix(in srgb, var(--color) 8%, transparent);
}
blockquote:is(.note, .tip, .important, .warning, .caution)::before {
	content: "";
	position: absolute;
	top: calc(.75rem + .3em);
	left: .875rem;
	width: 1rem;
	height: 1rem;
	background: var(--color);
	mask: var(--icon) center / contain no-repeat;
}
blockquote.note { --color: var(--note); --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='8' cy='8' r='6.75'/><path d='M8 7.5v3.75M8 4.75v.01'/></svg>"); }
blockquote.tip { --color: var(--tip); --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M6 12.75h4M6.75 15h2.5M8 1a4.75 4.75 0 0 0-2.9 8.5c.55.43.9 1 .9 1.7v.3h4v-.3c0-.7.35-1.27.9-1.7A4.75 4.75 0 0 0 8 1z'/></svg>"); }
blockquote.important { --color: var(--important); --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M2.75 1.75h10.5a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H8.5l-3.25 2.5v-2.5h-2.5a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1z'/><path d='M8 4.5v3.25M8 9.75v.01'/></svg>"); }
blockquote.warning { --color: var(--warning); --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M7.13 1.75a1 1 0 0 1 1.74 0l6.28 11a1 1 0 0 1-.87 1.5H1.72a1 1 0 0 1-.87-1.5z'/><path d='M8 6v3.25M8 11.5v.01'/></svg>"); }
blockquote.caution { --color: var(--caution); --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M5.1 1.25h5.8l3.85 3.85v5.8l-3.85 3.85H5.1l-3.85-3.85V5.1z'/><path d='M8 4.75v3.5M8 11v.01'/></svg>"); }

/* Code */
code, kbd, samp, pre { font-family: var(--mono); }
:not(pre) > code { padding: .15em .35em; border-radius: .3em; font-size: .875em; background: var(--bg-alt); }
kbd { padding: .1em .4em; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: .3em; font-size: .8em; }
pre { position: relative; font-size: .875rem; line-height: 1.5; border-radius: .5rem; background: var(--bg-alt); tab-size: 4; }
pre > code { display: block; overflow-x: auto; padding: 1rem 1.25rem; }
pre:not(:has(> code)) { overflow-x: auto; padding: 1rem 1.25rem; }
pre > button {
	position: absolute;
	top: .5rem;
	right: .5rem;
	width: 2rem;
	height: 2rem;
	border: 1px solid var(--border);
	border-radius: .375rem;
	color: var(--muted);
	background: var(--bg);
	cursor: pointer;
	opacity: 0;
	transition: opacity .2s;
}
pre:hover > button, pre > button:focus-visible, pre > button.copied { opacity: 1; }
@media (hover: none) { pre > button { opacity: 1; } }
pre > button:hover { color: var(--text); }
pre > button.copied { color: var(--tip); }
pre > button::before {
	content: "";
	display: block;
	width: 1rem;
	height: 1rem;
	margin: auto;
	background: currentColor;
	mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'><rect x='5.25' y='5.25' width='9' height='9' rx='1.5'/><path d='M10.75 5.25v-2a1.5 1.5 0 0 0-1.5-1.5h-6a1.5 1.5 0 0 0-1.5 1.5v6a1.5 1.5 0 0 0 1.5 1.5h2'/></svg>") center / contain no-repeat;
}
pre > button.copied::before { mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><path d='M2.75 8.5l3.5 3.5 7-8'/></svg>"); }

/* Syntax highlighting (highlight.js classes) */
.hljs-comment, .hljs-quote { color: var(--muted); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-template-tag, .hljs-meta .hljs-keyword { color: light-dark(#cf222e, #ff7b72); }
.hljs-string, .hljs-regexp, .hljs-meta .hljs-string, .hljs-char { color: light-dark(#0a3069, #a5d6ff); }
.hljs-number, .hljs-literal, .hljs-variable, .hljs-template-variable, .hljs-attr, .hljs-attribute, .hljs-symbol, .hljs-bullet, .hljs-link, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id, .hljs-selector-pseudo { color: light-dark(#0550ae, #79c0ff); }
.hljs-title, .hljs-section { color: light-dark(#8250df, #d2a8ff); }
.hljs-type, .hljs-built_in, .hljs-title.class_, .hljs-meta { color: light-dark(#953800, #ffa657); }
.hljs-name, .hljs-tag { color: light-dark(#116329, #7ee787); }
.hljs-addition { color: light-dark(#116329, #aff5b4); background: light-dark(#dafbe1, #033a16); }
.hljs-deletion { color: light-dark(#82071e, #ffdcd7); background: light-dark(#ffebe9, #67060c); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* Tables */
table { display: block; width: max-content; max-width: 100%; margin-inline: auto; overflow-x: auto; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: .4rem .75rem; border: 1px solid var(--border); text-align: start; vertical-align: top; }
th { font-weight: 600; background: var(--bg-alt); }
.clean :is(th, td) { border-inline: 0; }
.clean th { background: none; border-bottom-width: 2px; }

/* Images and media: centered when standing alone, zoomed on click */
img, video, iframe { max-width: 100%; }
figure { text-align: center; }
figure > * { vertical-align: middle; }
figcaption { margin-top: .5rem; font-size: .875rem; color: var(--muted); }
img.left, img.right { display: block; }
img.left { margin-right: auto; }
img.right { margin-left: auto; }
main img { transition: transform .3s; }
main img:not(a img) { cursor: zoom-in; }
main :has(img.zoomed) { overflow: visible !important; } /* tables and other scrolling blocks would clip the zoomed image */
main img.zoomed { position: relative; z-index: 10; cursor: zoom-out; background: var(--bg); box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 92%, transparent); }
@media (prefers-reduced-motion: reduce) { main img { transition: none; } }

/* GitHub's images for one theme: ![](image.png#gh-dark-mode-only) */
:root[data-theme="light"] img[src$="#gh-dark-mode-only"], :root[data-theme="dark"] img[src$="#gh-light-mode-only"] { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) img[src$="#gh-dark-mode-only"] { display: none; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) img[src$="#gh-light-mode-only"] { display: none; } }

/* Other text elements */
mark { color: inherit; background: light-dark(#fff3b0, #5c4a00); }
sub, sup { line-height: 0; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
summary { cursor: pointer; }
details[open] > summary { margin-bottom: .5rem; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: .25rem 0; }
.footnotes-sep { margin-top: 3rem; }
.footnotes { font-size: .875rem; color: var(--muted); }
.footnote-ref a { text-decoration: none; }

/* Narrow screens: the sidebar slides over the content */

@media (max-width: 50rem) {
	body { grid-template-columns: 0 minmax(0, 1fr); }
	body::before { display: none; }
	body > header { padding: .625rem 1rem; }
	body > menu { padding: .5rem .75rem; }
	body > main { padding: 0 1rem 3rem; }
	body > aside {
		display: none;
		position: fixed;
		inset: 0 auto 0 0;
		align-self: stretch;
		z-index: 20;
		width: min(var(--sidebar), 85vw);
		max-height: none;
		padding-inline: 1rem;
		background: var(--bg);
		box-shadow: 0 0 2rem rgb(0 0 0 / .3);
	}
	.sidebar-open body > aside { display: block; }
	search input:focus { width: 9rem; }
}
@media (min-width: 50.01rem) {
	.sidebar-hidden body { grid-template-columns: 0 minmax(0, 1fr); }
	.sidebar-hidden body > aside, .sidebar-hidden body::before { display: none; }
}

/* Print: only the content, in black on white */

@media print {
	:root, :root[data-theme] { color-scheme: light; }
	@page { margin: 2cm 1.8cm; }
	body { display: block; font-size: 11pt; line-height: 1.5; }
	body > :is(header, menu, aside, footer), body::before, pre > button { display: none !important; }
	body > main { max-width: none; padding: 0; }
	a { color: inherit; text-decoration: none; }
	a[data-href]::after { content: " (" attr(data-href) ")"; font-size: .85em; color: var(--muted); overflow-wrap: anywhere; }
	:is(h1, h2, h3, h4, h5, h6)[id] > a::after { display: none; }
	h1, h2, h3, h4, h5, h6, p:has(+ :is(pre, figure, table)) { break-after: avoid; }
	pre, blockquote, figure, tr, img, .katex-display { break-inside: avoid; }
	p, li { orphans: 3; widows: 3; }
	pre > code { white-space: pre-wrap; overflow: visible; }
	table { display: table; width: auto; overflow: visible; }
	pre, blockquote, :not(pre) > code, mark { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
	main img.zoomed { transform: none !important; box-shadow: none; }
	.katex-display { overflow: visible; }
}
