/* Planum's reading surface. Colours in conf.py mirror web/src/styles/tokens.css. */
@font-face {
  font-family: "Source Sans 3 Variable";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin-wght-normal.woff2") format("woff2-variations");
}
@font-face {
  font-family: "Source Sans 3 Variable";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-sans-3-latin-wght-italic.woff2") format("woff2-variations");
}

/* Adobe Source Serif 4, under the SIL Open Font License bundled with the files.
 * Official assets: https://adobe-fonts.github.io/source-serif/ */
@font-face {
  font-family: "Source Serif 4 Variable";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-variable-roman.woff2") format("woff2");
}
@font-face {
  font-family: "Source Serif 4 Variable";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/source-serif-4-variable-italic.woff2") format("woff2");
}

:root {
  --docs-header-height: max(3rem, 48px);
  --docs-sidebar-width: 19rem;
  --docs-reading-font: "Source Serif 4 Variable", Georgia, serif;
  --radius-control: 4px;
  --radius-panel: 6px;
}
html {
  font-size: 100%;
  scroll-padding-top: calc(var(--docs-header-height) + 1.5rem);
}
body {
  --rule: 1px solid var(--color-background-border);
  --color-sidebar-item-background--current: var(--color-accent-surface);
  --color-sidebar-link-text--top-level: var(--color-foreground-secondary);
  --color-code-background: var(--color-background-secondary);
  --color-code-foreground: var(--color-foreground-primary);
  height: auto;
  min-height: 100%;
  font-synthesis: none;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--color-accent-surface); color: var(--color-foreground-primary); }
:focus-visible { outline: 2px solid var(--color-brand-primary); outline-offset: 3px; }
input { caret-color: var(--color-brand-primary); }
:where(.sidebar-scroll, .toc-scroll, .table-wrapper, pre) {
  scrollbar-width: thin;
  scrollbar-color: var(--color-foreground-border) transparent;
}

/* One masthead, with the same identity and controls on every screen. */
.docs-header {
  container-type: inline-size;
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--docs-header-height);
  padding: 0 1.5rem;
  background: var(--color-background-primary);
  border-bottom: var(--rule);
}
.docs-identity { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.docs-identity, .docs-identity:visited { color: var(--color-foreground-primary); }
.brand-mark { flex: none; }
.docs-brand { font-size: 1.1875rem; font-weight: 600; letter-spacing: -0.02em; }
.docs-label {
  margin-left: 0.5rem;
  padding-left: 1rem;
  border-left: var(--rule);
  color: var(--color-foreground-secondary);
  font-size: 0.875rem;
}
.docs-actions { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.docs-link { color: var(--color-foreground-secondary); font-size: 0.875rem; text-decoration: none; }
.docs-link:hover { color: var(--color-brand-primary); }
.docs-open, .docs-open:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.125rem 0.75rem;
  box-sizing: border-box;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-brand-primary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.docs-open:hover { background: var(--color-accent-surface); color: var(--color-brand-primary); }
.docs-icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--color-foreground-secondary);
  cursor: pointer;
}
.docs-icon-button:hover { background: var(--color-background-hover); color: var(--color-foreground-primary); }
.docs-icon-button svg { width: 1.125rem; height: 1.125rem; fill: currentColor; }
.docs-nav-toggle:not([hidden]) {
  display: inline-flex;
  width: auto;
  gap: 0.5rem;
  margin-left: 1rem;
  padding-inline: 0.625rem;
  font: inherit;
  font-size: 0.875rem;
  white-space: nowrap;
}
.docs-nav-toggle[aria-expanded="true"] { color: var(--color-brand-primary); background: var(--color-accent-surface); }
.docs-toc-toggle, .docs-icon-button[hidden] { display: none; }
html:not(.no-js) .mobile-header, .content-icon-container { display: none; }

/* Independent navigation and page outlines frame one continuous reading column. */
.page { display: block; min-height: calc(100vh - var(--docs-header-height)); }
.main { display: block; padding-inline: 3rem; }
.main, .content, .article-container { min-width: 0; }
.content { box-sizing: border-box; width: 100%; max-width: 72ch; margin-inline: auto; padding: 0; font-family: var(--docs-reading-font); font-size: 1.125rem; }
.content > footer { font-family: var(--font-stack); font-size: 1rem; }
.article-container { padding-top: 3.5rem; }
.content :target { scroll-margin-top: 0.5rem; }
.sidebar-drawer {
  position: fixed;
  top: var(--docs-header-height);
  left: -20rem;
  width: var(--docs-sidebar-width);
  min-width: 0;
  max-width: calc(100vw - 3rem);
  height: calc(100dvh - var(--docs-header-height));
  background: var(--color-background-primary);
  border-right: var(--rule);
}
.sidebar-container { width: 100%; }
#__navigation:checked ~ .page .sidebar-drawer { top: var(--docs-header-height); }
.sidebar-overlay, .toc-overlay { top: var(--docs-header-height); }
.sidebar-sticky, .toc-sticky {
  top: var(--docs-header-height);
  height: calc(100vh - var(--docs-header-height));
  height: calc(100dvh - var(--docs-header-height));
}
.sidebar-sticky { top: 0; }
.sidebar-search-container {
  flex-shrink: 0;
  margin: 1.5rem 1rem 1rem;
  border: 1px solid var(--color-foreground-border);
  border-radius: var(--radius-control);
  background: var(--color-background-primary);
}
.sidebar-search-container::before { left: 0.75rem; width: 0.875rem; height: 0.875rem; }
.sidebar-search-container:focus-within { outline: 2px solid var(--color-brand-primary); outline-offset: 2px; }
.sidebar-search {
  min-height: 2.25rem;
  padding: 0.375rem 0.75rem 0.375rem 2rem;
  border: 0;
  font: inherit;
  font-size: 0.875rem;
}
.sidebar-search::placeholder { font-size: inherit; color: var(--color-foreground-muted); opacity: 1; }
.docs-overview {
  display: block;
  margin: 0 0.75rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-control);
  color: var(--color-foreground-secondary);
  font-size: 0.9375rem;
  text-decoration: none;
}
.docs-overview:hover { background: var(--color-background-hover); }
.docs-overview.is-current { background: var(--color-accent-surface); color: var(--color-brand-primary); font-weight: 600; }
.sidebar-tree { margin-top: 0; padding: 0 0.75rem 1.5rem; }
.sidebar-tree .caption {
  margin: 0;
  padding: 1.5rem 0.75rem 0.375rem;
  text-transform: none;
}
.sidebar-tree .caption-text {
  color: var(--color-foreground-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0;
}
.sidebar-tree .reference {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-control);
  font-size: 0.9375rem;
  line-height: 1.4;
}
.sidebar-tree .reference:hover { background: var(--color-background-hover); }
.sidebar-tree .current-page > .reference { background: var(--color-accent-surface); color: var(--color-brand-primary); font-weight: 600; }
/* Section headings belong in the page outline; the left rail stays a page index. */
.sidebar-tree .current-page > ul, .sidebar-tree .current-page > label { display: none; }
.sidebar-tree .current-page.has-children > .reference { padding-right: 0.75rem; }
.toc-sticky { padding-top: 3.5rem; }
.toc-title-container { margin: 0; padding: 0 0 0.75rem; }
.toc-title { color: var(--color-foreground-muted); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0; text-transform: none; }
.toc-tree { border-left: var(--rule); font-size: 0.875rem; line-height: 1.5; }
.toc-tree-container { padding: 0; }
.toc-tree a { padding-block: 0.375rem; overflow-wrap: anywhere; }
.toc-tree a:hover { color: var(--color-brand-primary); }

/* Journal reading scale: serif title 40px, section 28px, subsection 21px,
 * prose 18px/29px. Navigation, data, code and captions retain Source Sans 3.
 * The article has a 72ch measure; figures and tables share its outer edges.
 */
article {
  font-family: var(--docs-reading-font);
  font-size: 1.125rem;
  font-optical-sizing: auto;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
article h1, article h2, article h3, article h4 {
  margin-inline: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  font-family: var(--docs-reading-font);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-wrap: balance;
}
article h1 { margin: 0 0 1.5rem; font-size: 2.5rem; }
article h2 { margin: 3rem 0 1rem; font-size: 1.75rem; }
article h3 { margin: 2rem 0 0.75rem; font-size: 1.3125rem; }
article h4 { margin: 1.5rem 0 0.5rem; font-size: 1.125rem; }
article p, article li, article dd { line-height: 1.65; text-wrap: pretty; }
article p { margin-block: 0 1.25rem; }
article :is(ul, ol) { padding-left: 1.5rem; }
article :is(ul, ol) > li + li { margin-top: 0.5rem; }
article strong { font-weight: 600; }
article a.reference { text-decoration-thickness: 1px; text-decoration-color: var(--color-foreground-border); text-underline-offset: 3px; }
article a.reference:hover { text-decoration-color: currentColor; }
.headerlink { font-family: var(--font-stack); font-weight: 400; font-size: 0.65em; }
.hero-lede { color: var(--color-foreground-secondary); font-family: var(--font-stack); font-size: 1.25rem; line-height: 1.5; }

/* A directory, not a table of densely packed links. */
.methods-directory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; row-gap: 1.75rem; margin-block: 1.5rem 2.5rem; }
.methods-directory h3 { margin: 0 0 0.5rem; padding-top: 1rem; border-top: var(--rule); font-family: var(--font-stack); font-size: 1rem; letter-spacing: 0; }
.methods-directory ul { margin: 0; padding: 0; list-style: none; }
.methods-directory li + li { margin-top: 0; }
.methods-directory a.reference {
  display: block;
  padding-block: 0.3125rem;
  color: var(--color-foreground-secondary);
  line-height: 1.5;
  font-family: var(--font-stack);
  font-size: 1rem;
  text-decoration: none;
}
.methods-directory a.reference:hover { color: var(--color-brand-primary); text-decoration: underline; }

figure { margin: 2.5rem 0; }
figure img { display: block; box-sizing: border-box; width: 100%; height: auto; border: 0; border-radius: 0; }
figcaption { margin-top: 1rem; padding-bottom: 1.5rem; border-bottom: var(--rule); font-family: var(--font-stack); color: var(--color-foreground-secondary); font-size: 0.875rem; line-height: 1.6; }
figcaption p, figcaption .caption-text { text-align: left; line-height: inherit; }
figcaption .caption-number, figcaption strong { color: var(--color-foreground-primary); font-weight: 600; }

dl.myst { margin: 1.5rem 0; font-family: var(--font-stack); font-size: 1rem; }
dl.myst > dt { margin: 0; padding-top: 1rem; font-weight: 600; }
dl.myst > dt:first-child { padding-top: 0; }
dl.myst > dd { margin: 0.25rem 0 0; padding-bottom: 1rem; border-bottom: var(--rule); color: var(--color-foreground-secondary); }
dl.myst > dd > p { margin: 0; }

code.literal, kbd { border-radius: var(--radius-control); background: var(--color-background-hover); font-family: var(--font-stack--monospace); font-size: 0.8125em; }
code.literal { padding: 0.1em 0; border: 0; background: transparent; white-space: normal; overflow-wrap: anywhere; }
article code.docutils.literal { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
kbd { padding: 0.1em 0.35em; border: var(--rule); box-shadow: none; }
div.highlight { box-sizing: border-box; margin-block: 1.5rem; border: var(--rule); border-radius: var(--radius-panel); background: var(--color-code-background); }
div.highlight pre { margin: 0; padding: 1rem 1.25rem; border-radius: inherit; background: transparent; font-size: 0.8125rem; line-height: 1.7; overflow-wrap: normal; }
article pre { overflow-x: auto; }

/* Data stays tabular; long paths wrap rather than force unreadably narrow prose. */
article .table-wrapper { box-sizing: border-box; max-width: 100%; margin: 1.5rem 0; padding: 0; overflow-x: auto; }
article table.docutils { width: 100%; margin: 0; border: 0; border-collapse: collapse; box-shadow: none; font-family: var(--font-stack); font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
/* break-word, not anywhere: a column is never sized narrower than its longest word. */
table.docutils th, table.docutils td { padding: 0.875rem 1rem; border: 0; border-bottom: var(--rule); vertical-align: top; overflow-wrap: break-word; }
table.docutils th { border-top: 1px solid var(--color-foreground-secondary); background: transparent; color: var(--color-foreground-secondary); font-size: 0.875rem; font-weight: 600; }
table.docutils :is(th, td):first-child { padding-left: 0; }
table.docutils :is(th, td):last-child { padding-right: 0; }
table.docutils :is(th, td) p { margin: 0; line-height: 1.6; text-wrap: wrap; }
table.docutils code.literal { font-size: 0.875em; white-space: normal; overflow-wrap: anywhere; }
/* Give filenames, criteria and results a real column instead of letting the
 * longest prose cell squeeze its neighbours into fragments. */
table.docutils:has(tr > :nth-child(3)):not(:has(tr > :nth-child(4))) { min-width: 40rem; table-layout: fixed; }
#code-availability table.docutils { min-width: 32rem; table-layout: fixed; }
#code-availability table.docutils :is(th, td):first-child { width: 8rem; }
/* MyST's empty column heads in code-availability ledgers carry no information. */
table.docutils thead:has(th:empty):not(:has(th:not(:empty))) { display: none; }
.math-wrapper { max-width: 100%; overflow-x: auto; }
article .math, article mjx-container { max-width: 100%; }
article mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding-block: 0.25rem; }

.admonition, details { border: var(--rule); border-radius: var(--radius-panel); background: var(--color-admonition-background); box-shadow: none; font-size: 1rem; }
.admonition.warning, .admonition.danger, .admonition.error, .admonition.caution { border-color: var(--color-danger); }
.admonition > .admonition-title { padding: 0.75rem 1rem 0; background: transparent; font-size: 0.9375rem; font-weight: 600; }
.admonition > .admonition-title::before { display: none; }
dl.py > dt.sig { border: var(--rule); border-radius: var(--radius-control); background: var(--color-api-background); font-size: 0.875rem; }

/* Quiet, legible continuation at the end of every article. */
.related-pages { gap: 1.5rem; margin-top: 3rem; padding-top: 1.25rem; border-top: var(--rule); }
.related-pages a { min-width: 0; }
.related-pages .title { font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.related-pages .context { color: var(--color-foreground-muted); font-size: 0.8125rem; }
.related-pages a:hover .title { color: var(--color-brand-primary); }
.bottom-of-page { margin-top: 1.5rem; padding-block: 1.25rem; border-top: var(--rule); color: var(--color-foreground-muted); font-size: 0.8125rem; }
.back-to-top { top: calc(var(--docs-header-height) + 0.75rem); border: var(--rule); border-radius: var(--radius-control); box-shadow: none; }

@media (min-width: 82.01em) {
  .main { display: grid; grid-template-columns: minmax(0, 46rem) 12rem; justify-content: center; gap: 4rem; }
  .toc-drawer { width: 100%; padding: 0; z-index: auto; }
}
@media (min-width: 63.01em) {
  .no-js .page { display: grid; grid-template-columns: var(--docs-sidebar-width) minmax(0, 1fr); }
  .no-js .sidebar-drawer { position: static; width: 100%; }
  .no-js .sidebar-sticky { top: var(--docs-header-height); }
  .no-js .main { display: block; }
  .no-js .toc-drawer { display: none; }
}
@media (max-width: 82em) {
  .docs-toc-toggle:not([hidden]) { display: flex; }
  .toc-drawer { width: 17rem; max-width: calc(100vw - 3rem); right: -18rem; border-left: var(--rule); background: var(--color-background-primary); }
  .toc-sticky { padding: 1.5rem; }
  #__toc:checked ~ .page .toc-drawer { top: var(--docs-header-height); height: calc(100dvh - var(--docs-header-height)); }
}
@media (max-width: 63em) {
  .docs-header { gap: 0.5rem; padding-inline: 1rem; }
  .docs-nav-toggle:not([hidden]) { display: flex; margin-left: 0; }
  .docs-nav-toggle span { display: none; }
  .docs-actions { gap: 0.5rem; }
  .docs-label { font-size: 0.8125rem; }
  .page { display: block; }
  .main { display: block; padding-inline: 2rem; }
  .content { width: 100%; max-width: 72ch; margin-inline: auto; padding: 0; overflow: visible; }
  .article-container { padding-top: 2rem; }
  .sidebar-drawer { width: var(--docs-sidebar-width); max-width: calc(100vw - 3rem); left: -20rem; }
  .sidebar-container { width: 100%; }
  #__navigation:checked ~ .page .sidebar-drawer { top: var(--docs-header-height); height: calc(100dvh - var(--docs-header-height)); }
  .sidebar-sticky { top: 0; }
  .sidebar-overlay, .toc-overlay { top: var(--docs-header-height); }
  .no-js .docs-header { display: none; }
}
@media (max-width: 40em) {
  .docs-header { padding-inline: 0.5rem; }
  .docs-label, .docs-link { display: none; }
  .docs-identity { gap: 0.375rem; }
  .docs-actions { gap: 0.25rem; }
  .main { padding-inline: 1.25rem; }
  .article-container { padding-top: 1.75rem; }
  article h1 { font-size: 2rem; }
  article h2 { margin-top: 2.5rem; font-size: 1.5rem; }
  .hero-lede { font-size: 1.125rem; }
  .methods-directory { grid-template-columns: 1fr; gap: 1.5rem; }
  .methods-directory a.reference { padding-block: 0.4375rem; }
  figure { margin-block: 1.5rem; }
  table.docutils { min-width: 40rem; }
  /* Two-column source ledgers fit the page; three-column data tables scroll. */
  table.docutils:not(:has(tr > :nth-child(3))) { min-width: 0; }
  .related-pages { gap: 1rem; }
}
@media (pointer: coarse) {
  .docs-icon-button { width: max(2rem, 44px); height: max(2rem, 44px); }
  .docs-open { min-height: 2.75rem; }
  .sidebar-tree .reference, .docs-overview { padding-block: 0.6875rem; }
  .sidebar-search { min-height: 2.75rem; font-size: 1rem; }
  .methods-directory a.reference { padding-block: 0.625rem; }
}
@media (max-width: 22.5em) {
  /* The viewer remains in the navigation drawer's Project group. */
  .docs-open { display: none; }
}
/* Font-relative queries also keep the masthead usable with enlarged text. */
@container (max-width: 22.5rem) {
  .docs-open, .docs-label { display: none; }
  .docs-nav-toggle span { display: none; }
}
@container (max-width: 18rem) {
  .docs-brand { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html, .sidebar-scroll, .toc-scroll { scroll-behavior: auto; }
  .sidebar-drawer, .toc-drawer, .overlay, .skip-to-content { transition: none; }
}
@media (forced-colors: active) {
  .docs-open { border: 1px solid ButtonText; }
  .docs-overview.is-current, .sidebar-tree .current-page > .reference { outline: 1px solid Highlight; outline-offset: -1px; }
}
@media print {
  .docs-header, .sidebar-drawer, .toc-drawer, .back-to-top { display: none; }
  .page, .main { display: block; }
  .content { max-width: none; width: 100%; padding: 0; }
  .article-container { padding-top: 0; }
  .table-wrapper { overflow: visible; }
}
