/* Long-form pages: the API guide, "Reading a large collection", and the legal documents. Part 2 of the 13fragments
   style guide (research posts and stories), from 13fweb dist/assets/site.css: a title block, a contents rail on wide
   screens, a 660 px reading column, and wide plates for code and tables. */

/* ------------------------------------------------------------------ articles */
.post { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; counter-reset: sec; }
.post > * + * { margin-top: 40px; }
.post > *, .section > * { max-width: var(--measure); width: 100%; }
.post > .section, .section > :is(.code, .table-wrap, figure, details:has(.code, .table-wrap)) { max-width: none; }
.post > .title { max-width: 780px; }
.post > .section { counter-increment: sec; }
:where(.post) .section { gap: 20px; }
:where(.post) h2 { margin-top: 24px; }
:where(.post) h3 { margin-top: 8px; }
:where(.post :is(ul, ol):not([class])) { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }

/* Contents: inline after the title on narrow screens, a sticky rail on wide screens (js/contents.js marks the entry
   of the section in view). */
.contents { display: flex; flex-direction: column; gap: 10px; font-family: var(--sans); font-size: 14px; line-height: 1.4;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; }
.contents ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.contents a { display: grid; grid-template-columns: 34px 1fr; padding: 4px 0; color: var(--ink-soft); text-decoration: none; }
.contents a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.contents .num { font-size: 12px; color: var(--faint); padding-top: 1px; }

/* Items of a section, numbered 2.1, 2.2 after the section number. */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: item; }
.items > li { counter-increment: item; position: relative; padding-left: 44px; }
.items > li::before { content: counter(sec) "." counter(item); position: absolute; left: 0; top: 4px; font-family: var(--mono);
  font-size: 13px; line-height: 1.6; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.items ul { margin: 8px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
address { font-style: normal; }

/* An article without a contents block is one centered column; code and tables still use the wide width. */
.post:not(:has(> .contents)) { justify-items: center; }
.post:not(:has(> .contents)) > .title { max-width: var(--measure); }
.post:not(:has(> .contents)) .section > :not(.code, .table-wrap, figure) { margin-left: auto; margin-right: auto; }

/* ------------------------------------------------------------------ code */
/* A code block is a plate: a head with its language and a Copy button, then the code. Long lines scroll inside. */
.code { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.code-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 6px 6px 16px;
  border-bottom: 1px solid var(--rule); background: var(--surface-alt); }
.code-head > span { font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.code pre { margin: 0; padding: 14px 18px; overflow-x: auto; font-size: 13px; line-height: 1.6; tab-size: 2; color: var(--ink); }

/* ------------------------------------------------------------------ wide screens: contents rail */
@media (min-width: 1240px) {
  .post { grid-template-columns: var(--rail) minmax(0, var(--wide)); column-gap: var(--gutter); }
  .post > * { grid-column: 2; }
  .post > .contents { grid-column: 1; grid-row: 1 / span 99; margin-top: 0; position: sticky; top: 24px; background: none;
    border: 0; padding: 6px 0 0; font-size: 13px; }
  .post > .contents ol { border-left: 1px solid var(--rule); }
  .post > .contents a { padding: 5px 0 5px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); }
  .post > .contents a[aria-current="true"] { color: var(--ink); font-weight: 600; border-left-color: var(--accent); }
  .post > .contents a[aria-current="true"] .num { color: var(--accent-text); }
  .post:not(:has(> .contents)) { grid-template-columns: minmax(0, var(--wide)); justify-content: center; }
  .post:not(:has(> .contents)) > * { grid-column: 1; }
}

/* ------------------------------------------------------------------ phones */
@media (max-width: 640px) {
  .post > * + * { margin-top: 32px; }
  .code { border-radius: 10px; }
  .code pre { padding: 12px; }
  .items > li { padding-left: 38px; }
}

/* The one next step at the end of a long page. */
.next { padding-top: 14px; border-top: 1px solid var(--frame); font-family: var(--sans); font-size: 16px; font-weight: 600; }
.terms h3 { margin-top: 12px; }
.terms h3 .num { font-size: 12px; margin-right: .5em; }
