/* Rendered Markdown: text at a reading measure, centred in the space it's
   shown in so wide screens don't leave it off to one side, headings
   stepping down from the page's, and code on the page's background, where
   its colours keep 4.5:1. */
.markdown {
	max-width: 920px;
	margin-inline: auto;
	font-size: 15px;
	line-height: 1.6;
	overflow-wrap: break-word;
}

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

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

.markdown :is(p, ul, ol, blockquote, pre, .md-table, .md-html, details) {
	margin: 0 0 var(--s4);
}

.markdown :is(h2, h3, h4, h5, h6) {
	margin: var(--s6) 0 var(--s3);
	line-height: 1.3;
}

.markdown .md-h1 {
	padding-bottom: var(--s2);
	border-bottom: 1px solid var(--hairline);
	font-size: 28px;
}

.markdown .md-h2 {
	padding-bottom: var(--s2);
	border-bottom: 1px solid var(--hairline);
	font-size: 22px;
}

.markdown .md-h3 {
	font-size: 18px;
}

.markdown :is(.md-h4, .md-h5, .md-h6) {
	font-size: 15px;
}

.markdown :is(p, li, td, th, blockquote) a {
	--underline-rest: var(--border);
}

.markdown :is(ul, ol) {
	padding-left: var(--s5);
}

.markdown li + li,
.markdown li > :is(ul, ol) {
	margin-top: var(--s1);
}

.markdown li > :is(ul, ol) {
	margin-bottom: 0;
}

/* Task lists: M3's checkbox, read-only, where the bullet would be, so
   nested lists keep their steps in. 18px, a 2px outline in the muted
   colour, and checked, filled with the accent and a check in its ink. */
.markdown .md-task {
	list-style: none;
}

.markdown .md-check {
	appearance: none;
	display: inline-block;
	width: 18px;
	height: 18px;
	margin: 0 6px 0 -24px;
	vertical-align: -3px;
	border: 2px solid var(--muted);
	border-radius: 2px;
	background: transparent;
	opacity: 1;
}

.markdown .md-check:checked {
	border-color: var(--accent);
	background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23272e33' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat;
}

html[data-theme="light"]:not([data-browser="ladybird"]) .markdown .md-check:checked {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fffbef' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* A heading's link to its section, shown as the heading is pointed at or
   the link focused, and always where nothing hovers. */
.markdown .md-anchor {
	display: inline-flex;
	align-items: center;
	margin-left: var(--s2);
	padding: 2px;
	vertical-align: middle;
	border: 0;
	border-radius: 4px;
	background: none;
	color: var(--ink-quiet);
	opacity: 0;
	transition: opacity 150ms var(--ease-effects);
}

.markdown .md-anchor svg {
	width: 0.75em;
	height: 0.75em;
}

.markdown :is(h2, h3, h4, h5, h6):hover .md-anchor,
.markdown .md-anchor:focus-visible {
	opacity: 1;
}

@media (hover: none) {
	.markdown .md-anchor {
		opacity: 0.7;
	}
}

/* GitHub's alerts: a tinted block with a rule in its colour, and a title
   in the colour where that reads at 4.5:1 (the ink tokens, page.css). */
.markdown .md-alert {
	--alert: var(--blue);
	--alert-ink: var(--ink-info);
	margin: 0 0 var(--s4);
	padding: var(--s2) var(--s4) var(--s3);
	border-left: 3px solid var(--alert);
	border-radius: 0 var(--s2) var(--s2) 0;
	background: color-mix(in srgb, var(--alert) 6%, transparent);
}

.markdown .md-alert-tip {
	--alert: var(--green);
	--alert-ink: var(--ink-add);
}

.markdown .md-alert-important {
	--alert: var(--purple);
	--alert-ink: var(--purple);
}

.markdown .md-alert-warning {
	--alert: var(--yellow);
	--alert-ink: var(--ink-change);
}

.markdown .md-alert-caution {
	--alert: var(--red);
	--alert-ink: var(--ink-del);
}

html[data-theme="light"]:not([data-browser="ladybird"]) .markdown .md-alert-important {
	--alert-ink: var(--text);
}

.markdown .md-alert-title {
	display: flex;
	align-items: center;
	gap: var(--s2);
	margin: 0 0 var(--s1);
	color: var(--alert-ink);
	font-weight: 700;
}

.markdown .md-alert-title svg {
	width: 18px;
	height: 18px;
	color: var(--alert);
}

.markdown .md-alert > :last-child {
	margin-bottom: 0;
}

/* Footnotes: small numbers in the text, and the notes after it. */
.markdown .md-fn-ref {
	font-size: 0.75em;
	line-height: 0;
}

.markdown .md-fn-ref a {
	padding: 0 2px;
}

.markdown .md-footnotes {
	margin-top: var(--s6);
	padding-top: var(--s3);
	border-top: 1px solid var(--hairline);
	font-size: 13px;
	color: var(--ink-quiet);
}

.markdown .md-footnotes ol {
	margin: 0;
}

.markdown .md-fn-back a {
	--underline-rest: transparent;
	display: inline-flex;
	vertical-align: -2px;
}

.markdown .md-fn-back svg {
	width: 14px;
	height: 14px;
}

/* Details open and close by their height (files.js), the chevron turning
   with them. */
.markdown details {
	padding: var(--s2) var(--s3);
	border: 1px solid var(--hairline);
	border-radius: var(--s2);
}

.markdown summary {
	display: flex;
	align-items: center;
	gap: var(--s2);
	list-style: none;
	cursor: pointer;
}

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

.markdown summary::before {
	content: "";
	flex: none;
	width: 6px;
	height: 6px;
	margin: 0 4px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	rotate: -45deg;
	transition: rotate 200ms cubic-bezier(0.2, 0, 0, 1);
}

.markdown details[open]:not([data-closing]) > summary::before {
	rotate: 45deg;
}

.markdown details > :not(summary) {
	margin-top: var(--s2);
}

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

.markdown blockquote {
	padding: 0 0 0 var(--s4);
	border-left: 3px solid var(--border);
	color: var(--ink-quiet);
}

.markdown hr {
	height: 1px;
	margin: var(--s5) 0;
	border: 0;
	background: var(--hairline);
}

/* Inline code breaks where it must rather than running out of the text. */
.markdown code {
	padding: 1px 6px;
	border-radius: 6px;
	background: var(--surface);
	font: inherit;
	font-size: 0.9em;
	overflow-wrap: anywhere;
}

/* Displayed maths (math.css), centred, with its tag at the end of the line;
   wider than the text, it scrolls sideways. */
.markdown .md-math {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	margin: 0 0 var(--s4);
	padding-block: var(--s2);
	overflow-x: auto;
}

.markdown .md-math math {
	grid-column: 2;
}

.markdown .md-math-tag {
	grid-column: 3;
	justify-self: end;
	padding-left: var(--s4);
	color: var(--muted);
	font-variant-numeric: tabular-nums;
}

/* Code blocks: a head with the language and a copy button, over lines
   that scroll sideways rather than wrapping. */
.markdown .md-pre {
	border: 1px solid var(--hairline);
	border-radius: var(--s3);
	overflow: hidden;
}

.markdown .md-pre-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 36px;
	padding: 0 var(--s1) 0 var(--s4);
	border-bottom: 1px solid var(--hairline);
	font-size: 12px;
	color: var(--ink-quiet);
}

.markdown .md-pre-head .icon-button {
	width: 32px;
	height: 32px;
}

.markdown .md-pre-head .icon-button svg {
	width: 16px;
	height: 16px;
}

.markdown .md-pre pre {
	margin: 0;
	padding: var(--s3) var(--s4);
	font-size: 13px;
	line-height: 20px;
	overflow-x: auto;
	tab-size: 4;
}

.markdown .md-pre code {
	padding: 0;
	border-radius: 0;
	background: none;
	font-size: inherit;
	overflow-wrap: normal;
}

.markdown img {
	max-width: 100%;
	height: auto;
	vertical-align: middle;
}

.markdown .md-align-center {
	text-align: center;
}

.markdown .md-align-right {
	text-align: right;
}

/* Tables: M3's data table, measured as Material's own implementations
   measure it (Angular Material's M3 tokens, MDC): an outlined container,
   hairlines between rows and none between columns, 16px either side of
   each cell, and the header over the body in the text colour, bold where
   M3 asks for a weight Comic Mono doesn't have. Rows are 40px and the
   header 44px, the density of the file lists. Header labels keep to one
   line, so a table too wide for the text scrolls sideways within it, its
   cut-off column showing there's more (NN/g, "Mobile Tables"). A row tints
   as it's pointed at, to help the eye along it (NN/g, "Data Tables"). */
.markdown .md-table {
	width: fit-content;
	max-width: 100%;
	border: 1px solid var(--hairline);
	border-radius: var(--s3);
	overflow-x: auto;
}

.markdown table {
	border-collapse: collapse;
	font-size: 14px;
	line-height: 20px;
}

.markdown tr {
	border-bottom: 1px solid var(--hairline);
}

.markdown tbody tr:last-child {
	border-bottom: 0;
}

.markdown tbody tr {
	transition: background-color 150ms cubic-bezier(0.34, 0.8, 0.34, 1);
}

.markdown tbody tr:hover {
	background: color-mix(in srgb, var(--text) 4%, transparent);
}

.markdown :is(th, td) {
	padding: 10px var(--s4);
	text-align: left;
	vertical-align: top;
}

.markdown th {
	padding-block: var(--s3);
	font-weight: 700;
	white-space: nowrap;
}

/* Right-aligned columns hold figures, which don't break; nor do names and
   paths in code, which a table would otherwise squeeze to a letter a line
   (and Firefox would break after each slash). */
.markdown :is(td.md-align-right, th code, td code) {
	white-space: nowrap;
}

.markdown :is(th, td).md-align-center {
	text-align: center;
}

.markdown :is(th, td).md-align-right {
	text-align: right;
}

.markdown kbd {
	padding: 1px 6px;
	border: 1px solid var(--border);
	border-radius: 6px;
	font: inherit;
	font-size: 0.9em;
}

/* A paper's parts (renderMarkdown's paper mode): numbered sections, the
   number set off from the title in the quiet ink; figures with their
   caption under them and tables with theirs over them, as journals place
   them, the label leading in bold; and references to them by name, which
   read as links. */
.markdown .md-number {
	margin-right: 0.35em;
	color: var(--ink-quiet, var(--muted));
	font-variant-numeric: tabular-nums;
}

.markdown :is(.md-figure, .md-table-figure) {
	margin: var(--s6) 0;
}

.markdown :is(.md-figure, .md-table-figure) figcaption {
	max-width: 64ch;
	font-size: 13px;
	line-height: 20px;
	color: var(--ink-quiet, var(--muted));
}

.markdown .md-figure figcaption {
	margin-top: var(--s3);
}

.markdown .md-table-figure figcaption {
	margin-bottom: var(--s3);
}

.markdown .md-label {
	color: var(--text);
	font-weight: 700;
}

.markdown .md-figure > :is(img, .md-flow) {
	display: block;
	margin-inline: auto;
}

.markdown .md-table-figure .md-table {
	margin-bottom: 0;
}

.markdown .md-xref {
	--underline-rest: var(--border);
	white-space: nowrap;
}

.markdown .md-xref-missing {
	color: var(--ink-del, var(--red));
	font-style: italic;
}

@media (prefers-reduced-motion: reduce) {
	.markdown .md-anchor,
	.markdown summary::before,
	.markdown tbody tr {
		transition: none;
	}
}
