/* pipe — the docs pages' whole stylesheet.
 *
 * This is pipeOS's system (the box dashboard at pipe.local:
 * overlay/usr/local/share/pipeos/web/static/style.css), ported: warm paper
 * with a dark variant the OS picks, system-ui for reading, monospace only
 * where the content IS terminal, a left panel of rounded nav rows that
 * becomes a bottom tab bar on a phone. A third SYSTEM beside site.css and
 * mkt.css, not a skin — a docs page loads this sheet and no other (xtask's
 * head_for picks exactly one per page), so nothing here has to out-rank
 * anything and nothing here can reach the app or the marketing pages.
 *
 * Tokens keep pipeOS's names and shapes on purpose: the two files stay
 * diffable, and a fix found on one side carries to the other. The palette
 * is the one deliberate departure — cool greys where the box wears warm
 * paper, and robin's-egg blue where it wears green — a whiter, bluer egg. It is
 * spent super light as the FILL (the active pill, the mark's ring, the
 * get-started chip); text set in the accent takes the deep end of the same
 * hue, because a pastel cannot carry a letterform and still clear WCAG AA.
 *
 * Component index — the canonical set:
 *   nav[data-nav]   the site's side panel: brand + icon rows (chrome.ts
 *                   refills it); hidden on a phone, where the .tabbar takes
 *                   over (the pipeOS move — thumbs live at the bottom)
 *   .tabbar         the phone's fixed bottom bar, built by chrome.ts
 *   .docs-wrap      the docs shell: section rail + measure
 *   .docs-nav       the section rail: icon rows, accent pill on the current
 *                   page; a horizontal pill row on a phone
 *   .docs-body      the prose: h1/h2, tables, table.q command tables
 *   pre.term        anything literally terminal; stays DARK in both themes,
 *                   because it quotes the terminal rather than being the page
 *   footer          the one-liner legal line
 * A new docs element is one of these or it argues its way in here.
 */

/* ── tokens ──────────────────────────────────────────────────────────── */
:root {
  --bg: #f4f4f5;
  --bg2: #ebebed;
  --card: #ffffff;
  --ink: #1a1a1c;
  --muted: #64666a;
  --faint: #909296;
  --line: #dfe0e2;
  --accent: #1c608f;
  --accent-ink: #ffffff;
  --accent-soft: #e9f4fb;
  --warn: #96690a;
  --bad: #a83c2e;
  --ok: #2c7d5b;
  --shadow: 0 1px 2px rgba(10,10,12,.05), 0 8px 24px rgba(10,10,12,.05);
  --radius: 12px;
  /* the terminal, one polarity in both themes: it is a quote, not a surface */
  --term-bg: #18191b;
  --term-ink: #e8eaeb;
  --term-dim: #9a9da1;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --bg2: #1a1a1d;
    --card: #1f1f23;
    --ink: #e9e9eb;
    --muted: #a2a4a8;
    --faint: #707276;
    --line: #2e2e33;
    --accent: #a5d5ef;
    --accent-ink: #0d1b24;
    --accent-soft: #1f2b34;
    --warn: #d9a53f;
    --bad: #e0806a;
    --ok: #6bbb8c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.32);
    --term-bg: #1c1e21;
  }
}

/* ── base, type ──────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
/* the pipeOS shell: side panel left, page right (the marketing sheet's
   grid exactly, so the two shells feel like one) */
.wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.wrap > nav[data-nav] { grid-column: 1; grid-row: 1 / -1; }
.wrap > main { grid-column: 2; grid-row: 1; }
.wrap > footer { grid-column: 2; grid-row: 2; }
a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
code {
  font: 13px/1.5 var(--mono);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 5px;
  padding: .1em .35em;
}

/* ── the side panel ──────────────────────────────────────────────────── */
/* chrome.ts rebuilds the rows on load (signed-in state); both the
   prefilled markup and the rebuild are icon+label links inside
   nav[data-nav], so the selector is the attribute, not a class the JS
   would have to add. The idiom is the pipeOS sidenav verbatim. */
nav[data-nav] {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 12px 14px;
  background: var(--bg2); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
nav[data-nav] a, nav[data-nav] b {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  color: var(--muted); font-weight: 500; font-size: .93rem;
  padding: 8px 10px; border-radius: 9px;
}
nav[data-nav] a:hover { background: var(--card); color: var(--ink); }
nav[data-nav] b { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav[data-nav] .ic { width: 17px; height: 17px; flex: none; opacity: .8; }
nav[data-nav] .ic svg { width: 100%; height: 100%; display: block; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
nav[data-nav] .brand {
  font-weight: 700; font-size: 1.05rem; color: var(--ink); letter-spacing: .02em;
  background: none; margin-bottom: 12px;
}
nav[data-nav] .mark {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); display: inline-block;
}
nav[data-nav] .cta { color: var(--accent); }
nav[data-nav] .flux { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .8rem; margin-top: auto; padding: .5rem .6rem .1rem; }
nav[data-nav] .flux .drop { width: 7px; height: 9px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%; background: var(--accent); display: inline-block; }
nav[data-nav] .flux b { background: none; padding: 0; color: var(--ink); }
nav[data-nav] .signout, nav[data-nav] .alpha { font-size: .8rem; }
nav[data-nav] .alpha { color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; align-self: flex-start; margin: .4rem .6rem 0; }
nav[data-nav] > .alpha:first-of-type { margin-top: auto; }

/* the phone's bar; chrome.ts builds it, the breakpoint shows it */
.tabbar { display: none; }

/* ── the shell ───────────────────────────────────────────────────────── */
main.page { flex: 1; width: 100%; }
.docs-wrap {
  display: grid; grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  max-width: 72rem; margin: 0 auto;
  padding: 1.6rem clamp(1rem, 4vw, 2.4rem) 3rem;
  align-items: start;
}

/* the panel: pipeOS's sidenav rows, verbatim idiom */
.docs-nav { position: sticky; top: 1.2rem; display: flex; flex-direction: column; gap: 2px; }
/* group labels: the docs are two sections at one level, pipe and pipeOS */
.docs-nav .grp { color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; padding: .9rem .6rem .25rem; }
.docs-nav .grp:first-child { padding-top: .1rem; }
.docs-nav a {
  display: flex; align-items: center; gap: .6rem; text-decoration: none;
  color: var(--muted); font-weight: 500; font-size: .95rem;
  padding: .5rem .6rem; border-radius: 9px;
}
.docs-nav a:hover { background: var(--card); color: var(--ink); }
.docs-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.docs-nav .ic { width: 17px; height: 17px; flex: none; opacity: .8; }
.docs-nav .ic svg { width: 100%; height: 100%; display: block; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.docs-nav .lbs { display: none; }

/* ── the prose ───────────────────────────────────────────────────────── */
.docs-body { max-width: 46rem; min-width: 0; }
.docs-body h1 { font-size: 1.4rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.docs-body h2 { font-size: 1.05rem; margin: 1.9rem 0 .55rem; letter-spacing: -.01em; }
.docs-body h3 { font-size: .95rem; margin: 1.3rem 0 .4rem; }
.docs-body p { margin: .5rem 0 .9rem; }
.docs-body ul, .docs-body ol { margin: .5rem 0 .9rem; padding-left: 1.3rem; }
.docs-body li { margin: .25rem 0; }
.docs-body table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.docs-body td { padding: .5rem .8rem .5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs-body tr:last-child td { border-bottom: 0; }
table.q td.cmd { white-space: nowrap; font: 12.5px/1.5 var(--mono); color: var(--accent); font-weight: 600; }
table.q td.yes { color: var(--muted); }
.docs-flags { color: var(--faint); font-size: .8rem; font-family: var(--mono); }

/* the terminal: dark in both themes, the one deliberate dark on the page */
pre.term {
  background: var(--term-bg); color: var(--term-ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: .7rem .9rem; margin: .6rem 0 1.1rem;
  font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap; overflow-x: auto;
  box-shadow: var(--shadow);
}
pre.term .p { color: #a5d5ef; }
pre.term .c { color: var(--term-dim); }
pre.term.install { display: flex; align-items: center; gap: .6ch; cursor: pointer; white-space: nowrap; }
pre.term.install .copy { margin-left: auto; color: var(--term-dim); font-size: 11px; padding: 4px 8px; user-select: none; flex: none; text-transform: uppercase; letter-spacing: .06em; }
pre.term.install:hover .copy { color: var(--term-ink); }

/* ── the footer ──────────────────────────────────────────────────────── */
footer {
  display: flex; align-items: center; justify-content: center; gap: 1.2rem; flex-wrap: wrap;
  padding: 1rem clamp(1rem, 4vw, 2.4rem) 1.2rem;
  border-top: 1px solid var(--line);
  color: var(--faint); font-size: .8rem;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--ink); }
footer .pulse { color: var(--faint); }

/* ── the phone: the site tab bar below, the sections as a pill row ───── */
/* The pipeOS handoff: the side panel goes, the fixed bottom bar arrives —
   but the bar belongs to the SITE now (chrome.ts builds it everywhere), so
   the docs sections become a scrolling pill row above the prose instead of
   a second bar fighting for the same edge. */
@media (max-width: 760px) {
  .wrap { grid-template-columns: minmax(0, 1fr); }
  .wrap > main { grid-column: 1; }
  .wrap > footer { grid-column: 1; }
  nav[data-nav] { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; background: var(--bg2); border-top: 1px solid var(--line);
    padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar b {
    flex: 1; min-height: 44px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    font-size: .68rem; font-weight: 400; letter-spacing: .04em;
    color: var(--muted); text-decoration: none; position: relative;
  }
  .tabbar b { color: var(--accent); font-weight: 600; }
  .tabbar .glyph svg { width: 20px; height: 20px; display: block; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar .count { position: absolute; top: 2px; right: 50%; margin-right: -22px; font-size: .68rem; color: var(--accent); }
  .docs-wrap { grid-template-columns: 1fr; gap: .9rem; padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
  .docs-nav {
    position: static; height: auto; flex-direction: row; overflow-x: auto;
    gap: .3rem; margin: 0 -1rem; padding: 0 1rem .2rem;
  }
  /* the pill row groups by order alone; the labels would cost a thumb-width */
  .docs-nav .grp { display: none; }
  .docs-nav a { flex: none; flex-direction: row; gap: .35rem; padding: .35rem .7rem; font-size: .82rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
  .docs-nav a[aria-current="page"] { border-color: transparent; }
  .docs-nav .ic { width: 15px; height: 15px; }
  .docs-nav .lbl { display: none; }
  .docs-nav .lbs { display: inline; }
  .docs-body h1 { font-size: 1.3rem; }
  table.q td.cmd { white-space: normal; }
}
