/* flywheel-theme — the mono/green language from dedi.proto + schemes.proto.
 *
 * Design: monospace everything, paper ground, deep-green accent, hairline
 * borders, square-ish corners. Plain markdown output (h1..h3, p, lists,
 * tables, code, blockquote, hr, links, images) is styled with NO classes;
 * classed components are additive extras.
 *
 * Themes: light by default, dark via prefers-color-scheme, and an explicit
 * override via <html data-theme="dark"> / <html data-theme="light">.
 */

:root {
  --fw-bg: #fbfcfa;
  --fw-ink: #1c201d;
  --fw-mut: #66706a;
  --fw-accent: #2f6f4f;
  --fw-accent-soft: #e6f0ea;
  --fw-line: #d8ded9;
  --fw-panel: #ffffff;
  --fw-code-bg: #f2f5f2;
  --fw-ok: #1a7a37;
  --fw-bad: #b00020;
  /* JSON / code token colors */
  --fw-tok-key: #2f6f4f;
  --fw-tok-str: #a23c2c;
  --fw-tok-num: #1c66b3;
  --fw-tok-bool: #8a5a00;
  --fw-tok-null: #999999;
  /* terminal block roles */
  --fw-term-bg: #eef2ee;
  --fw-term-line: #d8ded9;
  --fw-term-out: #66706a;
  --fw-term-cmd: #1c201d;
  --fw-term-cmt: #8a948c;

  --fw-font: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* 13px matches the live sites: they declare bare `font-family: monospace`,
   * which triggers the browsers' default FIXED font size (13px, not 16px).
   * Naming real fonts disables that quirk, so the size must be explicit. */
  --fw-size: 13px;
  --fw-measure: 46em;   /* reading width; override on app-like pages */
}
@media (prefers-color-scheme: dark) {
  :root {
    --fw-bg: #121513; --fw-ink: #e4e8e4; --fw-mut: #9aa49d;
    --fw-accent: #7cc47f; --fw-accent-soft: #1d2b22; --fw-line: #2a312c;
    --fw-panel: #181c19; --fw-code-bg: #1d221e;
    --fw-ok: #6fbf82; --fw-bad: #e07a8a;
    --fw-tok-key: #7cc47f; --fw-tok-str: #d99a8e; --fw-tok-num: #7aaede;
    --fw-tok-bool: #cfa14f; --fw-tok-null: #949e96;
    --fw-term-bg: #101312; --fw-term-line: #242a26;
    --fw-term-out: #9aa49d; --fw-term-cmd: #e6e9e6; --fw-term-cmt: #8a948c;
  }
}
:root[data-theme="light"] {
  --fw-bg: #fbfcfa; --fw-ink: #1c201d; --fw-mut: #66706a;
  --fw-accent: #2f6f4f; --fw-accent-soft: #e6f0ea; --fw-line: #d8ded9;
  --fw-panel: #ffffff; --fw-code-bg: #f2f5f2;
  --fw-ok: #1a7a37; --fw-bad: #b00020;
  --fw-tok-key: #2f6f4f; --fw-tok-str: #a23c2c; --fw-tok-num: #1c66b3;
  --fw-tok-bool: #8a5a00; --fw-tok-null: #66706a;
  --fw-term-bg: #eef2ee; --fw-term-line: #d8ded9;
  --fw-term-out: #66706a; --fw-term-cmd: #1c201d; --fw-term-cmt: #66706a;
}
:root[data-theme="dark"] {
  --fw-bg: #121513; --fw-ink: #e4e8e4; --fw-mut: #9aa49d;
  --fw-accent: #7cc47f; --fw-accent-soft: #1d2b22; --fw-line: #2a312c;
  --fw-panel: #181c19; --fw-code-bg: #1d221e;
  --fw-ok: #6fbf82; --fw-bad: #e07a8a;
  --fw-tok-key: #7cc47f; --fw-tok-str: #d99a8e; --fw-tok-num: #7aaede;
  --fw-tok-bool: #cfa14f; --fw-tok-null: #949e96;
  --fw-term-bg: #101312; --fw-term-line: #242a26;
  --fw-term-out: #9aa49d; --fw-term-cmd: #e6e9e6; --fw-term-cmt: #8a948c;
}

/* ---------- base / markdown elements (no classes needed) ---------- */

html { background: var(--fw-bg); }
body {
  font-family: var(--fw-font);
  font-size: var(--fw-size);
  color: var(--fw-ink);
  line-height: 1.55;
  max-width: var(--fw-measure);
  margin: 1.5em auto;
  padding: 0 1em;
}

h1 { font-size: 1.3em;  letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 1.05em; margin: 1.6em 0 0.4em; }
h3 { font-size: 0.95em; margin: 1.3em 0 0.3em; }
h1, h2, h3 { line-height: 1.3; }

p { margin: 0.7em 0; }

a { color: var(--fw-accent); text-decoration: none; border-bottom: 1px solid var(--fw-line); }
a:hover, a:focus-visible { border-bottom-color: var(--fw-accent); outline: none; }

ul, ol { padding-left: 1.3em; margin: 0.5em 0; }
li { margin: 0.3em 0; }
li::marker { color: var(--fw-accent); }

strong { color: var(--fw-ink); }
hr { border: 0; border-top: 1px solid var(--fw-line); margin: 2em 0; }

img { max-width: 100%; height: auto; }

blockquote {
  margin: 1em 0; padding: 0.1em 0 0.1em 0.9em;
  border-left: 3px solid var(--fw-accent);
  color: var(--fw-mut);
}

code {
  background: var(--fw-code-bg);
  padding: 0.05em 0.3em; border-radius: 3px;
  font-family: var(--fw-font); font-size: 0.92em;
}
pre {
  background: var(--fw-code-bg);
  border: 1px solid var(--fw-line); border-radius: 4px;
  padding: 0.8em 1em; overflow-x: auto;
  font-size: 0.85em; line-height: 1.5;
}
pre code { background: transparent; padding: 0; font-size: inherit; }

table { border-collapse: collapse; width: 100%; font-size: 0.9em; margin: 0.8em 0; }
th, td { border: 1px solid var(--fw-line); padding: 0.35em 0.55em; text-align: left; vertical-align: top; }
th { background: var(--fw-code-bg); font-size: 0.85em; letter-spacing: 0.04em; }
td { font-variant-numeric: tabular-nums; }

::selection { background: var(--fw-accent-soft); }

/* ---------- components ---------- */

/* top navigation: <nav><a>…</a> <a>…</a></nav> */
nav { margin-bottom: 1em; }
nav a { display: inline-block; padding: 5px 0; margin-right: 1em; border-bottom: none; }
nav a:hover { border-bottom: 1px solid var(--fw-accent); }

/* uppercase section label, use above an h1/h2 */
.eyebrow {
  font-size: 0.72em; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--fw-accent); margin: 0 0 0.35em;
}

/* muted/secondary text (color only, body size) */
.mut { color: var(--fw-mut); }

/* subtext tier: smaller than body AND muted — captions, counts, result
   subtext, metadata lines ("3,289 results in 0.42s"). Semantic first:
   <small> and <figcaption> get it free; .sub for block-level use. */
small, figcaption, .sub { font-size: 0.85em; color: var(--fw-mut); line-height: 1.5; }

/* image with caption: plain markdown images stay unframed; figures get a
   hairline frame and a subtext caption */
figure { margin: 1em 0; }
figure img { display: block; border: 1px solid var(--fw-line); border-radius: 4px; }
figcaption { margin-top: 0.4em; }

/* lede paragraph under a title */
.thesis { color: var(--fw-mut); max-width: 62ch; }

/* small green chip: <span class="badge">Beckn 2.0.0</span> */
.badge {
  display: inline-block; background: var(--fw-accent-soft); color: var(--fw-accent);
  border-radius: 3px; padding: 1px 7px; font-size: 0.72em;
  letter-spacing: 0.03em; vertical-align: middle;
}

/* neutral chip for taxonomy: <span class="tag">pension</span> */
.tag {
  display: inline-block; background: var(--fw-code-bg); border-radius: 3px;
  padding: 1px 7px; font-size: 0.82em; margin-right: 0.3em; white-space: nowrap;
}

/* bordered box: <div class="card"><h3>…</h3><p>…</p></div> */
.card {
  border: 1px solid var(--fw-line); border-radius: 4px;
  padding: 0.9em 1em; background: var(--fw-panel);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

/* responsive card/two-column grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1rem; }
.cols2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1.4em; align-items: start; }
@media (max-width: 820px) { .cols2 { grid-template-columns: 1fr; } }

/* status text */
.ok { color: var(--fw-ok); }
.no { color: var(--fw-bad); }

/* verification / aside block with a rail */
.proof { border-left: 3px solid var(--fw-line); padding-left: 0.8em; }

/* data table: pair with datatable.js (@tanstack/table-core engine).
   <div data-fw-table>…</div>, or fwDataTable(el, {columns, data}). Sortable
   headers, a global filter, and pagination — all layered on the theme's plain
   table + control base, so it reads as the same system. */
.fw-datatable { margin: 0.8em 0; }
.fw-datatable table { margin: 0; }
.fw-dt-bar { display: flex; align-items: center; gap: 0.7em; margin-bottom: 0.5em; }
.fw-dt-filter { flex: 0 1 16em; min-width: 0; }
.fw-dt-count { margin-left: auto; font-size: 0.85em; color: var(--fw-mut); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fw-dt-scroll { overflow-x: auto; }
.fw-datatable th.fw-dt-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.fw-datatable th.fw-dt-sortable:hover { color: var(--fw-accent); }
.fw-datatable th[aria-sort] { color: var(--fw-accent); }
.fw-datatable th.fw-dt-sortable:focus-visible { outline: 2px solid var(--fw-accent); outline-offset: -2px; }
.fw-dt-sort { font-size: 0.8em; margin-left: 0.15em; }
.fw-datatable tbody tr:hover { background: var(--fw-accent-soft); }
.fw-dt-empty { color: var(--fw-mut); text-align: center; }
.fw-dt-pager { display: flex; align-items: center; gap: 0.7em; margin-top: 0.5em; }
.fw-dt-pager button { padding: 3px 10px; font-size: 0.85em; }
.fw-dt-pager button:disabled { opacity: 0.4; cursor: default; border-color: var(--fw-line); }
.fw-dt-page { font-size: 0.85em; color: var(--fw-mut); font-variant-numeric: tabular-nums; }

/* form controls, normalized to equal height (the searchbar language) */
input[type="text"], input[type="search"], textarea, select, button {
  box-sizing: border-box; border: 1px solid var(--fw-line);
  padding: 8px 10px; font: inherit; line-height: 1.5;
  background: var(--fw-panel); color: var(--fw-ink); border-radius: 0;
}
select, button { cursor: pointer; }
button:hover { border-color: var(--fw-accent); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--fw-accent); outline-offset: -1px;
}
.searchbar { display: flex; align-items: flex-end; gap: 8px; }
.searchbar > :first-child { flex: 1 1 auto; }
.searchbar > select, .searchbar > button { flex: 0 0 auto; }

/* mobile: comfortable touch targets, wrapping controls, scrolling tables */
@media (pointer: coarse) {
  button, select, input[type="text"], input[type="search"], textarea { padding: 10px 12px; }
  .copy-btn, .share-btn, .theme-toggle { padding: 6px 10px; }
}
@media (max-width: 600px) {
  .searchbar { flex-wrap: wrap; }
  .searchbar > :first-child { flex-basis: 100%; }
  table { display: block; overflow-x: auto; }
}

/* light/dark toggle, fixed top right: pair with theme.js (auto-inserted
   when no element with the class exists; names the mode it switches TO) */
.theme-toggle {
  position: fixed; top: 0.9em; right: 0.9em; z-index: 10;
  font-size: 0.85em; padding: 3px 9px; color: var(--fw-mut);
}
.theme-toggle:hover { color: var(--fw-accent); }

/* inline share button: pair with share.js (Web Share API, clipboard fallback) */
.share-btn { font-size: 0.85em; padding: 3px 9px; color: var(--fw-mut); }
.share-btn:hover { color: var(--fw-accent); }

/* WhatsApp-style growing textarea: pair with autogrow.js, rows="1" */
textarea.autogrow { resize: none; overflow-y: auto; max-height: 8em; }

/* Code blocks, IDE-flavoured.
   pre[data-lang] shows a language label; the token colors below map the class
   names emitted by common highlighters (highlight.js, Prism, Hugo/Chroma)
   onto the theme palette, so server- or client-side highlighting picks up the
   flavour with no extra stylesheet. */
pre[data-lang] { position: relative; }
pre[data-lang]::after {
  content: attr(data-lang); position: absolute; top: 0.5em; right: 0.7em;
  font-size: 0.85em; color: var(--fw-mut); letter-spacing: 0.04em;
}
pre .hljs-comment, pre .hljs-quote, pre .token.comment, .chroma .c, .chroma .c1, .chroma .cm, .chroma .ch {
  color: var(--fw-mut); font-style: italic; }
pre .hljs-keyword, pre .hljs-literal, pre .hljs-built_in, pre .hljs-type, pre .hljs-selector-tag,
pre .token.keyword, pre .token.boolean, .chroma .k, .chroma .kd, .chroma .kt, .chroma .kn {
  color: var(--fw-accent); }
pre .hljs-string, pre .token.string, .chroma .s, .chroma .s1, .chroma .s2, .chroma .sb {
  color: var(--fw-tok-str); }
pre .hljs-number, pre .token.number, .chroma .m, .chroma .mi, .chroma .mf {
  color: var(--fw-tok-num); }
pre .hljs-title, pre .hljs-function, pre .token.function, .chroma .nf {
  color: var(--fw-tok-bool); }
pre .hljs-attr, pre .hljs-property, pre .token.property, .chroma .na, .chroma .nx {
  color: var(--fw-tok-key); }
pre .hljs-meta, pre .token.punctuation, .chroma .gp { color: var(--fw-mut); }

/* terminal block: shell sessions with prompt/command/output roles, themed
   like everything else — tinted paper in light, near-black in dark.
   term.js produces this markup from plain ```sh fences. */
pre.term { background: var(--fw-term-bg); border-color: var(--fw-term-line); color: var(--fw-term-out); }
pre.term .p { color: var(--fw-accent); user-select: none; }
pre.term .cmd { color: var(--fw-term-cmd); }
pre.term .hljs-comment { color: var(--fw-term-cmt); }
pre.term[data-lang]::after { color: var(--fw-term-cmt); }

/* copy button on code blocks (copy.js): terminals copy just the commands */
pre.has-copy { position: relative; }
.copy-btn {
  position: absolute; top: 0.4em; right: 0.5em;
  font-size: 0.85em; padding: 1px 7px; line-height: 1.4;
  background: transparent; border: 1px solid transparent; color: var(--fw-mut);
}
.copy-btn:hover { border-color: var(--fw-line); color: var(--fw-accent); background: transparent; }
pre.term .copy-btn { color: var(--fw-term-cmt); }
pre.term .copy-btn:hover { color: var(--fw-accent); }
/* language label steps aside when the copy button is present */
pre.has-copy[data-lang]::after { right: 5em; }

/* mermaid diagrams: schematic paper — white in BOTH themes, so mermaid's
   standard 'neutral' theme stays legible and diagrams need no re-render when
   the theme toggles. Load mermaid yourself (CDN or bundled) and init with
   { startOnLoad: true, theme: 'neutral', securityLevel: 'strict' }. */
pre.mermaid, .mermaid {
  background: #ffffff; border: 1px solid var(--fw-line); border-radius: 4px;
  padding: 1em; overflow-x: auto;
}
/* mermaid's injected styles pin 16px on diagram text regardless of config;
   assert the theme's size so diagrams sit flush with the 13px page */
pre.mermaid svg text, pre.mermaid svg tspan, .mermaid svg text, .mermaid svg tspan {
  font-size: 13px !important;
}

/* JSON viewer token classes (pair with hljson.js) */
.json { white-space: pre; font-size: 0.8em; max-height: 320px; overflow: auto; }
.json .key { color: var(--fw-tok-key); }
.json .str { color: var(--fw-tok-str); }
.json .num { color: var(--fw-tok-num); }
.json .bool { color: var(--fw-tok-bool); }
.json .null { color: var(--fw-tok-null); }

/* page-width variants: <body class="wide"> for app-like pages */
body.wide { max-width: 68em; }
body.brief { max-width: 76em; }

@media (prefers-reduced-motion: no-preference) {
  a, button { transition: border-color 120ms ease; }
}
