/* Docs (/docs): sidebar + page + "On this page", in the site's look, light and dark (tokens from site.css).
   Wide screens: three columns. Under 1180px the "On this page" column folds into a dropdown above the page.
   Under 900px the sidebar becomes a menu that slides in from the left, under a top bar. */

body.docs { background: var(--bg); }
body.docs::before, body.docs::after { display: none; }
.docs-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr) 240px; min-height: 100vh; }

/* Sidebar */
.docs-side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 16px 16px; border-right: 1px solid var(--line); background: var(--surface-2);
}
.docs-side-top { display: flex; align-items: center; gap: 10px; padding: 4px 6px 0; }
.docs-brand img { height: 26px; width: auto; }
.docs-tag { font-size: 14px; font-weight: 600; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-strong); line-height: 1.2; }
.docs-search-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px 9px 12px; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--muted); text-align: left;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); transition: border-color .15s, color .15s;
}
.docs-search-btn:hover { border-color: var(--ink-2); color: var(--ink-2); }
.docs-search-btn span { flex: 1; }
.docs-kbd { font: 500 11px/1 -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); white-space: nowrap; }

.docs-nav { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.docs-group summary {
  display: flex; align-items: center; justify-content: space-between; padding: 7px 8px; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 600; color: var(--ink); border-radius: 8px;
}
.docs-group summary::-webkit-details-marker { display: none; }
.docs-group summary:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.docs-group summary svg { color: var(--muted); transition: rotate .2s; }
.docs-group:not([open]) summary svg { rotate: -90deg; }
.docs-group ul { list-style: none; margin: 2px 0 8px 12px; padding: 0 0 0 10px; border-left: 1px solid var(--line); }
.docs-group a {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; margin: 1px 0;
  font-size: 14px; color: var(--ink-2); text-decoration: none; border-radius: 8px; transition: background-color .15s, color .15s;
}
.docs-group a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
.docs-group a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.docs-solo { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; }
.docs-solo:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.docs-solo[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.docs-group a[aria-current="page"]::before { content: ""; position: absolute; left: -11px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); }

.docs-side-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 14px 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.docs-side-foot a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; }
.docs-side-foot a:hover { color: var(--ink); }
.docs-side-foot .icon-btn { margin-left: auto; width: 34px; height: 34px; }

.soon { display: inline-block; flex: none; margin-left: 8px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; letter-spacing: 0; vertical-align: middle; color: var(--accent); background: var(--accent-soft); }
h1 .soon { font-size: 12px; margin-left: 12px; translate: 0 -4px; }

/* Page */
.docs-main { min-width: 0; padding: 56px clamp(24px, 4vw, 64px) 80px; }
.doc { max-width: 760px; margin: 0 auto; }
.doc-section { margin: 0 0 12px; font-size: 14px; font-weight: 500; color: var(--accent); }
.doc h1 { margin: 0; font-size: clamp(30px, 3.4vw, 40px); line-height: 1.12; letter-spacing: -.03em; font-weight: 650; }
.doc-desc { margin: 14px 0 0; font-size: 19px; line-height: 1.5; color: var(--muted); }
.doc-body { margin-top: 36px; font-size: 16px; line-height: 1.75; color: var(--ink-2); }
.doc-body > :first-child { margin-top: 0; }
.doc-body p, .doc-body ul, .doc-body ol { margin: 0 0 18px; }
.doc-body ul, .doc-body ol { padding-left: 22px; }
.doc-body li { margin: 6px 0; padding-left: 4px; }
.doc-body li::marker { color: var(--muted); }
.doc-body strong { color: var(--ink); font-weight: 600; }
.doc-body a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
.doc-body a:hover { text-decoration-color: currentColor; }
.doc-body code { font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.doc-body h2, .doc-body h3 { position: relative; color: var(--ink); letter-spacing: -.02em; scroll-margin-top: 24px; }
.doc-body h2 { margin: 48px 0 14px; font-size: 24px; line-height: 1.25; font-weight: 650; }
.doc-body h3 { margin: 32px 0 10px; font-size: 18px; font-weight: 600; }
.doc-body .anchor { position: absolute; left: -1.1em; padding-right: .3em; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity .15s; }
.doc-body h2:hover .anchor, .doc-body h3:hover .anchor { opacity: 1; }
.doc-body blockquote { margin: 0 0 24px; padding: 14px 18px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--ink); }
.doc-body blockquote p { margin: 0; }

.table-wrap { margin: 0 0 24px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.doc-body table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.doc-body th, .doc-body td { padding: 12px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.doc-body th { font-weight: 600; color: var(--ink); background: var(--surface-2); }
.doc-body tr:last-child td { border-bottom: 0; }
.doc-body td:first-child { font-weight: 500; color: var(--ink); min-width: 140px; }

/* Intro "Sections" cards */
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 0 0 24px; }
.doc-body a.doc-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; text-decoration: none; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); transition: border-color .15s, translate .15s;
}
.doc-body a.doc-card:hover { border-color: var(--accent); translate: 0 -1px; }
.doc-card strong { color: var(--ink); font-size: 15px; }
.doc-card span { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* Previous / next */
.doc-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.doc-pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; transition: border-color .15s; }
.doc-pager a:hover { border-color: var(--accent); }
.doc-pager span { font-size: 13px; color: var(--muted); }
.doc-pager strong { font-size: 15px; font-weight: 600; color: var(--ink); }
.doc-pager .next { grid-column: 2; text-align: right; }
.doc-help { margin: 28px 0 0; font-size: 14px; color: var(--muted); }
.doc-help a { color: var(--ink-2); }

/* On this page (wide screens) */
.docs-toc { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 60px 24px 24px 0; font-size: 13px; }
.docs-toc p { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-weight: 600; color: var(--ink); }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.docs-toc a { display: block; margin-left: -1px; padding: 5px 0 5px 14px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4; transition: color .15s, border-color .15s; }
.docs-toc a:hover { color: var(--ink); }
.docs-toc a.on { color: var(--accent); border-left-color: var(--accent); }
.docs-toc-m { display: none; }

/* Search dialog */
.docs-search { width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 120px)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); overflow: hidden; }
.docs-search::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.ds-box { display: flex; flex-direction: column; max-height: inherit; }
.ds-field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.ds-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; color: var(--ink); }
.ds-field input::-webkit-search-cancel-button { display: none; }
.ds-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.ds-results a { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r); text-decoration: none; color: var(--ink-2); }
.ds-results a svg { margin-top: 3px; color: var(--muted); }
.ds-results a[aria-selected="true"] { background: var(--accent-soft); }
.ds-results a[aria-selected="true"] svg { color: var(--accent); }
.ds-results .ds-t { display: block; font-weight: 600; color: var(--ink); font-size: 15px; }
.ds-results .ds-d { display: block; font-size: 13px; color: var(--muted); line-height: 1.45; }
.ds-results .ds-s { display: block; font-size: 12px; color: var(--accent); margin-bottom: 2px; }
.ds-results mark { background: none; color: var(--accent); }
.ds-empty { padding: 20px 12px; color: var(--muted); font-size: 14px; }

/* Phones' top bar and the menu */
.docs-bar { display: none; }
.docs-scrim { display: none; }

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: 260px minmax(0, 1fr); }
  .docs-toc { display: none; }
  .docs-toc-m { display: block; max-width: 760px; margin: -24px auto 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 14px; }
  .docs-toc-m summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; color: var(--ink-2); }
  .docs-toc-m summary::-webkit-details-marker { display: none; }
  .docs-toc-m summary span { flex: 1; }
  .docs-toc-m summary svg:last-child { transition: rotate .2s; }
  .docs-toc-m[open] summary svg:last-child { rotate: 180deg; }
  .docs-toc-m ul { list-style: none; margin: 0; padding: 4px 14px 12px 38px; }
  .docs-toc-m a { display: block; padding: 5px 0; color: var(--muted); text-decoration: none; }
  .docs-toc-m a:hover { color: var(--ink); }
}
@media (max-width: 900px) {
  .docs-shell { display: block; }
  .docs-bar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 12px 0 16px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
  }
  .docs-bar .docs-tag { margin-right: auto; }
  .docs-bar .icon-btn { width: 38px; height: 38px; }
  #docs-menu .i-close { display: none; }
  #docs-menu[aria-expanded="true"] .i-open { display: none; }
  #docs-menu[aria-expanded="true"] .i-close { display: block; }
  .docs-side { position: fixed; z-index: 40; top: 60px; left: 0; bottom: 0; width: min(320px, 86vw); height: auto; translate: -100% 0; transition: translate .25s ease; box-shadow: none; }
  .docs-side.open { translate: 0 0; }
  .docs-side-top { display: none; }
  .docs-scrim { display: block; position: fixed; z-index: 35; inset: 60px 0 0; background: rgba(10, 10, 12, .4); }
  .docs-scrim[hidden] { display: none; }
  .docs-main { padding: 28px 16px 64px; }
  .docs-toc-m { margin: 0 0 28px; }
  .doc-desc { font-size: 17px; }
  .doc-pager { grid-template-columns: 1fr; }
  .doc-pager .next { grid-column: 1; }
  .doc-body .anchor { display: none; }
  .docs-search-btn .docs-kbd, .ds-field .docs-kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { .docs-side, .docs-group summary svg { transition: none; } }
