@import url("preflight.css");

/* The manual's look follows scuttle's menu bar: pages are numbered like workspaces in a top bar, the current one
   highlighted, and key bindings are keycaps. Green marks links and what is on; nothing else is colored. */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --bar: #e6e6e3;
  --fg: #222321;
  --dim: #6c6d69;
  --line: #d3d3cf;
  --accent: #0e7c66;
  --cap: #ffffff;
  --cap-edge: #bdbdb8;
  --code: #ebebe8;
  --tile: #fbfbfa;
  --measure: 74ch;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* The theme follows the system unless light or dark is chosen in the top bar, which sets data-theme on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #19191a;
    --bar: #232325;
    --fg: #e8e8e5;
    --dim: #9a9b96;
    --line: #333335;
    --accent: #3ccfac;
    --cap: #2c2c2f;
    --cap-edge: #4a4a4e;
    --code: #222224;
    --tile: #232325;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #19191a;
  --bar: #232325;
  --fg: #e8e8e5;
  --dim: #9a9b96;
  --line: #333335;
  --accent: #3ccfac;
  --cap: #2c2c2f;
  --cap-edge: #4a4a4e;
  --code: #222224;
  --tile: #232325;
}

html {
  line-height: 1.65;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
  text-decoration-thickness: 2px;
}

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

/* Top bar */

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  padding: 6px max(16px, 3vw);
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.bar .name {
  font-weight: 500;
  text-decoration: none;
}

.bar .repo {
  padding-left: 14px;
  border-left: 1px solid var(--line);
  text-decoration: none;
  color: var(--dim);
}

.bar .repo:hover {
  color: var(--fg);
}

.bar .end {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* A three-way toggle, drawn as one bordered control so it doesn't read as more links. */
.theme {
  display: flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.theme button {
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}

.theme button:hover {
  color: var(--fg);
}

.theme button[aria-pressed="true"] {
  background: var(--line);
  color: var(--fg);
}

.spaces {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.spaces a {
  padding: 1px 8px;
  border-radius: 4px;
  text-decoration: none;
}

.spaces a span {
  margin-left: 0.6ch;
  color: var(--dim);
}

.spaces a[aria-current="page"] {
  background: var(--fg);
  color: var(--bg);
}

.spaces a[aria-current="page"] span {
  color: var(--bg);
  opacity: 0.75;
}

/* Page */

main {
  max-width: calc(var(--measure) + 2 * max(16px, 3vw));
  padding: 36px max(16px, 3vw) 80px;
}

@media (min-width: 1000px) {
  main {
    margin-left: 10vw;
  }
}

h1,
h2,
h3 {
  font-weight: 500;
  line-height: 1.35;
  text-wrap: balance;
  scroll-margin-top: 64px;
}

h1 {
  margin: 0 0 1.2em;
  font-size: 21px;
}

h2 {
  margin: 2.4em 0 0.8em;
  font-size: 14px;
  color: var(--dim);
}

h2::before {
  content: "## ";
  color: var(--accent);
}

h3 {
  margin: 2em 0 0.6em;
  font-size: 14px;
}

h3::before {
  content: "### ";
  color: var(--accent);
}

h2 code,
h3 code {
  background: none;
  color: var(--fg);
}

p,
ul,
ol,
table,
pre,
blockquote {
  margin: 0 0 1.15em;
  max-width: var(--measure);
}

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

li + li {
  margin-top: 0.3em;
}

blockquote {
  padding-left: 2ch;
  border-left: 2px solid var(--line);
  color: var(--dim);
}

blockquote strong {
  color: var(--fg);
  font-weight: 500;
}

strong {
  font-weight: 500;
}

code {
  font: inherit;
  padding: 0 0.25em;
  border-radius: 3px;
  background: var(--code);
}

pre {
  max-width: 100%;
  padding: 12px 14px;
  overflow-x: auto;
  border-radius: 4px;
  background: var(--code);
}

pre code {
  padding: 0;
  background: none;
}

kbd {
  display: inline-block;
  min-width: 2.2em;
  padding: 0 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  white-space: nowrap;
  background: var(--cap);
  border: 1px solid var(--cap-edge);
  border-bottom-width: 2px;
  border-radius: 4px;
}

.app-icon {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 0 16px;
}

/* Tables */

table {
  width: 100%;
  border-collapse: collapse;
}

.wide-table {
  max-width: 120ch;
  margin-bottom: 1.15em;
  overflow-x: auto;
}

.wide-table table {
  min-width: 64ch;
  max-width: none;
  margin: 0;
}

th,
td {
  padding: 8px 2ch 8px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 500;
  color: var(--dim);
}

td:first-child {
  white-space: nowrap;
}

/* Figures */

figure {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 2ch;
  max-width: var(--measure);
  margin: 0 0 1.6em;
}

figure svg {
  flex: none;
  width: 22ch;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

figure.wide svg {
  width: 38ch;
}

figcaption {
  flex-basis: 100%;
  color: var(--dim);
  font-size: 13px;
}

figure .display {
  fill: var(--code);
  stroke: var(--line);
}

figure .tile {
  fill: var(--tile);
  stroke: var(--dim);
  vector-effect: non-scaling-stroke;
}

figure .off {
  opacity: 0.5;
}

figure .focus {
  stroke: var(--accent);
  stroke-width: 2;
}

figure text {
  fill: currentColor;
  font-size: 9px;
  text-anchor: middle;
  dominant-baseline: central;
}

@media (max-width: 600px) {
  body {
    font-size: 13px;
  }

  .spaces a span {
    display: none;
  }

  .spaces a[aria-current="page"] span {
    display: inline;
  }

  main {
    padding-top: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
