/*
 * Copyright (c) 2026 Marco Peereboom <marco@peereboom.us>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * The stick's console: phosphor green on black, the system's own
 * monospace font, nothing fetched.  The boot (index.html) is CSS alone:
 * each line typed by its width, in steps of one character.
 */
:root {
	--bg: #000;
	--fg: #20c020;		/* \033[0;32m */
	--hi: #55ff55;		/* \033[1;32m, EFI_LIGHTGREEN */
	color-scheme: dark;
}

html, body {
	margin: 0;
	overflow-wrap: break-word;
	background: var(--bg);
	color: var(--fg);
	font: 16px/1.4 ui-monospace, "DejaVu Sans Mono", Menlo, Consolas,
	    monospace;
}

pre.art {
	margin: 0;
	color: var(--hi);
	font-weight: bold;
	/* 72 columns across a phone's width, at most 16px. */
	font-size: min(16px, calc((100vw - 32px) / 44));
	line-height: 1.2;
	white-space: pre;
}

/* The boot: over the page, gone when it ends. */
.boot {
	position: fixed;
	inset: 0;
	padding: 0 16px;
	background: var(--bg);
	z-index: 1;
	animation: gone 0s var(--boot-end) forwards;
}

/*
 * A typed line: its width grows a character a step, and its right border
 * is the cursor, one character wide, just past the last letter.  The
 * cursor shows while its line types; on the last line it then blinks
 * until the boot goes, and the page has none.
 */
.t {
	display: inline-block;
	overflow: hidden;
	vertical-align: bottom;
	width: 0;
	border-right: 1ch solid transparent;
	animation: type var(--d) steps(var(--n)) var(--s) forwards,
	    cursor var(--d) step-end var(--s);
}

.t.last {
	animation: type var(--d) steps(var(--n)) var(--s) forwards,
	    cursor var(--d) step-end var(--s),
	    blink 0.5s step-end calc(var(--s) + var(--d)) infinite;
}

@keyframes type {
	to { width: calc(var(--n) * 1ch); }
}

@keyframes cursor {
	from, to { border-right-color: var(--hi); }
}

@keyframes blink {
	0% { border-right-color: var(--hi); }
	50% { border-right-color: transparent; }
}

@keyframes gone {
	to { visibility: hidden; }
}

.site {
	max-width: 46rem;
	padding: 2rem 16px;
}

.fig {
	font-size: min(16px, calc((100vw - 32px) / 42));
}

.tag {
	color: var(--hi);
	font-weight: bold;
}

dl {
	display: grid;
	grid-template-columns: fit-content(40%) minmax(0, 1fr);
	gap: 0.2rem 1.5rem;
}

dt {
	color: var(--hi);
	overflow-wrap: anywhere;
}

dd {
	margin: 0;
}

nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.5rem;
	margin-top: 2rem;
}

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

a:focus-visible {
	outline: 1px solid var(--hi);
	outline-offset: 2px;
}

/* The other pages: a header, then text. */
header {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem 1.5rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--fg);
}

header nav {
	margin-top: 0;
}

.home {
	font-weight: bold;
	text-decoration: none;
}

a[aria-current="page"] {
	color: var(--bg);
	background: var(--hi);
	text-decoration: none;
}

h1, h2, h3 {
	color: var(--hi);
	font-size: 1rem;
	line-height: 1.4;
}

h1 {
	margin: 2rem 0 1rem;
	font-size: 1.25rem;
}

h2 {
	margin: 2rem 0 0.5rem;
}

h3 {
	margin: 1.5rem 0 0.5rem;
	font-weight: normal;
}

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

li {
	margin: 0.3rem 0;
}

code {
	color: var(--hi);
	overflow-wrap: anywhere;
}

/* A long line scrolls in its block, not the page. */
pre:not(.art) {
	overflow-x: auto;
	margin: 0.5rem 0;
	padding: 0.5rem 0 0.5rem 1ch;
	border-left: 2px solid var(--fg);
	color: var(--hi);
}

.tbd {
	padding: 0 0.5ch;
	border: 1px dashed var(--hi);
}

/* A key to press: lit, in a box. */
kbd {
	padding: 0 0.3ch;
	border: 1px solid var(--fg);
	color: var(--hi);
	font: inherit;
	white-space: nowrap;
}

/* What the screen says: the rule dotted. */
pre.screen {
	border-left-style: dotted;
}

/* A page's own contents, under its title. */
.toc {
	padding: 0.5rem 0 0.5rem 1ch;
	border-left: 2px solid var(--fg);
	list-style: none;
}

.toc li {
	margin: 0.1rem 0;
}

/* The tutorial's steps: the number lit. */
ol.steps {
	padding-left: 0;
	list-style: none;
	counter-reset: step;
}

ol.steps > li {
	margin: 1.5rem 0;
	counter-increment: step;
}

ol.steps > li::before {
	content: counter(step) ". ";
	color: var(--hi);
	font-weight: bold;
}

/* A recipe: a dotted rule under it. */
.recipe {
	padding-bottom: 0.5rem;
	border-bottom: 1px dotted var(--fg);
}

/* A table scrolls in its block, as a long line does. */
table {
	display: block;
	overflow-x: auto;
	border-collapse: collapse;
}

th, td {
	padding: 0.1rem 1ch;
	min-width: 12ch;
	text-align: left;
	vertical-align: top;
}

/* The last column is the prose one. */
td:last-child {
	min-width: 30ch;
}

th {
	color: var(--hi);
	border-bottom: 1px solid var(--fg);
}

/* A man page (mandoc's): its title line across the page. */
table.head, table.foot {
	display: table;
	width: 100%;
	margin: 1rem 0;
}

table.head td, table.foot td {
	padding: 0;
	min-width: 0;
}

.head-vol {
	text-align: center;
}

.head-rtitle, .foot-os {
	text-align: right;
}

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

.Bd-indent {
	margin-left: 2ch;
}

/* Two columns where they fit; one on a phone. */
@media (max-width: 40rem) {
	dl {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
	}

	dd {
		margin: 0 0 0.6rem 2ch;
	}

	.head-vol {
		display: none;
	}
}

/* No motion asked for: the page at once. */
@media (prefers-reduced-motion: reduce) {
	.boot {
		display: none;
	}
}


/* A screenshot: the page's width at most, its caption under it. */
figure {
	margin: 1.5rem 0;
}

figure img {
	display: block;
	max-width: 100%;
	height: auto;
	border: 1px solid var(--fg);
}

figcaption {
	margin-top: 0.4rem;
	font-size: 0.9em;
}

/* Shots side by side where the width allows. */
.shots {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
	gap: 1rem;
}

.shots figure {
	margin: 0;
}
