/* Rind developer docs. Builds on /page.css (tokens, fonts, nav, footer). */
:root {
  --code-ink: #3b2412;
  --ok: #2f6b2f;
}
@media (prefers-color-scheme: dark) {
  :root { --code-ink: #f3e3cf; --ok: #8fd18f; }
}

/* The docs use the header's width (page.css: header.wrap, 1120px with 24px gutters). */
main.docs.wrap { max-width: 1120px; padding: 0 24px; }
@media (max-width: 600px) { main.docs.wrap { padding: 0 16px; } }
main.docs { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 0 44px; align-items: start; }
.side { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; margin-top: 24px; padding: 18px 10px; font-size: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; scrollbar-color: var(--line) transparent; }
.side::-webkit-scrollbar { width: 8px; }
.side::-webkit-scrollbar-track { background: transparent; border: 0; }
.side::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--surface); border-radius: 8px; box-shadow: none; }
.side-menu > summary { display: none; }
.side-title { margin: 0 0 10px 12px; font: 400 22px/1 var(--display); }
.side-h { margin: 18px 0 4px 12px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side-title + .side-h { margin-top: 4px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: flex; align-items: center; min-height: 38px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 600; text-decoration: none; }
.side a:hover, .side a[aria-current="page"] { color: var(--ink); background: var(--bg-2); }
.side a[aria-current="page"] { color: var(--accent-strong); }

article.doc { max-width: none; margin: 0; padding: 32px 0 64px; min-width: 0; }
article.doc h2 { margin-top: 48px; padding-top: 8px; border-top: 1px solid var(--line); }
article.doc h2:first-of-type { border-top: 0; }
article.doc h1 { font-size: clamp(40px, 6vw, 56px); }
article.doc table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 16px; display: block; overflow-x: auto; }
article.doc th, article.doc td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
article.doc th { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
article.doc td code { white-space: nowrap; }
article.doc td code.wrap { white-space: normal; }
article.doc ol:not(.crumbs ol) { padding-left: 24px; }
article.doc li { margin: 6px 0; }

/* Code blocks: The Pith's plain block, with the file and its type named on a quiet row
   inside it, and Copy beside them. */
figure.code { position: relative; margin: 20px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--code-bg); overflow: hidden; }
figure.code figcaption { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 8px 0 18px; font: 600 12.5px/1.2 var(--mono); color: var(--muted); }
figure.code .code-file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
figure.code .code-note { margin-left: 8px; font-family: var(--sans); font-weight: 500; color: var(--muted); }
figure.code .code-type { flex: none; padding: 3px 7px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-strong); font: 700 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; }
figure.code .code-file + .code-type { margin-left: 0; }
figure.code pre { margin: 0; padding: 8px 18px 16px; overflow-x: auto; tab-size: 4; background: none; border: 0; border-radius: 0; }
figure.code pre code { display: block; padding: 0; border: 0; background: none; border-radius: 0; font: 500 14.5px/1.65 var(--mono); color: var(--code-ink); overflow-wrap: normal; white-space: pre; }
figure.code:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
button.copy { appearance: none; margin-left: auto; min-height: 30px; min-width: 60px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--muted); font: 600 12.5px/1 var(--sans); cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
button.copy:hover, button.copy:focus-visible { border-color: var(--line); background: var(--surface); color: var(--accent-strong); }
button.copy[data-done] { color: var(--ok); border-color: var(--ok); }

/* Surface cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 18px 0; }
.card { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; transition: transform .25s var(--spring), border-color .2s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--ink); }
.card h3 { margin: 0 0 4px; font: 400 24px/1.1 var(--display); }
.card p { margin: 0; color: var(--muted); font-size: 16px; }
.card .tag { display: inline-block; margin-top: 8px; font: 600 13px/1 var(--mono); color: var(--accent); }

/* Notes read like the article pages' quotes: a rule and quieter text, no box. */
.note { margin: 22px 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--accent); color: var(--muted); }
.note p { margin: 0; }
.note strong:first-child { color: var(--ink); }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 56px; }
.pager a { display: block; flex: 1; max-width: 48%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; font-weight: 700; color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pager .next { text-align: right; margin-left: auto; }

@media (max-width: 900px) {
  main.docs { display: block; }
  /* Section nav collapses to a full-bleed, single-row horizontal strip (a tab bar),
     so the docs don't open behind four rows of links on a phone. */
  /* The tree folds into one disclosure row on a phone: the current page, tap for the rest. */
  .side { position: static; max-height: none; overflow: visible; margin: 8px 0 0; padding: 0; background: none; border: 0; border-radius: 0; }
  .side-menu { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .side-menu > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; cursor: pointer; list-style: none; font-weight: 700; }
  .side-menu > summary::-webkit-details-marker { display: none; }
  .side-menu > summary span { color: var(--muted); font-weight: 600; }
  .side-menu > summary b { margin-right: auto; }
  .side-menu > summary::after { content: ""; width: 9px; height: 9px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
  .side-menu[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
  .side-menu[open] { padding-bottom: 10px; }
  .side-title { display: none; }
  .side-h { margin-top: 12px; }
  article.doc { padding-top: 20px; }
}
@media (max-width: 560px) {
  figure.code pre code { font-size: 13px; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
@media print {
  .side, .pager, button.copy { display: none; }
  main.docs { display: block; }
  figure.code { break-inside: avoid; }
  figure.code pre code { white-space: pre-wrap; color: #000; }
}

article.doc .toc h2 { margin: 4px 0; padding: 0; border-top: 0; font-size: 15px; }

/* Group label above the title on guide and concept pages. */
article.doc .eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-strong); }

/* Syntax highlighting and code tooltips: the token classes and behaviour The Pith uses
   (pandoc's names), so the two read the same. */
:root { --tk-key: #a63c07; --tk-str: #6b4c8c; --tk-num: #2f6f66; --tk-com: #7a6450; --tk-fn: #2a1a0e; --tk-op: #7a6450; }
@media (prefers-color-scheme: dark) { :root { --tk-key: #ff9f5c; --tk-str: #c9b3ea; --tk-num: #8fcfc3; --tk-com: #b9a28a; --tk-fn: #f7ead9; --tk-op: #b9a28a; } }
.sourceCode .kw, .sourceCode .cf, .sourceCode .im, .sourceCode .sc { color: var(--tk-key); }
.sourceCode .kw, .sourceCode .cf, .sourceCode .im { font-weight: 600; }
.sourceCode .st, .sourceCode .ss, .sourceCode .ch, .sourceCode .vs { color: var(--tk-str); }
.sourceCode .dv, .sourceCode .fl, .sourceCode .bn, .sourceCode .cn { color: var(--tk-num); }
.sourceCode .co, .sourceCode .do, .sourceCode .cv { color: var(--tk-com); font-style: italic; }
.sourceCode .bu, .sourceCode .fu, .sourceCode .ex { color: var(--tk-fn); font-weight: 600; }
.sourceCode .op, .sourceCode .ot { color: var(--tk-op); }
.sourceCode .dt, .sourceCode .at { color: var(--tk-num); }
.sourceCode .va { color: var(--tk-str); }
a.tok-doc { color: inherit; text-decoration: underline dotted; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a.tok-doc:hover, a.tok-doc:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 3px; }
.tok-tip { position: absolute; z-index: 50; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); font-size: 14px; line-height: 1.45; }
.tok-tip code { display: block; margin-bottom: 4px; padding: 0; border: 0; background: none; font-size: 13px; color: var(--tk-key); overflow-wrap: anywhere; }

/* Terminal output, recorded from a real peel. */
figure.terminal { margin: 18px 0; border-radius: 14px; overflow: hidden; background: var(--dark-bg); border: 1px solid var(--dark-line); box-shadow: 0 10px 30px rgba(60, 30, 10, .16); }
.term-bar { position: relative; display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; background: var(--dark-bar); border-bottom: 1px solid var(--dark-line); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { position: absolute; left: 0; right: 0; text-align: center; font: 600 12px/1 var(--sans); color: var(--dark-muted-2); pointer-events: none; }
figure.terminal pre { margin: 0; padding: 14px 16px; overflow-x: auto; max-height: 460px; background: none; border: 0; border-radius: 0; }
figure.terminal pre code { display: block; padding: 0; border: 0; background: none; font: 500 13.5px/1.6 var(--mono); color: var(--dark-ink-2); white-space: pre; overflow-wrap: normal; }
figure.terminal pre code b { color: #fff; font-weight: 600; }
/* Played back once as it scrolls into view (docs.js); without scripts or with reduced motion it is simply all there. */
figure.terminal.is-ready .term-line { opacity: 0; }
figure.terminal .term-line.is-on { opacity: 1; transition: opacity .18s ease-out; }
figure.terminal .term-caret { display: inline-block; width: .6em; height: 1.1em; margin-left: 1px; vertical-align: text-bottom; background: var(--dark-accent); animation: term-blink 1s steps(1) infinite; }
@keyframes term-blink { 50% { opacity: 0; } }
.term-ps { color: #8fcfc3; user-select: none; }
figure.terminal figcaption { padding: 8px 16px 10px; border-top: 1px solid var(--dark-line); font-size: 13px; color: var(--dark-muted); }
figure.terminal figcaption code { background: none; border: 0; padding: 0; color: var(--dark-ink-2); }
figure.terminal pre:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Charts drawn from site/data/engine-scores.json. */
figure.chart { margin: 22px 0; padding: 16px 16px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
figure.chart svg { display: block; width: 100%; height: auto; }
figure.chart .ch-a { fill: var(--accent); }
figure.chart .ch-b { fill: color-mix(in srgb, var(--muted) 45%, transparent); }
figure.chart .ch-l { font: 600 13px var(--sans); fill: var(--ink); }
figure.chart .ch-v { font: 500 12px var(--mono); fill: var(--muted); }
figure.chart .ch-in { font-weight: 600; }
figure.chart .ch-in-a { fill: #fff; }
figure.chart .ch-in-b { fill: var(--ink); }
figure.chart rect { transition: opacity .15s; }
figure.chart svg:hover rect:not(:hover) { opacity: .55; }
figure.chart figcaption { margin-top: 10px; color: var(--muted); font-size: 14px; }
figure.chart details { margin-top: 8px; font-size: 15px; }
figure.chart summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; min-height: 32px; display: flex; align-items: center; }

/* App screenshots. */
figure.shot { margin: 22px 0; }
figure.shot img { display: block; width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(60, 30, 10, .12); }
figure.shot figcaption { margin-top: 8px; color: var(--muted); font-size: 15px; }

@media print { .tok-tip { display: none; } a.tok-doc { text-decoration: none; } figure.terminal { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { figure.chart rect, .side-menu > summary::after { transition: none; } }

/* Shell blocks are terminals too: dark in both themes, with the dark token colours. */
figure.code.code-shell { --tk-key: var(--dark-accent); --tk-str: #c9b3ea; --tk-num: #8fcfc3; --tk-com: var(--dark-muted); --tk-fn: #f7ead9; --tk-op: var(--dark-muted); background: var(--dark-bg); border-color: var(--dark-line); box-shadow: 0 10px 30px rgba(60, 30, 10, .16); }
figure.code.code-shell pre code { color: var(--dark-ink-2); }
figure.code.code-shell .code-file { color: var(--dark-ink-2); }
figure.code.code-shell .code-note { color: var(--dark-muted); }
figure.code.code-shell figcaption { color: var(--dark-muted); }
figure.code.code-shell .code-type { background: rgba(255, 159, 92, .16); color: var(--dark-accent); }
figure.code.code-shell button.copy { color: var(--dark-muted); }
figure.code.code-shell button.copy:hover, figure.code.code-shell button.copy:focus-visible { background: var(--dark-bar); border-color: var(--dark-line); color: var(--dark-accent); }
figure.code.code-shell a.tok-doc:hover, figure.code.code-shell a.tok-doc:focus-visible { background: rgba(255, 159, 92, .18); }
@media (prefers-reduced-motion: reduce) { figure.terminal .term-caret { animation: none; } }
@media print { figure.code.code-shell { background: none; box-shadow: none; } figure.code.code-shell pre code { color: #000; } }

/* Recorded output in a terminal's colours: jq for JSON, red for failures, green for passes. */
figure.terminal .t-key { color: #8fb8ff; }
figure.terminal .t-str { color: #a8d98f; }
figure.terminal .t-num, figure.terminal .t-lit { color: #f0c674; }
figure.terminal .t-err, figure.terminal .t-err .t-key, figure.terminal .t-err .t-str { color: #ff7b72; }
figure.terminal .t-ok { color: #7ee787; font-weight: 600; }
figure.terminal .t-dim { color: var(--dark-faint); }

/* Legibility in code: no programming ligatures (&& and || stay two characters), and a
   lighter weight with greyscale smoothing for light text on the dark blocks. */
figure.code pre code, figure.terminal pre code, code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
figure.code.code-shell pre code, figure.terminal pre code { font-weight: 400; font-size: 14.5px; line-height: 1.7; letter-spacing: .01em; color: var(--dark-ink); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
figure.terminal pre code b { font-weight: 600; }
figure.code.code-shell .sourceCode .co { font-style: normal; }
figure.code.code-shell .sourceCode .bu, figure.code.code-shell .sourceCode .fu, figure.code.code-shell .sourceCode .ex, figure.code.code-shell .sourceCode .kw { font-weight: 600; }
figure.code.code-shell .sh-caret { display: inline-block; width: .6em; height: 1.1em; margin-left: 1px; vertical-align: text-bottom; background: var(--dark-accent); animation: term-blink 1s steps(1) infinite; }
figure.code.code-shell.is-pending pre code { visibility: hidden; }
