/* Make a site look like a pkgdown site (Bootstrap 5): a tinted top navbar, a
   page header with a rule, a right sidebar ("On this page"), pale code blocks.
   Load it after the default site CSS. The TOC goes to the right via
   `toc: {class: "side side-right"}` in _litedown.yml. */
:root {
  --pk-primary: #0054ad;
  --pk-fg: #212529;
  --pk-muted: rgba(33, 37, 41, .75);
  --pk-bg: #fff;
  --pk-border: #dee2e6;
  --pk-code-bg: rgba(0, 0, 0, .04);
  --pk-soft: rgba(33, 37, 41, .1);
  --pk-nav-bg: color-mix(in oklab, var(--pk-bg) 90%, var(--pk-primary));
  --accent: var(--pk-primary);
  --muted-bg: var(--pk-code-bg);
  --border-color: var(--pk-border);
  --rule-color: var(--pk-border);
  --article-bg: transparent;
  --side-width: 16rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pk-bg: #deddd8;
  }
}

body {
  max-width: 1140px;
  padding-top: 0;
  background: var(--pk-bg);
  color: var(--pk-fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--pk-primary); }
article h2 { border: 0; }

/* tinted full-bleed navbar */
.site-nav {
  padding: .5rem 0;
  background: var(--pk-nav-bg);
  box-shadow: 0 0 0 100vmax var(--pk-nav-bg);
  clip-path: inset(0 -100vmax);
  & > p {
    align-items: center;
    margin: 0;
    &, &:last-child { border: 0; }
  }
  a, button {
    margin: 0;
    border-radius: .5rem;
    background: none;
    color: inherit;
    &:hover { background: var(--pk-soft); color: inherit; }
    &[aria-current] { box-shadow: none; margin-bottom: 0; background: var(--pk-soft); }
    &.brand { font-size: 1.25rem; }
  }
  .version { color: var(--pk-muted); margin-right: 1em; }
}

/* page without card; header with a rule below */
article:not(.pagesjs *), .frontmatter {
  margin: 0;
  background: none;
  box-shadow: none;
}
.frontmatter {
  margin: 1.5rem 0 .5rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--pk-border);
  text-align: left;
}

/* make room for the sidebar, which hangs in the right margin of the article */
@media (min-width: 62em) {
  article:not(.pagesjs *) { margin-right: calc(var(--side-width) + var(--side-gap)); }
}

/* "On this page" */
.side { background: var(--pk-bg); }

#TOC { position: sticky; }
#TOC.side {
  .active { color: var(--pk-primary); }
  &::before {
    content: "On this page";
    display: block;
    margin: .5rem 0;
    font-size: 1.25rem;
    font-weight: 500;
  }
  a { color: inherit; }
}
body:has(.pkg-desc) #TOC { display: none; }

/* code */
pre > code, pre > code[class] {
  border: 1px solid var(--pk-border);
  border-radius: .5rem;
  background: var(--pk-code-bg);
}
:not(pre) > code {
  border-radius: .5rem;
  background: var(--pk-code-bg);
}

footer {
  font-size: .875em;
  color: var(--pk-muted);
  border-top: 1px solid var(--pk-border);
}
