/* style.css - the look of teia: the colours and shapes of werc, on any
 * screen, light or dark.
 *
 * To change it, add rules to site/_theme/custom.css, which is loaded after
 * this file; often the colour variables are all you need:
 *
 *	:root { --bar: #555; --band: #9c0; }
 *
 * Or copy this file to site/_theme/style.css and make it yours.
 */

:root {
	--bar: #6487dc;		/* top bar, footer, menu hover, table heads */
	--bar-text: #fff;
	--band: #ff6d06;	/* the band with the site's name */
	--band-text: #000;
	--link: #0066cc;
	--text: #000;
	--muted: #555;
	--bg: #fff;
	--rule: #ddd;
	--code-bg: #f4f4f4;
	--side: 15em;		/* width of the menu */
	--measure: 40rem;	/* longest line of text */
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--link: #7cb0ff;
		--text: #ddd;
		--muted: #aaa;
		--bg: #1b1b1b;
		--rule: #383838;
		--code-bg: #262626;
	}
}

html {
	background: var(--bg);
	color: var(--text);
}

body {
	margin: 0;
	font: 100%/1.5 Helvetica, Verdana, Arial, "Liberation Sans", FreeSans, sans-serif;
	display: grid;
	grid-template-columns: var(--side) minmax(0, 1fr);
	grid-template-rows: auto 1fr auto;
	grid-template-areas: "head head" "side main" "foot foot";
	min-height: 100vh;
}

a {
	color: var(--link);
}

a:focus-visible, label:focus-visible, summary:focus-visible, button:focus-visible {
	outline: 2px solid var(--band);
	outline-offset: 1px;
}

/* Header: a bar of links, then the band with the site's name. */

header {
	grid-area: head;
}

.topbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1.5em;
	padding: .2em .6em;
	background: var(--bar);
	color: var(--bar-text);
	border-bottom: 2px solid #000;
	font-size: .9em;
}

.topbar a {
	color: inherit;
	text-decoration: none;
}

.topbar a:hover {
	text-decoration: underline;
}

/* The links of the site on the left; the rest, and last the languages,
 * on the right. */
.topbar > :first-child {
	margin-right: auto;
}

.languages {
	padding-left: 1em;
	border-left: 1px solid rgba(255, 255, 255, .5);
}

.site {
	margin: 0;
	padding: .1em 4mm .15em;
	background: var(--band);
	border-bottom: 2px solid #000;
	font-size: 2.3em;
	line-height: 1.3;
}

.site a {
	color: var(--band-text);
	text-decoration: none;
}

.site span {
	margin-left: .5em;
	font-size: .5em;
	font-style: italic;
}

/* The menu: the site's directories and pages, as a tree. */

.menu-toggle, .pathbar {
	display: none;
}

.sidebar {
	grid-area: side;
	padding: .6em 0 2em;
	border-right: 1px solid var(--rule);
}

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

.sidebar ul ul {
	padding-left: .7em;
}

.sidebar a {
	display: block;
	padding: .2em 1ex .2em 2mm;
	border-left: .2em solid transparent;
	font-weight: bold;
	text-decoration: none;
	overflow-wrap: anywhere;
}

.sidebar a::before {
	content: "\203A";
	display: inline-block;
	width: var(--mark);
}

.sidebar a[aria-current]::before {
	content: "\00BB";
}

.sidebar a[aria-current] {
	color: var(--text);
	font-style: italic;
}

.sidebar a:hover {
	color: var(--bar-text);
	background: var(--bar);
	border-left-color: #000;
}

/* A directory with pages under it: a triangle, which opens and closes
 * it in place (theme/details.js animates it), and its name, a link. */

.sidebar {
	--mark: 1em;		/* width of the triangle, and of the marks of pages */
}

.sidebar details {
	margin: 0;
}

.sidebar summary {
	display: flex;
	list-style: none;
	cursor: pointer;
	border-left: .2em solid transparent;
}

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

.sidebar summary::before {
	content: "\25B8";
	flex: none;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.3em;
	line-height: 1;
	width: calc(var(--mark) / 1.3);
	margin-left: calc(2mm / 1.3);
	color: var(--link);
	transition: transform .2s ease-out;
}

.sidebar details[open]:not(.closing) > summary::before {
	transform: rotate(90deg);
}

.sidebar summary > a {
	flex: 1;
	padding-left: 0;
	border-left: 0;
}

.sidebar summary > a::before {
	content: none;
}

.sidebar summary:hover {
	background: var(--bar);
	border-left-color: #000;
}

.sidebar summary:hover::before, .sidebar summary:hover > a {
	color: var(--bar-text);
}

.sidebar summary:focus-visible {
	outline: 2px solid var(--band);
	outline-offset: -2px;
}

/* The page itself. */

main {
	grid-area: main;
	min-width: 0;
	padding: .3em 6mm 3em;
	line-height: 1.6;
}

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

main > :is(figure, canvas, iframe, video, .wide) {
	max-width: 100%;
}

main h1, main h2, main h3, main h4, main h5, main h6 {
	color: var(--link);
	line-height: 1.25;
	margin: 1.6em 0 .5em;
}

main h1 {
	font-size: 1.6em;
	border-bottom: 2px solid var(--link);
	padding-bottom: .1em;
}

main h2 {
	font-size: 1.25em;
	border-bottom: 1px solid var(--link);
	padding-bottom: .1em;
}

main h3 {
	font-size: 1.1em;
}

main h4, main h5, main h6 {
	font-size: 1em;
}

main > h1:first-child {
	margin-top: .5em;
}

main a {
	text-decoration-thickness: 1px;
	text-underline-offset: .15em;
}

main a:hover {
	color: var(--bar);
}

img, video, canvas, svg, iframe {
	max-width: 100%;
}

/* Keep the proportions of a canvas when it is narrower than its width
 * attribute: scripts that size the drawing to the element, as they
 * should, then do not make it grow. */
img, video, canvas {
	height: auto;
}

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

blockquote {
	margin: 1em 0;
	padding: 0 0 0 1em;
	border-left: 3px solid var(--bar);
	color: var(--muted);
}

code, kbd, pre, samp {
	font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
	font-size: .9em;
}

pre {
	padding: .7em .9em;
	overflow-x: auto;
	background: var(--code-bg);
	border-left: 3px solid var(--rule);
	line-height: 1.45;
	tab-size: 4;
}

pre code {
	font-size: 1em;
}

:not(pre) > code {
	padding: .05em .3em;
	background: var(--code-bg);
	border-radius: 2px;
}

kbd {
	padding: 0 .3em;
	border: 1px solid var(--rule);
	border-bottom-width: 2px;
	border-radius: 3px;
}

table {
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
	margin: 1em 0;
}

th, td {
	padding: .25em .7em;
	border: 1px solid var(--rule);
	text-align: left;
	vertical-align: top;
}

th {
	color: var(--bar-text);
	background: var(--bar);
}

tbody tr:nth-child(even) td {
	background: rgba(128, 128, 128, .08);
}

li.task {
	list-style: none;
	margin-left: -1.3em;
}

details {
	margin: 1em 0;
}

summary {
	cursor: pointer;
	color: var(--link);
}

/* Directory listings. */

main h1.path a {
	text-decoration: none;
}

table.listing td {
	border: 0;
	padding: .15em 1.5em .15em .3em;
}

table.listing a {
	text-decoration: none;
	font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

table.listing a:hover {
	text-decoration: underline;
}

table.listing .size, table.listing .date {
	color: var(--muted);
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

table.listing .size {
	text-align: right;
}

/* GLSL pages (.frag): the canvas fills the width of the page. */

figure.glsl {
	max-width: 64rem;
	margin: 1em 0;
}

figure.glsl canvas {
	display: block;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #000;
	touch-action: none;
}

figure.glsl figcaption {
	display: flex;
	gap: .5em;
	margin-top: .4em;
	font-size: .9em;
}

figure.glsl button {
	font: inherit;
	padding: .15em .7em;
	color: var(--link);
	background: none;
	border: 1px solid var(--rule);
	border-radius: 3px;
	cursor: pointer;
}

.glsl-error {
	color: #c00;
	border-left-color: #c00;
	white-space: pre-wrap;
}

/* Lists of names (.list): an index of letters, then the names in two
 * columns, one on narrow screens. */

nav.letters {
	display: flex;
	flex-wrap: wrap;
	gap: .1em .55em;
	margin: 1.2em 0 1.5em;
	padding: .4em .6em;
	border-top: 1px solid var(--rule);
	border-bottom: 1px solid var(--rule);
	font-weight: bold;
}

nav.letters a {
	text-decoration: none;
}

nav.letters span {
	color: var(--rule);
}

main > .list {
	max-width: 64rem;
	columns: 2;
	column-gap: 3em;
}

.list h2 {
	margin: 0 0 .4em;
	break-after: avoid;
}

.list h2:not(:first-child) {
	margin-top: .8em;
}

.list dl {
	margin: 0;
}

.list dl > div {
	break-inside: avoid;
	padding: .25em 0;
}

.list dt a {
	text-decoration: none;
}

.list .dates {
	color: var(--muted);
	font-size: .9em;
	white-space: nowrap;
}

.list dd {
	margin: 0 0 0 1.2em;
	color: var(--muted);
	font-size: .9em;
	line-height: 1.4;
}

/* Authors' pages (.works): the collection above the name, what the
 * author was below it, and the works as in a catalogue, one to a line,
 * the title first. */

.page-works main > p:first-child,
.page-book main > p:first-child,
.page-work main > p:first-child {
	margin: 1em 0 0;
	color: var(--muted);
	font-size: .9em;
}

.page-works main > p:first-child + h1 {
	margin-top: .15em;
}

.page-works main > h1 + p {
	margin-top: -.2em;
	color: var(--muted);
	font-style: italic;
}

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

.works li {
	margin: .4em 0;
	padding-left: 1.2em;
	text-indent: -1.2em;
	line-height: 1.45;
}

.works li > :first-child {
	font-weight: bold;
}

.works li > a:first-child,
.works li > em:first-child > a {
	text-decoration: none;
}

/* Books (.book): the first page of the PDF beside the title, and the
 * files to download, each with its format and size. */

.page-book main > p:first-child + p,
.page-work main > p:first-child + p {
	margin-top: .2em;
	color: var(--muted);
}

main > .book {
	display: flex;
	align-items: flex-start;
	gap: 1.8em;
	max-width: 64rem;
	margin: 1.5em 0 2em;
	padding: 1.2em 0;
	border-top: 1px solid var(--rule);
	border-bottom: 1px solid var(--rule);
}

.book .cover {
	flex: none;
	width: 12rem;
}

.book .cover img {
	display: block;
	width: 100%;
	height: auto;
	background: #fff;
	border: 1px solid #999;
	box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

.book .cover:hover img {
	border-color: var(--link);
}

.book-head {
	flex: 1;
	min-width: 0;
	max-width: var(--measure);
}

.book-head h1:first-child {
	margin-top: 0;
}

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

.downloads li {
	margin: .5em 0;
	padding-left: 3.6em;
	text-indent: -3.6em;
}

.downloads .format {
	display: inline-block;
	width: 3.4em;
	margin-right: .2em;
	text-indent: 0;
	text-align: center;
	color: var(--bar-text);
	background: var(--bar);
	border-radius: 2px;
	font: bold .75em/1.7 ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
	vertical-align: .1em;
}

.downloads a {
	font-weight: bold;
}

.downloads .size {
	color: var(--muted);
	white-space: nowrap;
}

.downloads li > p {
	margin: 0;
}

/* The other versions of a file: a triangle, down when they are hidden
 * and up when they show, opens and closes them (theme/details.js). */

.downloads details.versions {
	margin: .1em 0 .5em;
	text-indent: 0;
}

.downloads details.versions > summary {
	display: inline-block;
	list-style: none;
	font-size: .9em;
}

.downloads details.versions > summary::-webkit-details-marker {
	display: none;
}

.downloads details.versions > summary::before {
	content: "\25BC";
	display: inline-block;
	width: 1.4em;
	font-size: .75em;
}

.downloads details.versions[open]:not(.closing) > summary::before {
	content: "\25B2";
}

.downloads details.versions ul {
	margin: .3em 0 0;
}

/* Works not yet published (.work): below their text, a table of the
 * length, the rate, the price of digitizing them and the address that
 * receives contributions, with its QR code. The address is selected
 * whole with one click, to be copied. */

main > .work {
	max-width: var(--measure);
	margin: 1.5em 0 2em;
	padding: 1em 0;
	border-top: 1px solid var(--rule);
	border-bottom: 1px solid var(--rule);
}

.work dl {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: .55em 1.4em;
	margin: 0;
}

.work dt {
	color: var(--muted);
}

.work dd {
	margin: 0;
}

.work .price {
	font-size: 1.15em;
}

.work .reckoning {
	display: block;
	color: var(--muted);
	font-size: .85em;
}

.work .qr-link {
	display: block;
	width: 11rem;
	max-width: 100%;
}

.work .qr {
	display: block;
	width: 100%;
	height: auto;
	border: 1px solid var(--rule);
}

.work code.xmr {
	display: block;
	margin: .7em 0 .3em;
	padding: .3em .45em;
	font-size: .85em;
	overflow-wrap: anywhere;
	user-select: all;
	-webkit-user-select: all;
}

.work .received progress {
	display: block;
	width: 100%;
	max-width: 20rem;
	height: .6em;
	margin: .45em 0 .2em;
	accent-color: var(--band);
}

.work .received .done,
.work .received .asof {
	display: block;
	font-size: .85em;
}

.work .received .asof {
	color: var(--muted);
}

.work .scan,
.work .none {
	color: var(--muted);
	font-size: .9em;
}

@media (max-width: 30em) {
	.work dl {
		grid-template-columns: minmax(0, 1fr);
		gap: .15em;
	}

	.work dd + dt {
		margin-top: .6em;
	}
}

/* Footer. */

footer {
	grid-area: foot;
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	gap: .3em 1.5em;
	padding: .8em 1em;
	color: var(--bar-text);
	background: var(--bar);
	font-size: .9em;
}

footer a {
	color: inherit;
}

/* Narrow screens: one column. The menu folds under a button, next to
 * the path of the page; the checkbox before it keeps it working
 * without JavaScript. */

@media (max-width: 48em) {
	body {
		display: flex;
		flex-direction: column;
	}

	main {
		flex: 1;
	}

	.site {
		font-size: 1.7em;
		padding: .2em 4mm .3em;
	}

	.site span {
		display: block;
		margin: 0;
		font-size: .55em;
	}

	.menu-toggle {
		display: block;
		position: absolute;
		width: 1px;
		height: 1px;
		opacity: 0;
	}

	.pathbar {
		display: flex;
		align-items: center;
		gap: .7em;
		padding: .45em 4mm;
		border-bottom: 1px solid var(--rule);
	}

	.pathbar label {
		flex: none;
		padding: .25em .8em;
		border: 1px solid var(--rule);
		border-radius: 3px;
		color: var(--link);
		font-weight: bold;
		cursor: pointer;
		user-select: none;
	}

	.pathbar label::before {
		content: "\2261\00A0";
	}

	.menu-toggle:checked + .pathbar label {
		color: var(--bar-text);
		background: var(--bar);
		border-color: var(--bar);
	}

	.menu-toggle:focus-visible + .pathbar label {
		outline: 2px solid var(--band);
	}

	.crumbs {
		overflow-x: auto;
		white-space: nowrap;
		font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
		font-size: .9em;
	}

	.crumbs a {
		text-decoration: none;
	}

	.sidebar {
		display: none;
		padding: .3em 0 .6em;
		border-right: 0;
		border-bottom: 1px solid var(--rule);
	}

	.menu-toggle:checked ~ .sidebar {
		display: block;
	}

	.sidebar a {
		padding-top: .45em;
		padding-bottom: .45em;
	}

	.sidebar {
		--mark: 1.6em;
	}

	.languages {
		padding-left: 0;
		border-left: 0;
	}

	main {
		padding: .2em 4mm 2.5em;
	}

	table.listing .date {
		display: none;
	}

	main > .list {
		columns: 1;
	}

	main > .book {
		flex-direction: column;
		gap: 1em;
	}

	.book .cover {
		width: 10rem;
	}
}

@media print {
	.topbar, .pathbar, .sidebar, footer {
		display: none;
	}

	body {
		display: block;
	}

	.site {
		background: none;
		border-bottom: 1px solid #000;
	}
}
