/* Gavelr docs: the shell (top bar, sidebar, mobile drawer, pager) and the prose styles.
   Loaded after gv.css, so it uses the same paper, ink, seal and type tokens. */

body.docs { --bar-h: 64px; --side-w: 250px; --doc-w: 780px; }

/* Before docs.js mounts the shell (or without JavaScript) the article still reads well. */
body.docs > article.doc { max-width: calc(var(--doc-w) + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); }

/* ---------- faint drafting grid: hairlines drawn by an SVG tile, faded toward the bottom ---------- */
.dgridbg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .34;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M0 .5H48M.5 0V48' fill='none' stroke='%23d8cfbe' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%);
          mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

body.docs > .footer { position: relative; z-index: 1; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 200; padding: 10px 14px; background: var(--ink); color: var(--paper); font: 500 13px/1 var(--sans); text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- top bar ---------- */
.dbar { position: sticky; top: 0; z-index: 60; height: var(--bar-h); background: rgba(241, 236, 226, .9); -webkit-backdrop-filter: saturate(1.2) blur(8px); backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--ink); }
.dbar-in { height: 100%; max-width: calc(1320px + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); display: flex; align-items: center; gap: 16px; }
.dbar .brand { gap: 10px; }
.dbar .brand-mark { width: 30px; height: 30px; }
.dbar .brand-word { font-size: 23px; }
.dbar-div { width: 1px; height: 24px; background: var(--rule-strong); flex: none; }
.dbar-label { font: 500 11.5px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--seal-ink); text-decoration: none; }
.dbar-links { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.dbar-links a { padding: 10px 12px; font: 500 11.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.dbar-links a:hover { color: var(--seal-ink); }
.dburger { display: none; margin-left: auto; width: 42px; height: 42px; flex: none; align-items: center; justify-content: center; border: 1px solid var(--ink); border-radius: 2px; background: transparent; color: var(--ink); cursor: pointer; }
.dburger .ic { width: 20px; height: 20px; }

/* ---------- two columns: sidebar and article, centred together ---------- */
.dwrap { position: relative; z-index: 1; max-width: calc(1320px + 2 * var(--gutter)); margin: 0 auto; padding-inline: var(--gutter); display: grid; grid-template-columns: var(--side-w) minmax(0, var(--doc-w)); justify-content: center; gap: clamp(40px, 5.2vw, 84px); }
.dmain { min-width: 0; padding: 0 0 96px; }

/* ---------- sidebar (and the drawer, which uses the same groups) ---------- */
.dside { position: sticky; top: var(--bar-h); align-self: start; max-height: calc(100vh - var(--bar-h)); max-height: calc(100dvh - var(--bar-h)); overflow-y: auto; overscroll-behavior: contain; padding: 44px 4px 48px 0; }
.dgroup + .dgroup { margin-top: 30px; }
.dgroup-label { margin: 0 0 10px; font: 500 11px/1.2 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--seal-ink); opacity: .85; }
.dlist { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule-strong); }
.dlist a { display: block; margin-left: -1px; border-left: 2px solid transparent; padding: 7px 14px; font: 400 14.5px/1.35 var(--sans); color: var(--ink-2); text-decoration: none; }
.dlist a:hover { color: var(--ink); border-left-color: var(--rule-strong); }
.dlist a[aria-current="page"] { color: var(--seal-ink); border-left-color: var(--seal); background: rgba(184, 50, 30, .07); font-weight: 500; }

/* ---------- mobile drawer ---------- */
.ddrawer-backdrop { position: fixed; inset: 0; z-index: 90; border: 0; padding: 0; background: rgba(23, 21, 15, .45); opacity: 0; pointer-events: none; transition: opacity .22s; }
.ddrawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; width: min(86vw, 330px); height: 100dvh; display: flex; flex-direction: column; background: var(--sheet); border-right: 1px solid var(--ink); transform: translateX(-102%); visibility: hidden; transition: transform .26s cubic-bezier(.2, .7, .2, 1), visibility 0s linear .26s; }
body.docs-open { overflow: hidden; }
/* Visible at once when opening (so the close button can take focus), hidden only after sliding out. */
body.docs-open .ddrawer { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.2, .7, .2, 1), visibility 0s; }
body.docs-open .ddrawer-backdrop { opacity: 1; pointer-events: auto; }
.ddrawer-head { flex: none; height: var(--bar-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px 0 18px; border-bottom: 1px solid var(--ink); }
.ddrawer-head .brand-mark { width: 28px; height: 28px; }
.ddrawer-head .brand-word { font-size: 22px; }
.dclose { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--rule-strong); border-radius: 2px; background: transparent; color: var(--ink); cursor: pointer; }
.ddrawer-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px 18px 28px; }
.ddrawer .dlist a { padding: 10px 14px; font-size: 15.5px; }
.ddrawer-site { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--rule); }
.ddrawer-site a { padding: 10px 8px; font: 500 11.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); text-decoration: none; }
.ddrawer-foot { flex: none; padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--ink); }
.ddrawer-foot .btn { width: 100%; justify-content: center; }

/* ---------- the article ---------- */
.doc { min-width: 0; padding-top: 48px; }
.doc [id] { scroll-margin-top: calc(var(--bar-h) + 20px); }
.doc-kicker { display: block; font: 500 11px/1.2 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.doc h1 { margin-top: 14px; font-family: var(--serif); font-weight: 400; font-variation-settings: "opsz" 60; font-size: clamp(38px, 4.4vw, 54px); line-height: 1.04; letter-spacing: -.018em; color: var(--ink); }
.doc-lead { margin-top: 20px; max-width: 68ch; font: 400 19.5px/1.6 var(--serif); color: var(--ink-2); }
.doc .doc-lead strong { color: var(--ink); font-weight: 600; }
.doc h2 { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--rule-strong); font: 500 27px/1.2 var(--serif); letter-spacing: -.006em; color: var(--ink); }
.doc h3 { margin-top: 34px; font: 600 17px/1.35 var(--sans); color: var(--ink); }
.doc h3.mname { font: 500 18.5px/1.35 var(--mono); overflow-wrap: anywhere; }
.doc h3.mname span { color: var(--ink-3); font-weight: 400; }
.doc p { margin-top: 16px; font-size: 16px; line-height: 1.75; color: var(--ink-2); }
.doc strong, .doc b { color: var(--ink); font-weight: 600; }
.doc ul, .doc ol { margin: 14px 0 0; padding-left: 22px; color: var(--ink-2); }
.doc li { font-size: 16px; line-height: 1.7; padding-left: 4px; }
.doc li + li { margin-top: 7px; }
.doc li::marker { color: var(--ink-3); }
.doc a { color: var(--seal-ink); text-decoration: underline; text-decoration-color: rgba(154, 38, 20, .35); text-underline-offset: 3px; overflow-wrap: anywhere; }
.doc a:hover { text-decoration-color: currentColor; }
.doc a.btn { color: var(--paper); text-decoration: none; }
.doc a.btn-line { color: var(--ink); }
.doc a.btn-line:hover { color: var(--paper); }
.doc :not(pre) > code { font-size: .86em; background: var(--paper-deep); border: 1px solid var(--rule); padding: 0 5px; border-radius: 2px; color: var(--ink); overflow-wrap: anywhere; }
.doc a > code { color: inherit; }
.doc a.hx { font-family: var(--mono); font-size: 13px; color: var(--ink-2); text-decoration: underline dotted var(--rule-strong); text-underline-offset: 4px; word-break: break-all; }
.doc a.hx:hover { color: var(--seal-ink); text-decoration-color: currentColor; }
.doc .muted { color: var(--ink-3); }
.doc .small { font-size: 14px; line-height: 1.6; color: var(--ink-3); }
.doc .mono { font-family: var(--mono); font-size: .92em; }
.doc hr { border: 0; height: 1px; background: var(--rule); margin: 32px 0 0; }

/* positioning list: "X - one-liner" */
.doc ul.xlist { list-style: none; padding: 0; border-top: 1px solid var(--rule); }
.doc ul.xlist li { padding: 11px 0; margin: 0; border-bottom: 1px solid var(--rule); }

/* ---------- tables: they scroll inside themselves on small screens ---------- */
.dtable { margin-top: 20px; overflow-x: auto; border: 1px solid var(--ink); background: var(--sheet); }
.dtable table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.55; }
.dtable th { text-align: left; vertical-align: bottom; padding: 14px 14px 10px; border-bottom: 1.5px solid var(--ink); font: 500 11px/1.3 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.dtable td { padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; color: var(--ink-2); overflow-wrap: break-word; }
.dtable td code { overflow-wrap: break-word; }
.dtable tr:last-child td { border-bottom: 0; }
.dtable td:first-child { color: var(--ink); }
.dtable td.m, .dtable td .m { font-family: var(--mono); font-size: 13px; }
.dtable td.nw { white-space: nowrap; overflow-wrap: normal; }
.dtable td.num, .dtable th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dtable .tag { text-transform: none; letter-spacing: .02em; }
.dtable p { margin-top: 0; font-size: inherit; line-height: inherit; }

/* ---------- two-column key rows ("Where everything lives") ---------- */
.drows { margin-top: 20px; border-top: 1px solid var(--ink); }
.drow { display: grid; grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr); gap: 4px 24px; padding: 13px 16px; border-bottom: 1px solid var(--rule); font-size: 15px; line-height: 1.55; }
.drow > :first-child { color: var(--ink-2); }
.drow > :last-child { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.drow .m, .drow code { font-family: var(--mono); font-size: 13px; }
.drow-head { padding: 22px 16px 8px; border-bottom: 1px solid var(--rule); font: 500 11px/1.2 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--seal-ink); }
.drow .note { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-3); font-family: var(--sans); }

/* ---------- callouts ---------- */
.callout { margin-top: 24px; padding: 16px 20px 17px; border: 1px solid var(--rule-strong); border-left: 3px solid var(--ink-3); background: var(--sheet); }
.callout-label { display: block; margin-bottom: 6px; font: 500 11px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.callout p { margin-top: 0; font-size: 15px; line-height: 1.65; }
.callout p + p, .callout ul { margin-top: 10px; }
.callout li { font-size: 15px; line-height: 1.6; }
.callout.warn { border-left-color: var(--warn); }
.callout.warn .callout-label { color: var(--warn); }
.callout.seal { border-left-color: var(--seal); }
.callout.seal .callout-label { color: var(--seal-ink); }
.callout.pass { border-left-color: var(--pass); }
.callout.pass .callout-label { color: var(--pass); }

/* ---------- code: highlighted, with a copy bar (pre.code is wrapped by docs.js) ---------- */
.doc pre.code { margin: 20px 0 0; }
.codebox { margin-top: 20px; min-width: 0; border: 1px solid var(--ink); background: var(--paper-deep); }
.codebar { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 5px 0 16px; border-bottom: 1px solid var(--rule-strong); background: var(--sheet); }
.codebar .lbl { flex: 1; min-width: 0; font: 500 12px/1.2 var(--mono); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Long lines wrap rather than hide off to the side. */
.doc .codebox pre.code { margin: 0; border: 0; background: transparent; font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.code .s { color: var(--warn); }
.copy { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; flex: none; border: 1px solid var(--rule-strong); border-radius: 2px; background: transparent; font: 500 12px/1 var(--sans); color: var(--ink-2); cursor: pointer; }
.copy:hover { border-color: var(--ink); color: var(--ink); }
.copy .ic { width: 14px; height: 14px; }
.copy.done { color: var(--pass); border-color: var(--pass); }
.sig { display: block; margin-top: 14px; padding: 12px 16px; background: var(--paper-deep); border: 1px solid var(--rule); font: 400 13px/1.6 var(--mono); color: var(--ink); overflow-wrap: anywhere; }

/* method facts (Returns / Fails with) */
.facts { display: grid; grid-template-columns: 112px minmax(0, 1fr); margin: 16px 0 0; border-top: 1px solid var(--rule); }
.facts dt, .facts dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--rule); }
.facts dt { padding-top: 11px; font-size: 13px; color: var(--ink-3); }
.facts dd { min-width: 0; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.mmeta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; }
.mmeta .net { font-size: 10.5px; }
.method { margin-top: 40px; padding-top: 28px; border-top: 1px dashed var(--rule-strong); }
.method > h3.mname { margin-top: 0; }
.mgroup { margin-top: 44px; font: 500 11.5px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--seal-ink); }
.mgroup + .method { margin-top: 16px; }

/* ---------- the loop: stage cards ---------- */
.stages { margin-top: 22px; border: 1px solid var(--ink); background: var(--sheet); counter-reset: stage; }
.stage { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 4px 16px; padding: 18px 20px 20px; border-bottom: 1px solid var(--rule); }
.stage:last-child { border-bottom: 0; }
.stage-n { grid-row: span 3; font: 400 40px/0.9 var(--serif); font-variation-settings: "opsz" 72; letter-spacing: -.03em; color: var(--ink); }
.stage-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.doc .stage h3 { margin: 0; font: 600 17px/1.3 var(--sans); }
.doc .stage p { margin-top: 6px; font-size: 15px; line-height: 1.65; }

/* ---------- the life of one job: a timeline ---------- */
.tline { list-style: none; margin: 22px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.doc .tline li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 4px 18px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.tline .t { font: 500 14px/1.5 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.tline .t span { display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.tline .what { min-width: 0; }
.tline .what b { display: block; font: 600 15.5px/1.4 var(--sans); color: var(--ink); }
.tline .what p { margin-top: 4px; font-size: 15px; line-height: 1.65; }
.tline .tx { margin-top: 6px; overflow-wrap: anywhere; word-break: break-all; }

/* ---------- figures ---------- */
.dfigs { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); margin-top: 22px; border: 1px solid var(--ink); background: var(--sheet); }
.dfig { padding: 16px 18px; border-right: 1px solid var(--rule); min-width: 0; }
.dfig:last-child { border-right: 0; }
.dfig b { display: block; font: 400 34px/1 var(--serif); font-variation-settings: "opsz" 60; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.dfig span { display: block; margin-top: 8px; font-size: 13px; line-height: 1.4; color: var(--ink-3); }

/* state diagram (The escrow) */
.statefig { margin: 22px 0 0; border: 1px solid var(--ink); background: var(--sheet); }
.statefig .sf-scroll { overflow-x: auto; }
.statefig svg { width: 100%; min-width: 680px; height: auto; display: block; }
.statefig .st { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.4; }
.statefig .st.pass { fill: var(--pass-wash); stroke: var(--pass); }
.statefig .st.end { fill: var(--ink); }
.statefig .nm { font: 600 15px var(--sans); fill: var(--ink); }
.statefig .sb { font: 400 11px var(--mono); fill: var(--ink-3); }
.statefig .end-t { fill: var(--paper); }
.statefig .end-s { fill: #b9b1a1; }
.statefig .edge { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.statefig .edge.seal { stroke: var(--seal); }
.statefig .fn { font: 500 12px var(--mono); fill: var(--ink); }
.statefig .fn.seal { fill: var(--seal-ink); }
.statefig .wh { font: 400 10.5px var(--mono); fill: var(--ink-3); }
.statefig figcaption { padding: 12px 18px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--ink-3); }

/* reading order and on-this-page lists */
.doc ol.reading { list-style: none; padding: 0; counter-reset: rd; border-top: 1px solid var(--rule); }
.doc ol.reading li { counter-increment: rd; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 2px 10px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.doc ol.reading li::before { content: counter(rd) "."; grid-row: span 2; font: 500 13px/1.75 var(--mono); color: var(--seal); }
.doc ol.reading a { font-weight: 600; }
.doc ol.reading span { color: var(--ink-2); }
.dtoc { margin-top: 28px; padding: 14px 18px 16px; border: 1px solid var(--rule-strong); background: var(--sheet); }
.dtoc .callout-label { margin-bottom: 8px; }
.doc .dtoc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.doc .dtoc li { margin: 0; padding: 0; font-size: 14.5px; }

/* FAQ (reuses gv.css .faq, sized for the article) */
.doc .faq { margin-top: 20px; }
.doc .faq summary { font-size: 20px; padding: 18px 0; }
.doc .faq details > div { padding-bottom: 20px; }
.doc .faq details > div p:first-child { margin-top: 0; }

/* ---------- pager ---------- */
.dpager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 80px; padding-top: 28px; border-top: 1px solid var(--ink); }
.dpager a { display: block; min-width: 0; padding: 16px 18px 18px; border: 1px solid var(--rule-strong); background: var(--sheet); text-decoration: none; color: var(--ink); }
.dpager a:hover { border-color: var(--ink); }
.dpager a:hover .dpager-title { color: var(--seal-ink); }
.dpager .next { grid-column: 2; text-align: right; }
.dpager-label { display: block; font: 500 11px/1.2 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-3); }
.dpager-title { display: block; margin-top: 8px; font: 500 19px/1.3 var(--serif); color: var(--ink); }

/* live block on Real results */
.dloading { padding: 22px 18px; font-size: 14.5px; color: var(--ink-3); display: flex; gap: 10px; align-items: center; }

/* ---------- tablet and phone ---------- */
@media (max-width: 900px) {
  body.docs { --bar-h: 60px; }
  .dbar-links { display: none; }
  .dburger { display: inline-flex; }
  .dwrap { grid-template-columns: minmax(0, 1fr); }
  .dside { display: none; }
  .doc { padding-top: 32px; }
  .doc h2 { margin-top: 44px; padding-top: 24px; font-size: 24px; }
  .doc-lead { font-size: 18px; }
  .dtable table { min-width: var(--minw, 600px); }
  .doc .codebox pre.code { padding: 14px 16px; font-size: 12.5px; }
  .dfigs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dfig:nth-child(2n) { border-right: 0; }
  .dfig { border-bottom: 1px solid var(--rule); }
}
@media (max-width: 640px) {
  .drow { grid-template-columns: minmax(0, 1fr); padding: 12px 2px; }
  .drow-head { padding-inline: 2px; }
  .stage { grid-template-columns: 38px minmax(0, 1fr); padding: 16px 16px 18px; gap: 4px 12px; }
  .stage-n { font-size: 30px; }
  .doc .tline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tline .t span { display: inline; margin-left: 8px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .facts dt { border-bottom: 0; padding-bottom: 0; }
  .dpager { grid-template-columns: minmax(0, 1fr); }
  .dpager .next { grid-column: auto; }
  .dbar .brand-word { font-size: 21px; }
  .dbar-in { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .ddrawer, .ddrawer-backdrop { transition: none; }
}
