/* saetta.dev/docs: the pages web/docs-src/build.mjs writes. Loaded after styles.css, whose tokens
   (colors, fonts, the header, the footer, .code blocks) it reuses. */

:root {
  --hl-kw: #ff7b72; --hl-str: #a5d6ff; --hl-num: #79c0ff; --hl-fn: #d2a8ff;
  --hl-com: #8b949e; --hl-var: #ffa657; --hl-add: #3fb950; --hl-del: #f85149;
}
:root[data-theme="light"] {
  --hl-kw: #cf222e; --hl-str: #0a3069; --hl-num: #0550ae; --hl-fn: #8250df;
  --hl-com: #6e7781; --hl-var: #953800; --hl-add: #1a7f37; --hl-del: #cf222e;
}

.docs .footer { margin-top: 0; }

/* the bar with the menu button: phone width only */
.ds-bar { display: none; }

.docs-shell {
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 208px; gap: 40px;
  max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 32px);
}

/* sidebar */
.ds {
  position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto;
  padding: 28px 8px 40px 0; border-right: 1px solid var(--border); scrollbar-width: thin;
}
.ds-head { display: flex; gap: 6px; align-items: center; margin: 0 0 22px; padding-right: 12px; }
.ds-filter {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card); color: var(--fg); font: 13px var(--sans);
}
.ds-filter:focus { outline: none; border-color: var(--accent); }
.ds-close { display: none; }
.ds-title { font: 500 11px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); margin: 0 0 8px; padding: 0 10px; }
.ds-group { margin-bottom: 22px; }
.ds ul { list-style: none; margin: 0; padding: 0; }
.ds li a {
  display: block; padding: 5px 10px; margin-right: 12px; border-radius: 6px;
  font-size: 14px; color: var(--muted); text-decoration: none; line-height: 1.4;
}
.ds li a:hover { color: var(--fg); background: var(--card-2); }
.ds li a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.ds-none { font-size: 13px; color: var(--muted); padding: 0 10px; }
.links a[aria-current="page"] { color: var(--fg); }

/* content */
.doc { min-width: 0; padding: 40px 0 72px; }
.doc-body { max-width: 760px; font-size: 15.5px; line-height: 1.7; color: var(--fg); }
.doc-body > :first-child { margin-top: 0; }
.doc-body h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.12; letter-spacing: -0.035em; margin: 0 0 18px; max-width: none; }
.doc-body h2 { font-size: 24px; line-height: 1.25; letter-spacing: -0.025em; margin: 44px 0 12px; max-width: none; padding-top: 4px; }
.doc-body h3 { font-size: 18px; line-height: 1.3; letter-spacing: -0.015em; margin: 32px 0 8px; font-weight: 600; }
.doc-body h4 { font-size: 15.5px; margin: 24px 0 6px; font-weight: 600; }
.doc-body h2, .doc-body h3, .doc-body h4 { position: relative; }
.anchor {
  position: absolute; left: -0.9em; width: 0.9em; color: var(--dim); text-decoration: none;
  font-weight: 400; opacity: 0;
}
.doc-body :is(h2, h3, h4):hover .anchor, .anchor:focus { opacity: 1; }
.doc-body p, .doc-body ul, .doc-body ol { margin: 0 0 16px; }
.doc-body ul, .doc-body ol { padding-left: 22px; }
.doc-body li { margin: 4px 0; }
.doc-body li > p { margin: 0 0 6px; }
.doc-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.doc-body a:hover { text-decoration-color: var(--accent); }
.doc-body strong { font-weight: 600; }
.doc-body hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.doc-body blockquote { margin: 0 0 16px; padding: 2px 16px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--card); border-radius: 0 6px 6px 0; }
.doc-body blockquote p { margin: 10px 0; }
.doc-body :not(pre) > code {
  font-size: 0.86em; padding: 1px 5px; border-radius: 4px;
  background: var(--card-2); border: 1px solid var(--border); overflow-wrap: anywhere;
}
.doc-body img { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; display: block; margin: 20px 0; }
.doc-wip { color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; padding: 16px 18px; }

/* code blocks: the main page's .code box, with a copy button */
.doc-code { margin: 0 0 18px; }
.doc-code .code-head span { text-transform: lowercase; }
.doc-code pre { font: 13px/1.65 var(--mono); }
.doc-code pre code { font: inherit; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-literal, .hljs-type { color: var(--hl-kw); }
.hljs-string, .hljs-regexp, .hljs-attr + .hljs-string, .hljs-meta .hljs-string { color: var(--hl-str); }
.hljs-number, .hljs-attr, .hljs-attribute, .hljs-symbol, .hljs-bullet { color: var(--hl-num); }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: var(--hl-fn); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-com); }
.hljs-variable, .hljs-template-variable, .hljs-params, .hljs-subst { color: var(--hl-var); }
.hljs-addition { color: var(--hl-add); }
.hljs-deletion { color: var(--hl-del); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

/* tables */
.doc-table { border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; margin: 0 0 18px; }
.doc-table table { min-width: 0; font-size: 14px; }
.doc-table th { font: 500 11px var(--mono); letter-spacing: 0.08em; padding: 10px 14px; white-space: nowrap; }
.doc-table td { padding: 10px 14px; color: var(--fg); vertical-align: top; line-height: 1.55; }
.doc-table td:first-child code { white-space: nowrap; }
.doc-table td:first-child code { font-size: 0.86em; }

/* previous / next, edit link */
.doc-edit { max-width: 760px; margin: 40px 0 0; font-size: 13px; }
.doc-edit a { color: var(--muted); text-decoration: none; }
.doc-edit a:hover { color: var(--fg); }
.doc-pager { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.doc-pager a {
  display: block; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
  text-decoration: none; font-weight: 500; font-size: 15px; min-width: 0;
}
.doc-pager a:hover { background: var(--card-2); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.doc-pager span { display: block; font: 400 12px var(--sans); color: var(--muted); margin-bottom: 2px; }
.doc-pager .next { text-align: right; grid-column: 2; }

/* on this page */
.doc-toc { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; padding: 40px 0 24px; font-size: 13px; }
.doc-toc .ds-title { padding: 0; }
.doc-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.doc-toc a { display: block; margin-left: -1px; border-left: 1px solid transparent; padding: 3px 0 3px 12px; color: var(--muted); text-decoration: none; line-height: 1.45; }
.doc-toc .d3 a { padding-left: 24px; }
.doc-toc a:hover { color: var(--fg); }
.doc-toc a.on { color: var(--fg); border-left-color: var(--accent); }

@media (max-width: 1140px) {
  .docs-shell { grid-template-columns: 220px minmax(0, 1fr); gap: 36px; }
  .doc-toc { display: none; }
}

/* phone and narrow tablet: the sidebar is a drawer behind the menu button */
@media (max-width: 820px) {
  .docs-shell { display: block; }
  .ds-bar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 56px; z-index: 20;
    padding: 8px clamp(16px, 4vw, 32px); border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  }
  .ds-open {
    display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; height: 30px; padding: 0 10px;
    font: 500 13px var(--sans); color: var(--fg); background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  }
  .ds-crumb { min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ds {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; height: auto; width: min(300px, 86vw);
    padding: 16px 8px 32px 16px; background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform 0.18s ease; visibility: hidden;
  }
  .ds.open { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, 0.35); }
  .ds-close { display: inline-grid; flex: 0 0 auto; }
  .ds-scrim { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(2px); }
  .doc { padding-top: 28px; }
  [id] { scroll-margin-top: 112px; }
}
@media (max-width: 520px) {
  .doc-body { font-size: 15px; }
  .doc-body h1 { font-size: 30px; }
  .doc-body h2 { font-size: 21px; margin-top: 36px; }
  .doc-code pre { font-size: 12px; padding: 12px; }
  .doc-pager { grid-template-columns: 1fr; }
  .doc-pager .next { grid-column: 1; }
  .anchor { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ds { transition: none; } }
