/* The header every page shares, the docs included (the build puts this file at the top of site.css and of
   docs.css): the brand on the left, the links on the right, fixed at the top. It has no background of its
   own, so a full-screen scene runs behind it; only the brand and the links take the pointer. */
:root {
  /* The room the header takes at the top: the page content starts below it. */
  --head: calc(36px + 1.25rem);
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  justify-content: space-between;
  gap: 5px 20px;
  min-height: var(--head);
  padding: 20px 20px 0;
  background: var(--head-bg, transparent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  pointer-events: none;
}

.site-header a {
  color: var(--ascii-text);
  line-height: 1.2;
  text-decoration: none;
  pointer-events: auto;
}

.site-header .brand {
  padding: 4px 8px;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.site-header .nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
}

.site-header .nav a {
  padding: 6px 8px;
  font-size: 0.85rem;
}

.site-header .nav a:hover,
.site-header .nav a[aria-current="page"] {
  color: var(--ascii-accent);
}

.site-header .nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.site-header a:focus-visible {
  outline: 2px solid var(--ascii-text);
  outline-offset: 2px;
}

/* On a phone the brand and the links do not fit on one line: the links go on a second line, under the brand. */
@media (max-width: 640px) {
  :root {
    --head: calc(72px + 1.25rem);
  }

  .site-header {
    padding: 20px 12px 0;
  }

  .site-header .brand {
    padding: 4px 6px;
  }

  .site-header .nav {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .site-header .nav a {
    padding: 6px;
    font-size: 0.8rem;
  }
}

/* The narrowest phones: the five links still fit on one line. */
@media (max-width: 359px) {
  .site-header .nav a {
    padding: 6px 4px;
    font-size: 0.75rem;
  }
}

:root {
  --bg: #080c12;
  --ascii-text: #d8e1ee;
  --ascii-accent: #5fd0c5;
  --line: color-mix(in srgb, var(--ascii-text) 18%, transparent);
  /* The text scrolls under the shared header (header.css): the page colour behind it keeps the two apart. */
  --head-bg: var(--bg);
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--ascii-text);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

a {
  color: var(--ascii-accent);
}

a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ascii-text);
  outline-offset: 2px;
}

/* A small animated word beside the title, at the top of the text. */
#masthead {
  float: right;
  display: block;
  width: 260px;
  height: 110px;
  margin: 0 0 8px 20px;
}

/* Body: the sections list beside the text, both below the shared header. */
.layout {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 40px;
  max-width: 72rem;
  margin: 0 auto;
  padding: calc(var(--head) + 8px) 20px 10vh;
}

.toc {
  position: sticky;
  top: calc(var(--head) + 16px);
  align-self: start;
  max-height: calc(100vh - var(--head) - 32px);
  overflow-y: auto;
  font-size: 0.85rem;
}

.toc summary {
  display: none;
}

.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: 6px 8px;
  color: var(--ascii-text);
  line-height: 1.35;
  text-decoration: none;
}

.toc a:hover {
  color: var(--ascii-accent);
}

main {
  min-width: 0;
  max-width: 48rem;
  font-size: 0.95rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

main h1 {
  margin: 0 0 12px;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.15;
}

main h2 {
  margin: 2.4em 0 0.6em;
  padding-top: 0.6em;
  border-top: 1px solid var(--line);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  line-height: 1.25;
  scroll-margin-top: calc(var(--head) + 16px);
}

main h3 {
  margin: 1.8em 0 0.5em;
  font-size: 1.05rem;
}

main p,
main ul,
main ol {
  margin: 0 0 1em;
}

main li {
  margin-bottom: 0.35em;
}

code {
  font-family: inherit;
  font-size: 0.9em;
  color: var(--ascii-accent);
  overflow-wrap: anywhere;
}

pre {
  box-sizing: border-box;
  margin: 0 0 1.2em;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--ascii-text) 5%, var(--bg));
  font-size: 0.85rem;
  line-height: 1.5;
}

pre code {
  color: var(--ascii-text);
  font-size: inherit;
  overflow-wrap: normal;
}

.table-wrap {
  margin: 0 0 1.2em;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  font-size: 0.85rem;
  line-height: 1.5;
}

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

th {
  color: var(--ascii-accent);
  font-weight: 600;
}

/* A phone: one column, the sections list folded under the header and always one tap away. */
@media (max-width: 900px) {
  .layout {
    display: block;
    padding-top: var(--head);
  }

  .toc {
    position: sticky;
    top: var(--head);
    z-index: 2;
    max-height: 60vh;
    margin: 0 -20px 16px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .toc summary {
    display: block;
    min-height: 44px;
    box-sizing: border-box;
    padding: 12px 0;
    color: var(--ascii-accent);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .toc a {
    padding: 11px 8px;
  }

  main h2 {
    scroll-margin-top: calc(var(--head) + 56px);
  }
}

@media (max-width: 640px) {
  .layout {
    padding-left: 12px;
    padding-right: 12px;
  }

  .toc {
    margin: 0 -12px 16px;
    padding: 0 12px;
  }

  #masthead {
    float: none;
    width: 100%;
    height: 90px;
    margin: 0 0 8px;
  }
}
