@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

/*
 * Press Start 2P, the face the client wears, on exactly two things: the name of
 * the game and the way into it. It is a display type — near enough square per
 * character, no lowercase rhythm — and asking it to carry three thousand lines
 * of documentation was tried and was worse. Everything else is a plain sans,
 * which is what the reading is for.
 */
:root {
  color-scheme: light dark;
  --font-display: "Press Start 2P", ui-monospace, monospace;
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ink: #1b1b1f;
  --ink-soft: #5b5b66;
  --page: #fbfbfa;
  --panel: #f2f1ee;
  --line: #dcdad4;
  --accent: #8a5a2b;
  --measure: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e6e1;
    --ink-soft: #9b978e;
    --page: #16161a;
    --panel: #1d1d22;
    --line: #2e2e36;
    --accent: #d8a35f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.7 var(--font-body);
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 1rem;
  top: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--panel);
  z-index: 2;
}

.shell {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr) 12rem;
  gap: 3rem;
  max-width: 82rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
.shell.no-aside { grid-template-columns: 17rem minmax(0, 1fr); max-width: 76rem; }

nav {
  position: sticky;
  top: 2rem;
  align-self: start;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  font-size: 0.9rem;
}

.mark { display: block; flex: none; image-rendering: pixelated; }

/* One of the two things wearing the game's face. */
nav .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--ink);
  text-decoration: none;
}

/* And the other. Square, with a hard offset shadow that moves when pressed:
   a rounded corner was the one thing here that could not have been drawn on a
   grid. */
nav .play {
  display: block;
  margin-bottom: 1.75rem;
  padding: 0.7rem 0.9rem;
  background: var(--accent);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.7rem;
  text-align: center;
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--line);
}
nav .play:hover { filter: brightness(1.08); }
nav .play:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--line); }

nav h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  margin: 1.5rem 0 0.5rem;
}

nav ul { list-style: none; margin: 0; padding: 0; }
nav li { margin: 0.1rem 0; }

/* ---- search ---- */

.find { position: relative; margin-bottom: 0.5rem; }
.find input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
}
.find input::placeholder { color: var(--ink-soft); }
.find kbd {
  position: absolute;
  right: 0.5rem;
  top: 0.5rem;
  font-size: 0.7rem;
  color: var(--ink-soft);
  pointer-events: none;
}
.find input:focus + kbd { display: none; }

.hits { list-style: none; margin: 0; padding: 0; }
.hits li a {
  display: block;
  padding: 0.5rem 0.6rem;
  margin: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.hits b { display: block; color: var(--ink); font-size: 0.85rem; }
.hits em {
  display: block;
  font-style: normal;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}
.hits mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; }
.hits .where { font-weight: 400; font-size: 0.72rem; color: var(--ink-soft); }
.none { color: var(--ink-soft); font-size: 0.82rem; padding: 0.6rem 0.2rem; }

/* A link that names no page keeps its words and loses its promise. */
.dead-link { color: var(--ink-soft); }

/* ---- on this page ---- */

.onpage {
  position: sticky;
  top: 2rem;
  align-self: start;
  font-size: 0.8rem;
  line-height: 1.4;
}
.onpage h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}
.onpage a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.6rem;
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  text-decoration: none;
}
.onpage a:hover { color: var(--ink); }
.onpage a.deep { padding-left: 1.3rem; font-size: 0.75rem; }
.onpage a.on { color: var(--accent); border-left-color: var(--accent); }

/* ---- previous and next ---- */

.walk {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.walk a { max-width: 46%; text-decoration: none; color: var(--ink); }
.walk a:hover { color: var(--accent); }
.walk span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.walk .fwd { text-align: right; }

/* ---- the bar that only small screens see ---- */

.bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar button {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}
.bar b { font-size: 0.85rem; }

nav a {
  display: block;
  padding: 0.25rem 0.6rem;
  margin-left: -0.6rem;
  border-radius: 4px;
  color: var(--ink-soft);
  text-decoration: none;
}
nav a:hover { color: var(--ink); background: var(--panel); }
nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--panel);
  box-shadow: inset 2px 0 0 var(--accent);
}

main { max-width: var(--measure); min-width: 0; }

article h1 {
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}
article h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
article h3 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }

article a { color: var(--accent); text-underline-offset: 2px; }

/* Kept from when every table was wider than the screen. It costs nothing when
   they fit and saves the page from scrolling sideways on a phone when they do
   not. */
.scroll { overflow-x: auto; margin: 1.25rem 0; }

article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
article th, article td {
  text-align: left;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
article th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

article code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--panel);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
article pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
article pre code { background: none; padding: 0; }

article blockquote {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--line);
  color: var(--ink-soft);
}

article hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* The contents column is the first thing to go: it is a convenience, and the
   article is not. */
@media (max-width: 72rem) {
  .shell, .shell.no-aside { grid-template-columns: 17rem minmax(0, 1fr); }
  .onpage { display: none; }
}

@media (max-width: 52rem) {
  .shell, .shell.no-aside { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 1rem; }
  .bar { display: flex; }
  /* Off to the side until asked for, rather than a wall of links above every
     page. */
  .rail {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(20rem, 86vw);
    max-height: none;
    padding: 1.5rem 1.25rem;
    background: var(--panel);
    border-right: 1px solid var(--line);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  .rail.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.45); }
}

@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
}
