/* The site's whole stylesheet: one warm, quiet page for a README.
   Chrome at the top, then the article, then the small screen. */

:root {
  color-scheme: light dark;
  --bg: #fbf8f4;
  --surface: #fffdfa;
  --ink: #221d19;
  --muted: #6b6058;
  --line: #e8dfd4;
  --accent: #b3522e;
  --accent-ink: #fff8f4;
  --code: #f3ece2;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: #1b1713;
    --ink: #f2ebe3;
    --muted: #a2968b;
    --line: #302821;
    --accent: #e98b62;
    --accent-ink: #17120e;
    --code: #201a15;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans", "PingFang SC",
    "Hiragino Sans", "Microsoft YaHei", sans-serif;
  font-size: 16.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.06em;
}

a:hover {
  text-decoration-thickness: 0.12em;
}

/* --- chrome -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.locales {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-left: auto;
}

.locales a {
  padding: 0.15rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
}

.locales a:hover {
  border-color: var(--line);
  color: var(--ink);
}

.locales a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.gh {
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: none;
  white-space: nowrap;
}

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

.wrap {
  max-width: 64rem;
  margin: 0 auto;
  padding: 2.2rem 1.25rem 4rem;
}

/* --- the README, rendered ------------------------------------------------ */

.doc {
  max-width: 47rem;
  margin: 0 auto;
}

.doc > :first-child {
  margin-top: 0;
}

.doc h1 {
  margin: 0.4rem 0 0.9rem;
  font-size: clamp(2rem, 1.4rem + 2.6vw, 2.9rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* Every README opens by pointing at the documentation; it is a signpost, so it
   reads as small print rather than as the first sentence of the page. */
.doc h1 + p {
  color: var(--muted);
  font-size: 0.9rem;
}

.doc h2 {
  margin: 3.4rem 0 1rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.6rem);
  line-height: 1.3;
  letter-spacing: -0.02em;
  scroll-margin-top: 5.5rem;
}

.doc h3 {
  margin: 2.2rem 0 0.6rem;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  scroll-margin-top: 5.5rem;
}

.doc h4 {
  margin: 1.8rem 0 0.4rem;
  font-size: 1rem;
}

.doc p {
  margin: 1rem 0;
}

.doc p[align="center"] {
  text-align: center;
}

.doc ul,
.doc ol {
  margin: 1rem 0;
  padding-left: 1.35rem;
}

.doc li {
  margin: 0.4rem 0;
}

.doc strong {
  font-weight: 650;
}

.doc hr {
  margin: 2.6rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.doc img {
  max-width: 100%;
  height: auto;
}

.doc a img {
  vertical-align: middle;
}

.doc blockquote {
  margin: 1.4rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.doc code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
}

.doc :not(pre) > code {
  padding: 0.12em 0.38em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code);
}

.doc pre {
  margin: 1.4rem 0;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--code);
  font-size: 0.84rem;
  line-height: 1.7;
}

.doc pre code {
  font-size: inherit;
}

.table-wrap {
  margin: 1.4rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.doc th,
.doc td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.doc th {
  background: var(--code);
  font-weight: 600;
  white-space: nowrap;
}

/* The state tables lead with a name and a sprite; without a floor the browser
   gives that column all the shrinking and the names break one character wide. */
.doc th:first-child,
.doc td:first-child {
  min-width: 6.5rem;
}

.doc tbody tr:last-child td {
  border-bottom: 0;
}

/* The animation gallery is centred art, not data: it keeps its own layout. */
.table-gallery {
  border: 0;
  background: none;
}

.doc table[align="center"] {
  width: auto;
  margin: 0 auto;
}

.doc table[align="center"] td {
  min-width: 0;
  padding: 0.2rem 0.35rem;
  border: 0;
  text-align: center;
  vertical-align: middle;
}

.doc table[align="center"] img {
  display: block;
  margin: 0 auto 0.3rem;
}

.doc sub {
  color: var(--muted);
  font-size: 0.76rem;
}

/* --- footer -------------------------------------------------------------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  max-width: 47rem;
  margin: 3.5rem auto 0;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}

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

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

/* --- 404 ----------------------------------------------------------------- */

.not-found {
  max-width: 30rem;
  margin: 16vh auto;
  padding: 0 1.25rem;
  text-align: center;
}

.not-found-code {
  margin: 0;
  font-size: 4rem;
  font-weight: 650;
  letter-spacing: -0.04em;
  color: var(--accent);
}

/* --- small screens ------------------------------------------------------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .topbar-inner {
    padding: 0.6rem 1rem;
  }

  /* Two rows: the name and the repository link share the first, the language
     switcher takes the second, rather than the link falling to a third. */
  .brand {
    order: 0;
  }

  .gh {
    order: 1;
    margin-left: auto;
  }

  .locales {
    order: 2;
    width: 100%;
    margin-left: 0;
  }

  .wrap {
    padding: 1.6rem 1rem 3rem;
  }
}
