/* SPDX-License-Identifier: MIT */

@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Source Serif 4";
  src: url("/fonts/source-serif-4-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ground: #0B0F17;
  --raised: #141A26;
  --ink: #ECE8DF;
  --ink-2: #B9B5AC;
  --ink-3: #8A8780;
  --rule: #263042;
  --amber: #E39B3B;
  --amber-wash: rgba(227, 155, 59, 0.09);
  --amber-fill: rgba(227, 155, 59, 0.22);
  --sans: "Space Grotesk", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 38rem;
  --margin: 16rem;
  --gutter: 3rem;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ground: #F4F1EA;
    --raised: #FFFFFF;
    --ink: #141821;
    --ink-2: #4A4F5A;
    --ink-3: #6E727B;
    --rule: #DAD5CA;
    --amber: #B86E14;
    --amber-wash: rgba(184, 110, 20, 0.08);
    --amber-fill: rgba(184, 110, 20, 0.16);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.0625rem/1.65 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration-color: var(--amber); text-underline-offset: 0.2em; }
a:hover { color: var(--amber); }
a:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }

code { font-family: var(--mono); font-size: 0.86em; }

/* The bar, top and foot. */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.mark { width: 1.75rem; height: 1.75rem; }
.mark .ring { fill: none; stroke: var(--ink); stroke-width: 34; }
.mark .trojan { fill: var(--amber); stroke: var(--ground); stroke-width: 12; }

.bar nav { display: flex; gap: 1.25rem; }
.bar nav a { text-decoration: none; color: var(--ink-2); }
.bar nav a:hover { color: var(--amber); }
.bar nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--amber); }

.foot {
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 0.9rem;
}
.foot a { text-decoration: none; }

main {
  flex: 1;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* The landing page. */

.hero { padding: 1rem 0 2.5rem; }

.orbit { display: block; width: 100%; height: auto; margin: 0 0 1.5rem; }
.orbit .arc { fill: none; stroke: var(--ink); stroke-opacity: 0.4; stroke-width: 2; }
.orbit .frame { fill: none; stroke: var(--ink); stroke-opacity: 0.14; stroke-width: 1.5; }
.orbit .planet { fill: var(--ink); }
.orbit .swarm { fill: var(--ink); fill-opacity: 0.55; }
.orbit .l4 { fill: var(--amber); }

h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 34rem;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  line-height: 1.4;
  color: var(--ink-2);
}

.prose { max-width: 40rem; }
.prose p { margin: 0 0 1.1rem; }

h2 { font-size: 1.35rem; margin: 0 0 0.75rem; }

.status {
  padding: 0.9rem 1.1rem;
  border-left: 3px solid var(--amber);
  background: var(--raised);
  border-radius: 0 6px 6px 0;
}

.links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.1rem 1.2rem;
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s;
}
.card:hover { color: inherit; border-color: var(--amber); }
.card .label { font-weight: 700; font-size: 1.1rem; }
.card .label::after { content: " \2192"; color: var(--amber); }
.card .what { color: var(--ink-2); font-size: 0.95rem; line-height: 1.5; }

.missing { padding: 4rem 1rem; }
.missing h1 { font-size: clamp(2.5rem, 8vw, 4rem); }

/* An explainer: one reading column in the serif, notes in the margin beside it. */

.page article {
  max-width: var(--measure);
  padding-top: 1.5rem;
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.6;
  font-optical-sizing: auto;
}

.page h1 {
  font-family: var(--sans);
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  line-height: 1.05;
}

.page .lede { font-family: var(--serif); font-style: italic; margin-bottom: 2.5rem; max-width: none; }

.page h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 3rem 0 1rem;
}

.page p, .page ul { margin: 0 0 1.25rem; }
.page ul { padding-left: 1.25rem; }
.page li { margin-bottom: 0.6rem; }
.page li::marker { color: var(--amber); }

.page .status { font-size: 1.0625rem; margin: 1.75rem 0; }
.page .status strong { font-family: var(--sans); }

.chapter {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.asof {
  margin-top: 3rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--ink-3);
}

/* Margin notes: the number in the text, the note beside the paragraph or, on a narrow screen,
   under the line it belongs to. */

.ref {
  font-family: var(--sans);
  font-size: 0.7em;
  line-height: 0;
  margin-left: 0.1em;
}
.ref a { color: var(--amber); text-decoration: none; padding: 0 0.1em; }

.note {
  display: block;
  margin: 0.6rem 0 0.9rem;
  padding: 0.1rem 0 0.1rem 0.9rem;
  border-left: 2px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.note .n { color: var(--amber); font-weight: 700; margin-right: 0.25em; }
.note code { font-size: 0.82rem; overflow-wrap: anywhere; }
.note:target { border-left-color: var(--amber); }

@media (min-width: 62rem) {
  .note {
    float: right;
    clear: right;
    width: var(--margin);
    margin: 0.3rem calc(-1 * (var(--margin) + var(--gutter))) 1rem 0;
    padding: 0;
    border: 0;
  }
}

/* Figures: wider than the column, so they read as set pieces. */

.wide { margin: 2.5rem 0; clear: both; }
@media (min-width: 62rem) {
  .wide { width: calc(var(--measure) + var(--gutter) + var(--margin)); }
}

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 1.25rem;
}

.panel {
  background: var(--raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1rem 1rem 0.25rem;
}
.panel svg { display: block; width: 100%; height: auto; }
.panel p {
  font-family: var(--sans);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0.75rem 0;
}
.panel p strong { color: var(--ink); }

.bounds .lbl { font-family: var(--sans); font-size: 15px; fill: var(--ink-2); }
.bounds .lbl.amber { fill: var(--amber); font-weight: 600; }
.bounds .lbl.ink { fill: var(--ink); font-weight: 600; }
.bounds .space { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.bounds .spec { fill: var(--amber-wash); stroke: var(--amber); stroke-width: 2; }
.bounds .does { fill: var(--ink); }
.bounds .hollow { fill: var(--raised); stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 3 3; }
.bounds .witness { fill: none; stroke: var(--ink); stroke-opacity: 0.5; stroke-width: 2; }
.bounds .throwaway { fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-dasharray: 6 5; }
.bounds .cross { stroke: var(--ink-2); stroke-width: 2.5; stroke-linecap: round; }
.bounds .boot { fill: var(--ink); }
.bounds .way { fill: var(--amber); stroke: var(--raised); stroke-width: 3; }

/* Previous and next, at the end of a page that has them. */

.turn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: var(--measure);
  margin-top: 3rem;
}
.turn a {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.turn a:hover { border-color: var(--amber); color: inherit; }
.turn span { font-size: 0.8rem; font-weight: 400; color: var(--ink-3); }
.turn .next { grid-column: 2; text-align: right; }

/* Diagrams and plots: drawn in the page's colours, so they follow light and dark. */

.figure .panel { padding-top: 1.25rem; }
.diagram text, .plot text { font-family: var(--sans); }
.diagram .lbl, .plot .lbl { font-size: 15px; fill: var(--ink-2); }
.diagram .lbl.ink, .plot .lbl.ink { fill: var(--ink); font-weight: 600; }
.diagram .lbl.amber, .plot .lbl.amber { fill: var(--amber); font-weight: 600; }
.diagram .tick, .plot .tick { font-size: 14px; fill: var(--ink-3); }
.diagram .node rect { fill: var(--ground); stroke: var(--ink-2); stroke-width: 1.5; }
.diagram .node text { font-size: 14px; fill: var(--ink); }
.diagram .node.key rect { stroke: var(--amber); stroke-width: 2; }
.diagram .run { fill: var(--amber-wash); stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 5 4; }
.diagram .link { fill: none; stroke: var(--ink-3); stroke-width: 2; }
.diagram .cell { fill: var(--ground); stroke: var(--rule); stroke-width: 1.5; }
.diagram .cell.off { fill: none; stroke-dasharray: 3 3; }
.diagram .cell.key { fill: var(--amber-fill); stroke: var(--amber); stroke-width: 2; }
.diagram .cell.hidden { fill: var(--rule); }
.diagram .cell.block { fill: var(--amber-fill); stroke: var(--amber); }
.diagram .blk { fill: var(--amber-fill); stroke: var(--amber); stroke-width: 2; }
.diagram .brace { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.diagram .arrow { fill: none; stroke: var(--amber); stroke-width: 2; }
.diagram .names { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.plot .grid { stroke: var(--rule); stroke-width: 1; }
.plot .series { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.plot .reach { fill: var(--amber); stroke: var(--raised); stroke-width: 2; }
.plot .limit { stroke: var(--amber); stroke-width: 2; }
.plot .floor { stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 6 5; }

/* A plot or table wider than a phone scrolls inside its frame rather than shrinking past reading. */

.scroll { overflow-x: auto; }
.scroll .plot { min-width: 36rem; }

.page table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.page th, .page td { padding: 0.55rem 0.9rem; text-align: right; border-bottom: 1px solid var(--rule); }
.page th:first-child, .page td:first-child { text-align: left; }
.page thead th { color: var(--ink-2); font-weight: 600; font-size: 0.85rem; vertical-align: bottom; }
.page thead th[colspan] { text-align: center; border-bottom-color: var(--ink-3); }
.page tr.now td { color: var(--amber); font-weight: 600; }

/* Two lists side by side, each under a heading. */

.tally ul { font-family: var(--sans); font-size: 0.95rem; line-height: 1.5; margin: 0 0 1rem; }
.tally li { margin-bottom: 0.5rem; }
.tally .tally-head { color: var(--ink); font-weight: 700; font-size: 1rem; margin: 0 0 0.75rem; }

.page ol.steps { padding-left: 1.5rem; }
.page ol.steps li::marker { color: var(--amber); font-family: var(--sans); font-weight: 700; }

/* A section's pages, listed on its first page. */

.page ol.contents { list-style: none; padding: 0; margin: 1.5rem 0 2rem; counter-reset: q; }
.contents li { counter-increment: q; margin: 0; border-top: 1px solid var(--rule); }
.contents li:last-child { border-bottom: 1px solid var(--rule); }
.contents a {
  display: block;
  padding: 1rem 0 0.2rem 2.5rem;
  position: relative;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.35;
  text-decoration: none;
}
.contents a::before {
  content: counter(q);
  position: absolute;
  left: 0;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.contents span { display: block; padding: 0 0 1rem 2.5rem; font-size: 1rem; line-height: 1.5; color: var(--ink-2); }
