/*
 * Chambers App documentation. The app's visual world (apps/web/DESIGN.md) set for long reading:
 * cool paper, blue-black ink, one accent, hairline rules instead of boxes, no shadows, the system
 * sans for both scripts, tabular numerals. Light and dark follow the system unless the reader picks one.
 */

:root {
  color-scheme: light;
  --paper: oklch(0.985 0.003 250);
  --panel: oklch(0.958 0.008 250);
  --ink: oklch(0.24 0.035 262);
  --ink-soft: oklch(0.44 0.03 262);
  --ink-faint: oklch(0.54 0.025 262);
  --rule: oklch(0.88 0.012 255);
  --rule-strong: oklch(0.24 0.035 262);
  --band: oklch(0.24 0.035 262);
  --on-band: oklch(0.985 0.003 250);
  --on-band-soft: oklch(0.83 0.03 255);
  --band-field: oklch(0.31 0.035 262);
  --seal: oklch(0.55 0.2 28);
  --seal-text: oklch(0.5 0.19 28);
  --seal-wash: oklch(0.955 0.03 28);
  --code-bg: oklch(0.958 0.008 250);
  --scroll-thumb: oklch(0.8 0.015 255);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  /* About 72 characters a line in the system sans; the craft floor asks for 65 to 75. */
  --measure: 62ch;
  --band-height: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: oklch(0.2 0.022 262);
    --panel: oklch(0.245 0.026 262);
    --ink: oklch(0.93 0.008 255);
    --ink-soft: oklch(0.79 0.018 258);
    --ink-faint: oklch(0.69 0.02 258);
    --rule: oklch(0.34 0.025 262);
    --rule-strong: oklch(0.78 0.02 258);
    --band: oklch(0.15 0.02 262);
    --on-band: oklch(0.95 0.006 255);
    --on-band-soft: oklch(0.78 0.02 258);
    --band-field: oklch(0.24 0.026 262);
    --seal: oklch(0.66 0.17 30);
    --seal-text: oklch(0.74 0.14 32);
    --seal-wash: oklch(0.28 0.035 28);
    --code-bg: oklch(0.245 0.026 262);
    --scroll-thumb: oklch(0.4 0.025 262);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: oklch(0.2 0.022 262);
  --panel: oklch(0.245 0.026 262);
  --ink: oklch(0.93 0.008 255);
  --ink-soft: oklch(0.79 0.018 258);
  --ink-faint: oklch(0.69 0.02 258);
  --rule: oklch(0.34 0.025 262);
  --rule-strong: oklch(0.78 0.02 258);
  --band: oklch(0.15 0.02 262);
  --on-band: oklch(0.95 0.006 255);
  --on-band-soft: oklch(0.78 0.02 258);
  --band-field: oklch(0.24 0.026 262);
  --seal: oklch(0.66 0.17 30);
  --seal-text: oklch(0.74 0.14 32);
  --seal-wash: oklch(0.28 0.035 28);
  --code-bg: oklch(0.245 0.026 262);
  --scroll-thumb: oklch(0.4 0.025 262);
}

/* ---- Base ---- */

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--band-height) + 16px);
  scrollbar-color: var(--scroll-thumb) transparent;
}

body {
  margin: 0;
  background: var(--paper);
  font-size: 1rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection {
  background: var(--seal-wash);
  color: var(--ink);
}

input {
  caret-color: var(--seal);
}

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

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
  border: 2px solid var(--paper);
}
::-webkit-scrollbar-track {
  background: transparent;
}

a {
  color: inherit;
  text-decoration-color: var(--ink-faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover {
  text-decoration-color: currentColor;
}

code,
pre,
kbd {
  font-family: var(--mono);
  font-size: 0.875em;
}

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

.skip {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
}
.skip:focus {
  top: 8px;
}
.skip:focus-visible {
  outline: 2px solid var(--on-band);
  outline-offset: 2px;
}

/* The band is dark in both themes: its focus rings are drawn in the band's own text colour. */
.band :focus-visible {
  outline-color: var(--on-band);
}

/* ---- The band ---- */

.band {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--band);
  color: var(--on-band);
  padding-top: env(safe-area-inset-top);
}

.band-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--band-height);
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
}

.wordmark {
  flex: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  text-decoration: none;
  min-width: 0;
}
.wordmark-name {
  white-space: nowrap;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.wordmark-sub {
  font-size: 0.75rem;
  color: var(--on-band-soft);
}

.search {
  position: relative;
  margin-left: auto;
  flex: 1 1 auto;
  max-width: 340px;
  min-width: 0;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 8px 0 10px;
  border-radius: 4px;
  background: var(--band-field);
  color: var(--on-band-soft);
  cursor: text;
  transition: background-color 150ms var(--ease-out);
}
.search-field:focus-within {
  background: var(--paper);
  color: var(--ink-soft);
  outline: 2px solid var(--on-band);
  outline-offset: 1px;
}
.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--on-band);
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.search-field:focus-within input {
  color: var(--ink);
}
.search-field input::placeholder {
  color: var(--on-band-soft);
}
.search-field input::-webkit-search-cancel-button {
  display: none;
}
.search-field kbd {
  padding: 0 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 18px;
  opacity: 0.8;
}
.search-field:focus-within kbd {
  display: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(480px, calc(100vw - 32px));
  max-height: min(60vh, 520px);
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  overscroll-behavior: contain;
}
.search-results li a {
  display: block;
  padding: 8px 14px;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.search-results li:last-child a {
  border-bottom: 0;
}
.search-results li a:hover {
  background: var(--panel);
}
/* The keyboard's option: an inset rule in the accent on its leading edge, the wash, and stronger text. */
.search-results li[aria-selected="true"] a {
  background: var(--seal-wash);
  box-shadow: inset 3px 0 0 var(--seal);
}
.search-results li[aria-selected="true"] .r-title {
  font-weight: 650;
}
.search-results .r-title {
  display: block;
  font-weight: 550;
  overflow-wrap: anywhere;
}
.search-results .r-where {
  display: block;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.search-results .r-empty {
  padding: 10px 14px;
  color: var(--ink-soft);
}

.theme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--on-band-soft);
  border-radius: 4px;
  background: transparent;
  color: var(--on-band);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 140ms var(--ease-out),
    border-color 140ms var(--ease-out);
}
.theme:active {
  transform: scale(0.97);
}
@media (hover: hover) and (pointer: fine) {
  .theme:hover {
    border-color: var(--on-band);
  }
}
.theme:focus-visible {
  outline-color: var(--on-band);
}

/* ---- Shell: navigation and article ---- */

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1320px;
  margin: 0 auto;
}

/* On narrow screens the contents stay within reach: a sticky bar under the band, whose open list scrolls on its own. */
.sidebar {
  position: sticky;
  top: calc(var(--band-height) + env(safe-area-inset-top));
  z-index: 10;
  padding: 0 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
@media (max-width: 959px) {
  .nav-toggle[open] .nav-pages {
    max-height: calc(100dvh - var(--band-height) - 64px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  html {
    scroll-padding-top: calc(var(--band-height) + 64px);
  }
}

.nav-toggle > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.nav-toggle > summary::-webkit-details-marker {
  display: none;
}
.nav-toggle > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  rotate: 45deg;
  translate: 0 -2px;
  transition: rotate 200ms var(--ease-out);
}
.nav-toggle[open] > summary::after {
  rotate: 225deg;
  translate: 0 2px;
}
.nav-current {
  margin-left: auto;
  font-weight: 400;
  color: var(--ink-soft);
}

.nav-pages,
.nav-sections {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-pages {
  padding-bottom: 12px;
}
.nav-pages > li > a {
  display: block;
  padding: 7px 10px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
}
.nav-pages > li.current > a {
  background: var(--seal-wash);
  box-shadow: inset 3px 0 0 var(--seal);
  font-weight: 650;
}
@media (hover: hover) and (pointer: fine) {
  .nav-pages > li:not(.current) > a:hover {
    background: var(--panel);
  }
  .nav-sections a:hover {
    color: var(--ink);
  }
}
.nav-sections {
  margin: 4px 0 8px 10px;
  border-left: 1px solid var(--rule);
}
.nav-sections a {
  display: block;
  padding: 4px 10px 4px 12px;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--ink-soft);
  text-decoration: none;
}
.nav-sections a.active {
  color: var(--ink);
  font-weight: 550;
}

main {
  min-width: 0;
  padding: 0 16px 64px;
  outline: none;
}

@media (min-width: 960px) {
  .shell {
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 40px;
    padding: 0 24px;
  }
  .sidebar {
    position: sticky;
    top: var(--band-height);
    z-index: auto;
    background: transparent;
    align-self: start;
    max-height: calc(100dvh - var(--band-height));
    overflow-y: auto;
    padding: 28px 8px 32px 0;
    border-bottom: 0;
    scrollbar-width: thin;
  }
  .nav-toggle > summary {
    display: none;
  }
  .nav-toggle::details-content {
    content-visibility: visible;
    display: contents;
  }
  main {
    padding: 0 0 96px;
  }
}

/* ---- The article ---- */

.doc {
  max-width: 920px;
  padding-top: 32px;
}

.doc > :where(p, ul, ol, .note, dl, blockquote),
.doc section > :where(p, ul, ol, .note, dl, blockquote),
.doc .cap > :where(p, ul, ol, dl) {
  max-width: var(--measure);
}

.doc h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lede {
  margin: 10px 0 0;
  font-size: 1.125rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.doc h2,
.doc h3,
.doc h4 {
  position: relative;
  text-wrap: balance;
}

.doc h2 {
  margin: 56px 0 16px;
  padding-top: 12px;
  border-top: 2px solid var(--rule-strong);
  font-size: 1.375rem;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.doc h3 {
  margin: 36px 0 10px;
  font-size: 1.0625rem;
  line-height: 1.4;
  font-weight: 650;
}
.doc h4 {
  margin: 24px 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.anchor {
  position: absolute;
  left: -22px;
  top: 0.25em;
  display: inline-flex;
  padding: 2px;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity 150ms var(--ease-out);
}
.doc h2 .anchor {
  top: calc(12px + 0.3em);
}
.doc :is(h2, h3, h4):hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}
@media (max-width: 959px) {
  .anchor {
    display: none;
  }
}

.doc p,
.doc li {
  text-wrap: pretty;
}
.doc p {
  margin: 0 0 14px;
}
.doc ul,
.doc ol {
  margin: 0 0 16px;
  padding-left: 1.25em;
}
.doc li {
  margin: 4px 0;
}
.doc li::marker {
  color: var(--ink-faint);
}

.doc :not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--code-bg);
  overflow-wrap: anywhere;
}

.note {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 4px;
  background: var(--panel);
}
.note > :last-child {
  margin-bottom: 0;
}

/* Code blocks, with the copy button the script adds. */
.code-wrap {
  margin: 0 0 18px;
  border-radius: 4px;
  background: var(--code-bg);
}
.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 4px 6px 0 16px;
}
.code-lang {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: lowercase;
}
/* A block with no language has no bar: the copy button sits in its top right corner, and the code keeps clear of it. */
.code-wrap.bare {
  position: relative;
}
.code-wrap.bare .copy {
  position: absolute;
  top: 8px;
  right: 8px;
}
.code-wrap.bare pre.code {
  padding-top: 14px;
  padding-right: 88px;
  border-radius: 4px;
}
pre.code {
  margin: 0 0 18px;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 4px;
  background: var(--code-bg);
  line-height: 1.55;
  tab-size: 2;
  scrollbar-width: thin;
}
.code-wrap pre.code {
  margin: 0;
  padding-top: 4px;
  border-radius: 0 0 4px 4px;
}
.copy {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out);
}
.copy:active {
  transform: scale(0.97);
}
@media (hover: hover) and (pointer: fine) {
  .copy:hover {
    border-color: var(--ink-soft);
    color: var(--ink);
  }
}
.copy[data-state="copied"] {
  color: var(--ink);
  border-color: var(--ink-soft);
}

/* Tables scroll inside their own container, never the page. */
.table-scroll {
  max-width: 100%;
  margin: 0 0 20px;
  overflow-x: auto;
  scrollbar-width: thin;
  /* Scroll shadows: a soft edge appears on whichever side has more table to show. */
  background:
    linear-gradient(to right, var(--paper) 30%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 30%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, color-mix(in oklch, var(--ink) 18%, transparent), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, color-mix(in oklch, var(--ink) 18%, transparent), transparent) right / 12px 100% no-repeat scroll;
}
.table-scroll:focus-visible {
  outline-offset: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.45;
}
caption {
  text-align: left;
  padding-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.875rem;
}
th {
  text-align: left;
  font-weight: 600;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
td code {
  overflow-wrap: normal;
  white-space: nowrap;
}
td.wrap code,
td .wrap code {
  white-space: normal;
  overflow-wrap: anywhere;
}
th:last-child,
td:last-child {
  padding-right: 0;
}
.num {
  text-align: right;
}
.nowrap,
.nowrap code {
  white-space: nowrap;
}
.meta-inline {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
.doc section > ul.rules {
  max-width: none;
}
ul.rules {
  margin: -8px 0 20px;
  padding: 0;
  list-style: none;
  font-size: 0.9375rem;
}
ul.rules li {
  margin: 0;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
}
ul.rules code {
  color: var(--ink);
  overflow-wrap: anywhere;
}
.route-desc {
  min-width: 18rem;
  max-width: var(--measure);
}
.route-desc p {
  margin: 0 0 6px;
}
.route-desc .route-src {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}
td dl.rows,
dd ol {
  margin-bottom: 0;
}
dl.rows dd p {
  margin: 0 0 6px;
}
dl.rows dd ol {
  padding-left: 1.25em;
  color: var(--ink);
}

.check {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.4em;
  border: 1.5px solid var(--ink-soft);
  border-radius: 2px;
  vertical-align: -0.08em;
}
.doc li:has(> .check) {
  list-style: none;
  margin-left: -1.25em;
}

/* Small labels: kind, access, flags. Text in a hairline frame, never a filled pill. */
.tag {
  display: inline-block;
  padding: 0 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: nowrap;
}
.tag.strong {
  border-color: var(--ink-soft);
  color: var(--ink);
}
.tag.accent {
  border-color: var(--seal);
  color: var(--seal-text);
}

/* Definition rows: a term and what it means, on hairlines. */
dl.rows {
  margin: 0 0 20px;
  border-top: 1px solid var(--rule);
}
dl.rows > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
@media (min-width: 640px) {
  dl.rows > div {
    grid-template-columns: 13rem minmax(0, 1fr);
  }
}
dl.rows dt {
  font-weight: 600;
  overflow-wrap: anywhere;
}
dl.rows dd {
  margin: 0;
  color: var(--ink-soft);
}

/* ---- Capability and table entries: ruled rows, not cards ---- */

.entry {
  padding: 18px 0 8px;
  border-top: 1px solid var(--rule);
}
/* A deep link or a search result washes its entry, with a little room either side, and the wash fades. */
.entry {
  margin-inline: -10px;
  padding-inline: 10px;
  border-radius: 4px;
  transition: background-color 600ms var(--ease-out);
}
.entry:has(:target),
.entry.flash {
  background-color: var(--seal-wash);
  transition-duration: 0ms;
}
.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin-bottom: 6px;
}
.entry-head h3,
.entry-head h4 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.entry-head .anchor {
  top: 0.15em;
}
.entry .meta {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}
.entry .meta code {
  color: var(--ink);
}
.entry details {
  margin: 4px 0 12px;
}
.entry details > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.875rem;
  list-style: none;
}
.entry details > summary::-webkit-details-marker {
  display: none;
}
.entry details > summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  rotate: -45deg;
  transition: rotate 200ms var(--ease-out);
}
.entry details[open] > summary::before {
  rotate: 45deg;
}
@media (hover: hover) and (pointer: fine) {
  .entry details > summary:hover {
    color: var(--ink);
  }
}
.entry details pre.code {
  font-size: 0.8125rem;
}
.fields {
  min-width: 520px;
}
.fields td:nth-child(2) {
  min-width: 7rem;
  max-width: 16rem;
}
.fields td:nth-child(2) code {
  white-space: normal;
  overflow-wrap: break-word;
}
.fields td:first-child code {
  white-space: normal;
  overflow-wrap: anywhere;
}
.fields td:first-child {
  min-width: 9rem;
}


.toc-grid {
  columns: 15rem auto;
  column-gap: 32px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}
.toc-grid li {
  break-inside: avoid;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule);
}
.toc-grid a {
  text-decoration: none;
}
.toc-grid .count {
  float: right;
  color: var(--ink-faint);
}

.filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 20px;
}
.filter input {
  flex: 1 1 260px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ink-faint);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  transition: border-color 150ms var(--ease-out);
}
.filter input:focus {
  border-color: var(--ink);
  outline: none;
}
.filter input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.filter output {
  color: var(--ink-soft);
  font-size: 0.875rem;
}
.hidden-by-filter {
  display: none;
}

/* ---- Diagrams ---- */

.diagram {
  margin: 8px 0 28px;
}
.diagram-scroll {
  overflow-x: auto;
  padding: 12px 0 4px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  scrollbar-width: thin;
}
.diagram svg {
  display: block;
  width: 100%;
  /* Every diagram is drawn 860 units wide: below that it scrolls inside its frame at full size, so its text never drops under 12px. */
  min-width: 860px;
  height: auto;
  font-family: var(--sans);
}
.diagram figcaption {
  max-width: var(--measure);
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.d-title {
  font-size: 14px;
  font-weight: 650;
  fill: var(--ink);
}
.d-sub {
  font-size: 12.5px;
  fill: var(--ink-soft);
}
.d-mono {
  font-family: var(--mono);
  font-size: 12px;
}
.d-mono-title {
  font-family: var(--mono);
  font-size: 13px;
}
.d-label {
  font-size: 12px;
  fill: var(--ink-soft);
}
.d-plain rect {
  fill: var(--paper);
  stroke: var(--ink-soft);
  stroke-width: 1;
}
.d-quiet rect {
  fill: var(--paper);
  stroke: var(--ink-faint);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
.d-strong rect {
  fill: var(--band);
  stroke: var(--rule-strong);
  stroke-width: 1;
}
.d-strong .d-title {
  fill: var(--on-band);
}
.d-strong .d-sub {
  fill: var(--on-band-soft);
}
.d-accent rect {
  fill: var(--seal-wash);
  stroke: var(--seal);
  stroke-width: 1.5;
}
.d-frame rect {
  fill: var(--panel);
  stroke: var(--rule);
}
.d-line {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.25;
}
.d-dashed {
  stroke-dasharray: 4 3;
}
.d-head {
  fill: var(--ink-soft);
}

/* ---- Footer ---- */

.foot {
  max-width: 920px;
  margin-top: 64px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--ink-soft);
}
.foot p {
  max-width: var(--measure);
  margin: 0;
}

@media (max-width: 560px) {
  .wordmark-sub,
  .theme-label {
    display: none;
  }
  .doc h1 {
    font-size: 1.625rem;
  }
  .doc h2 {
    font-size: 1.25rem;
    margin-top: 44px;
  }
  .search-field kbd {
    display: none;
  }
}

/* Phones: reference tables become ruled rows, each cell under its column's name, so nothing hides past the edge. */
@media (max-width: 639px) {
  .table-scroll:has(> table.stack) {
    overflow-x: visible;
    background: none;
  }
  table.stack,
  table.stack.fields {
    min-width: 0;
  }
  table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td {
    display: block;
  }
  table.stack tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--rule);
  }
  table.stack tbody tr:first-child {
    border-top: 1px solid var(--rule-strong);
  }
  table.stack td {
    padding: 2px 0;
    border: 0;
    min-width: 0;
    max-width: none;
  }
  table.stack td.empty {
    display: none;
  }
  table.stack td:first-child {
    font-weight: 600;
  }
  /* The column's name hangs to the left of the value, so a value that wraps stays in its own column. */
  table.stack td + td {
    position: relative;
    padding-left: 7.25rem;
  }
  table.stack td + td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    top: 0.3em;
    width: 6.75rem;
    color: var(--ink-faint);
    font-size: 0.8125rem;
    line-height: 1.35;
  }
  table.stack td code,
  table.stack td .nowrap code {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table.stack .route-desc {
    min-width: 0;
  }
}

/* Phones: the search results hang from the band's edges, not from the field, so they never run off the screen. */
@media (max-width: 560px) {
  .search {
    position: static;
  }
  .band-inner {
    position: relative;
  }
  .search-results {
    left: 16px;
    right: 16px;
    top: calc(100% + 6px);
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* A washed entry keeps its wash behind its tables: the scroll shadows' paper covers would show as blocks. */
.entry:has(:target) .table-scroll,
.entry.flash .table-scroll {
  background: none;
}
