* {
  box-sizing: border-box;
}

:root {
  --gray: #e8e8e8;
  --border: 2px solid var(--gray);
  --font-mono: "DejaVu Sans Mono", monospace;
  --link: #346bed;
  --margin: 30px;
  --text: #222;
  --radius: 3px;
}

@font-face {
  font-family: "Ubuntu";
  src: url("/fonts/Ubuntu-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Ubuntu";
  src: url("/fonts/Ubuntu-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
}

@font-face {
  font-family: "Ubuntu";
  src: url("/fonts/Ubuntu-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: "Ubuntu";
  src: url("/fonts/Ubuntu-BoldItalic.ttf") format("truetype");
  font-weight: 700;
  font-style: italic;
}

@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/fonts/DejaVuSansMono.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/fonts/DejaVuSansMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
}

html {
  font-size: 16px;
  scroll-padding-top: 20px;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Ubuntu", sans-serif;
  max-width: 900px;
  min-height: 100vh;
  margin-inline: auto;
  padding: 40px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 40px 20px;
}

header {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
}

header a {
  color: inherit;
}

#logo {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
  font-size: 1.4em;
  color: #000;
  font-weight: bold;
}

#logo img {
  height: 1.2em;
  width: 1.2em;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: right;
  gap: 10px 20px;
}

nav ul,
nav li {
  display: contents;
}

#title {
  border-left: var(--border);
  padding-left: 20px;
}

#title p {
  font-size: 0.95rem;
  margin: 5px 2px 0;
}

#parent {
  color: inherit;
}

h1 {
  display: inline-block;
  font-size: 1.4rem;
  margin: 0;
}

h1,
h2,
h3 {
  break-after: avoid;
  color: #444;
}

h1 a[href^="#"], h1 a[href^="."], h2 a[href^="#"], h3 a[href^="#"] {
  color: inherit;
}

h2 {
  font-size: 1.2rem;
  margin-block: var(--margin);
}

h3 {
  font-size: 1.0rem;
  margin-block: var(--margin);
}

h2 code,
h3 code {
  padding: 0;
  background-color: transparent;
  font-size: 0.9em;
}

.contents {
  font-weight: bold;
  padding: 0;
  list-style: none;
}

.std {
  font-family: var(--font-mono);
}

.std .tag {
  padding: 0;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  margin-top: 3px;

  &::before {
    display: none;
  }

  &[title="Global"] {
    background-color: #d4b0ff;
  }

  &[title="Constant"] {
    background-color: #a1d2fb;
  }
}

.page-links {
  padding: 0;
  list-style: none;
}

.page-links p {
  margin: 0;
}

.page-links a {
  color: var(--text);
  display: block;
  margin-block: calc(var(--margin) / 2) 0;
}

.page-links li {
  border: var(--border);
  padding: 12px 16px;
  border-radius: var(--radius);
}

.page-links strong {
  margin-bottom: 8px;
  display: block;
  font-size: 1.1rem;
  color: var(--link);
}

article {
  display: contents;
}

main {
  min-width: 0; /* Don't let wide code blocks overflow */
}

main > hr:first-child {
  display: none;
}

main > hr:first-child + *,
main > :first-child {
  margin-top: 0;
}

p, li {
  line-height: 1.6;
}

p {
  margin-block: var(--margin);
}

ul,
ol {
  margin-block: var(--margin);
}

li + li {
  margin-block: calc(var(--margin) / 4) 0;
}

hr {
  border: none;
  background-color: var(--gray);
  height: 2px;
  margin-block: calc(var(--margin) * 1.4);
}

table {
  border-collapse: collapse;
  table-layout: fixed;
  margin-inline: auto;
  background-color: white;
  margin-block: var(--margin);
}

tbody tr:nth-child(odd) {
  background-color: var(--gray);
}

th,
td {
  border: 2px solid #ddd;
  padding: 5px 12px;
}

blockquote {
  padding: 20px;
  border: var(--border);
  margin: var(--margin) 0;
  background-color: #f7f7f7;
}

blockquote > :first-child {
  margin-top: 0;
}

blockquote > :last-child {
  margin-bottom: 0;
}

code,
pre,
kbd,
.snippet {
  font-family: var(--font-mono);
}

a {
  text-decoration: none;
  color: var(--link);
}

/* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/kbd */

kbd {
  background-color: var(--gray);
  border: 1px solid #ccc;
  display: inline-block;
  font-size: 0.9em;
  font-weight: bold;
  line-height: 1;
  padding: 2px 4px;
}

pre {
  padding: 14px;
  overflow: auto;
  background-color: #f1f1f1;
  border: var(--border);
  margin-block: var(--margin);
  font-size: 0.9rem;
  line-height: 1.25;
}

pre:has(code.ptls) {
  background-color: #fef5ea;
  border-color: #f7e3ca;
}

code {
  background-color: #ffeed9;
  padding: 1px 4px;
  font-size: 0.9rem;
}

pre code {
  font-size: inherit;
  background-color: transparent;
  padding: 0;
  white-space: pre;
  color: #444;
}

pre.wrap code {
  white-space: pre-wrap;
}

kbd,
code {
  white-space: nowrap;
}

pre,
blockquote,
table,
.snippet {
  break-inside: avoid;
}

pre,
code,
blockquote,
kbd {
  border-radius: var(--radius);
}

.snippet {
  margin-block: var(--margin);
}

.snippet.yes::after,
.snippet.no::after {
  align-content: center;
  color: #aaa;
  font-size: 0.9rem;
  white-space: pre;
}

.snippet.yes::after {
  content: "yes";
}

.snippet.no::after {
  content: "no ";
}

.snippet.no {
  margin-top: -16px;
}

.snippet.yes,
.snippet.no {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.snippet pre {
  margin-block: 0;
}

.snippet .result {
  margin-top: 8px;
}

.snippet .panic {
  background-color: #fee4e4;
  border-color: #f1c1c1;
}

.var-name {
  font-family: var(--font-mono);
  color: #333;
  padding: 10px 14px;
  background-color: var(--gray);
  margin: -14px -14px 14px;
}

.def-name {
  font-size: 1.16rem;
}

.def-info {
  margin-left: 24px;
}

.tag {
  font-weight: bold;
  font-size: 0.8em;
  padding: 2px 4px;
  border-radius: var(--radius);
  cursor: help;
  display: inline-block;

  &[title="Global"] {
    background-color: #ead9ff;
    color: #b77ecd;

    &::before {
      content: "Global";
    }
  }

  &[title="Constant"] {
    background-color: #c6e5ff;
    color: #4f99e8;

    &::before {
      content: "Constant";
    }
  }
}

#sequencer {
  margin-block: var(--margin);
  font-size: 1.1rem;
  font-weight: bold;
}

#sequencer > div {
  display: grid;
  grid-template-columns: 1fr auto;
}

#sequencer a div {
  font-weight: normal;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

#sequencer .next {
  text-align: right;
}

@media (width < 800px) {
  body {
    padding: 20px;
    gap: 30px;
  }

  header {
    padding: 0;
    grid-template-columns: auto;
  }

  #logo {
    margin-inline: auto;
  }

  nav {
    justify-content: center;
  }

  kbd,
  code {
    white-space: normal;
  }
}

@media print {
  header {
    display: none;
  }

  body {
    display: block;
  }

  #sidebar {
    display: none;
  }

  article > * {
    margin-bottom: 30px !important;
  }

  pre code {
    white-space: pre-wrap;
  }

  #sequencer {
    display: none;
  }
}

.ptls .call,
.ptls .std {
  color: #256bd7;
}

.ptls .string {
  color: #387a13;
}

.ptls .quotes {
  color: #157c8d;
}

.ptls .comment {
  color: #707070;
}

.ptls .keyword,
.ptls .interpolated,
.ptls .escape {
  color: #a34baf;
}

.ptls .function {
  color: #027e7e;
}

.ptls .argument,
.ptls .number {
  color: #a95f00;
}

.ptls .operator,
.ptls .constant {
  color: #c14a1c;
}
