/* =====================================================================
   Tokens (design/BRIEF.md, the same values as web/src/app.css)
   ===================================================================== */
:root {
	color-scheme: light;
	--paper: #f8f6f1; /* page */
	--paper-sunk: #efebe3; /* code */
	--ink: #221f1a; /* text */
	--ink-2: #5d574d; /* secondary text */
	--ink-3: #766f63; /* numerals, notes */
	--rule: #d6cfc2; /* hairlines */
	--accent: #2536c4; /* blue pencil: the links */
	--accent-wash: #e4e6f6;
	--on-accent: #ffffff; /* text on an accent fill */

	--font-display: 'Brygada 1918', 'Iowan Old Style', Palatino, Georgia, serif;
	--font-text: 'Alegreya Sans', 'Gill Sans', 'Seravek', 'Segoe UI', sans-serif;
	--font-mono: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;

	--t-xs: 0.8125rem; /* 13 */
	--t-sm: 0.9375rem; /* 15 */
	--t-md: 1.125rem; /* 18, body */
	--t-lg: 1.3125rem; /* 21 */
	--t-xl: 1.75rem; /* 28 */
	--t-2xl: 2.25rem; /* 36 */
	--t-3xl: 3rem; /* 48 */

	--s-1: 0.25rem;
	--s-2: 0.5rem;
	--s-3: 0.75rem;
	--s-4: 1rem;
	--s-5: 1.5rem;
	--s-6: 2rem;
	--s-7: 3rem;
	--s-8: 4rem;
	--s-9: 6rem;

	--measure: 36rem; /* running text */
	--page: 74rem;
	--gutter: clamp(1rem, 4vw, 3rem);
	--radius: 3px;
}
/* Dark follows the system unless the toggle chose light; the toggle can also choose dark. */
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		color-scheme: dark;
		--paper: #1a1916;
		--paper-sunk: #24221e;
		--ink: #ece7dc;
		--ink-2: #b3ac9f;
		--ink-3: #948d80;
		--rule: #3a362f;
		--accent: #9aa6ff;
		--accent-wash: #262a47;
		--on-accent: #14151f;
	}
}
:root[data-theme='dark'] {
	color-scheme: dark;
	--paper: #1a1916;
	--paper-sunk: #24221e;
	--ink: #ece7dc;
	--ink-2: #b3ac9f;
	--ink-3: #948d80;
	--rule: #3a362f;
	--accent: #9aa6ff;
	--accent-wash: #262a47;
	--on-accent: #14151f;
}

/* =====================================================================
   Base
   ===================================================================== */
*,
*::before,
*::after {
	box-sizing: border-box;
}
html {
	-webkit-text-size-adjust: 100%;
	background: var(--paper);
}
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--font-text);
	font-size: var(--t-md);
	line-height: 1.5;
	font-variant-numeric: oldstyle-nums proportional-nums;
	text-rendering: optimizeLegibility;
	-webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
	font-family: var(--font-display);
	font-weight: 500;
	line-height: 1.15;
	margin: 0;
}
p,
ul,
ol {
	margin: 0;
}
code {
	font-family: var(--font-mono);
	font-size: 0.84em;
	font-variant-numeric: normal;
	letter-spacing: -0.01em;
}
a {
	color: var(--accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}
a:hover {
	text-decoration-thickness: 2px;
}
button {
	font: inherit;
	color: inherit;
}
:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 3px;
	border-radius: 2px;
}
.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}
.page {
	max-width: var(--page);
	margin: 0 auto;
	padding: 0 var(--gutter);
}

/* =====================================================================
   Masthead
   ===================================================================== */
.masthead {
	border-bottom: 1px solid var(--rule);
}
.masthead__inner {
	max-width: var(--page);
	margin: 0 auto;
	padding: var(--s-4) var(--gutter);
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: var(--s-2) var(--s-5);
}
.wordmark {
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 600;
	font-size: 1.5rem;
	letter-spacing: -0.01em;
	color: var(--ink);
	text-decoration: none;
}
.tools {
	display: flex;
	align-items: baseline;
	gap: var(--s-5);
	margin-left: auto;
}
.theme-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--s-2);
	background: none;
	border: 1px solid var(--rule);
	border-radius: 999px;
	padding: 2px var(--s-3);
	font-size: var(--t-sm);
	color: var(--ink-2);
	cursor: pointer;
}
.theme-toggle:hover {
	color: var(--ink);
	border-color: var(--ink-3);
}
.theme-toggle[hidden] {
	display: none;
}
.theme-toggle svg {
	width: 14px;
	height: 14px;
}
.sign-in {
	font-weight: 500;
	text-decoration: none;
}
.sign-in:hover {
	text-decoration: underline;
	text-decoration-thickness: 2px;
}

/* =====================================================================
   Hero: the question, and a proof sheet of error lines read with a
   blue pencil
   ===================================================================== */
.hero {
	max-width: var(--page);
	margin: 0 auto;
	padding: clamp(3.5rem, 9vw, 8rem) var(--gutter) clamp(4rem, 10vw, 9rem);
	display: grid;
	grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
	align-items: center;
	column-gap: var(--s-8);
}
.hero__title {
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 400;
	font-size: clamp(3rem, 1.4rem + 5.6vw, 5.75rem);
	line-height: 1.02;
	letter-spacing: -0.02em;
}
/* The pencil underlines the word the product is named for. */
.hero__our {
	position: relative;
	white-space: nowrap;
}
.hero__our svg {
	position: absolute;
	left: -2%;
	bottom: -0.16em;
	width: 104%;
	height: 0.26em;
	overflow: visible;
}
.hero__our path {
	fill: none;
	stroke: var(--accent);
	stroke-width: 3;
	stroke-linecap: round;
	vector-effect: non-scaling-stroke;
	stroke-dasharray: 100;
}
.lede {
	margin-top: var(--s-6);
	max-width: 24em;
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 1rem + 0.9vw, 1.625rem);
	line-height: 1.4;
	color: var(--ink-2);
}

/* The proof sheet. Lines are greeked: a tag and a few words as bars. */
.proof {
	margin: 0;
}
.proof svg {
	display: block;
	width: 100%;
	height: auto;
	max-height: 32rem;
}
.proof .tag,
.proof .bar {
	fill: var(--ink-3);
}
.proof .tag {
	opacity: 0.6;
}
.proof .bar {
	opacity: 0.3;
}
/* A pencil stroke: hidden until drawn, by running its dash offset from the path's length to none. */
.proof .mark {
	fill: none;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 100 101;
	stroke-dashoffset: 101; /* one past the length, so the round cap leaves no dot */
}
.proof .ring {
	stroke: var(--accent);
	stroke-width: 1.8;
}
.proof .strike {
	stroke: var(--ink-2);
	stroke-width: 1.3;
}
.proof .ours {
	font-family: var(--font-display);
	font-style: italic;
	font-size: 19px;
	fill: var(--accent);
	opacity: 0;
}
/* Without motion the sheet is still: the lines above the reading line are marked, the ones below are not. */
.proof .mark.seen {
	stroke-dashoffset: 0;
}
.proof .ours.seen {
	opacity: 1;
}

@media (width < 64rem) {
	.hero {
		grid-template-columns: minmax(0, 1fr);
		row-gap: var(--s-7);
	}
	.proof svg {
		max-height: 22rem;
	}
}

/* The stream travels one copy of its lines every 28 seconds, the period build/landing-hero.py times each
   mark against: --at is the second a line reaches the reading line, and a mark stays drawn until the line
   has left the top. */
@media (prefers-reduced-motion: no-preference) {
	.hero__our path {
		stroke-dashoffset: 100;
		animation: underline 0.9s ease-out 0.5s forwards;
	}
	.proof .stream {
		animation: drift 28s linear infinite;
	}
	.proof .mark {
		animation: pencil 28s linear infinite;
		animation-delay: calc(var(--at) * 1s - 28s);
	}
	.proof .ours {
		animation: margin-note 28s linear infinite;
		animation-delay: calc(var(--at) * 1s - 28s);
	}
}
@keyframes underline {
	to {
		stroke-dashoffset: 0;
	}
}
@keyframes drift {
	to {
		transform: translateY(-476px);
	}
}
@keyframes pencil {
	0% {
		stroke-dashoffset: 101;
		animation-timing-function: ease-out;
	}
	3.2%,
	60% {
		stroke-dashoffset: 0;
	}
	60.01%,
	100% {
		stroke-dashoffset: 101;
	}
}
@keyframes margin-note {
	0%,
	3% {
		opacity: 0;
	}
	5.5%,
	60% {
		opacity: 1;
	}
	60.01%,
	100% {
		opacity: 0;
	}
}

/* =====================================================================
   Parts: a section title in the margin, its content beside it
   ===================================================================== */
.part {
	display: grid;
	grid-template-columns: 12rem minmax(0, 1fr);
	column-gap: var(--s-8);
	border-top: 2px solid var(--ink);
	padding: var(--s-6) 0 var(--s-9);
}
.part > h2 {
	font-size: var(--t-xl);
}
@media (max-width: 52rem) {
	.part {
		grid-template-columns: minmax(0, 1fr);
	}
	.part {
		padding-bottom: var(--s-8);
	}
	.part > h2 {
		margin-bottom: var(--s-6);
	}
}

/* =====================================================================
   Steps: a numbered sequence, the numeral in its own column
   ===================================================================== */
.steps {
	list-style: none;
	padding: 0;
	max-width: 44rem;
	counter-reset: step;
}
.steps li {
	counter-increment: step;
	display: grid;
	grid-template-columns: 2.5rem minmax(0, 1fr);
	padding: var(--s-5) 0;
	border-bottom: 1px solid var(--rule);
}
.steps li:first-child {
	padding-top: var(--s-1);
}
.steps li::before {
	content: counter(step);
	grid-row: span 2;
	font-family: var(--font-display);
	font-size: var(--t-xl);
	line-height: 1;
	color: var(--ink-3);
	font-variant-numeric: lining-nums;
}
.steps h3 {
	font-size: var(--t-lg);
	line-height: 1.25;
}
.steps p {
	margin-top: var(--s-2);
	color: var(--ink-2);
	max-width: var(--measure);
}
@media (min-width: 64rem) {
	/* Wide: the steps two to a row, read across and down, a hairline above each row after the first. */
	.steps {
		max-width: none;
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: var(--s-7);
	}
	.steps li,
	.steps li:first-child {
		align-content: start;
		padding: var(--s-5) 0 var(--s-6);
		border-bottom: 0;
		border-top: 1px solid var(--rule);
	}
	.steps li:nth-child(-n + 2) {
		padding-top: var(--s-1);
		border-top: 0;
	}
}

/* =====================================================================
   Points: short titled items in two columns, in no order
   ===================================================================== */
.points {
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	column-gap: var(--s-7);
}
.points li {
	padding: var(--s-4) 0 var(--s-5);
	border-bottom: 1px solid var(--rule);
}
.points li:nth-child(-n + 2) {
	padding-top: var(--s-1);
}
.points h3 {
	font-size: var(--t-lg);
	font-style: italic;
	font-weight: 400;
	line-height: 1.25;
}
.points p {
	margin-top: var(--s-1);
	color: var(--ink-2);
	max-width: var(--measure);
}
.points code {
	background: var(--paper-sunk);
	color: var(--ink);
	padding: 0.05em 0.3em;
	border-radius: var(--radius);
	white-space: nowrap;
}
@media (max-width: 36rem) {
	.points {
		grid-template-columns: minmax(0, 1fr);
	}
	.points li:nth-child(2) {
		padding-top: var(--s-4);
	}
}

/* =====================================================================
   The numbers: a short table of each judgement against its labelled
   set. On a narrow window each row restacks, its cells named in italic.
   ===================================================================== */
.measured > p:first-child {
	max-width: var(--measure);
	color: var(--ink-2);
}
.measures {
	margin-top: var(--s-5);
	width: 100%;
	max-width: 44rem;
	border-collapse: collapse;
	font-size: var(--t-sm);
	line-height: 1.45;
	font-variant-numeric: lining-nums tabular-nums;
}
.measures thead th {
	text-align: left;
	vertical-align: bottom;
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 400;
	font-size: var(--t-md);
	padding: 0 var(--s-4) var(--s-2) 0;
	border-bottom: 1px solid var(--ink);
	white-space: nowrap;
}
.measures tbody th,
.measures td {
	text-align: left;
	vertical-align: top;
	padding: var(--s-3) var(--s-4) var(--s-3) 0;
	border-bottom: 1px solid var(--rule);
}
.measures tbody th {
	font-family: var(--font-text);
	font-weight: 500;
}
.measures td {
	color: var(--ink-2);
}
.measures td:last-child {
	color: var(--ink);
}
.measures th:last-child,
.measures td:last-child {
	padding-right: 0;
}
.measured .note {
	margin-top: var(--s-5);
}
@media (max-width: 36rem) {
	.measures,
	.measures tbody,
	.measures tr,
	.measures th,
	.measures td {
		display: block;
	}
	.measures thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.measures tbody {
		border-top: 1px solid var(--ink);
	}
	.measures tr {
		padding: var(--s-3) 0;
		border-bottom: 1px solid var(--rule);
	}
	.measures tbody th,
	.measures td {
		border: 0;
		padding: 0;
	}
	.measures tbody th {
		padding-bottom: var(--s-1);
	}
	.measures td {
		display: flex;
		gap: var(--s-2);
	}
	.measures td::before {
		content: attr(data-label);
		flex: 0 0 7rem;
		font-family: var(--font-display);
		font-style: italic;
		color: var(--ink-3);
	}
}

/* =====================================================================
   Kept and not kept: two short columns
   ===================================================================== */
.ledger {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--s-7) var(--s-8);
}
@media (max-width: 36rem) {
	.ledger {
		grid-template-columns: minmax(0, 1fr);
	}
}
.ledger h3 {
	font-size: var(--t-lg);
	font-style: italic;
	font-weight: 400;
	padding-bottom: var(--s-2);
	border-bottom: 1px solid var(--ink);
}
.ledger ul {
	list-style: none;
	padding: 0;
}
.ledger li {
	padding: var(--s-4) 0;
	border-bottom: 1px solid var(--rule);
}
.note {
	margin-top: var(--s-7);
	max-width: var(--measure);
	color: var(--ink-3);
	font-size: var(--t-sm);
}

/* The link to how-it-works.html, after the steps, in the lede's voice. */
.onward {
	padding-bottom: var(--s-8);
	max-width: 30em;
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 1rem + 0.9vw, 1.625rem);
	line-height: 1.4;
	color: var(--ink-2);
}
.onward a {
	white-space: nowrap;
}

/* The one line on cost, closing the page above the colophon, at the lede's size and measure. */
.coda {
	border-top: 2px solid var(--ink);
	padding: var(--s-6) 0 var(--s-8);
	font-family: var(--font-display);
	font-size: clamp(1.25rem, 1rem + 0.9vw, 1.625rem);
	line-height: 1.4;
	color: var(--ink-2);
}
.coda span {
	display: block;
	max-width: 30em;
}

/* =====================================================================
   Colophon
   ===================================================================== */
.colophon {
	border-top: 1px solid var(--rule);
	padding: var(--s-6) 0 var(--s-9);
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--s-3) var(--s-6);
	font-size: var(--t-sm);
}
.colophon p {
	color: var(--ink-2);
	font-family: var(--font-display);
	font-style: italic;
	max-width: var(--measure);
}
.colophon ul {
	list-style: none;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-2) var(--s-5);
}

/* =====================================================================
   Documents: the second pages, data-retention.html (.doc) and
   how-it-works.html (.more), set as one column at the reading measure
   under a large italic title, each section opened by a 2px ink rule.
   ===================================================================== */
.doc,
.more {
	display: grid;
	grid-template-columns:
		[full-start] minmax(0, 1fr)
		[measure-start] minmax(0, var(--measure))
		[measure-end] minmax(0, 1fr)
		[full-end];
	padding: clamp(2.5rem, 7vw, 5rem) 0 var(--s-8);
}
/* Grid items keep their margins apart, so each block sets only the space above it. */
.doc > *,
.more > * {
	grid-column: measure;
	min-width: 0;
}
.doc > * + *,
.more > * + * {
	margin-top: var(--s-4);
}
.doc__title,
.more__title {
	font-style: italic;
	font-weight: 400;
	font-size: clamp(2.25rem, 1.5rem + 3vw, 3.75rem);
	line-height: 1.05;
	letter-spacing: -0.02em;
}
.doc > .doc__changed {
	margin-top: var(--s-3);
	color: var(--ink-3);
	font-size: var(--t-sm);
}
.doc > .doc__changed + * {
	margin-top: var(--s-6);
}
.doc > h2,
.more h2 {
	font-size: var(--t-xl);
	border-top: 2px solid var(--ink);
	padding-top: var(--s-5);
}
.doc > h2,
.more > section {
	margin-top: var(--s-8);
}
.doc > h2 + *,
.more h2 + * {
	margin-top: var(--s-5);
}

/* how-it-works.html: the landing page's points, numbers and ledger, read down the one column. */
.more > .more__lede {
	margin-top: var(--s-5);
	font-family: var(--font-display);
	font-size: var(--t-lg);
	line-height: 1.45;
	color: var(--ink-2);
}
.more .points {
	grid-template-columns: minmax(0, 1fr);
}
.more .points li:nth-child(2) {
	padding-top: var(--s-4);
}
.more .ledger {
	column-gap: var(--s-6);
}

/* The data retention policy, which build/data-retention-page.py writes from the public blocks of
   docs/DATA-RETENTION.md. A table of four or more columns alone takes the page's column, between hairlines.
   Tables restack into one card per row on a narrow window. */
.doc ol,
.doc ul {
	padding-left: 1.4em;
}
.doc li + li {
	margin-top: var(--s-3);
}
.doc li::marker {
	color: var(--ink-3);
	font-variant-numeric: lining-nums;
}
.doc strong {
	font-weight: 500;
}
/* A placeholder the contract still holds: marked so it cannot pass for text. The deploy refuses to publish the page while one is left. */
.doc > .doc__placeholder {
	padding: var(--s-3) var(--s-4);
	border: 1px dashed var(--accent);
	background: var(--accent-wash);
	color: var(--ink);
}
.doc > .doc__table,
.doc > .doc__table + * {
	margin-top: var(--s-5);
}
.doc > .doc__table--wide {
	grid-column: full;
	border-top: 1px solid var(--rule);
	border-bottom: 1px solid var(--rule);
	padding: var(--s-4) 0;
}
.doc table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--t-sm);
	line-height: 1.45;
}
.doc th {
	text-align: left;
	vertical-align: bottom;
	font-family: var(--font-display);
	font-style: italic;
	font-weight: 400;
	font-size: var(--t-md);
	padding: 0 var(--s-4) var(--s-2) 0;
	border-bottom: 1px solid var(--ink);
	white-space: nowrap;
}
.doc td {
	vertical-align: top;
	padding: var(--s-3) var(--s-4) var(--s-3) 0;
	border-bottom: 1px solid var(--rule);
	overflow-wrap: break-word;
}
.doc th:last-child,
.doc td:last-child {
	padding-right: 0;
}
.doc td:first-child {
	font-weight: 500;
}
@media (max-width: 40rem) {
	/* One card per row: the first cell is its heading, every other cell carries its column's name. The ARIA roles
	   on the table keep it a table for assistive technology after display changes. */
	.doc table,
	.doc thead,
	.doc tbody,
	.doc tr,
	.doc td {
		display: block;
	}
	.doc thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.doc tbody {
		border-top: 1px solid var(--ink);
	}
	.doc tr {
		padding: var(--s-4) 0;
		border-bottom: 1px solid var(--rule);
	}
	.doc td {
		position: relative;
		border: 0;
		padding: var(--s-1) 0 var(--s-1) 6.75rem;
		overflow-wrap: anywhere;
	}
	.doc td::before {
		content: attr(data-label);
		position: absolute;
		left: 0;
		width: 6rem;
		font-family: var(--font-display);
		font-style: italic;
		color: var(--ink-3);
	}
	.doc td:first-child {
		padding-left: 0;
		font-size: var(--t-md);
		padding-bottom: var(--s-2);
	}
	.doc td:first-child::before {
		content: none;
	}
}

/* =====================================================================
   Status: status.html, read from the canary's status.json. A state is
   a word: down in the accent, degraded at 500, unknown in italics. Each
   component's 90 days are a strip of marks, one per UTC day.
   ===================================================================== */
.more > .status__checked {
	margin-top: var(--s-3);
	color: var(--ink-3);
	font-size: var(--t-sm);
}
.status__components {
	list-style: none;
	padding: 0;
}
.status__component {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: baseline;
	gap: var(--s-2) var(--s-4);
	padding: var(--s-4) 0 var(--s-5);
	border-top: 1px solid var(--rule);
}
.status__component:first-child {
	border-top: 0;
	padding-top: 0;
}
.status__component h3 {
	font-size: var(--t-lg);
	font-weight: 500;
}
.status__state {
	color: var(--ink-2);
}
.status__component[data-state='degraded'] .status__state {
	color: var(--ink);
	font-weight: 500;
}
.status__component[data-state='down'] .status__state {
	color: var(--accent);
	font-weight: 700;
}
.status__component[data-state='unknown'] .status__state {
	color: var(--ink-3);
	font-style: italic;
}
.status__days {
	grid-column: 1 / -1;
	list-style: none;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(90, minmax(0, 1fr));
	gap: 1px;
	height: 1.75rem;
}
.status__day {
	background: var(--paper-sunk);
}
.status__day--clean {
	background: var(--ink-3);
}
.status__day--failed {
	background: var(--ink);
}
.status__summary {
	grid-column: 1 / -1;
	color: var(--ink-3);
	font-size: var(--t-sm);
}
