/*
 * Docs' look: the icons' warm paper and red-brown ink, Instrument
 * Serif for titles, Inter for reading. On a phone one column, the contents
 * behind the button at the top; wider, the contents on the left and the
 * page's headings on the right.
 */

@font-face {
  font-family: 'Instrument Serif';
  src: url('./fonts/instrument-serif-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Instrument Serif';
  src: url('./fonts/instrument-serif-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('./fonts/inter-var-normal.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f7f2ea;
  --paper-raised: #fdfaf5;
  --paper-sunk: #efe7da;
  --ink: #2b1f19;
  --ink-dim: #6b5a50;
  --ink-faint: #a08f83;
  --accent: #8c3b22;
  --accent-soft: rgba(140, 59, 34, 0.1);
  --patch: #dbbf99;
  --mark: rgba(219, 191, 153, 0.6);
  --line: rgba(43, 31, 25, 0.1);
  --serif: 'Instrument Serif', 'Iowan Old Style', Palatino, Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --top: 56px;
  --gutter: 20px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1816;
    --paper-raised: #24201d;
    --paper-sunk: #2c2724;
    --ink: #eee5d9;
    --ink-dim: #b3a598;
    --ink-faint: #7d7066;
    --accent: #e8a68a;
    --accent-soft: rgba(232, 166, 138, 0.12);
    --patch: #6e5a45;
    --mark: rgba(219, 160, 110, 0.35);
    --line: rgba(238, 229, 217, 0.1);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--top) + 16px);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16.5px/1.62 var(--sans);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

button {
  font: inherit;
  color: inherit;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- the bar at the top ---------------------------------------------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  height: calc(var(--top) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.top__menu {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
}

.top__menu svg {
  width: 22px;
  height: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
  font: 26px/1 var(--serif);
  letter-spacing: -0.01em;
}

.brand img {
  border-radius: 6px;
}

.top__search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-raised);
  color: var(--ink-dim);
  font-size: 15px;
  cursor: pointer;
}

.top__search svg {
  width: 18px;
  height: 18px;
}

.top__search kbd {
  display: none;
  font: 12px/1 var(--mono);
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.status {
  margin: 0;
  padding: 7px var(--gutter);
  background: var(--paper-sunk);
  color: var(--ink-dim);
  font-size: 14px;
  text-align: center;
}

/* ---- the three columns ---------------------------------------------- */

.layout {
  display: block;
}

.nav {
  position: fixed;
  inset: calc(var(--top) + env(safe-area-inset-top)) 0 0 0;
  z-index: 15;
  overflow-y: auto;
  padding: 18px var(--gutter) calc(40px + env(safe-area-inset-bottom));
  background: var(--paper);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0.25s;
}

.menu-open .nav {
  transform: none;
  visibility: visible;
}

.menu-open {
  overflow: hidden;
}

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

.nav__home,
.nav__item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
}

.nav__home {
  font: 22px/1.2 var(--serif);
  margin-bottom: 6px;
}

.nav__item--d1 {
  font-weight: 600;
  margin-top: 2px;
}

.nav__item--d2 {
  padding-left: 26px;
  color: var(--ink-dim);
}

.nav__item--d3 {
  padding-left: 40px;
  color: var(--ink-dim);
  font-size: 15px;
}

.nav__item--d4 {
  padding-left: 54px;
  color: var(--ink-dim);
  font-size: 15px;
}

.nav__item:hover,
.nav__home:hover {
  background: var(--paper-sunk);
}

.nav .is-here {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav__lock {
  display: inline-flex;
  margin-left: auto;
  color: var(--ink-faint);
}

.nav__lock svg {
  width: 14px;
  height: 14px;
}

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px max(var(--gutter), env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.toc {
  display: none;
}

@media (min-width: 980px) {
  .top__menu {
    display: none;
  }

  .top__search {
    min-width: 220px;
  }

  .top__search kbd {
    display: inline-block;
    margin-left: auto;
  }

  .layout {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .nav {
    position: sticky;
    top: var(--top);
    height: calc(100vh - var(--top));
    transform: none;
    visibility: visible;
    background: none;
    border-right: 1px solid var(--line);
    padding: 22px 14px 40px;
  }

  .view {
    width: 100%;
    padding: 34px 48px 80px;
  }
}

@media (min-width: 1320px) {
  .layout {
    grid-template-columns: 290px minmax(0, 1fr) 240px;
  }

  .toc {
    display: block;
    position: sticky;
    top: var(--top);
    height: calc(100vh - var(--top));
    overflow-y: auto;
    padding: 40px 20px 40px 8px;
    font-size: 14px;
  }

  .toc__title {
    margin: 0 0 8px;
    color: var(--ink-faint);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--line);
  }

  .toc a {
    display: block;
    padding: 4px 0 4px 14px;
    color: var(--ink-dim);
    text-decoration: none;
    line-height: 1.35;
  }

  .toc .l3 a {
    padding-left: 26px;
    font-size: 13.5px;
  }

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

  .local {
    display: none;
  }
}

/* ---- a page --------------------------------------------------------- */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--ink-faint);
  font-size: 14px;
}

.crumbs a {
  color: var(--ink-dim);
  text-decoration: none;
}

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

.page h1,
.empty h1,
.note h1 {
  margin: 0 0 14px;
  font: 44px/1.05 var(--serif);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

@media (min-width: 980px) {
  .page h1 {
    font-size: 54px;
  }
}

.only {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 18px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--paper-sunk);
  color: var(--ink-dim);
  font-size: 14px;
}

.only svg {
  width: 15px;
  height: 15px;
}

.only code {
  font-size: 13px;
}

.local {
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-raised);
  font-size: 15px;
}

.local summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--ink-dim);
  font-weight: 500;
}

.local ul {
  margin: 0;
  padding: 0 14px 12px 30px;
}

.local li {
  padding: 2px 0;
}

.local .l3 {
  margin-left: 14px;
  list-style: circle;
}

.local a {
  color: var(--ink);
  text-decoration: none;
}

/* What Markdown makes. */

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

.prose h2 {
  margin: 2.1em 0 0.5em;
  font: 31px/1.15 var(--serif);
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 1.8em 0 0.4em;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
}

.prose h4 {
  margin: 1.5em 0 0.3em;
  font-size: 16px;
  font-weight: 650;
}

.prose :is(h2, h3, h4).is-target {
  animation: target 2s ease-out;
}

@keyframes target {
  0% {
    background: var(--mark);
  }
  100% {
    background: transparent;
  }
}

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

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li {
  margin: 0.25em 0;
}

.prose li::marker {
  color: var(--ink-faint);
}

.prose strong {
  font-weight: 620;
}

.prose a.is-code::after {
  content: '↗';
  display: inline-block;
  margin-left: 2px;
  font-size: 0.8em;
  text-decoration: none;
}

.prose a.is-closed {
  color: var(--ink-dim);
  text-decoration-style: dotted;
}

.prose code {
  font: 0.86em/1.4 var(--mono);
  padding: 0.12em 0.36em;
  border-radius: 5px;
  background: var(--paper-sunk);
  overflow-wrap: anywhere;
}

.code {
  position: relative;
  margin: 0 0 1.2em;
}

.prose pre {
  margin: 0 0 1.2em;
  padding: 14px 46px 14px 16px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--paper-sunk);
  font: 13.5px/1.55 var(--mono);
}

.code pre {
  margin: 0;
}

.prose pre code {
  padding: 0;
  background: none;
  font: inherit;
  overflow-wrap: normal;
}

.copy {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: var(--paper-sunk);
  color: var(--ink-faint);
  cursor: pointer;
}

.copy svg {
  width: 17px;
  height: 17px;
}

.copy:hover {
  color: var(--accent);
}

.copy.is-done {
  color: var(--accent);
}

@media (max-width: 600px) {
  .prose pre {
    font-size: 12.5px;
  }
}

.prose blockquote {
  margin: 0 0 1.2em;
  padding: 10px 16px;
  border-left: 3px solid var(--patch);
  background: var(--paper-raised);
  border-radius: 0 10px 10px 0;
  color: var(--ink-dim);
}

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

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.prose .table {
  margin: 0 0 1.3em;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-raised);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.45;
}

.prose th,
.prose td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

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

.prose th {
  color: var(--ink-dim);
  font-size: 13px;
  font-weight: 600;
  background: var(--paper-sunk);
}

.prose thead th:empty {
  padding: 0;
}

.prose thead:has(th:empty:first-child):not(:has(th:not(:empty))) {
  display: none;
}

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

.prose td code {
  overflow-wrap: normal;
}

/* A folder's page: what is in it. */

.children {
  list-style: none;
  margin: 2em 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.children a {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-raised);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.children a:hover {
  border-color: var(--patch);
}

.children strong {
  font-weight: 620;
}

.children svg {
  width: 14px;
  height: 14px;
  margin-left: 6px;
  color: var(--ink-faint);
  vertical-align: -1px;
}

.children span {
  display: block;
  margin-top: 3px;
  color: var(--ink-dim);
  font-size: 14.5px;
  line-height: 1.45;
}

/* The page's end. */

.page__foot {
  margin-top: 3em;
  padding-top: 1.4em;
  border-top: 1px solid var(--line);
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pager a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
}

.pager a:hover {
  border-color: var(--patch);
}

.pager small {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-faint);
  font-size: 13px;
}

.pager__next {
  text-align: right;
}

.source {
  margin: 18px 0 0;
  color: var(--ink-faint);
  font-size: 13.5px;
}

.source a {
  color: var(--ink-dim);
}

.source code {
  font: 12.5px var(--mono);
}

.empty p,
.loading {
  color: var(--ink-dim);
}

.linkish {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- searching -------------------------------------------------------- */

.search {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(20, 14, 10, 0.35);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top) + 10px) 10px 10px;
}

.searching {
  overflow: hidden;
}

.search__box {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 20px - env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--paper-raised);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

@media (min-width: 700px) {
  .search {
    padding-top: 12vh;
  }
}

.search__field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.search__field svg {
  width: 20px;
  height: 20px;
  color: var(--ink-faint);
  flex: none;
}

.search__field input {
  flex: 1;
  min-width: 0;
  height: 56px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: 18px var(--sans);
}

.search__field input::-webkit-search-cancel-button {
  display: none;
}

.search__field button {
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}

.search__results {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
}

.search__results:empty {
  display: none;
}

.search__results a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  outline: 0;
}

.search__results a:hover,
.search__results a:focus {
  background: var(--accent-soft);
}

.search__results strong {
  display: block;
  font-weight: 600;
  line-height: 1.35;
}

.search__results strong span {
  color: var(--ink-faint);
  font-weight: 400;
}

.search__snip {
  display: block;
  margin-top: 2px;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.45;
}

.search__snip mark {
  background: var(--mark);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

.search__none {
  padding: 14px 12px;
  color: var(--ink-dim);
}

/* ---- the small pages of signing in ------------------------------------ */

.note main {
  max-width: 520px;
  margin: 18vh auto 0;
  padding: 0 var(--gutter);
}

.note .button {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  text-decoration: none;
  font-weight: 550;
}
