/*
 * press.css — the structural layer.
 * Direct-perception structure: open forms, hairline rules, a single readable
 * measure, mono for labels and numerics. References ONLY the token interface
 * (var(--…)); carries no brand values. Swap tokens.css to re-skin.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.press-paper {
  max-width: calc(var(--figure-measure, var(--measure, 43rem)) + 3rem);
  margin: 0 auto;
  padding: 4rem 1.5rem 6rem;
}

/* Beside the Contents rail (wider screens), the paper starts level with the rail's
   list: the tops of the title's capitals line up with the top of its first entry
   (the Main text | Supplement switch, when there is one). */
@media screen and (width > 900px) {
  .press-contents ~ .press-paper {
    padding-top: 51px;
  }
  /* With a link home, the rail's label takes a row of its own beneath the link's
     bar (24px gap + 16px line, in the head's grid below), so the list starts
     40px lower. */
  .press-contents-with-home ~ .press-paper {
    padding-top: 91px;
  }
}

/* Text runs at the measure; figures may run wider (--figure-measure), with their
   captions brought back to the measure. Both default to the same width. */
.press-paper > :not(.press-figure),
.press-figure figcaption {
  max-width: var(--measure, 43rem);
  margin-left: auto;
  margin-right: auto;
}

/* Reading size and leading for the prose blocks only: headings keep their own
   sizes and figures keep the base 1rem/1.6 their layouts assume. */
.press-paper > :is(p, ul, ol, dl, blockquote) {
  font-size: var(--text-size, 1rem);
  line-height: var(--leading, 1.6);
}

/* Body text alignment and hyphenation (--text-align, --hyphens). Justified text
   goes ragged on narrow screens, where justifying a short line opens rivers. */
.press-paper > p {
  text-align: var(--text-align, start);
  hyphens: var(--hyphens, manual);
  -webkit-hyphens: var(--hyphens, manual);
}

@media screen and (max-width: 600px) {
  .press-paper > p {
    text-align: start;
  }
}

/* ---------- Front matter ---------- */
.press-frontmatter {
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

/* The header keeps the text column's left edge and may run wider to the right
   (--frontmatter-measure, e.g. out to the figures' edge); by default it is the
   text column. */
.press-paper > .press-frontmatter {
  max-width: var(--frontmatter-measure, var(--measure, 43rem));
  margin-left: max(0px, (100% - var(--measure, 43rem)) / 2);
  margin-right: auto;
}

.press-title {
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 1.25rem;
  letter-spacing: 0.0em;
}

/* A supplement's header names the main text it belongs to, just under its title
   and in the title's face. */
.press-supplement-of {
  margin: -0.6rem 0 1.25rem;
  font-family: var(--display, var(--serif));
  font-size: 1.25rem;
  line-height: 1.35;
  color: var(--ink-muted);
}

.press-supplement-of a {
  color: var(--ink);
}

/* The byline (names and affiliations) takes --byline-font; the date,
   correspondence and citation take --meta-font. Both default to the text font. */
.press-authors {
  font-family: var(--byline-font, var(--serif));
  font-size: 1.05rem;
  line-height: 1.5;
}

/* With a group author, the group takes the author line and its members
   follow, a step smaller. */
.press-members {
  font-family: var(--byline-font, var(--serif));
  margin-top: 0.3rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.press-author sup {
  font-family: var(--byline-font, var(--serif));
  font-size: 0.62em;
  color: var(--ink-muted);
  padding-left: 0.1em;
}

.press-corresponding {
  color: var(--ink-muted);
}

.press-affiliations {
  font-family: var(--byline-font, var(--serif));
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.press-affiliation {
  margin: 0.1rem 0;
}

.press-affiliation sup {
  font-family: var(--byline-font, var(--serif));
  padding-right: 0.15em;
}

.press-correspondence,
.press-date {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-family: var(--meta-font, var(--serif));
}

.press-links {
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.press-link {
  color: var(--ink-muted);
  text-decoration: none;
}

.press-link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.press-link-sep,
.press-date-sep {
  color: var(--line);
  padding: 0 0.15rem;
}

/* The build stamp (`press build --stamp`) closes the page: the commit it was built
   from and that commit's date, set as the header's links are, centred. */
.press-stamp {
  margin-top: 5rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.press-citation {
  font-family: var(--meta-font, var(--serif));
  margin-top: 0.6rem;
  max-width: 46rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink-muted);
}

/* ---------- Headings ---------- */
h1,
h2,
h3,
h4 {
  font-family: var(--display, var(--serif));
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 2.5rem 0 0.75rem;
}

h2 {
  font-size: 1.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}

h3 {
  font-size: 1.2rem;
}

h4 {
  font-size: 1.02rem;
  color: var(--ink-fill);
}

/* Below the three numbered levels, press sets the fourth heading level run-in,
   as LaTeX's \paragraph: a bold span that opens its paragraph ("Architecture.
   The model…"). Before a list, figure or equation it stays a block heading, in
   the same type at text size. Plain class selectors, so a theme can restyle them. */
.press-subhead {
  font-family: var(--display, var(--serif));
  font-weight: 700;
  font-style: normal;
  color: var(--ink);
  hyphens: manual;
  -webkit-hyphens: manual;
}

span.press-subhead {
  font-size: 0.94em;
  margin-right: 0.14em;
}

/* The centered dot closing a run-in heading, with about 0.4em of white on either
   side (with the no-break space before it and the word space after). */
.press-subhead-sep {
  margin-left: 0.16em;
}

.press-subhead:where(h1, h2, h3, h4, h5, h6) {
  font-size: calc(var(--text-size, 1rem) * 0.94);
  line-height: var(--leading, 1.6);
  margin: 1.5rem 0 0.25rem;
  padding: 0;
  border: 0;
}

/* ---------- Section numbers ---------- */
/* press numbers the paper's top-level h1, h2 and h3 at build time (1, 2.1,
   2.1.1, counting from the shallowest level and skipping the abstract) into
   data-secnum, which the contents rail shows too. The numbers stay hidden
   unless the theme sets --section-numbers (e.g. inline-block).
   --section-number-hang hangs them in the left margin on the heading's
   baseline; they sit inline again on narrow screens and in print. */
.press-paper > [data-secnum]::before {
  content: attr(data-secnum);
  display: var(--section-numbers, none);
  box-sizing: border-box;
  width: var(--section-number-hang, auto);
  margin-left: calc(-1 * var(--section-number-hang, 0px));
  padding-right: var(--section-number-gap, 0.7em);
  text-align: right;
  font-family: var(--section-number-font, var(--mono));
  font-style: normal;
  font-weight: 400;
  font-size: var(--section-number-size, 0.72em);
  letter-spacing: 0.02em;
  color: var(--section-number-color, var(--ink-muted));
}

@media (max-width: 900px) {
  .press-paper > [data-secnum]::before {
    width: auto;
    margin-left: 0;
    padding-right: 0.7em;
    text-align: left;
  }
}

/* A heading jumped to (from the contents or a #fragment) lands a little below
   the window's top edge. */
.press-paper :is(h1, h2, h3, h4, h5, h6, .press-subhead)[id] {
  scroll-margin-top: 1.5rem;
}

/* ---------- Prose ---------- */
p {
  margin: var(--paragraph-gap, 1rem) 0;
}

/* Links are ink with an underline in --link-underline (deeper on hover). */
a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: var(--link-underline-offset, 2px);
  text-decoration-thickness: 1px;
  text-decoration-color: var(--link-underline, var(--ink-muted));
}

a:hover {
  text-decoration-thickness: 2px;
  text-decoration-color: var(--link-underline-hover, var(--ink));
}

/* A URL shown as link text (a bare autolink): it breaks only at the <wbr>
   after each "/", never with an inserted hyphen; a segment too long for the
   line may still break rather than overflow. */
.press-url {
  hyphens: manual;
  -webkit-hyphens: manual;
  overflow-wrap: break-word;
}

strong,
b {
  font-weight: 600;
}

em,
i {
  font-style: italic;
}

ul,
ol {
  margin: 1rem 0;
  padding-left: 1.6rem;
}

li {
  margin: 0.3rem 0;
}

blockquote {
  margin: 1.25rem 0;
  padding: 0 0 0 1.2rem;
  border-left: 2px solid var(--line);
  color: var(--ink-muted);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

/* ---------- Code ---------- */
code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--wash);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  overflow-x: auto;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

pre code {
  background: none;
  padding: 0;
}

/* ---------- Tables ---------- */
/* Table text uses the theme's table font, else its figure font, with tabular
   figures so numeric columns line up. */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  font-family: var(--table-font, var(--figure-font, inherit));
  font-variant-numeric: tabular-nums;
}

/* 0.82rem in a 0.92rem table, written relative so a .press-small table's heads
   scale with its text. */
th {
  font-family: var(--mono);
  font-weight: 500;
  font-size: calc(0.82em / 0.92);
  color: var(--ink-muted);
  text-align: left;
}

th,
td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

/* Honor the GFM delimiter row's alignment (the align attribute alone loses to
   th { text-align: left }). */
th[align="right"],
td[align="right"] {
  text-align: right;
}

th[align="center"],
td[align="center"] {
  text-align: center;
}

/* A trailing interval in a table cell ("2.72 (2.55–2.88)") reads as secondary:
   smaller, muted, and kept on one line. */
.press-interval {
  font-size: 0.85em;
  color: var(--ink-muted);
  white-space: nowrap;
}

td.num,
th.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Every table scrolls sideways in its own box on a narrow screen. */
.press-table-scroll {
  overflow-x: auto;
}

/* A numbered :::table sits at the text measure, its caption above it. */
.press-table {
  margin: 2.5rem 0;
}

.press-table > figcaption {
  margin: 0 0 0.6rem;
}

.press-table table {
  margin: 0;
}

/* :::table{.small}: a dense table's text at the caption's size. Heads and
   intervals are sized relative to it, so they follow. */
.press-table.press-small table {
  font-size: 0.85rem;
}

/* ---------- Figures ---------- */
.press-figure {
  margin: 2.5rem 0;
}

.press-mount {
  display: block;
  width: 100%;
  min-height: 3rem;
}

/* Figure text (plot labels, legends, controls) uses the theme's figure font.
   The svg is named explicitly because Observable Plot defaults it to system-ui
   via zero-specificity :where() rules, which would beat inheritance. */
.press-mount,
.press-mount svg {
  font-family: var(--figure-font, var(--serif));
}

.press-figure-img,
.press-static-fallback {
  display: block;
  width: 100%;
  height: auto;
}

figcaption {
  font-family: var(--caption-font, var(--serif));
  margin-top: 0.85rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Match the bold caption lead-in: same serif, weight, and ink. */
.press-figure-label,
.press-table-label {
  font-weight: 600;
  color: var(--ink-fill);
}

figcaption strong {
  color: var(--ink-fill);
}

/* ---------- End matter ---------- */
/* The acknowledgments, author contributions, Supporting Information and references
   close the paper as one block under a rule: unnumbered, in smaller type, their
   headings at one size. */
.press-end-matter {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.press-end-matter :where(h1, h2, h3):not(.press-subhead) {
  font-size: 1.1rem;
  margin: 2rem 0 0.75rem;
  padding: 0;
  border: none;
}

/* The first heading sits close under the rule, whether the block opens with the
   author's heading or with press's own section. */
.press-end-matter > :first-child,
.press-end-matter > section:first-child > :first-child {
  margin-top: 0;
}

.press-end-matter .press-subhead:where(h1, h2, h3, h4, h5, h6) {
  font-size: 0.94em;
}

/* ---------- Supporting Information ---------- */
/* With a supplement, the main text ends with a section listing what it holds; its
   sections carry their S numbers when the theme shows them. */
.press-supplement-sections {
  list-style: none;
  padding-left: 0;
}

.press-supplement-sections li {
  margin: 0.25rem 0;
}

.press-supplement-num {
  display: var(--section-numbers, none);
  min-width: 2.2rem;
  font-family: var(--section-number-font, var(--mono));
  font-size: 0.8em;
  color: var(--ink-muted);
}

/* ---------- References ---------- */
.press-reference-list {
  padding-left: 1.8rem;
  line-height: 1.5;
}

.press-reference {
  margin: 0.5rem 0;
}

.press-reference::marker {
  font-family: var(--mono);
  color: var(--ink-muted);
}

/* ---------- Math ---------- */
.katex {
  font-size: 1.05em;
}

/* Wide display equations scroll inside their own box rather than widening the
   page. rehype-katex replaces the .math-display element with KaTeX's own
   .katex-display wrapper, so match that too. */
.math-display,
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.25rem 0;
}

/* ---------- Contents ---------- */
/* The Contents rail (src/render/contents.ts; its DOCK, WIDE and DRAWER queries
   must match the breakpoints here). Narrow (<= 900px): none. Wider: a 28px
   strip with one tick per top-level section and a chevron that opens the rail.
   From 1120px the open rail docks beside the paper, which re-centres in the
   space left (open by default from 1400px); narrower it overlays the page as a
   drawer. Without JS the strip stays, its tick links working. With the `home`
   setting, a link home heads the open rail, in a bar of its own with the
   chevron, and leads the narrow bar. */
.press-contents {
  display: none;
}

.press-contents ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.press-contents li {
  margin: 0;
}

.press-contents a {
  color: var(--ink-muted);
  text-decoration: none;
}

.press-contents-link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 14px 3px 20px;
  font-size: 13px;
  line-height: 1.35;
}

.press-contents-list > li > .press-contents-link {
  font-size: 14px;
}

/* Each level's title steps in 18px (44, 62, 80), so deep titles keep most of
   the rail's width. */
.press-contents-item[data-depth="2"] > .press-contents-link {
  padding-left: 30px;
}

.press-contents-item[data-depth="3"] > .press-contents-link {
  padding-left: 38px;
}

.press-contents a:hover,
.press-contents-list li.is-path > .press-contents-link {
  color: var(--ink);
}

/* The current section: ink, semibold, and a short bar in the accent (a border,
   so it survives forced colors). */
.press-contents-link[aria-current="location"] {
  color: var(--ink);
  font-weight: 600;
}

.press-contents-link[aria-current="location"]::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  border-left: 2px solid var(--accent, var(--ink));
}

/* Section numbers in the rail follow the body's: shown only when the theme
   shows them (--section-numbers). Their column widths are minimums, so a
   supplement's longer numbers (S3.1.1) push their titles over rather than
   crowding them. */
.press-contents-num {
  display: var(--section-numbers, none);
  flex: none;
  min-width: 16px;
  font-family: var(--section-number-font, var(--mono));
  font-size: 11px;
  font-weight: 400;
}

.press-contents-item[data-depth="2"] > .press-contents-link .press-contents-num {
  min-width: 24px;
}

.press-contents-item[data-depth="3"] > .press-contents-link .press-contents-num {
  min-width: 34px;
}

.press-contents .katex {
  font-size: 1em;
}

/* With a supplement, a "Main text | Supplement" switch heads the list (an item of
   it, so it shows and hides with the list at every width). */
/* Styled as the figures' toggles: the current page a filled ink box, the other
   outlined. */
.press-contents-pages {
  display: flex;
  gap: 4px;
  padding: 4px 14px 12px 20px;
}

.press-contents-page {
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  font-family: var(--figure-font, var(--sans, inherit));
  font-size: 11.5px;
  line-height: 1.4;
}

.press-contents .press-contents-page[aria-current="page"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
}

.press-contents-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0 10px;
}

.press-contents-label {
  display: none;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.press-contents-toggle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
}

.press-contents-toggle:hover {
  color: var(--ink);
}

/* One tick per top-level section; the current one longer and in ink. */
.press-contents-tick {
  display: block;
  position: relative;
  height: 20px;
}

.press-contents-tick::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 9px;
  border-top: 2px solid var(--ink-muted);
  opacity: 0.45;
}

.press-contents-tick:hover::before {
  opacity: 0.8;
}

.press-contents-tick.is-current::before {
  left: 7px;
  width: 13px;
  border-top-color: var(--ink);
  opacity: 1;
}

.press-contents-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.press-contents :focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: -2px;
}

/* The link home: ink in the display face, underlined on hover. It keeps the
   toggle's 24px line, so the head's first row (and the ticks' top: 56px) hold
   whatever its size; themes set its face and size, not its height. Clipped
   sideways only, so a long label ends in an ellipsis and descenders survive. */
.press-contents .press-contents-home {
  overflow-x: clip;
  color: var(--ink);
  font-family: var(--display, var(--serif));
  font-size: 18px;
  line-height: 24px;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.press-contents .press-contents-home:hover {
  text-decoration-color: var(--line);
}

.press-contents .press-contents-home:focus-visible {
  outline-offset: 2px;
}

/* With JS, only the reading branch unfolds; without it the toggle can't work. */
html[data-press-contents-js] .press-contents-list ol {
  display: none;
}

html[data-press-contents-js] .press-contents-list li.is-path > ol {
  display: block;
}

html:not([data-press-contents-js]) .press-contents-toggle {
  display: none;
}

/* Wider than 900px the rail is always 248px wide and slides, as NGI's does.
   Closed, all but its last 28px sits off-screen, leaving a strip with the
   chevron and one tick per top-level section; open, it slides fully in and its
   list fades up. Docked (>= 1120px) it sits beside the paper; narrower it
   overlays the page as a drawer. */
@media screen and (width > 900px) {
  .press-contents {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 248px;
    border-right: 1px solid var(--line);
    background: var(--paper);
    font-family: var(--sans, var(--serif));
    transform: translateX(-220px);
  }
  .press-contents-head {
    justify-content: space-between;
    padding: 18px 2px 14px 20px;
  }
  .press-contents-label {
    display: inline;
  }
  /* With a link home, the head is a grid: the link and the chevron on the first
     row, the label across the second. Placed, so the chevron stays put. The
     first row, with the padding above it and 14px below, is the link's bar:
     56px, the height the ticks start at, ending in a rule (::after). Behind it
     is the bar's ground (::before), which is empty: a theme draws on it with a
     background or a mask. */
  .press-contents-with-home .press-contents-head {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 24px;
    align-items: center;
    row-gap: 24px;
  }
  .press-contents-with-home .press-contents-head::before,
  .press-contents-with-home .press-contents-head::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 55px;
    pointer-events: none;
  }
  .press-contents-with-home .press-contents-head::before {
    z-index: -1;
  }
  .press-contents-with-home .press-contents-head::after {
    top: 55px;
    height: 1px;
    background: var(--line);
  }
  .press-contents-head .press-contents-home {
    grid-area: 1 / 1;
  }
  .press-contents-with-home .press-contents-toggle {
    grid-area: 1 / 2;
  }
  .press-contents-with-home .press-contents-label {
    grid-area: 2 / 1 / 3 / 3;
    line-height: 16px;
  }
  .press-contents-toggle svg {
    transform: rotate(180deg);
  }
  .press-contents-head::before,
  .press-contents-head::after,
  .press-contents-label,
  .press-contents-home,
  .press-contents-list {
    opacity: 0;
    visibility: hidden;
  }
  .press-contents-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-bottom: 24px;
  }
  /* The ticks, in the visible right edge of the closed rail. */
  .press-contents-ticks {
    position: absolute;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }
  html[data-press-contents-open] .press-contents {
    transform: none;
  }
  html[data-press-contents-open] .press-contents-head {
    padding-right: 10px;
  }
  html[data-press-contents-open] .press-contents-toggle svg {
    transform: none;
  }
  html[data-press-contents-open] .press-contents-head::before,
  html[data-press-contents-open] .press-contents-head::after,
  html[data-press-contents-open] .press-contents-label,
  html[data-press-contents-open] .press-contents-home,
  html[data-press-contents-open] .press-contents-list {
    opacity: 1;
    visibility: visible;
  }
  html[data-press-contents-open] .press-contents-ticks {
    opacity: 0;
    visibility: hidden;
  }
}

/* The slide: NGI's 0.3s ease-out, with the list fading in just behind it and
   out just ahead of it (visibility flips at the end of a fade-out). The paper's
   re-centring below uses the same curve. */
@media screen and (width > 900px) and (prefers-reduced-motion: no-preference) {
  .press-contents {
    transition: transform 0.3s cubic-bezier(0.22, 0.68, 0, 1);
  }
  .press-contents-head {
    transition: padding 0.3s cubic-bezier(0.22, 0.68, 0, 1);
  }
  .press-contents-toggle svg {
    transition: transform 0.3s cubic-bezier(0.22, 0.68, 0, 1);
  }
  .press-contents-head::before,
  .press-contents-head::after,
  .press-contents-label,
  .press-contents-home,
  .press-contents-list {
    transition: opacity 0.16s, visibility 0.3s;
  }
  html[data-press-contents-open] .press-contents-head::before,
  html[data-press-contents-open] .press-contents-head::after,
  html[data-press-contents-open] .press-contents-label,
  html[data-press-contents-open] .press-contents-home,
  html[data-press-contents-open] .press-contents-list {
    transition: opacity 0.2s 0.06s, visibility 0s;
  }
  .press-contents-ticks {
    transition: opacity 0.2s 0.1s, visibility 0s;
  }
  html[data-press-contents-open] .press-contents-ticks {
    transition: opacity 0.12s, visibility 0.12s;
  }
}

/* Docked, the paper re-centres in the space beside the open rail: it shifts
   right by half the rail (124px) and keeps its width, so figures don't
   re-render. Both margins are explicit so the shift can slide. */
@media screen and (width >= 1120px) {
  html[data-press-contents-js] .press-paper {
    margin-left: max(0px, calc((100% - var(--figure-measure, var(--measure, 43rem)) - 3rem) / 2));
    margin-right: auto;
  }
  html[data-press-contents-open] .press-paper {
    margin-left: max(0px, calc((100% - var(--figure-measure, var(--measure, 43rem)) - 3rem) / 2 + 124px));
  }
}

/* Jumps from the contents snap straight to the section. Once the page has
   loaded, the paper slides when the docked rail opens or closes (not under
   reduced motion). */
@media screen and (prefers-reduced-motion: no-preference) {
  html[data-press-contents-ready] .press-paper {
    transition: margin-left 0.3s cubic-bezier(0.22, 0.68, 0, 1);
  }
}

/* Narrow screens (<= 900px), with JS: a running bar across the top showing the
   current section, hidden until a section is current. Its label rolls over as
   the section changes (src/render/contents.ts); tapping it rolls the label to
   "Contents", turns the chevron and unfolds the list beneath over a dimmed page.
   With a link home, the bar shares a row with it: the link, a divider, then the
   bar. Behind the row is its ground (::before), empty as the rail's is, for a
   theme to draw on. */
.press-contents-bar,
.press-contents-bar-row {
  display: none;
}

.press-contents-panel {
  display: contents;
}

@media screen and (width <= 900px) {
  html[data-press-contents-js] .press-contents {
    display: block;
    position: fixed;
    inset: 0 0 auto;
    z-index: 50;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    font-family: var(--sans, var(--serif));
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.24s, opacity 0.2s, visibility 0.24s, box-shadow 0.24s;
  }
  html[data-press-contents-bar] .press-contents {
    transform: none;
    opacity: 1;
    visibility: visible;
  }
  html[data-press-contents-bar][data-press-contents-open] .press-contents {
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.1);
  }
  html[data-press-contents-js] .press-contents-head,
  html[data-press-contents-js] .press-contents-ticks {
    display: none;
  }
  html[data-press-contents-js] .press-contents-bar-row {
    position: relative;
    display: flex;
    align-items: center;
  }
  .press-contents-bar-row::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    pointer-events: none;
  }
  .press-contents-bar-row .press-contents-home {
    position: relative;
    flex: none;
    box-sizing: border-box;
    max-width: 40%;
    height: 48px;
    padding: 0 12px 0 1.5rem;
    line-height: 48px;
  }
  .press-contents-bar-row .press-contents-home::after {
    content: "";
    position: absolute;
    top: 18px;
    right: 0;
    width: 1px;
    height: 12px;
    background: var(--line);
  }
  /* Beside the link, the bar takes the rest of the row, from the divider. */
  html[data-press-contents-js] .press-contents-bar-row > .press-contents-bar {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    padding-left: 12px;
  }
  html[data-press-contents-js] .press-contents-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
    height: 48px;
    padding: 0 1.5rem;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .press-contents-window {
    position: relative;
    flex: 1 1 0%;
    min-width: 0;
    height: 1.6em;
    overflow: hidden;
  }
  .press-contents-reading,
  .press-contents-open-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .press-contents-reading {
    gap: 10px;
  }
  .press-contents-reading-out {
    pointer-events: none;
  }
  .press-contents-bar-num {
    display: var(--section-numbers, none);
    flex: none;
    font-family: var(--section-number-font, var(--mono));
    font-size: 12px;
    color: var(--ink-muted);
    white-space: nowrap;
  }
  .press-contents-bar-divider {
    display: var(--section-numbers, none);
    flex: none;
    width: 1px;
    height: 0.8em;
    background: var(--line);
  }
  .press-contents-bar-num:empty,
  .press-contents-bar-num:empty + .press-contents-bar-divider {
    display: none;
  }
  .press-contents-bar-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .press-contents-open-label {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--ink-muted);
    transform: translateY(110%);
  }
  html[data-press-contents-open] .press-contents-reading {
    transform: translateY(-110%);
  }
  html[data-press-contents-open] .press-contents-open-label {
    transform: none;
  }
  html[data-press-contents-js] .press-contents-bar svg {
    flex: none;
    color: var(--ink-muted);
    transform: rotate(-90deg);
    transition: transform 0.24s;
  }
  html[data-press-contents-open] .press-contents-bar svg {
    transform: rotate(90deg);
  }
  html[data-press-contents-js] .press-contents-panel {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    transition: grid-template-rows 0.24s cubic-bezier(0.22, 0.68, 0, 1), opacity 0.2s, visibility 0.24s;
  }
  html[data-press-contents-open] .press-contents-panel {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
  }
  html[data-press-contents-js] .press-contents-list {
    min-height: 0;
    max-height: calc(100dvh - 48px - env(safe-area-inset-top, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0;
  }
  /* The list's breathing room is content, not padding, so it folds away with the
     panel (padding would stay, leaving a band under the closed bar). */
  html[data-press-contents-js] .press-contents-list::before,
  html[data-press-contents-js] .press-contents-list::after {
    content: "";
    display: block;
  }
  html[data-press-contents-js] .press-contents-list::before {
    height: 4px;
  }
  html[data-press-contents-js] .press-contents-list::after {
    height: 16px;
  }
  /* Anything jumped to lands below the bar. */
  html[data-press-contents-js] .press-paper [id] {
    scroll-margin-top: calc(48px + 1rem);
  }
}

@media screen and (prefers-reduced-motion: reduce) {
  .press-contents,
  .press-contents-head,
  .press-contents-head::before,
  .press-contents-head::after,
  .press-contents-label,
  .press-contents-home,
  .press-contents-list,
  .press-contents-ticks,
  .press-contents-toggle svg,
  .press-contents-reading,
  .press-contents-open-label,
  .press-contents-bar svg,
  .press-contents-panel {
    transition: none !important;
  }
}

/* ---------- Docs ---------- */
/* A page of a docs site (src/docs/): the paper's article with a head of its own, a
   line saying where the page sits and then its title, and the rail listing the
   site's pages. A page's sections are set as a paper's (its `##` is an h1), so the
   headings above, and a theme's, serve both. */
.press-doc img {
  max-width: 100%;
  height: auto;
}

.press-doc-head {
  margin-bottom: 24px;
}

.press-doc-head .press-title {
  margin: 0;
}

/* The line keeps its height on the home page, where it says nothing, so every
   page's title sits at the same height. */
.press-doc-crumbs {
  margin: 0 0 13px;
  min-height: 16px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.press-doc-crumbs a {
  color: inherit;
  text-decoration: none;
}

.press-doc-crumbs a:hover {
  color: var(--ink);
}

.press-doc-sep {
  margin: 0 0.7em;
  opacity: 0.55;
}

/* That line is level with the rail's label; under the narrow bar, which a docs
   page has from its top, it clears the bar. */
@media screen and (width > 900px) {
  .press-contents ~ .press-doc {
    padding-top: 22px;
  }
  .press-contents-with-home ~ .press-doc {
    padding-top: 66px;
  }
}

@media screen and (width <= 900px) {
  html[data-press-contents-js] .press-doc {
    padding-top: calc(48px + 30px);
  }
}

/* Tables run to the figures' measure; code stays at the text's. */
.press-doc > .press-table-scroll {
  max-width: var(--figure-measure, var(--measure, 43rem));
}

/* Two slots, empty as press writes them, for the site the docs are part of to put
   its own navigation in: one at the page's top corner, scrolling away with the
   page, and on narrow screens one heading the list under the bar, staying put as
   the list scrolls. An empty slot takes no room. */
.press-doc-corner {
  position: absolute;
  top: 12px;
  right: 26px;
  z-index: 40;
}

.press-doc-site {
  display: none;
}

@media screen and (width <= 900px) {
  .press-doc-corner {
    display: none;
  }
  .press-doc-site {
    display: block;
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 1.5rem 12px;
    background: var(--paper);
  }
}

@media screen and (width <= 600px) {
  .press-doc-site {
    padding-left: 20px;
    padding-right: 20px;
  }
}

.press-doc-corner:empty,
.press-doc-site:empty {
  display: none;
}

/* The rail's list is the site's pages (src/docs/rail.ts). Each level steps in 11px. */
.press-contents-docs .press-contents-link {
  font-size: 14px;
}

.press-contents-docs .press-doc-section > .press-contents-link {
  font-size: 13px;
}

/* A group with no page of its own is a name, not a link, in the links' grey. */
.press-contents-docs span.press-contents-link {
  color: var(--ink-muted);
}

.press-contents-docs .press-doc-here > .press-contents-link {
  color: var(--ink);
  font-weight: 600;
}

.press-contents-docs .press-contents-item[data-depth="1"] > .press-contents-link {
  padding-left: 20px;
}

.press-contents-docs .press-contents-item[data-depth="2"] > .press-contents-link {
  padding-left: 31px;
}

.press-contents-docs .press-contents-item[data-depth="3"] > .press-contents-link {
  padding-left: 42px;
}

.press-contents-docs .press-contents-item[data-depth="4"] > .press-contents-link {
  padding-left: 53px;
}

.press-contents-docs .press-contents-item[data-depth="5"] > .press-contents-link {
  padding-left: 64px;
}

/* Every page is listed, where a paper's rail folds to the reading branch. A group
   at the top is a small label, with its pages back out at the edge beneath it. */
html[data-press-contents-js] .press-contents-docs .press-doc-pages {
  display: block;
}

html[data-press-contents-js] .press-contents-list > .press-doc-group > .press-contents-link {
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* A page listed after a group stands clear of it, or it would read as the group's. */
html[data-press-contents-js] .press-contents-list > .press-doc-group + .press-doc-page:not(.press-doc-group) > .press-contents-link {
  margin-top: 16px;
}

html[data-press-contents-js] .press-contents-docs .press-doc-group .press-contents-item[data-depth="2"] > .press-contents-link {
  padding-left: 20px;
}

html[data-press-contents-js] .press-contents-docs .press-doc-group .press-contents-item[data-depth="3"] > .press-contents-link {
  padding-left: 31px;
}

html[data-press-contents-js] .press-contents-docs .press-doc-group .press-contents-item[data-depth="4"] > .press-contents-link {
  padding-left: 42px;
}

html[data-press-contents-js] .press-contents-docs .press-doc-group .press-contents-item[data-depth="5"] > .press-contents-link {
  padding-left: 53px;
}

html[data-press-contents-js] .press-contents-docs .press-doc-group .press-doc-section[data-depth="2"] > .press-contents-link {
  padding-left: 31px;
}

/* A long group (more than five entries) is one line and a count, until the reader
   is on its page or inside it. */
html[data-press-contents-js] .press-contents-docs .press-doc-fold:not(.is-path) > .press-doc-pages {
  display: none;
}

.press-doc-count {
  margin-left: 8px;
  opacity: 0.6;
  font-weight: 400;
}

.press-doc-fold.is-path > .press-contents-link .press-doc-count {
  display: none;
}

/* ---------- Print ---------- */
@page {
  size: letter;
  margin: 1in;
}

@media print {
  .press-contents,
  .press-doc-corner {
    display: none !important;
  }
  html {
    font-size: 10.5pt;
  }
  body {
    background: var(--paper);
  }
  .press-paper {
    max-width: none;
    padding: 0;
  }
  .press-paper > :is(p, ul, ol, dl, blockquote) {
    font-size: 1rem;
    line-height: 1.6;
  }
  .press-subhead:where(h1, h2, h3, h4, h5, h6) {
    font-size: 0.94rem;
    line-height: 1.6;
  }
  .press-paper > :not(.press-figure),
  .press-figure figcaption {
    max-width: none;
  }
  .press-paper > .press-frontmatter {
    margin-left: 0;
  }
  p {
    margin: 1rem 0;
  }
  a {
    text-decoration: none;
    color: var(--ink);
  }
  /* Print the baked static figure (exported screenshot or author image); the
     live interactive mount can't lay out for the print page. */
  .press-mount {
    display: none !important;
  }
  .press-static-fallback {
    display: block !important;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
  }
  .press-figure {
    break-inside: avoid;
  }
  /* Keep a table on one page where it fits; a longer one breaks between rows and
     repeats its header. Chromium won't break inside an overflow box, so the
     screen scroller is undone. */
  .press-table {
    break-inside: avoid;
  }
  .press-table-scroll {
    overflow: visible;
  }
  thead {
    display: table-header-group;
  }
  tr {
    break-inside: avoid;
  }
  .press-figure img {
    max-width: 100%;
    height: auto;
  }
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    break-after: avoid;
  }
}
