/* Docs, and Risk and terms. Tokens and shared classes come from system.css. Class prefix: doc-

   The page: a dark masthead (title, what the page is, the index of sections), then the reading part on paper.
   Every section is ruled: the tick scale, its heading in the left column, its body in the right.
   On a phone the index becomes a bar that stays at the top of the paper.

   Monospace is for figures only. Code names (functions, events) are set in DM Sans, in a ruled box. */

/* ---- masthead ---- */
.doc-top { padding: 20px 0 32px; }
.doc-meta { margin-top: 12px; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.doc-top .lede { margin-top: 20px; max-width: 46ch; }
.doc-notice { margin-top: 20px; padding: 14px 16px; border: 1px solid var(--hair-2); border-radius: var(--r); font-size: 16px; line-height: 1.5; color: var(--text-2); max-width: 60ch; }
.doc-notice b { font-weight: 600; color: var(--text); }
.doc-notice.first { font-size: 17px; font-weight: 500; color: var(--text); }

/* the index of sections: a ruled strip, numbered. From 720 px. */
.doc-index { display: none; }

/* ---- the bar that carries the index on a phone ---- */
.doc-bar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--rule); }
.doc-bar summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 var(--gutter); font: 500 15px/1.2 var(--sans); color: var(--ink); }
.doc-bar summary::-webkit-details-marker { display: none; }
.doc-bar summary::after { content: "+"; flex: none; font: 400 20px/1 var(--mono); color: var(--ink-2); }
.doc-bar[open] summary::after { content: "\2212"; }
.doc-now { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; color: var(--ink-2); }
.doc-bar ol { max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px); overflow-y: auto; padding: 0 var(--gutter) 8px; border-top: 1px solid var(--rule); }
.doc-bar li a { display: flex; align-items: center; min-height: 48px; border-bottom: 1px solid var(--rule); font-size: 16px; text-decoration: none; color: var(--ink); }
.doc-bar li:last-child a { border-bottom: 0; }
.doc-bar li a[aria-current="true"] { font-weight: 600; }

/* ---- a ruled section on paper ---- */
.doc-paper { background: var(--paper); color: var(--ink); }
.doc-sec { position: relative; scroll-margin-top: 40px; }
.doc-bar + .doc-sec { padding-top: 24px; }
/* a second id for a section (#prices for #keeper, #burn for #token) lands on the same spot */
.doc-alias { position: absolute; top: 0; left: 0; width: 0; height: 0; scroll-margin-top: 40px; }
.doc-sub { display: none; }

/* ---- the body column ---- */
.doc-body { min-width: 0; font-size: 17px; line-height: 1.6; color: var(--ink); }
.doc-body > * + * { margin-top: 16px; }
.doc-body p, .doc-body > ul, .doc-body > ol { max-width: 68ch; }
.doc-body h3 { margin-top: 44px; scroll-margin-top: 56px; text-wrap: balance; }
.doc-body > h3:first-child { margin-top: 0; }
.doc-body h3 + * { margin-top: 12px; }
.doc-body a { color: var(--teal); }
.doc-body b, .doc-body strong { font-weight: 600; }
.doc-body ul, .doc-body ol.doc-steps { display: grid; gap: 8px; padding-left: 20px; list-style: disc; }
.doc-body ol.doc-steps { list-style: decimal; padding-left: 22px; }
.doc-body li::marker { color: var(--ink-2); }
.doc-body code { font: 500 0.94em/1.3 var(--sans); padding: 1px 5px; background: rgba(24, 24, 27, 0.05); border: 1px solid var(--rule); border-radius: 4px; overflow-wrap: anywhere; }
.doc-body .note { margin-top: 28px; max-width: 68ch; font-size: 14px; }
.doc-body .note + .table-wrap { margin-top: 10px; }

/* facts and sums: label left, sentence right */
.doc-body .ruled { margin-top: 20px; }
.doc-body > .ruled:first-child { margin-top: 0; }
.doc-body .ruled dd { font-size: 16px; line-height: 1.55; }
.doc-body .ruled dd p + p { margin-top: 10px; }
.doc-sum dd { font-size: 17px; }
/* a list of points, each a statement and what it means */
.doc-points dt { font-size: 16px; line-height: 1.4; font-weight: 600; color: var(--ink); text-wrap: balance; }
.doc-points dd { color: var(--ink-2); }
.light .doc-points dt { color: var(--ink); }

/* two lists side by side: what it can do, what it cannot */
.doc-two { display: grid; gap: 28px; margin-top: 20px; }
.doc-two > div { border-top: 1px solid var(--ink-3); padding-top: 14px; }
.doc-body .doc-two h3 { margin: 0 0 10px; font-size: 17px; line-height: 1.3; }
.doc-two ul { font-size: 16px; line-height: 1.55; }

/* tables: hairlines, text that wraps */
.doc-body .table { font-size: 15px; line-height: 1.45; }
.doc-body .table th { padding-right: 16px; }
.doc-body .table td, .doc-body .table tbody th { height: auto; padding: 12px 16px 12px 0; white-space: normal; vertical-align: top; border-bottom: 1px solid var(--rule); }
.doc-body .table tbody th { text-align: left; font: 600 15px/1.45 var(--sans); color: var(--ink); overflow-wrap: anywhere; }
.doc-body .table th:last-child, .doc-body .table td:last-child { padding-right: 0; }
.doc-body .table td.num { white-space: nowrap; }
.doc-body .table tbody th.when { font-weight: 500; white-space: nowrap; }
/* a table of figures keeps its columns together: it is as wide as the reading column, not the whole page */
.doc-body .table.doc-fit { max-width: 68ch; }
.doc-fn, .doc-terms { table-layout: fixed; }
.doc-fn thead th:first-child, .doc-terms thead th:first-child { width: 192px; }
.doc-fn thead th:nth-child(2):not(:last-child) { width: 216px; }
.doc-terms thead th:last-child { width: 232px; }

/* the request, as text you can copy. Figures are the only monospace in it */
.doc-req { margin-top: 20px; max-width: 68ch; }
.doc-req-cap { font-size: 14px; line-height: 1.45; color: var(--ink-2); overflow-wrap: anywhere; }
.doc-req pre { margin: 8px 0 0; padding: 16px 18px; background: var(--ground); color: var(--text); border-radius: var(--r); font: 400 15px/1.6 var(--sans); white-space: pre; overflow-x: auto; }
.doc-req pre code { font: inherit; padding: 0; background: none; border: 0; overflow-wrap: normal; }
.doc-req pre:focus-visible { outline-color: var(--teal); }
.doc-run { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 12px; }
.doc-run .note { margin: 0; }
.doc-body .doc-out { margin-top: 12px; max-width: 68ch; }

/* changelog */
.doc-log { margin-top: 0; border-top: 1px solid var(--ink-3); }
.doc-log > div { display: grid; gap: 8px; padding: 20px 0; border-bottom: 1px solid var(--rule); }
.doc-log dt { font-size: 15px; line-height: 1.5; font-weight: 600; }
.doc-log dt .fig { display: block; font-weight: 400; font-size: 14px; color: var(--ink-2); }
.doc-log dd { font-size: 16px; line-height: 1.55; }
.doc-log dd ul { margin-top: 10px; }

.doc-body .qa { margin-top: 0; }
.doc-body .qa summary { text-wrap: balance; }
.doc-body .qa details p { text-wrap: pretty; }

@media (hover: hover) {
  .doc-index a:hover { color: var(--text); background: rgba(160, 220, 240, 0.06); }
  .doc-sub a:hover { color: var(--ink); }
  .doc-body a:hover { color: var(--ink); }
}

/* ---- phone only ---- */
@media (max-width: 719.98px) {
  .doc-body .table { font-size: 14px; }
  .doc-body .table td, .doc-body .table tbody th, .doc-body .table th { padding-right: 10px; }
  .doc-body .table td.num { font-size: 13px; }
  .doc-money td:first-child { min-width: 116px; }

  /* a table of names and what they do becomes a ruled list of blocks */
  .doc-stack { border-top: 1px solid var(--ink-3); }
  .doc-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .doc-stack, .doc-stack tbody, .doc-stack tr, .doc-stack th, .doc-stack td { display: block; }
  .doc-stack tr { padding: 14px 0; border-bottom: 1px solid var(--rule); }
  .doc-body .doc-stack tbody th, .doc-body .doc-stack td { padding: 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .doc-body .doc-stack tbody th { font-size: 16px; }
  .doc-body .doc-stack td { margin-top: 4px; font-size: 16px; line-height: 1.5; }
  .doc-stack td[data-label]:not(:only-of-type)::before { content: attr(data-label) ": "; font-size: 13px; color: var(--ink-2); }
}

/* ---- from 720 px ---- */
@media (min-width: 720px) {
  .doc-top { padding: 40px 0 0; }
  .doc-meta { margin-top: 16px; font-size: 14px; }

  .doc-index { display: block; margin-top: 56px; padding-bottom: 72px; }
  .doc-index ol { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 32px; counter-reset: doc; }
  .doc-index li { counter-increment: doc; border-bottom: 1px solid var(--hair); }
  .doc-index a { display: flex; align-items: baseline; gap: 14px; min-height: 52px; padding: 15px 8px 13px 0; text-decoration: none; font-size: 16px; line-height: 1.4; font-weight: 500; color: var(--text); transition: background-color 0.15s var(--ease); }
  .doc-index.five ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-index a::before { content: counter(doc, decimal-leading-zero); flex: none; font: 400 13px/1.4 var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); }

  .doc-bar { display: none; }
  .doc-sec, .doc-alias { scroll-margin-top: 0; }
  .doc-body h3 { scroll-margin-top: 8px; }
  .doc-two { grid-template-columns: 1fr 1fr; column-gap: 32px; }
  .doc-log > div { grid-template-columns: 148px minmax(0, 1fr); column-gap: 24px; }
  .doc-points > div { grid-template-columns: 232px minmax(0, 1fr); }
}

/* between 720 and 960 the heading sits above its body, as on a phone */
@media (min-width: 720px) and (max-width: 959.98px) {
  .doc-sec .cols > .a4, .doc-sec .cols > .a8 { grid-column: 1 / -1; }
}

/* ---- from 960 px: heading left, body right, and the heading follows the reading ---- */
@media (min-width: 960px) {
  .doc-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 520px); column-gap: 48px; align-items: start; }
  .doc-head > div:last-child { padding-top: 12px; }
  .doc-head > div:last-child > :first-child { margin-top: 0; }
  /* the 4 px of padding keeps a focus ring inside the scrolling box */
  .doc-stick { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; margin: -4px; padding: 4px; }
  .doc-side .h-section { font-size: clamp(32px, 2.9vw, 42px); line-height: 1.04; }
  .doc-sub { display: block; margin-top: 24px; max-width: 300px; border-top: 1px solid var(--rule); }
  .doc-sub a { display: flex; align-items: center; min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 14px; line-height: 1.3; text-decoration: none; color: var(--ink-2); transition: color 0.15s var(--ease); }
  .doc-sub a.up { color: var(--teal); }
  .doc-sub li:last-child a { border-bottom: 0; }
}
@media (min-width: 1100px) {
  .doc-index ol { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .doc-index.five ol { grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: 24px; }
}

/* ---- shared footer, held open ----
   system.css gives the text column of the footer no width between 720 and about 900 px (the link column
   takes the whole row). This keeps the text column at 240 px or more on these pages. Remove it once
   system.css sets .foot-in to minmax(240px, 1fr) minmax(0, auto) itself. */
@media (min-width: 720px) {
  .site-foot .foot-in { grid-template-columns: minmax(240px, 1fr) minmax(0, auto); }
}

/* Contract addresses are 42 characters with no break point: let them wrap on a phone. */
.doc-sec code.fig, dd code.fig { overflow-wrap: anywhere; word-break: break-all; white-space: normal; }
