/* docs.html: a placeholder docs page. Structure follows
   superlogical.com/rex/docs: a fixed sidebar (icon, search, grouped links,
   the current page's sections as a small tree) and one narrow article
   column. Loaded after styles.css. */

.docs {
  --measure: clamp(38rem, calc(38rem + (100vw - 90rem) * 0.2667), 46rem);
  /* Ink mixed 62% and 42% into the background, written out as plain values:
     on Robby's phone the color-mix() versions came out as full white. */
  --soft: #8a8e92;
  --muted: #5d6064;
}

/* On body, not html: a font size on html would change what a rem is. */
.docs body {
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.docs-page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ---------- sidebar ---------- */

.docs-side {
  font-size: 0.875rem;
}

.docs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.docs-side .mark {
  position: static;
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 11px;
  box-shadow: 0 0 0 1px var(--line) inset;
}

.docs-menu,
.docs-search {
  appearance: none;
  -webkit-appearance: none;
  opacity: 1;
}

.docs-menu {
  display: grid;
  gap: 5px;
  padding: 0.75rem 0.25rem;
  border: 0;
  background: none;
  cursor: pointer;
}

.docs-menu span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: #e8ecf1;
}

/* open: the two bars cross into an x */
.docs-side.open .docs-menu span {
  transition: transform 0.2s;
}

.docs-side.open .docs-menu span:first-child {
  transform: translateY(3.25px) rotate(45deg);
}

.docs-side.open .docs-menu span:last-child {
  transform: translateY(-3.25px) rotate(-45deg);
}

.docs-body {
  display: none;
}

.docs-side.open .docs-body {
  display: block;
}

/* The way out of the docs: always the first thing under the icon. */
.docs-home {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--soft);
}

.docs-home:hover,
.docs-nav a:hover {
  color: var(--ink);
}

.docs-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: calc(100% + 0.75rem);
  margin: 1rem 0 0 -0.75rem;
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.docs-search::before {
  content: "";
  width: 0.6em;
  height: 0.6em;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.docs-search kbd {
  margin-left: auto;
  font: inherit;
  font-size: 0.75rem;
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  padding-top: 1.75rem;
}

.docs-nav h2 {
  margin: 0;
  padding-bottom: 0.75rem;
  font: inherit;
  color: var(--muted);
}

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

.docs-nav a {
  display: block;
  padding: 0.25rem 0;
  color: var(--soft);
}

.docs-nav a[aria-current] {
  color: var(--ink);
}

.docs-nav .soon {
  padding: 0.25rem 0;
  color: var(--muted);
}

/* the current page's sections, drawn as a tree */
.docs-nav .tree {
  padding-bottom: 0.25rem;
  font-size: calc(13em / 14);
  line-height: 1.25;
}

.docs-nav .tree li {
  position: relative;
  padding-left: 1.5em;
}

.docs-nav .tree li::before {
  content: "";
  position: absolute;
  left: 0.4em;
  top: 0;
  width: 0.6em;
  height: 100%;
  border-left: 1px solid var(--line);
}

.docs-nav .tree li::after {
  content: "";
  position: absolute;
  left: 0.4em;
  top: 0.95em;
  width: 0.6em;
  border-top: 1px solid var(--line);
}

.docs-nav .tree li:last-child::before {
  height: 0.95em;
}

/* ---------- article ---------- */

.docs-article {
  padding-top: 2.5rem;
  color: var(--soft);
}

.docs-article h1 {
  margin: 0 0 1.75rem;
  color: var(--ink);
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.docs-article h2 {
  margin: 3rem 0 1.25rem;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  scroll-margin-top: 2rem;
}

.docs-article p {
  margin: 0 0 1rem;
}

.docs-article strong {
  color: var(--ink);
  font-weight: 400;
}

.docs-article a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.docs-article ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.docs-article li {
  margin: 0.4rem 0;
}

.docs-article li::marker {
  color: var(--muted);
}

.docs-article code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.875em;
  letter-spacing: 0;
}

.docs-article pre {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow-x: auto;
}

.docs-article pre code {
  padding: 0;
  background: none;
  color: var(--ink);
}

/* ---------- small screens: the open menu takes over the whole screen ---------- */

@media (width < 46rem) {
  html.docs-menu-open {
    overflow: hidden;
  }

  .docs-side.open {
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: 2rem 1.5rem 4rem;
    background: var(--bg);
    font-size: 1.375rem;
    line-height: 1.3;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .docs-side.open .docs-home {
    margin-top: 1.75rem;
  }

  .docs-side.open .docs-search {
    margin-top: 1.25rem;
    padding: 0.55rem 0.75rem;
  }

  .docs-side.open .docs-search kbd {
    display: none;
  }

  .docs-side.open .docs-nav {
    gap: 2.25rem;
    padding-top: 2.25rem;
  }

  .docs-side.open .docs-nav a,
  .docs-side.open .docs-nav .soon {
    padding: 0.35rem 0;
  }
}

/* ---------- wide screens: the sidebar is pinned beside the article ---------- */

@media (width >= 46rem) {
  /* Same breakpoint and offsets as the reference: the sidebar shows from
     46rem (736px), which includes a phone held sideways. */
  .docs-page {
    margin: 0 auto 0 max(15rem, calc(50vw - 18rem));
    padding: 5rem 2rem 4rem 0;
  }

  .docs-side {
    position: fixed;
    top: 0;
    left: clamp(0.5rem, calc(50vw - 33rem), 4rem);
    width: 12.5rem;
    max-height: 100vh;
    padding: 5rem 0.5rem 2rem 1rem;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .docs-side::-webkit-scrollbar {
    display: none;
  }

  .docs-menu {
    display: none;
  }

  .docs-body {
    display: block;
  }

  .docs-article {
    padding-top: 0;
  }
}

.square .docs-side .mark,
.square .docs-search,
.square .docs-article code,
.square .docs-article pre {
  border-radius: 0;
}

/* ---------- the rest of what Markdown can produce ---------- */

.docs-article h3 {
  margin: 2rem 0 0.75rem;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 400;
}

.docs-article img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border-radius: 8px;
}

.docs-article blockquote {
  margin: 0 0 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}

.docs-article hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.docs-article table {
  width: 100%;
  margin: 0 0 1rem;
  border-collapse: collapse;
}

.docs-article th,
.docs-article td {
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.docs-article th {
  color: var(--ink);
  font-weight: 400;
}

/* Code blocks come highlighted; keep our own panel behind them. */
.docs-article pre {
  background: var(--panel) !important;
  font-size: 0.8125rem;
  line-height: 1.6;
}

/* A [[wikilink]] to a note that does not exist, or is still a draft. */
.docs-article .broken {
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: help;
}
