html, body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  background: #fff;
  color: #24292f;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

code, .code {
  font-family: "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  font-size: .9em;
}
code { white-space: nowrap; }

a { color: #1f5fae; text-decoration: none; }
main a { text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

/* ---------- index */

nav {
  flex: none;
  width: 23em;
  overflow-y: auto;
  padding: 1em 1em 2em 1.25em;
  background: #fafafa;
  border-right: 1px solid #e6e8eb;
  font-size: 13px;
  line-height: 1.5;
}

#toggle { display: none; }

#filter {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 8px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 4px;
}

nav h3 {
  margin: 1.5em 0 .3em;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: #6e7781;
}
nav ul { list-style: none; margin: 0; padding: 0; }
nav li { margin: 0; }
#list a { display: block; padding: 1px 6px; color: #24292f; }
#list > ul > li { margin-bottom: .35em; }

/* Algorithms hang from their specification as a tree. A branch ends at the last entry the
   filter leaves visible; the branch to the algorithm shown is drawn dark, above the others. */
nav ul ul { margin-left: 12px; }
nav ul ul li { position: relative; padding-left: 14px; }
nav ul ul li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: #b8bfc6; }
nav ul ul li:not(:has(~ li:not([hidden])))::before { bottom: auto; height: 11px; }
nav ul ul li::after { content: ""; position: absolute; left: 0; top: 11px; width: 10px; height: 1px; background: #b8bfc6; }
#list ul ul a { padding-left: 4px; color: #57606a; }
#list ul ul a[aria-current] { color: #24292f; }
nav ul ul li:has(~ li:not([hidden]) > a[aria-current])::before { z-index: 1; width: 2px; background: #24292f; }
nav ul ul li:has(> a[aria-current])::before {
  z-index: 1;
  width: 2px;
  background: linear-gradient(#24292f, #24292f) 0 0 / 2px 13px no-repeat,
              linear-gradient(#b8bfc6, #b8bfc6) 0 0 / 1px 100% no-repeat;
}
nav ul ul li:has(> a[aria-current])::after { height: 2px; background: #24292f; }

/* ---------- pages */

/* One scroll through all pages. A specification stays in view beside its algorithms until
   its page ends; the last page is a screen high, so that it too can be scrolled to the top. */
main { flex: 1; min-width: 0; overflow-y: auto; }
.page + .page { border-top: 1px solid #d8dde2; }
.page:last-child { min-height: 100vh; }

.solo { box-sizing: border-box; padding: 1.75em 2em 2.5em; }
.solo > * { max-width: 46rem; }
.home p { margin: 0; }
.home .cite { margin-top: .75em; padding-left: .9em; border-left: 2px solid #e6e8eb; }
.split { display: flex; }
.spec {
  flex: 0 0 40%;
  max-width: 32em;
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 1.75em 1.75em 1.5em 2em;
}
.impl { flex: 1; min-width: 0; padding: 1.75em 2em .5em; border-left: 1px solid #e6e8eb; }
.alg + .alg { padding-top: 1.75em; border-top: 1px solid #e6e8eb; }

h1 { font-size: 19px; font-weight: 600; line-height: 1.3; margin: 0 0 .75em; }
h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 1.75em 0 .9em;
  padding-bottom: .3em;
  border-bottom: 1px solid #e6e8eb;
}
p { margin: .6em 0; }

/* ---------- specification */

.ev { margin: 0 0 1.1em; }
.ev p { margin: .3em 0 0 1px; }
.pair { display: inline-flex; align-items: stretch; border: 1px solid #d8dde2; border-radius: 3px; }
.sig { padding: 1px 7px; background: #f6f7f8; }
.kind { display: flex; align-items: center; padding: 0 7px; font-size: 11px; color: #57606a; border-left: 1px solid #d8dde2; }

.pr { display: grid; grid-template-columns: auto 1fr; column-gap: .55em; margin: 0 0 1.1em; }
.pr .num { color: #8c959f; font-size: 12px; }
.pr .pn { font-weight: 600; }
.pr p { margin: .3em 0 0 1px; }
.paren { font-size: 12px; color: #6e7781; }
.paren::before { content: "("; }
.paren::after { content: ")"; }

.tip {
  position: fixed;
  z-index: 10;
  padding: 3px 8px;
  white-space: nowrap;
  pointer-events: none;
  font-size: 12px;
  line-height: 1.4;
  color: #fff;
  background: #24292f;
  border-radius: 3px;
}
.tip[hidden] { display: none; }

.sig.hl, .evref.hl { background: #fff1bf; }
.evref { border-radius: 2px; }

/* ---------- code */

.code {
  margin: 0 0 1.25em;
  padding: 12px 16px;
  overflow-x: auto;
  line-height: 1.6;
  background: #f6f7f8;
  border-radius: 3px;
}
.l { display: flex; min-height: 1.6em; white-space: pre; }
.l .g { display: flex; flex: none; }
.l .b { flex: 1; min-width: 0; white-space: pre-wrap; padding-left: 8ch; text-indent: -8ch; }
.l .b.with-cm { display: flex; flex-wrap: wrap; column-gap: 3ch; padding-left: 0; text-indent: 0; }
.l .c { flex: none; white-space: pre; }
.ind { width: 4ch; box-shadow: inset 1px 0 #dcdfe3; }
.kw { color: #2f4a8a; font-weight: 600; }
.tag { color: #9a3a2a; }
.cm { color: #6e7781; }
sup { font-size: .72em; line-height: 0; }

img { display: block; max-width: 100%; margin: 0 0 1.25em; }

/* ---------- narrow screens */

@media (max-width: 900px) {
  body, main { display: block; height: auto; overflow: visible; }
  nav { width: auto; border-right: 0; border-bottom: 1px solid #e6e8eb; padding: .6em 1em; }
  #toggle { display: block; font: inherit; color: #1f5fae; background: none; border: 0; padding: 0; }
  #list { display: none; margin-top: .75em; }
  body.open #list { display: block; }
  .page, .split { display: block; height: auto; }
  .solo, .spec, .impl { height: auto; overflow: visible; max-width: none; padding: 1.25em 1em; border: 0; }
  .spec { position: static; max-height: none; }
  .impl { border-top: 1px solid #e6e8eb; }
}
