/* The reading layout (reading-markup.js), the one page shape of the developer docs and the help pages: imported by
   pages/docs.css and pages/text.css, so the two can't drift apart. Inside the page width: the left column (232) and
   the text column 48px beside it; the words and tables at most 680 wide (one right edge). The left
   column stays as long as the desktop frame does (900 and wider; under 1024 it and the gap are a little narrower);
   below 900 (the phone frame) it goes and Contents, a slim row stuck under the top bar, opens the same list. Colours:
   tokens only. Class prefix: rd-.

   Both pages load this file (once through each stylesheet), so a page's own rules never restyle an rd- class at the
   same strength: they style their own classes (dc-, tx-) or add a class to the selector. */

.rd {
  --rd-measure: 680px;
  --rd-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  display: grid; grid-template-columns: 232px minmax(0, 1fr); column-gap: 48px; align-items: start;
}
:where(.rd) :where(p, h1, h2, h3, ul, ol) { margin: 0; }

/* ---------------------------------------------------------------- the list: the left column and Contents */
/* the area's name ("Help", "For developers"), a group's small label (the docs' four), the pages, the open page's
   sections. The open page is the one lit item: the link colour and a 3px bar in the margin on its left (so every word
   in the column starts at the same edge, the logo's); the section being read is the link colour too. The rest are in
   the label grey; the area's name and the groups' labels in eel, in sentence case like every label on the site. */
.rd-nav__title { margin: 0 0 8px; color: var(--color-eel); font: 700 17px/24px var(--font); }
.rd-grp + .rd-grp { margin-top: 20px; }
.rd-grp__label { margin: 0 0 2px; color: var(--color-eel); font: 700 14px/20px var(--font); }
.rd-nav__title + .rd-grp > .rd-grp__label { margin-top: 8px; }   /* as far from the name as the help pages' first page */
.rd-pages, .rd-subs { margin: 0; padding: 0; list-style: none; }
.rd-page {
  position: relative; display: flex; align-items: center; min-height: 36px; padding: 8px 0;
  color: var(--color-label); font: 700 15px/20px var(--font); text-decoration: none; text-wrap: pretty;
  transition: color var(--m-fast) var(--m-ease-out);
}
.rd-page.is-active { color: var(--color-link); }
.rd-page.is-active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--color-link); }
/* the open page's sections: nested under it, smaller, on a 2px rail (the site's swan line) that starts under the page's
   name; the section being read is the link colour, with its stretch of the rail in the link colour too. reading.js
   glides that mark from section to section as you read, and the page's bar from page to page */
.rd-subs { position: relative; padding: 0 0 8px 16px; }
.rd-subs::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 14px; width: 2px; border-radius: 1px; background: var(--color-swan); }
.rd-sub {
  position: relative; display: flex; align-items: center; min-height: 32px; padding: 6px 0;
  color: var(--color-label); font: 400 14px/20px var(--font); text-decoration: none; text-wrap: pretty;
  transition: color var(--m-fast) var(--m-ease-out);
}
.rd-sub::before { content: ""; position: absolute; left: -16px; top: 6px; bottom: 6px; width: 2px; border-radius: 1px; background: var(--color-link); opacity: 0; }
.rd-sub.is-active { color: var(--color-link); }
.rd-sub.is-active::before { opacity: 1; }
/* while a mark glides (reading.js): the moving one stands in for the lit section's and the open page's own */
.rd-subs.is-gliding .rd-sub::before, .rd-side.is-gliding .rd-page.is-active::before { opacity: 0; }
.rd-mark, .rd-bar { position: absolute; left: 0; top: 0; pointer-events: none; background: var(--color-link); }
.rd-mark { width: 2px; height: 1px; transform-origin: 0 0; }
.rd-bar { width: 3px; border-radius: 2px; }
@media (hover: hover) { :is(.rd-page, .rd-sub):not(.is-active):hover { color: var(--color-eel); } }
:is(.rd-page, .rd-sub):focus-visible { outline: 2px solid var(--color-macaw); outline-offset: 2px; border-radius: 6px; }

/* the left column: under the bar while you read; its own scroll only when it is taller than the window (the docs' four
   groups on a short one), its scrollbar showing only under the pointer. It reaches 16px into the margin, so the bar
   and focus rings aren't cut by its scroll box. */
.rd-side {
  position: sticky; top: calc(var(--f-top-h) + 28px);
  max-height: calc(100vh / var(--zoom, 1) - var(--f-top-h) - 28px); max-height: calc(100dvh / var(--zoom, 1) - var(--f-top-h) - 28px); overflow-y: auto;
  margin-left: -16px; padding: 0 4px 24px 16px;
  scrollbar-width: thin; scrollbar-color: transparent transparent;
}
.rd-side:hover, .rd-side:focus-within { scrollbar-color: var(--color-swan) transparent; }
.rd-side::-webkit-scrollbar { width: 6px; }
.rd-side::-webkit-scrollbar-thumb { border-radius: 3px; background: transparent; }
.rd-side:hover::-webkit-scrollbar-thumb { background: var(--color-swan); }

/* ---------------------------------------------------------------- the text column */
.rd-main { min-width: 0; }
/* the site's one page header (spec/nav/UX.md): the H1 at pop.css's size, one muted line */
.rd-head { max-width: var(--rd-measure); }
.rd-head .rd-title { margin: 0 0 4px; text-wrap: balance; }
.rd-lead { color: var(--color-label); font: 400 17px/24px var(--font); text-wrap: pretty; }

/* Contents (below 900): a slim row stuck under the top bar, the window's whole width like the bar (the bar's look: snow
   and a 2px swan edge), "Contents · <the section being read>" on the words' left edge and its ▾ at the row's right end
   (it holds its place while the section's name changes as you read, or as a reload comes back halfway down); the same
   list in a dropdown
   under it (the account menu's look). It is the article's first thing, pulled up against the bar (the page grid's
   20px top padding there, app/frame.css .f-grid). reading.js names the section and closes the list on a pick, a click
   outside and Escape. */
.rd-toc { display: none; }
.rd-toc__btn {
  display: flex; align-items: center; box-sizing: border-box; height: 46px; list-style: none; cursor: pointer;
  padding: 0 max(var(--f-gutter), env(safe-area-inset-right, 0px)) 0 max(var(--f-gutter), env(safe-area-inset-left, 0px));
  border-bottom: 2px solid var(--color-swan); background: var(--color-snow);
  color: var(--color-eel); font: 700 15px/20px var(--font); -webkit-tap-highlight-color: transparent;
}
.rd-toc__btn::-webkit-details-marker { display: none; }
.rd-toc__btn::marker { content: ""; }
.rd-toc__in { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; border-radius: 8px; }
.rd-toc__txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-toc__at { color: var(--color-label); }
.rd-toc__chev { flex-shrink: 0; margin-left: auto; color: var(--color-label); transition: transform var(--m-fast) var(--m-ease-out); }
.rd-toc[open]:not(.is-closing) .rd-toc__chev { transform: rotate(-180deg); }
@media (hover: hover) { .rd-toc__btn:hover .rd-toc__at, .rd-toc__btn:hover .rd-toc__chev { color: var(--color-eel); } }
.rd-toc__btn:focus-visible { outline: none; }
.rd-toc__btn:focus-visible .rd-toc__in { outline: 2px solid var(--color-macaw); outline-offset: 4px; }
.rd-toc__panel {
  position: absolute; z-index: 20; top: calc(100% + 8px); left: max(var(--f-gutter), env(safe-area-inset-left, 0px));
  box-sizing: border-box; width: min(calc(100% - 2 * var(--f-gutter)), 400px);
  max-height: calc(60vh / var(--zoom, 1)); max-height: calc(60svh / var(--zoom, 1)); overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px 8px 20px;
  border: 2px solid var(--u-drop-edge); border-radius: 16px; background: var(--color-snow);
  box-shadow: var(--u-drop-shadow); scrollbar-width: thin;
  animation: f-drop var(--m-fast) var(--m-ease-out) both; transform-origin: top left;
}
/* closing (a pick, a tap outside, Escape): it fades and lifts the way it came, then reading.js closes it */
.rd-toc.is-closing .rd-toc__panel { animation: f-drop-out var(--m-fast) var(--m-ease-in) both; pointer-events: none; }
/* fingers: 44px rows */
.rd-toc__panel .rd-page { min-height: 44px; padding: 12px 0; }
.rd-toc__panel .rd-page.is-active::before { left: -12px; top: 12px; bottom: 12px; }
.rd-toc__panel .rd-subs::before { top: 10px; bottom: 18px; }
.rd-toc__panel .rd-sub { min-height: 40px; padding: 10px 0; }
.rd-toc__panel .rd-sub::before { top: 10px; bottom: 10px; }
.rd-toc__panel .rd-sub::after { content: ""; position: absolute; inset: -2px 0; }   /* 44px to tap, the rows as they are */

/* ---------------------------------------------------------------- the words: one size and rhythm on both */
.rd-body { padding-top: 32px; }
.rd-body > * + *, .rd-sec > * + * { margin-top: 16px; }
/* sections are split by space and a heading (UX.md 15), never lines or boxes */
.rd-body > * + .rd-h2, .rd-body > * + .rd-sec, .rd-body > .rd-sec + * { margin-top: 48px; }
.rd-h2 + * { margin-top: 12px; }
.rd-sec > .rd-h3, .rd-body > .rd-h3 { margin-top: 32px; }
.rd-h3 + * { margin-top: 8px; }
.rd-h2 { max-width: var(--rd-measure); font: 700 25px/32px var(--font); color: var(--color-eel); text-wrap: balance; }
.rd-h3 { max-width: var(--rd-measure); font: 700 19px/28px var(--font); color: var(--color-eel); text-wrap: balance; }
.rd-p { max-width: var(--rd-measure); font: 400 18px/28px var(--font); color: var(--color-eel); text-wrap: pretty; }
.rd-main b { font-weight: 700; color: var(--color-eel); }
/* links in the words (app/content/inline.js draws them without a class) */
.rd-main a:not([class]) { color: var(--color-link); font-weight: 700; text-decoration: none; }
@media (hover: hover) { .rd-main a:not([class]):hover { text-decoration: underline; text-underline-offset: 3px; } }
.rd-main a:not([class]):focus-visible { outline: 2px solid var(--color-macaw); outline-offset: 2px; border-radius: 4px; }
/* the owner's missing details ({{email}}): a highlighted placeholder (6.7:1) */
.ct-todo { padding: 0 4px; border-radius: 4px; background: var(--note-bg); color: var(--color-warn-text); font-weight: 700; }

/* inline code. It never breaks inside a word (app/content/inline.js codeTag): code with spaces wraps at them, only
   addresses break anywhere; in a table's columns (600 and wider) a word or an address never wraps, a command only at
   its spaces (so a table never needs to scroll sideways) */
.rd-code {
  padding: 1px 6px; border: 1px solid var(--color-swan); border-radius: 6px; background: var(--color-polar);
  font: 400 15px/1.5 var(--rd-mono); color: var(--color-eel); white-space: nowrap;
}
.rd-code.is-words { white-space: normal; }
.rd-code .ct-w { white-space: nowrap; }
.rd-code.is-url, .rd-code .ct-url { white-space: normal; overflow-wrap: anywhere; }
@media (min-width: 600px) { .rd-table .rd-code:not(.is-words), .rd-table .rd-code > span { white-space: nowrap; overflow-wrap: normal; } }
.rd-table--cols .rd-code, .rd-table--cols .rd-code > span { white-space: nowrap; overflow-wrap: normal; }

/* bullets: small green dots, centred on the first line */
.rd-list { display: flex; flex-direction: column; gap: 12px; max-width: var(--rd-measure); padding: 0; list-style: none; }
.rd-list > li { position: relative; padding-left: 24px; font: 400 18px/28px var(--font); color: var(--color-eel); text-wrap: pretty; }
.rd-list > li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-owl); }

/* numbered steps: pop.css's step circle, a line joining them */
.rd-steps { display: flex; flex-direction: column; max-width: var(--rd-measure); padding: 0; list-style: none; }
.rd-step { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; padding-bottom: 24px; }
.rd-step:last-child { padding-bottom: 0; }
.rd-step:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 46px; bottom: 6px; width: 2px; background: var(--color-swan); }
.rd-step__t { margin-top: 4px; font: 700 18px/28px var(--font); color: var(--color-eel); }
.rd-step__x { font: 400 18px/28px var(--font); color: var(--color-eel); text-wrap: pretty; }

/* notes: a rule on their left, blue for an aside, orange for a warning */
.rd-note { max-width: var(--rd-measure); padding: 2px 0 2px 16px; border-left: 4px solid var(--note-info-line); font: 400 17px/26px var(--font); color: var(--color-eel); text-wrap: pretty; }
.rd-note--warn { border-left-color: var(--color-fox); }

/* tables: no frame (UX.md 15): small grey column names, rows split by lines, each row's name (its first cell) bold and
   flush with the words. As wide as the words, so every page has one right edge; a table of values only as wide as it
   needs, its values right-aligned in tabular figures */
.rd-table { max-width: var(--rd-measure); overflow-x: auto; }
.rd-table table { width: 100%; border-collapse: collapse; }
.rd-table th, .rd-table td { padding: 12px 16px 12px 0; text-align: left; vertical-align: top; font: 400 16px/24px var(--font); color: var(--color-wolf); }
.rd-table th:last-child, .rd-table td:last-child { padding-right: 0; }
.rd-table thead th { padding-top: 0; padding-bottom: 8px; color: var(--color-label); font: 700 14px/20px var(--font); white-space: nowrap; }
.rd-table tbody th { min-width: 120px; font-weight: 700; color: var(--color-eel); }
.rd-table tbody tr + tr > *, .rd-table thead + tbody tr:first-child > * { border-top: 2px solid var(--color-swan); }
.rd-table--values table { width: auto; min-width: min(320px, 100%); }
.rd-table .rd-num { padding-left: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.rd-num .u-val { color: var(--color-eel); }

/* ---------------------------------------------------------------- narrower */
/* 900 to 1023: the same two columns, the left one and the gap a little narrower (the words keep ~600px) */
@media (max-width: 1023px) {
  .rd { grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; }
}
/* below 900 (the phone frame) the left column goes; Contents, stuck under the top bar, opens the same list. A jump to a
   section lands under both bars. */
@media (max-width: 899px) {
  html:has(.rd-toc) { scroll-padding-top: calc(var(--f-top-h) + 46px + 16px); }
  .rd { grid-template-columns: minmax(0, 1fr); }
  .rd-side { display: none; }
  .rd-toc {
    display: block; position: sticky; z-index: 40; top: var(--f-top-h);
    margin: -20px calc(-1 * max(var(--f-gutter), env(safe-area-inset-right, 0px))) 24px calc(-1 * max(var(--f-gutter), env(safe-area-inset-left, 0px)));
  }
  .rd-body { padding-top: 24px; }
}
@media (max-width: 699px) {
  .rd-table tbody th { min-width: 96px; }
}
/* phones: a row stacks (its first cell, bold, over the others), rows split by the same lines. With three columns or
   more each other cell starts with its column's name (data-k). Short tables and tables of values keep their columns. */
@media (max-width: 599px) {
  .rd-table:not(.rd-table--cols) :is(table, tbody, tr, th, td) { display: block; }
  .rd-table:not(.rd-table--cols) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .rd-table:not(.rd-table--cols) tr { padding: 12px 0; }
  .rd-table:not(.rd-table--cols) tbody tr:first-child { padding-top: 0; }
  .rd-table:not(.rd-table--cols) tbody tr + tr { border-top: 2px solid var(--color-swan); }
  .rd-table:not(.rd-table--cols) :is(tbody tr, tbody tr + tr, thead + tbody tr:first-child) > * { min-width: 0; padding: 0; border-top: 0; }
  .rd-table:not(.rd-table--cols) tbody tr > * + * { margin-top: 4px; }
  .rd-table:not(.rd-table--cols) td[data-k]::before {
    content: attr(data-k); margin-right: 6px;
    color: var(--color-label); font: 700 14px/20px var(--font);
  }
  /* "400 bad_request": the first two cells on one line */
  .rd-table--pair tbody tr > :nth-child(-n+2) { display: inline-block; }
  .rd-table--pair tbody tr > :nth-child(2) { margin: 0 0 0 8px; }
}
