/* mdsite "docs" theme: sidebar tree, content column, "On this page". No framework. */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-hover: #eef0f3;
  --border: #e3e6ea;
  --text: #1f2328;
  --muted: #636c76;
  --accent: #2f6feb;
  --accent-soft: rgba(47, 111, 235, .10);
  --code-bg: #f3f4f6;
  --note: #2f6feb;
  --tip: #1a7f37;
  --important: #8250df;
  --warning: #9a6700;
  --caution: #cf222e;
  --topbar-h: 3.5rem;
  --sidebar-w: 17rem;
  --toc-w: 14rem;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --bg-soft: #161a20;
    --bg-hover: #1d222a;
    --border: #262c35;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --accent: #6ea8ff;
    --accent-soft: rgba(110, 168, 255, .14);
    --code-bg: #1a1f26;
    --note: #6ea8ff;
    --tip: #3fb950;
    --important: #a371f7;
    --warning: #d29922;
    --caution: #f85149;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, button, textarea { font: inherit; color: inherit; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

/* Top bar */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.icon-btn {
  display: none; flex: none;
  width: 2.25rem; height: 2.25rem;
  align-items: center; justify-content: center;
  border-radius: var(--radius); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn svg { width: 1.3rem; height: 1.3rem; }
.topbar-search { margin-left: auto; position: relative; width: min(20rem, 50vw); }
.topbar-search svg {
  position: absolute; left: .65rem; top: 50%;
  width: 1rem; height: 1rem; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.topbar-search input {
  width: 100%; height: 2.25rem; padding: 0 .75rem 0 2rem;
  font-size: .9rem; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius); outline: none;
}
.topbar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Three columns */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100vh - var(--topbar-h));
}

/* Sidebar tree */

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem .75rem 2rem;
  border-right: 1px solid var(--border);
  font-size: .9rem;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar ul ul { margin: .1rem 0 .3rem .8rem; padding-left: .45rem; border-left: 1px solid var(--border); }
.sidebar a {
  display: block; padding: .32rem .55rem; border-radius: 6px;
  color: var(--text); line-height: 1.35;
}
.sidebar a:hover { background: var(--bg-hover); text-decoration: none; }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar > ul > li > a,
.sidebar > ul > li > details > summary > a { font-weight: 550; }
.sidebar details > summary { display: flex; align-items: center; list-style: none; cursor: pointer; border-radius: 6px; }
.sidebar details > summary::-webkit-details-marker { display: none; }
.sidebar details > summary a { flex: 1; min-width: 0; }
.sidebar details > summary::after {
  content: ""; flex: none;
  width: .42rem; height: .42rem;
  margin: 0 .6rem 0 .45rem;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s ease;
}
.sidebar details[open] > summary::after { transform: rotate(45deg); }
.sidebar details > summary:hover::after { border-color: var(--text); }

/* Content column */

.main { min-width: 0; padding: 2rem 2.5rem 3rem; }
.main > * { max-width: 48rem; margin-left: auto; margin-right: auto; }

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); margin-bottom: 1.25rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumbs span { opacity: .5; }

.prose { overflow-wrap: break-word; }
.prose h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 1.25rem; }
.prose h2 { font-size: 1.45rem; line-height: 1.3; letter-spacing: -.01em; margin: 2.5rem 0 .8rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.15rem; line-height: 1.35; margin: 2rem 0 .5rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose .table-wrap, .prose dl { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose li > ul, .prose li > ol { margin: .25rem 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 650; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.prose img, .prose svg { max-width: 100%; height: auto; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); padding: .12em .35em; border-radius: 4px; }
.prose pre { background: var(--code-bg); padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: .85rem; }
.prose blockquote {
  margin-left: 0; padding: .65rem 1rem;
  color: var(--muted); background: var(--bg-soft);
  border-left: 3px solid var(--border); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose blockquote.alert { color: var(--text); border-left-width: 4px; }
.prose blockquote.alert::before { content: attr(data-alert); display: block; font-weight: 650; font-size: .85rem; margin-bottom: .2rem; }
.prose .alert-note { border-left-color: var(--note); } .prose .alert-note::before { color: var(--note); }
.prose .alert-tip { border-left-color: var(--tip); } .prose .alert-tip::before { color: var(--tip); }
.prose .alert-important { border-left-color: var(--important); } .prose .alert-important::before { color: var(--important); }
.prose .alert-warning { border-left-color: var(--warning); } .prose .alert-warning::before { color: var(--warning); }
.prose .alert-caution { border-left-color: var(--caution); } .prose .alert-caution::before { color: var(--caution); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; line-height: 1.5; }
.prose th, .prose td { padding: .5rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { background: var(--bg-soft); font-weight: 600; }
.prose td { min-width: 7rem; }
.prose tr:last-child td { border-bottom: 0; }
.prose .footnotes { font-size: .9rem; color: var(--muted); }
.prose input[type="checkbox"] { margin-right: .4rem; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin-top: 2rem; margin-bottom: 0; }
.tags li { font-size: .78rem; padding: .12rem .6rem; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted); }

.footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }

/* Form controls, for extensions such as the backlog filters */

.main input[type="search"], .main input[type="text"], .main select {
  height: 2.25rem; padding: 0 .6rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
.main fieldset { border: 0; padding: 0; margin: 0 0 .75rem; }
.main fieldset[role="group"] { display: flex; flex-wrap: wrap; gap: .5rem; }
.main details > summary { cursor: pointer; }

/* On this page */

.toc {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto; padding: 2rem 1rem 2rem .5rem;
  font-size: .82rem;
}
.toc-title { margin: 0 0 .5rem; font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; margin-left: -1px; padding: .22rem .75rem; border-left: 2px solid transparent; color: var(--muted); line-height: 1.35; }
.toc .toc-l3 a { padding-left: 1.5rem; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* Search results */

#search {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--bg-soft);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  --pagefind-ui-font: var(--font);
}

.scrim { display: none; }

/* Narrower screens */

@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 900px) {
  .icon-btn { display: inline-flex; }
  .layout { display: block; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
    width: min(20rem, 85vw); height: auto;
    padding-top: 1rem; background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 32px rgba(0, 0, 0, .25);
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .nav-toggle:checked ~ .layout .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }
  .nav-toggle:checked ~ .layout .scrim { display: block; }
  body:has(.nav-toggle:checked) { overflow: hidden; }
  .main { padding: 1.25rem 1rem 2.5rem; }
  .prose h1 { font-size: 1.7rem; }
  .prose h2 { font-size: 1.3rem; }
  .topbar-search { flex: 1; width: auto; margin-left: .25rem; }
  .sidebar a { padding: .45rem .55rem; }
}
