/* Documentation pages. Uses the tokens of src/styles/global.css. */
.docs-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  gap: 56px;
  align-items: start;
  padding: 48px 0 96px;
}
.docs-side {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}
.docs-navwrap > summary {
  display: none;
}
.docs-nav {
  display: grid;
  gap: 2px;
  font-size: 13px;
}
.docs-nav a {
  display: block;
  padding: 6px 10px;
  border-radius: 5px;
  color: var(--text-dim);
  line-height: 1.4;
}
.docs-nav a:hover {
  color: var(--text);
  background: var(--surface-panel);
}
.docs-nav a[aria-current="page"] {
  color: var(--accent);
  background: #65d9ed12;
  box-shadow: inset 2px 0 0 var(--accent);
}
.docs-nav .docs-home {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.docs-nav details {
  border-top: 1px solid var(--border-subtle);
}
.docs-nav summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  cursor: pointer;
  color: var(--text);
  font-weight: 550;
  list-style: none;
  border-radius: 5px;
}
.docs-nav summary::-webkit-details-marker {
  display: none;
}
.docs-nav summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(-45deg);
  transition: transform var(--fast);
  flex: none;
}
.docs-nav details[open] > summary::before {
  transform: rotate(45deg);
}
.docs-nav summary span {
  flex: 1;
}
.docs-nav summary small {
  font: 10px var(--font-mono);
  color: var(--text-faint);
}
.docs-nav summary:hover {
  background: var(--surface-panel);
}
.docs-nav ul {
  list-style: none;
  margin: 0 0 10px;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border-subtle);
  margin-left: 13px;
}

/* Search */
.docs-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  background: var(--surface-panel);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--text-faint);
}
.docs-search:focus-within {
  border-color: var(--accent);
}
.docs-search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.docs-search input::placeholder {
  color: var(--text-faint);
}
.docs-search kbd {
  font: 10px var(--font-mono);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}
.docs-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: min(440px, calc(100vw - 40px));
  max-height: 60vh;
  overflow: auto;
  z-index: 30;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 50px #00000080;
  padding: 6px;
}
.docs-results a {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 6px;
}
.docs-results a:hover,
.docs-results a[aria-selected="true"] {
  background: var(--surface-panel);
}
.docs-results small {
  font: 10px var(--font-mono);
  color: var(--accent);
}
.docs-results strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}
.docs-results span {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}
.docs-results mark {
  background: #65d9ed30;
  color: var(--text);
  border-radius: 2px;
}
.docs-results p {
  margin: 0;
  padding: 12px;
  color: var(--text-dim);
  font-size: 13px;
}

/* Article */
.docs-article {
  min-width: 0;
  max-width: 780px;
}
.docs-crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  font: 11px var(--font-mono);
  color: var(--text-faint);
}
.docs-crumbs li + li::before {
  content: "/";
  margin-right: 6px;
  color: var(--border-strong);
}
.docs-crumbs a {
  color: var(--text-dim);
}
.docs-crumbs a:hover {
  color: var(--accent);
}
.docs-article > h1 {
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -1.6px;
  line-height: 1.1;
  margin-bottom: 28px;
  text-wrap: balance;
}
.docs-body {
  font-size: 15.5px;
  line-height: 1.75;
  color: #d4dce8;
  overflow-wrap: break-word;
}
.docs-body h2,
.docs-body h3,
.docs-body h4 {
  position: relative;
  color: var(--text);
  scroll-margin-top: 110px;
  text-wrap: balance;
}
.docs-body h2 {
  font-size: 24px;
  letter-spacing: -0.5px;
  margin: 2.2em 0 0.7em;
  padding-top: 1.2em;
  border-top: 1px solid var(--border-subtle);
}
.docs-body h3 {
  font-size: 18px;
  margin: 1.8em 0 0.5em;
}
.docs-body h4 {
  font-size: 15.5px;
  margin: 1.5em 0 0.4em;
}
.docs-anchor {
  position: absolute;
  left: -0.9em;
  color: var(--text-faint);
  opacity: 0;
  text-decoration: none;
  font-weight: 400;
}
.docs-body h2:hover .docs-anchor,
.docs-body h3:hover .docs-anchor,
.docs-body h4:hover .docs-anchor {
  opacity: 1;
}
.docs-body p,
.docs-body ul,
.docs-body ol {
  margin: 0 0 1.05em;
}
.docs-body ul,
.docs-body ol {
  padding-left: 1.3em;
}
.docs-body li {
  margin: 0.3em 0;
}
.docs-body li::marker {
  color: var(--text-faint);
}
.docs-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: #65d9ed55;
  text-underline-offset: 3px;
}
.docs-body a:hover {
  text-decoration-color: currentColor;
}
.docs-body a.docs-ext::after {
  content: "↗";
  font-size: 0.8em;
  margin-left: 2px;
  color: var(--text-faint);
}
.docs-body strong {
  color: var(--text);
  font-weight: 600;
}
.docs-body code {
  font: 0.86em var(--font-mono);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}
.docs-body blockquote {
  margin: 0 0 1.1em;
  padding: 12px 18px;
  border-left: 2px solid var(--accent);
  background: var(--surface-panel);
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
}
.docs-body blockquote p:last-child {
  margin: 0;
}
.docs-body hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: 2em 0;
}
.docs-code {
  position: relative;
  margin: 0 0 1.2em;
}
.docs-code pre {
  margin: 0;
  padding: 16px 18px;
  padding-right: 92px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}
.docs-code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  color: #dfe7f3;
  overflow-wrap: normal;
  white-space: pre;
}
.docs-copy {
  position: absolute;
  top: 9px;
  right: 9px;
  font: 11px var(--font-mono);
  color: var(--text-dim);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 10px;
}
.docs-copy:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.docs-copy[data-done] {
  color: var(--ok);
  border-color: var(--ok);
}
.docs-table {
  overflow-x: auto;
  margin: 0 0 1.3em;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.docs-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  line-height: 1.55;
}
.docs-table th,
.docs-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.docs-table th {
  background: var(--surface-panel);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.docs-table tr:last-child td {
  border-bottom: 0;
}
.docs-table td code {
  overflow-wrap: normal;
  white-space: nowrap;
}

/* Chapter cards on the docs home */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 44px;
}
.docs-cards a {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  row-gap: 4px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-panel);
  transition:
    border-color var(--fast),
    transform var(--base) var(--ease-enter),
    background-color var(--fast);
}
.docs-cards a:hover {
  border-color: var(--accent);
  background: var(--surface-raised);
  transform: translateY(-2px);
}
.docs-cards span {
  grid-row: span 3;
  font: 11px var(--font-mono);
  color: var(--accent);
  padding-top: 3px;
}
.docs-cards strong {
  font-weight: 600;
}
.docs-cards p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
.docs-cards small {
  font: 10px var(--font-mono);
  color: var(--text-faint);
}

/* Previous and next */
.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 56px 0 28px;
}
.docs-pager a {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color var(--fast);
}
.docs-pager a:hover {
  border-color: var(--accent);
}
.docs-pager a[rel="next"] {
  text-align: right;
  grid-column: 2;
}
.docs-pager small {
  font: 10px var(--font-mono);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.docs-pager span {
  color: var(--accent);
  font-size: 14px;
}
.docs-source {
  border-top: 1px solid var(--border-subtle);
  padding-top: 18px;
  font-size: 12px;
  color: var(--text-faint);
}
.docs-source p {
  margin: 0 0 6px;
  line-height: 1.6;
}
.docs-source a {
  color: var(--text-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.docs-source code {
  font: 11px var(--font-mono);
}

/* On this page */
.docs-toc {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 130px);
  overflow: auto;
  font-size: 12.5px;
}
.docs-toc p {
  font: 10px var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.docs-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border-subtle);
}
.docs-toc a {
  display: block;
  padding: 5px 12px;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--text-dim);
  line-height: 1.45;
}
.docs-toc .l3 a {
  padding-left: 24px;
  font-size: 12px;
}
.docs-toc a:hover {
  color: var(--text);
}
.docs-toc a[data-current] {
  color: var(--accent);
  border-left-color: var(--accent);
}

@media (max-width: 1250px) {
  .docs-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 44px;
  }
  .docs-toc {
    display: none;
  }
}
@media (max-width: 900px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding-top: 24px;
  }
  .docs-side {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
  }
  .docs-navwrap {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-panel);
    margin-bottom: 24px;
  }
  .docs-navwrap > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 550;
    list-style: none;
  }
  .docs-navwrap > summary::-webkit-details-marker {
    display: none;
  }
  .docs-navwrap > summary::after {
    content: "+";
    font: 16px var(--font-mono);
    color: var(--accent);
  }
  .docs-navwrap[open] > summary::after {
    content: "−";
  }
  .docs-navwrap .docs-nav {
    padding: 0 8px 10px;
  }
  .docs-cards {
    grid-template-columns: minmax(0, 1fr);
  }
  .docs-anchor {
    display: none;
  }
}
@media (max-width: 520px) {
  .docs-pager {
    grid-template-columns: minmax(0, 1fr);
  }
  .docs-pager a[rel="next"] {
    grid-column: 1;
  }
  .docs-body {
    font-size: 15px;
  }
}

/* Fixed line boxes above the article, so that the web fonts arriving late
   cannot move the page (layout shift). */
.docs-crumbs,
.docs-crumbs li {
  line-height: 18px;
  min-height: 18px;
}
.docs-search kbd {
  line-height: 14px;
}
.docs-navwrap > summary {
  line-height: 20px;
}
.docs-nav summary,
.docs-nav a {
  line-height: 20px;
}
