::selection {
	background: #347d;
	color: #fef3e5;
}

img::selection {background: #3478}

a::selection {
	color: #fff;
	text-decoration: underline;
}

::backdrop {
	background: #0007;
	backdrop-filter: blur(8px);
}

:root {
	--br-s: 		.25rem;
	--c-bg: 		light-dark(var(--c-white), var(--c-black));
	--c-fg: 		light-dark(#432, var(--c-white));
	--c-black: 		#100a03;
	--c-red: 		light-dark(#923d, #a34c);
	--c-green: 		light-dark(#791, #ad3);
	--c-white: 		#fef3e5;
	--c-border-t1: 	color-mix(in srgb, var(--c-fg), #0000 93%);
	--c-border-t2: 	color-mix(in srgb, var(--c-fg), #0000 82%);
	--c-border-t3: 	color-mix(in srgb, var(--c-fg), #0000 71%);
	--c-fg-t1: 		color-mix(in srgb, var(--c-fg), #0000 93%);
	--c-fg-t5: 		color-mix(in srgb, var(--c-fg), #0000);
	--c-link-h: 	#7be;
	--c-link-v: 	light-dark(#75d, #a7e);
	--c-link: 		#38e;
	--ff: 			'Twemoji Country Flags', 	'Athelas', 			'Cardo', 	'EB Garamond', 'Celestia Antiqua MVB', 'Kepler Std Caption', serif;
	--ff-drop-cap: 	'Floral Capitals', 			var(--ff-run-in);
	--ff-heading: 	'SG1500s', 					'GryphiusMVB', 		serif;
	--ff-mono: 		'Code Saver', 				'Consolas', 		'Courier', 	monospace;
	--ff-run-in: 	'SG1500s-SC', 				'GryphiusMVB-SC', 	serif;
	--ff-ts: 		'Syne Mono', 				'Spectral', 		serif;
}

* {
	scrollbar-width: thin;
	scrollbar-color: light-dark(#0003, #fff3) #0000;
	text-size-adjust: none !important;
	font-variant-numeric: lining-nums tabular-nums slashed-zero !important;
}

:root {
	color-scheme: dark light;
	scroll-behavior: smooth;
	scrollbar-width: thin;
	scrollbar-color: light-dark(#0003, #fff3) var(--c-bg);
	font-size: 100%;
	font-family: var(--ff);
	line-height: 1.4;
	tab-size: 4;
	height: 100%;
	background: var(--c-bg);
	color: var(--c-fg);
	transition: background .1s, color .2s .1s;

	&.theme-dark {color-scheme: dark}
	&.theme-light {color-scheme: light}
}

body {
	overflow-x: hidden;
	position: relative;
	display: flow-root;
	min-height: 100%;
	padding-left: .5rem;
	margin: 0;

	&:is(.theme-dark body)::after {filter: brightness(2) opacity(.5)}

	&::before {
		--bg-gbc: 	light-dark(#0000, var(--c-black));
		--bg-gc: 	light-dark(
			rgb(from var(--bg-gbc) r g b / .3),
			rgb(from var(--c-black) r g b / .6)
		);

		content: '';
		position: absolute;
		z-index: -1;
		inset: 0;
		background:
			linear-gradient(0deg, var(--bg-gc), var(--bg-gc)),
			url('/assets/img/rough-cloth-light.png');
	}

	&::after {
		--w: clamp(15px, 2vw, 75px);
		content: '';
		background: url('/assets/img/border0.png') repeat-y calc(var(--w) / -2.2) -4em / var(--w) auto;
		position: absolute;
		inset: 0;
		pointer-events: none;
	}
}

:root.theme-light body::before {filter: invert(1)}

@media (prefers-color-scheme: light) {
	:root:not(.theme-dark) body::before {filter: invert(1)}
}

h1 {
	font-size: 2.1em;
	font-size: calc(1.6379rem + 0.2889vw); /* 1.7 - 2.1 */
	font-weight: 700;
	font-weight: normal;
	line-height: 1.1;
	margin: .5rem 0 1rem;
	text-wrap-style: pretty;

	code {font-size: .7em}

	/* Gryphius MVB */
	font-family: var(--ff-heading);
	font-size: calc(1.4826rem + 1.0113vw);
	line-height: 1;
	margin-bottom: .25rem;

	code {font-size: .6em}
}

h2 {
	font-family: 'Cardo', serif;
	font-size: 1.5em;
	line-height: 1.3;
	padding-bottom: .5rem;
	border-bottom: 2px solid color-mix(in srgb, currentColor, #0000 40%);
	margin: 2rem 0 1rem;
}

h3 {
	font-family: var(--ff-run-in);
	font-weight: normal;
	font-size: 1.9em;
	line-height: .7;
	margin: 2rem 0 1rem;
	text-transform: lowercase;

	&::before {
		content: '¶';
		font-size: .8em;
		margin-right: .7rem;
	}
}

a {
	color: var(--c-link);
	text-decoration: none;
	transition: color .2s;

	&:visited {color:var(--c-link-v)}

	&:hover,
	&:focus-visible
	{color: var(--c-link-h)}

	.icon-arrow-up-right-from-square {
		font-size: .7em;
		font-size: clamp(9px, round(nearest, .5em, 1px), .8em);
		margin: auto auto -.1em .4em;
		display: none;
	}
}

q {
	font-style: italic;

	&::before,
	&::after
	{font-style: normal}
}

svg {
	overflow: visible;

	&.icon {
		--icon-size: 1.2em;

		width: var(--icon-size, 1.2em);
		height: var(--icon-size, 1.2em);
	}
}

form {margin: 0}
button * {pointer-events: none}

button,
input,
textarea,
select {
	font: inherit;
	font-weight: normal;
	line-height: 1;
}

input {
	appearance: none;
	font: inherit;
	font-weight: normal;
	line-height: 1;
	border: 1px solid light-dark(var(--c-border-t2), var(--c-border-t1));
	background: var(--c-bg);
	color: inherit;
	transition: border-color .1s, background .1s, color .1s;

	&:disabled {
		background:  color-mix(in srgb, var(--c-bg), light-dark(#888, #444));
		color:  color-mix(in srgb, var(--c-fg), light-dark(#888, #444));
	}

	&:focus-visible {
		outline: none;
		border-color: light-dark(var(--c-border-t3), var(--c-border-t2));
	}

	&:not([type='radio'], [type='checkbox']) {
		display: block;
		width: 100%;
		padding: .5em .7em;
	}

	&[type='checkbox'] {
		box-sizing: border-box;
		display: inline-block;
		vertical-align: middle;
		width: 1.5rem;
		height: 1.5rem;
		margin: 0 .5rem;
		border: 1px solid light-dark(var(--c-border-t2), var(--c-border-t1));
		corner-shape: scoop;
		border-radius: 20%;
		place-content: center;
		cursor: pointer;

		&:hover {border-color: light-dark(var(--c-border-t3), var(--c-border-t2))}

		&:checked {
			&::before {
				content: '';
				display: block;
				min-width: 50%;
				width: calc(100% - 8px);
				min-height: 50%;
				height: calc(100% - 8px);
				margin: auto;
				corner-shape: inherit;
				border-radius: inherit;
				background: var(--c-red);
				box-shadow: inset 0 0 4px 2px #0008,
							inset 0 0 1px 1px #fed5;
			}
		}
	}

	&::-webkit-datetime-edit-fields-wrapper {padding: 0}
}

textarea {
	appearance: none;
	font: inherit;
	line-height: 1.4;
	display: block;
	width: 100% !important;
	padding: .5em .7em;
	border: 1px solid light-dark(var(--c-border-t2), var(--c-border-t1));
	background: var(--c-bg);
	color: inherit;
	resize: vertical;
	transition: border-color .1s, background .1s, color .1s;

	&:disabled {
		background:  color-mix(in srgb, var(--c-bg), #888);
		color:  color-mix(in srgb, var(--c-fg), #888);
	}

	&:focus-visible {
		outline: none;
		border-color: light-dark(var(--c-border-t3), var(--c-border-t2));
	}
}

label {
	&:has(input, select, textarea) {
		display: contents;
		cursor: pointer;
	}

	&.field-label--inline {
		display: flex;
		align-items: center;
		width: max-content;
		max-width: 100%;
		margin: .5em 0;
	}
}

pre {
	overflow-x: auto;
	font-family: var(--ff-mono);
	font-size: calc(.769rem + .1445vw); /* .8 - 1 */
	flex: 1 1 auto;
	padding: 1em;
	margin: 0;
	border-radius: .2rem;
	background: light-dark(#222, #0004);
	color: var(--c-white);
}

code {
	font-family: var(--ff-mono);
	font-style: normal;
	line-height: 1.5;
	letter-spacing: 0;
	vertical-align: baseline;
	text-shadow: none;

	&:where(:not(pre code)) {
		font-size: .8em;
		font-weight: normal;
		line-height: 1;
		white-space: normal;
		word-break: break-word;
		padding: .1em .3em;
		_border: 1px solid var(--c-border-t1);
		border-radius: .2rem;
		background: light-dark(#333, #0004);
		background: var(--c-p, var(--c-bg));
		color: var(--c-fg);
		filter: url('#paper') drop-shadow(rgba(0, 0, 0, .21) 0 0 .5px);
		filter: url('#paper') drop-shadow(light-dark(#0004, #000) -1px -1px 1px) drop-shadow(light-dark(#fff, #fff3) 1px 1px 1px);
	}
}

details {
	> summary {
		line-height: 1.2;
		display: block;
		width: max-content;
		max-width: 100%;
		padding: .5em .8em;
		border: 1px solid var(--c-border-t2);
		border-radius: .3rem;
		cursor: pointer;
		transition: background .1s;

		&::before {
			content: '';
			display: inline-block;
			width: .5em;
			height: .5em;
			border-right: 1px solid currentColor;
			border-bottom: 1px solid currentColor;
			margin-right: .5em;
			transform: translateY(0) rotateZ(-45deg);
			transition: transform .1s;
		}

		&:hover {background: var(--c-fg-t1)}

		+ * {margin-top: 0}
	}

	&:open > summary {
		margin-bottom: .5em;

		&::before {transform: translateY(-.2em) rotateZ(45deg)}
	}
}

time {
	font-family: var(--ff-ts);
	font-size: 1em;
	text-box: trim-both cap alphabetic;
	display: block;
	color: var(--c-border-t3);
}

ul {
	box-sizing: border-box;
	list-style: disc;
	overflow-y: auto;
	padding: 0 0 0 1.4em;
	margin: 0 0 1.1lh;
	width: max-content;
	max-width: min(49rem, calc(100% - 1rem));
	max-height: min(14em, 35vh);
	text-align: left;

	&:not(span + ul) {margin: 1.1lh 0}
}

ol {
	box-sizing: border-box;
	list-style-position: inside;
	overflow-y: auto;
	padding: 0 0 0 1.4em;
	margin: 0 0 1.1lh;
	width: max-content;
	max-width: min(49rem, 100%);
	max-height: min(17em, 35vh);
	text-align: left;

	&:not(span + ol) {margin: 1.1lh 0}
}

li {
	> :first-child {margin-top: 0}
	> :last-child {margin-bottom: 0}

	> p {font-size: 1em}
}

table {
	table-layout: fixed;
	border-spacing: 0;
	font-size: .8rem;
	line-height: inherit;
}

caption {
	font-size: 1.4rem;
	font-weight: 900;
	text-box: trim-both ex text;
	padding: .2em 0;
	border-bottom: 1px dashed var(--c-fg-t5);
	margin-bottom: .5rem;
	text-align: left;
}

th {
	line-height: 1;
	font-weight: 300;
	vertical-align: bottom;
	padding-block: .75rem;
	border-bottom: 1px solid var(--c-border-t1);
	text-transform: uppercase;
	color: var(--c-fg-t5);
}

td {
	word-break: break-word;
	padding-block: 1rem;
}

:is(th, td) {
	&:not(:first-child) {padding-left: 1rem}

	&:not(:last-child) {
		border-right: 1px solid var(--c-border-t1);
		padding-right: 1rem;
	}
}

p {
	font-size: calc(.9689em + .1445vw); /* 1 - 1.2 */
	width: 49em; /* TODO: Refactor p{width} to :has(>p){width} */
	max-width: min(calc(100vw - 1rem), 100%);
	margin: 0 0 1.1lh;
}

sup {
	line-height: 0;

	a {
		aspect-ratio: 1;
		position: relative;
		display: inline-block;
		padding: 1.2em;
		margin: -1.2em;
		border-radius: 50%;
		place-content: center;
	}
}

dfn {
	border-bottom: 2px dotted color-mix(in srgb, var(--c-fg), #0000);

	&:not([title]) {
		border-bottom-color: var(--c-red);
		color: var(--c-red);
	}
}

figure {
	position: relative;
	width: max-content;
	max-width: 100%;
	padding: 1em;
	margin: 1.1lh auto;

	&::after {
		content: '';
		position: absolute;
		inset: auto 0 0 auto;
		width: 2rem;
		height: 2rem;
		border-right: 1px solid;
		border-bottom: 1px solid;
		color: var(--c-fg-t5);
	}
}

figcaption {
	font-size: .9em;
	font-style: italic;
	line-height: 1.2;
	position: relative;
	inset: 0;
	min-width: calc-size(max-content, min(size, 100%));
	width: 0;
	padding: 0 2rem 1rem 0;
	color: var(--c-fg-t5);
	word-break: break-word;

	&::before {
		content: '';
		transform: translate(-1rem, calc(100% + -1rem));
		position: absolute;
		inset: calc(100% - 2rem) 0 0 0;
		min-width: 2rem;
		height: 2rem;
		border-top: 1px dashed;
		border-left: 1px solid;
	}
}

aside {
	font-size: .9em;
	margin: 1.1lh 0;
}

iframe {border: none}

:is(
	[type='button'],
	[type='submit'],
	[type='reset'],
	button
) {
	appearance: none;
	font-family: var(--ff-run-in);
	font-size: 1em;
	line-height: 1;
	padding: 0;
	border: none;
	background: none;
	color:  color-mix(in srgb, var(--c-fg), var(--c-bg) 30%);
	text-transform: uppercase;
	transition: background .1s, color .1s, border-color .1s, box-shadow .1s;

	&:not(.disabled, [disabled], :disabled) {
		cursor: pointer;

		&:hover {color:  color-mix(in srgb, var(--c-fg), var(--c-bg) 10%)}
		&:active {color:  color-mix(in srgb, var(--c-fg), var(--c-bg) 50%)}
	}
}

dialog {
	padding: clamp(.5rem, 3vw, 4rem);
	border: 2px solid var(--c-border-t1);
	border-radius: 1em 0 1em 1em;
	corner-shape: notch;
	box-shadow: .2em .4em .8em -.1em #0004;
	background: var(--c-bg);
	color: var(--c-fg);

	h1 {
		font-family: var(--ff-run-in);
		font-size: 2em;
		border-bottom: 1px solid color-mix(in srgb, var(--c-fg), #000 80%);
		padding-bottom: .25rem;
		margin: 0 0 1.5rem;
	}

	p {
		width: calc-size(max-content, min(size, 35em));
		max-width: min(35em, 100%);
	}
}

.visually-hidden {
	position: absolute !important;
	z-index: -1 !important;
	min-width: 0 !important;
	width: .01px !important;
	min-height: 0 !important;
	height: .01px !important;
	padding: 0 !important;
	border: none !important;
	margin: 0 !important;
	box-shadow: none !important;
	background: #0000 !important;
	color: #0000 !important;
}

.btn-action {
	padding: .9em 1.7em;
	border: 3px solid var(--c-bg);
	corner-shape: scoop;
	border-radius: .5em;
	background:  color-mix(in srgb, var(--c-bg), var(--c-fg) 20%);
	box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 80%);

	&:not(.disabled, [disabled], :disabled) {
		&:hover {
			background:  color-mix(in srgb, var(--c-bg), var(--c-fg) 30%);
			box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 70%);
		}

		&:active {
			background:  color-mix(in srgb, var(--c-bg), var(--c-fg) 10%);
			box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 90%);
		}
	}
}

.btn-cancel {
	padding: .9em 1.7em;
	border: 3px solid var(--c-bg);
	corner-shape: scoop;
	border-radius: .5em;
	box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 80%);
	color:  color-mix(in srgb, var(--c-fg), var(--c-bg) 40%);

	&:not(.disabled, [disabled], :disabled) {
		&:hover {
			background:  var(--c-fg-t1);
			box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 70%);
		}

		&:active {
			background:  color-mix(in srgb, var(--c-bg), #0000 80%);
			box-shadow: 0 0 1px 2px color-mix(in srgb, var(--c-fg), #0000 90%);
		}
	}
}

.btn-close {
	font-size: .7rem;
	position: absolute;
	inset: 0 0 auto auto;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: none;
	box-shadow: none;
	background: none;
}

.clamp {
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: inherit;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	margin-bottom: 1rem;

	&[data-lines] {-webkit-line-clamp: attr(data-lines type(<integer>), none)}
}

.dli 	{display: list-item}
.db 	{display: block}
.fwb 	{font-weight: bold}
.fwn 	{font-weight: normal}
.lsn 	{list-style: none}
.oxa 	{overflow-x: auto}
.p0 	{padding: 0}
.wbba 	{word-break: break-all}
.wsp 	{white-space: pre}

.x-ref {
	font-style: italic;
	margin-left: .3rem;

	&::before {
		content: '☞';
		font-style: normal;
		margin-right: .1rem;
	}
}

.post {
	--fs-drop-cap: calc(6.9247rem + 1.1725vw);

	@media (max-width: 49rem) {--fs-drop-cap: calc(5.0436rem + .7273vw)}

	> header {
		max-width: min(calc(100vw - 2rem), 100%);
		margin-left: clamp(
			calc(var(--fs-drop-cap) * -.33),
			calc(var(--fs-drop-cap) * -.33 + 55rem - 100vw),
			0px
		) !important;
	}
}

.article-body {
	> :first-child {margin-top: 0}

	&:not(:has(:first-child)),
	&:not(:has(.run-in)) > :first-child,
	.run-in {
		&::first-letter {
			font-family: var(--ff-drop-cap);
			font-size: 8.8rem;
			font-size: var(--fs-drop-cap);
			line-height: .71;
			float: left;
			margin: .15rem .2rem 0 clamp(-.33em, calc(-.33em + 55rem - 100vw), 0px);
			color: var(--c-red);
			text-transform: uppercase;

			@media (max-width: 49rem) {margin-right: .1rem}
		}
	}
}

.field-label-content {
	font-family: var(--ff-mono);
	font-size: .8rem;
	text-box: trim-both text;
	display: block;
	width: max-content;
	max-width: 100%;
	margin: 1rem 0 -.1em;
	text-transform: uppercase;
	letter-spacing: .1em;
}

.run-in {
	font-family: var(--ff-run-in);
	font-size: 1.4em;
	line-height: .9;
	display: block;
}

.code-and-preview {
	display: flex;
	gap: .5rem;
	flex-flow: row wrap;
	margin-bottom: 1rem;
}

.preview {
	overflow: auto;
	flex: 1 1 auto;
	border: 1px solid var(--c-border-t1);
	border-radius: .2rem;
	background: var(--c-border-t1);

	&::before {
		content: 'Preview:';
		font-weight: 900;
		display: block;
		padding: .5rem;
		text-transform: uppercase;
	}
}

.tableware {
	position: relative;
	left: 50%;
	transform: translateX(-50%);
	min-width: 49rem;
	width: 49rem !important;
	max-width: calc(100vw - 2rem) !important;
	padding: 1em;
	border: 1px solid var(--c-fg-t1);
	margin: 2rem auto 0 !important;

	&:has(details:open) {width: 77rem !important}

	:where(:is(th, td):not(.col-notes)) {text-align: center}

	.col-notes {text-align: left}

	td {
		&:first-child {font-size: 1rem}

		&.col-reasons ul {margin: 0 auto}
	}

	ul {
		overflow: visible;
		margin: 0;
	}

	.td-mobile-label {display: none}

	@media (max-width: 49rem) {
		transform: none;
		position: static;
		display: block;
		min-width: 0;
		width: auto !important;
		max-width: 100vw !important;
		padding: 0;
		border: none;

		thead {display: none}
		tbody {display: block}

		tr {
			overflow: hidden;
			display: flex;
			flex-flow: row wrap;
			border-radius: var(--br-s);
			background: var(--c-border-t1);
		}

		td {
			box-sizing: border-box;
			overflow: hidden;
			flex: 0 1 20%;
			display: flex;
			flex-flow: column nowrap;
			padding: 1rem;
			text-align: center;

			&.col-notes {
				order: 1;
				flex: 0 0 100%;
				border-top: 1px solid var(--c-border-t1);
				border-right: none;
				text-align: left;
			}
		}

		.td-mobile-label {
			line-height: 1;
			font-weight: 300;
			font-size: .7rem;
			display: block;
			margin-bottom: .5rem;
			text-transform: uppercase;
			color: var(--c-fg-t5);
		}

		.cell-content {
			flex: 1 1 auto;
			place-content: center;

			> :first-child {margin-top: 0}
			> :last-child {margin-bottom: 0}
		}
	}

	@media (max-width: 43rem) {
		tr {flex-flow: column nowrap}

		td {
			gap: .5rem 2rem;
			flex-flow: row wrap;
			text-align: right;

			&:not(:first-child) {border-top: 1px solid var(--c-border-t1)}

			&.col-notes {text-align: left}

			&.col-reasons ul {
				padding-right: 0;
				margin: 0 0 0 auto;
			}
		}

		.td-mobile-label {
			margin: 0;
			place-content: center;
			text-align: left;
		}

		.cell-content {max-width: 100%}

		details:open {margin-top: .5em !important}
	}
}

.footnotes {padding-right: 1em}
.footnote {white-space: nowrap}

.footnote-wrap {
	white-space: normal;
	display: inline-flex;
	align-items: flex-start;
	gap: .5em;
}

.footnote-i {display: none}
.footnote-content {flex: 0 1 auto}
.footnote-backlink {flex: 0 0 auto}

.postnav {
	ol {
		list-style: none;
		display: flex;
		justify-content: space-between;
		width: 100%;
		padding: 0;
		margin: 3em auto;

		a {
			line-height: 1;
			display: flex;
			gap: .5em;
			align-items: center;
			padding: 1em;

			svg {font-size: .7em}
		}
	}
}

.filter {position: absolute}

.illustration-octopus {
	display: block;
	height: 7rem;
	margin: 4rem auto 2rem;
	color: var(--c-fg-t5);
}

c- 	{color: light-dark(#222, #fff)}
c-a {color: light-dark(#28c, #4ef)}
c-f {color: light-dark(#480, #ad3)}
c-n {color: light-dark(#95c, #97e)}
c-p {color: light-dark(#aaa, #777)}
c-t {color: light-dark(#d45, #e27)}
c-v {color: light-dark(#c85, #ee8)}

c- 	{color: #fff}
c-a {color: #4ef}
c-f {color: #ad3}
c-n {color: #a7e}
c-o {color: #e27}
c-p {color: #888}
c-t {color: #e27}
c-v {color: #ee8}
c-i {color: #fb2}
