/*
 * Docker Gallery.
 *
 * The design starts from what a registry actually is: a manifest. Names people
 * choose, pointing at content named by its own hash. So the page is built like
 * one — rows on hairlines, figures in a fixed-width face lining up down a
 * column, and no card anywhere. The proportional face carries what a person
 * wrote; the monospace face carries what a machine computed, and never a label.
 *
 * The one loud thing on any page is the command block. Copying the right pull
 * line is the job most visits are here to do, so that is where the contrast,
 * the accent rule and the size go, and everything around it stays quiet.
 *
 * There is no build step. One stylesheet, plain CSS, custom properties for the
 * palette — the dark scheme redefines the tokens and never a second set of
 * rules.
 */

/* IBM Plex, vendored rather than fetched: an internal registry should draw
   itself on a network that cannot reach a font host, and the licence (SIL OFL,
   static/fonts/LICENSE.txt) is what makes carrying it here allowed. The latin
   subset only, one variable file for the sans and two weights of the mono. */
@font-face {
	font-family: "IBM Plex Sans";
	src: url("/static/fonts/plex-sans-var-latin.woff2") format("woff2");
	font-weight: 400 700;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "IBM Plex Mono";
	src: url("/static/fonts/plex-mono-400-latin.woff2") format("woff2");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "IBM Plex Mono";
	src: url("/static/fonts/plex-mono-600-latin.woff2") format("woff2");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}

:root {
	color-scheme: light dark;

	/* Paper with a trace of green in it, ink that is nearly black but not
	   grey, and one accent: a deep pine that is neither the blue every
	   container tool reaches for nor a warning colour. */
	--paper: #f2f4f2;
	--surface: #ffffff;
	--sunken: #eaefec;
	--ink: #0f1a18;
	--ink-muted: #566662;
	--rule: #d3dbd8;
	--rule-soft: #e5eae8;

	--accent: #0e5b4e;
	--accent-strong: #0a463c;
	--accent-soft: #e2efeb;
	--danger: #96301c;
	--danger-soft: #f7e7e3;

	/* Not the accent. A focus ring in the same colour as the links is a ring
	   that has to be looked for; this amber clears 3:1 on both grounds. */
	--focus: #a85a0d;

	--sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
	--mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", "Cascadia Mono", monospace;

	--fs-xs: 0.8125rem;
	--fs-s: 0.875rem;
	--fs-base: 1rem;
	--fs-m: 1.0625rem;
	--fs-l: 1.3125rem;
	--fs-xl: 1.75rem;

	--gap-xs: 0.35rem;
	--gap-s: 0.6rem;
	--gap: 1rem;
	--gap-l: 1.75rem;
	--gap-xl: 3rem;

	/* Radii by role. A chip and a panel are not the same shape. */
	--round-control: 3px;
	--round-panel: 5px;

	--column: 68rem;
	--column-narrow: 34rem;
}

/* The choice wins in both directions: a reader who asked for dark on a light
   machine gets dark, and one who asked for light on a dark machine gets light. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--paper: #0d1413;
		--surface: #141d1b;
		--sunken: #0a1211;
		--ink: #e5efec;
		--ink-muted: #8ba29c;
		--rule: #27332f;
		--rule-soft: #1b2523;

		--accent: #56bda4;
		--accent-strong: #7bd3bb;
		--accent-soft: #12302a;
		--danger: #e58b74;
		--danger-soft: #341913;

		--focus: #e0973a;
	}
}

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

html {
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--sans);
	font-size: var(--fs-base);
	line-height: 1.55;
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

h1,
h2,
h3 {
	margin: 0;
	font-weight: 600;
	letter-spacing: -0.011em;
	line-height: 1.2;
}

h1 {
	font-size: var(--fs-xl);
}

h2 {
	font-size: var(--fs-l);
}

h3 {
	font-size: var(--fs-m);
}

p {
	margin: 0 0 var(--gap);
	max-width: 68ch;
}

p:last-child {
	margin-bottom: 0;
}

a {
	color: var(--accent);
	text-decoration: none;
}

/* The underline is the thing that moves, so it says "this one" rather than
   "these are links" on a page that is largely names pointing at things. */
a:hover {
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
	border-radius: 2px;
}

.skip,
.visually-hidden {
	position: absolute;
	left: -9999px;
}

.skip:focus {
	left: var(--gap);
	top: var(--gap);
	z-index: 10;
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: var(--round-control);
	padding: var(--gap-s) var(--gap);
}

/* ---------------------------------------------------------------- masthead */

.masthead {
	background: var(--surface);
	border-bottom: 1px solid var(--rule);
}

.masthead-row {
	max-width: var(--column);
	margin: 0 auto;
	padding: var(--gap-s) var(--gap-l);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--gap);
}

.mark {
	display: block;
	color: inherit;
	padding: var(--gap-xs) 0;
}

.mark:hover {
	text-decoration: none;
}

.mark-name {
	display: block;
	font-size: var(--fs-xs);
	color: var(--ink-muted);
}

/* The host is the one string a visitor cannot work out for themselves, so it
   is set as what it is: something to be typed, in the face it will be typed
   in. */
.mark-host {
	display: block;
	font-family: var(--mono);
	font-size: var(--fs-m);
	font-weight: 600;
	letter-spacing: -0.01em;
}

.mark:hover .mark-host {
	color: var(--accent);
}

.menu {
	display: flex;
	align-items: center;
	gap: var(--gap-l);
}

.menu-link {
	color: var(--ink-muted);
	font-size: var(--fs-s);
	font-weight: 500;
	padding: var(--gap-xs) 0;
	border-bottom: 2px solid transparent;
}

.menu-link:hover {
	color: var(--ink);
	text-decoration: none;
}

.menu-link--here {
	color: var(--ink);
	border-bottom-color: var(--accent);
}

.menu-form {
	margin: 0;
}

/* Quiet on purpose: it is there to be checked, not read. The host beside it is
   what the masthead is for. */
.menu-who {
	color: var(--ink-muted);
	font-size: var(--fs-s);
	max-width: 14rem;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.linkish {
	border: 0;
	background: none;
	padding: var(--gap-xs) 0;
	font: inherit;
	font-size: var(--fs-s);
	font-weight: 500;
	color: var(--ink-muted);
	cursor: pointer;
}

.linkish:hover {
	color: var(--ink);
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

/* -------------------------------------------------------------------- page */

.page {
	flex: 1;
	width: 100%;
	max-width: var(--column);
	margin: 0 auto;
	padding: var(--gap-xl) var(--gap-l);
}

.page--narrow {
	max-width: var(--column-narrow);
}

.page-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--gap);
	margin-bottom: var(--gap-l);
}

.page-head-text {
	min-width: 0;
}

.page-head-actions {
	display: flex;
	gap: var(--gap-s);
}

.trail {
	font-size: var(--fs-s);
	color: var(--ink-muted);
	margin-bottom: var(--gap-xs);
}

.trail a {
	color: var(--ink-muted);
}

.trail a:hover {
	color: var(--ink);
}

.trail-step {
	padding: 0 0.4em;
	color: var(--rule);
}

.lead {
	margin: var(--gap-xs) 0 0;
	color: var(--ink-muted);
	max-width: 62ch;
}

.section {
	margin-top: var(--gap-xl);
}

.section-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--gap);
	margin-bottom: var(--gap-s);
}

.section-note {
	margin: 0;
	color: var(--ink-muted);
	font-size: var(--fs-s);
}

/* ----------------------------------------------------------------- command */

/* The loud thing. Everything else on the page is quiet so this can be found
   without being looked for. */
.command {
	position: relative;
	margin: 0 0 var(--gap);
	background: var(--sunken);
	border: 1px solid var(--rule);
	border-left: 3px solid var(--accent);
	border-radius: var(--round-panel);
	padding: var(--gap) var(--gap-l) var(--gap) var(--gap);
}

.command figcaption {
	font-size: var(--fs-xs);
	color: var(--ink-muted);
	margin-bottom: var(--gap-xs);
}

.command pre {
	margin: 0;
	overflow-x: auto;
	font-family: var(--mono);
	font-size: var(--fs-s);
	line-height: 1.7;
	white-space: pre;
}

.copy {
	position: absolute;
	top: var(--gap-s);
	right: var(--gap-s);
	border: 1px solid var(--rule);
	background: var(--surface);
	color: var(--ink-muted);
	border-radius: var(--round-control);
	font: inherit;
	font-size: var(--fs-xs);
	padding: 0.2rem 0.55rem;
	cursor: pointer;
}

.copy:hover {
	color: var(--ink);
	border-color: var(--ink-muted);
}

/* ------------------------------------------------------------------- shelf */

/* The listing. Rows on hairlines rather than cards: what tells one image from
   the next is its name and its figures, and a box around each would only
   repeat the gap that is already there. */
.shelf {
	border-top: 1px solid var(--rule);
}

.shelf-row {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--gap-s) var(--gap-l);
	padding: var(--gap) 0;
	border-bottom: 1px solid var(--rule-soft);
}

.shelf-main {
	min-width: 16rem;
	flex: 1;
}

.shelf-name {
	font-size: var(--fs-m);
	font-weight: 600;
	color: var(--ink);
	font-family: var(--mono);
	letter-spacing: -0.01em;
}

.shelf-name:hover {
	color: var(--accent);
}

.settings-name {
	font-size: var(--fs-m);
	font-weight: 600;
	color: var(--ink);
}

.settings-name:hover {
	color: var(--accent);
}

.shelf-note {
	margin: var(--gap-xs) 0 0;
	color: var(--ink-muted);
	font-size: var(--fs-s);
	max-width: 60ch;
}

/* The figures line up down the page, which is the whole reason they are set in
   a fixed-width face and given tabular numerals. */
.figures {
	display: flex;
	flex-wrap: wrap;
	gap: var(--gap-l);
	font-family: var(--mono);
	font-size: var(--fs-s);
	font-variant-numeric: tabular-nums;
	color: var(--ink-muted);
}

.figure-value {
	color: var(--ink);
}

.public {
	color: var(--accent);
	font-weight: 600;
}

.private {
	color: var(--ink-muted);
}

/* ------------------------------------------------------------------ tables */

.scroller {
	overflow-x: auto;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--fs-s);
}

thead th {
	text-align: left;
	font-weight: 500;
	font-size: var(--fs-xs);
	color: var(--ink-muted);
	padding: 0 var(--gap) var(--gap-xs) 0;
	border-bottom: 1px solid var(--rule);
	white-space: nowrap;
}

tbody td {
	padding: var(--gap-s) var(--gap) var(--gap-s) 0;
	border-bottom: 1px solid var(--rule-soft);
	vertical-align: baseline;
}

thead th:last-child,
tbody td:last-child {
	padding-right: 0;
	text-align: right;
}

/* Machine text, in the face machine text belongs in. */
td.machine,
th.machine {
	font-family: var(--mono);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.digest {
	font-family: var(--mono);
	color: var(--ink-muted);
	cursor: help;
}

.tagname {
	font-family: var(--mono);
	font-weight: 600;
}

/* ------------------------------------------------------------------ panels */

.panel {
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: var(--round-panel);
	padding: var(--gap-l);
}

.facts {
	margin: 0;
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: var(--gap-xs) var(--gap-l);
	font-size: var(--fs-s);
}

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

.facts dd {
	margin: 0;
	overflow-wrap: anywhere;
}

.nothing {
	border: 1px dashed var(--rule);
	border-radius: var(--round-panel);
	padding: var(--gap-xl) var(--gap-l);
	text-align: center;
	color: var(--ink-muted);
}

.nothing p {
	margin: 0 auto var(--gap);
	max-width: 44ch;
}

/* ------------------------------------------------------------------- forms */

.form {
	margin: 0;
}

.field {
	display: grid;
	gap: var(--gap-xs);
	margin-bottom: var(--gap);
}

.field label {
	font-size: var(--fs-s);
	font-weight: 500;
}

.field .help {
	font-size: var(--fs-xs);
	color: var(--ink-muted);
}

input[type="text"],
input[type="email"],
input[type="number"],
select,
textarea {
	font: inherit;
	font-size: var(--fs-s);
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--rule);
	border-radius: var(--round-control);
	padding: 0.55rem 0.65rem;
	min-height: 2.4rem;
	width: 100%;
}

textarea {
	min-height: 5rem;
	resize: vertical;
}

input.code {
	font-family: var(--mono);
	font-size: var(--fs-m);
	letter-spacing: 0.18em;
}

.choices {
	display: grid;
	gap: var(--gap-xs);
	border: 1px solid var(--rule);
	border-radius: var(--round-panel);
	padding: var(--gap-s) var(--gap);
	max-height: 15rem;
	overflow-y: auto;
	background: var(--surface);
}

.choice {
	display: flex;
	align-items: center;
	gap: var(--gap-s);
	font-size: var(--fs-s);
}

.choice input {
	width: auto;
	min-height: auto;
	accent-color: var(--accent);
}

.choice-name {
	font-family: var(--mono);
}

.actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--gap-s);
	margin-top: var(--gap-l);
}

.inline-form {
	display: inline;
	margin: 0;
}

.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.4rem;
	padding: 0.45rem 0.9rem;
	border: 1px solid var(--rule);
	border-radius: var(--round-control);
	background: var(--surface);
	color: var(--ink);
	font: inherit;
	font-size: var(--fs-s);
	font-weight: 500;
	cursor: pointer;
}

.button:hover {
	border-color: var(--ink-muted);
	text-decoration: none;
}

.button--primary {
	background: var(--accent);
	border-color: var(--accent);
	color: #ffffff;
}

.button--primary:hover {
	background: var(--accent-strong);
	border-color: var(--accent-strong);
}

.button--danger {
	color: var(--danger);
	border-color: var(--rule);
	background: var(--surface);
}

.button--danger:hover {
	border-color: var(--danger);
}

.button--wide {
	width: 100%;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) .button--primary {
		color: #06120f;
	}

	:root:not([data-theme="light"]) .modal {
		box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.55);
	}

	:root:not([data-theme="light"]) .modal::backdrop {
		background: rgba(0, 0, 0, 0.62);
	}
}

/* ------------------------------------------------------------------ modals */

/*
 * A form or a question over the page it was asked for from. This is the one
 * place a shadow is spent: everything else here is separated by a hairline
 * because it sits on the page, and a dialog does not — it is above it, and the
 * shadow is what says so.
 */
.modal {
	width: calc(100% - 2 * var(--gap));
	max-width: 34rem;
	max-height: calc(100vh - 4 * var(--gap));
	overflow-y: auto;
	padding: var(--gap-l);
	border: 1px solid var(--rule);
	border-radius: var(--round-panel);
	background: var(--surface);
	color: var(--ink);
	box-shadow: 0 1.5rem 3rem rgba(8, 20, 18, 0.22);
}

.modal--ask {
	max-width: 27rem;
}

.modal::backdrop {
	background: rgba(12, 24, 22, 0.5);
}

.modal-title {
	margin-bottom: var(--gap-s);
}

.modal-body {
	color: var(--ink-muted);
	font-size: var(--fs-s);
	margin-bottom: 0;
}

.modal-actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: var(--gap-s);
	margin-top: var(--gap-l);
}

/* The form inside a dialog has already been introduced by the heading above
   it, so it does not open with the gap a panel on a page would want. */
.modal .form .field:first-child {
	margin-top: 0;
}

/* One movement, answering the press that opened it. Anybody who has asked not
   to be moved gets the dialog already in place. */
@media (prefers-reduced-motion: no-preference) {
	.modal[open] {
		animation: modal-in 140ms ease-out;
	}

	@keyframes modal-in {
		from {
			opacity: 0;
			transform: translateY(0.5rem);
		}
	}
}

/* ------------------------------------------------------------------- notes */

.note {
	margin: 0 0 var(--gap-l);
	padding: var(--gap-s) var(--gap);
	border-radius: var(--round-control);
	font-size: var(--fs-s);
	max-width: none;
}

.note--done {
	background: var(--accent-soft);
	border-left: 3px solid var(--accent);
}

.note--wrong {
	background: var(--danger-soft);
	border-left: 3px solid var(--danger);
}

/* The secret, shown once. It is loud on purpose: this is the only moment the
   token exists anywhere a person can read it. */
.secret {
	border: 1px solid var(--accent);
	border-radius: var(--round-panel);
	padding: var(--gap-l);
	background: var(--accent-soft);
	margin-bottom: var(--gap-l);
}

.secret h2 {
	margin-bottom: var(--gap-xs);
}

/* ------------------------------------------------------------------ narrow */

@media (max-width: 46rem) {
	.masthead-row,
	.page {
		padding-left: var(--gap);
		padding-right: var(--gap);
	}

	.page {
		padding-top: var(--gap-l);
	}

	.menu {
		gap: var(--gap);
	}

	.figures {
		gap: var(--gap);
	}

	.facts {
		grid-template-columns: minmax(0, 1fr);
		gap: 0 0;
	}

	.facts dt {
		margin-top: var(--gap-s);
	}
}
