/* --- Docs (DESIGN.md § Docs, decided 2026-10-16): the public documentation at
   /docs. The Rails header with a `Docs` section link, the sections on the left,
   the page in a reading column, and its contents on the right. Only the
   system's tokens, type scale, hairlines and radii; no shadow, no new colour.
   Below 1100px the contents column goes; below 900px the sections fold into a
   `Docs menu` disclosure above the page. --- */

/* A line icon (IconHelper, DESIGN.md § Icons): it takes the colour of its text. */
.icon {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

.docs-skip {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 10;
  padding: 8px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-ctl);
  background: var(--canvas);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.docs-skip:focus {
  top: 12px;
}

.docs-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

.docs-header__section {
  padding-left: var(--space-md);
  border-left: 1px solid var(--rule-strong);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 24px;
  text-decoration: none;
}

.docs-header__section:hover {
  color: var(--primary);
}

.docs {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 208px;
  max-width: 1440px;
  margin: 0 auto;
}

.docs-menu {
  display: none;
}

.docs-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
  border-right: 1px solid var(--rule);
}

.docs-nav__section {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: var(--space-lg) 0 var(--space-xs);
  padding: 0 var(--space-sm);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-nav__section:first-child {
  margin-top: 0;
}

.docs-nav__list,
.docs-nav__sub {
  list-style: none;
}

.docs-nav__sub {
  margin: 2px 0 var(--space-xs) var(--space-sm);
  padding-left: var(--space-sm);
  border-left: 1px solid var(--rule);
}

.docs-nav__link {
  display: block;
  padding: 4px var(--space-sm);
  border-radius: var(--r-ctl);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.docs-nav__link--sub {
  font-size: 12.5px;
  color: var(--muted);
}

.docs-nav__link:hover {
  background: var(--panel);
  color: var(--ink);
}

.docs-nav__link[aria-current="page"] {
  background: var(--panel-2);
  color: var(--primary);
  font-weight: 600;
}

/* The dataset pages fold under Datasets except where the reader is among them. */
.docs-nav__more-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 2px var(--space-sm);
  padding: 2px var(--space-sm);
  border-radius: var(--r-ctl);
  list-style: none;
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}

.docs-nav__more-summary::-webkit-details-marker {
  display: none;
}

.docs-nav__more-summary::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(-45deg);
}

.docs-nav__more[open] > .docs-nav__more-summary::before {
  transform: rotate(45deg);
}

.docs-nav__more-summary:hover {
  color: var(--primary);
}

.docs-main {
  min-width: 0;
  padding: var(--space-2xl) var(--space-xl) var(--space-3xl);
}

.docs-main:focus {
  outline: none;
}

/* Prose keeps a reading measure; tables take the column's width. */
.docs-article,
.docs-foot {
  max-width: 960px;
}

.docs-lede,
.docs-body > p,
.docs-body > ul,
.docs-body > ol,
.docs-body > .docs-note,
.docs-body > .docs-code {
  max-width: 80ch;
}

.docs-head {
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--rule);
}

.docs-eyebrow {
  margin-bottom: var(--space-sm);
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-title {
  font-size: clamp(34px, 6vw, 44px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
}

.docs-lede {
  max-width: 72ch;
  margin-top: var(--space-md);
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
}

/* A dataset's summary is a paragraph, not a line: the body size. */
.docs-lede--dataset {
  max-width: 80ch;
  font-size: 15px;
  line-height: 1.6;
}

/* A provenance stamp: 9px mono capitals in a hairline box, the drafted 2px radius. */
.docs-stamps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.docs-stamp {
  padding: 2px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-data);
  font-family: var(--font-data);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.docs-stamp--muted {
  color: var(--muted);
}

.docs-markdown {
  margin-top: var(--space-md);
  font-size: 12.5px;
}

.docs-markdown a,
.docs-foot a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-markdown a:hover,
.docs-foot a:hover {
  color: var(--primary);
}

.docs-body {
  margin-top: var(--space-xl);
  overflow-wrap: break-word;
  counter-reset: docs-section;
  font-size: 15px;
}

/* A section opens on a hairline with its number over the heading, as the
   report's summary numbers its points (10px mono, `--muted`). */
.docs-body h2 {
  scroll-margin-top: var(--space-lg);
  margin: var(--space-2xl) 0 var(--space-md);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--rule);
  counter-increment: docs-section;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.docs-body h2::before {
  content: counter(docs-section, decimal-leading-zero);
  display: block;
  margin-bottom: var(--space-sm);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* The page head already closes on a hairline. */
.docs-body > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.docs-body h3 {
  scroll-margin-top: var(--space-lg);
  margin: var(--space-xl) 0 var(--space-sm);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.docs-body h4 {
  scroll-margin-top: var(--space-lg);
  margin: var(--space-lg) 0 var(--space-xs);
  font-size: 15px;
  font-weight: 600;
}

.docs-body p,
.docs-body ul,
.docs-body ol {
  margin-bottom: 12px;
  line-height: 1.65;
}

/* Numbered steps: the number is a mono figure in a hairline box. */
.docs-body ol {
  padding-left: 0;
  list-style: none;
  counter-reset: docs-step;
}

.docs-body ol > li {
  position: relative;
  margin-bottom: 10px;
  padding-left: 36px;
  counter-increment: docs-step;
}

.docs-body ol > li::before {
  content: counter(docs-step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-data);
  background: var(--panel);
  font: 500 11px/20px var(--font-data);
  text-align: center;
  color: var(--ink);
}

.docs-body ul > li::marker {
  color: var(--muted);
}

/* An API operation (`#### \`GET /path\``): the method as a stamp, the path in mono. */
.docs-body .docs-endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px dashed var(--rule);
  font-size: 15px;
}

.docs-method {
  padding: 1px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-data);
  background: var(--panel-2);
  font: 600 10px/1.6 var(--font-data);
  letter-spacing: 0.1em;
  color: var(--ink);
}

/* The first operation under its group's h3 needs no rule of its own. */
.docs-body h3 + .docs-endpoint {
  margin-top: var(--space-sm);
  padding-top: 0;
  border-top: none;
}

.docs-body .docs-endpoint code {
  padding: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
}

.docs-body ul {
  padding-left: var(--space-lg);
}

.docs-body li {
  margin-bottom: 6px;
}

.docs-body a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-body a:hover {
  color: var(--primary-hover);
}

.docs-body code {
  padding: 0 4px;
  border-radius: var(--r-chip);
  background: var(--panel-2);
  font-family: var(--font-data);
  font-size: 0.86em;
}

.docs-note {
  margin: var(--space-md) 0;
  padding: 12px var(--space-md);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
  background: var(--panel);
  font-size: 14px;
}

.docs-note p:last-child {
  margin-bottom: 0;
}

/* A labelled callout (`> [!NOTE]`, `> [!WARNING]`, ...): the note's plate with
   a 10px mono label in the semantic colour; a warning also takes that colour
   on its hairline. No side stripe, no fill colour. */
.docs-note__label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--info);
}

.docs-note--important .docs-note__label {
  color: var(--ink);
}

.docs-note--warning {
  border-color: var(--warning);
}

.docs-note--warning .docs-note__label {
  color: var(--warning);
}

/* Tables scroll sideways inside their own frame; the page never does. */
.docs-table {
  margin: var(--space-md) 0;
  overflow-x: auto;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
}

.docs-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.45;
}

.docs-table th {
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--rule-strong);
  font-family: var(--font-data);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.docs-table td {
  padding: 8px 12px;
  border-top: 1px solid var(--rule);
  vertical-align: top;
  min-width: 10ch;
}

/* A unit or a rule is a sentence: give it room to read as one. */
.docs-table td:nth-child(n+3) {
  min-width: 22ch;
}

.docs-table tr:first-child td {
  border-top: none;
}

.docs-table tbody tr:hover td {
  background: var(--panel);
}

.docs-table td a {
  overflow-wrap: anywhere;
}

.docs-table td code {
  white-space: nowrap;
}

.docs-table:focus-visible,
.docs-code pre:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.docs-code {
  margin: var(--space-md) 0;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
  background: var(--panel);
}

.docs-code {
  overflow: hidden;
}

.docs-code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 4px 4px 4px 12px;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--panel-2);
}

.docs-code__lang {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-code__copy {
  padding: 3px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-ctl);
  background: var(--canvas);
  color: var(--ink);
  font: 600 12px/1.5 var(--font-ui);
  cursor: pointer;
}

.docs-code__copy:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.docs-code pre {
  margin: 0;
  padding: 14px var(--space-md);
  overflow-x: auto;
  font-family: var(--font-data);
  font-size: 12.5px;
  line-height: 1.55;
}

.docs-code--wrap pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.docs-code pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* The docs home's ways in: the agent directory's plates, numbered like a plat's
   parcels, each a link to its page. */
.docs-entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.docs-entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) 20px 20px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
}

.docs-entry:hover {
  border-color: var(--primary);
}

.docs-entry:hover .docs-entry__title {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.docs-entry__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-entry__no {
  color: var(--ink);
}

/* The page's icon in the agents' 36px mark box. */
.docs-entry__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-data);
  background: var(--canvas);
  color: var(--primary);
}

.docs-entry__meta {
  padding-top: 2px;
  text-align: right;
}

.docs-entry__title {
  margin-top: var(--space-xs);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--primary);
}

.docs-entry__body {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.docs-entry__path {
  align-self: flex-start;
  margin-top: auto;
  padding: 2px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-data);
  background: var(--canvas);
  font-family: var(--font-data);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* A dataset page's source at a glance, above its tables: the register's
   ledger cells, a 9px mono label over the value. */
.docs-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: var(--space-xl);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
  background: var(--panel);
  overflow: hidden;
}

.docs-facts__item {
  padding: 12px var(--space-md);
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: 0 -1px -1px 0;
}

.docs-facts__item--wide {
  grid-column: span 2;
}

.docs-facts dt {
  margin-bottom: 4px;
  font-family: var(--font-data);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-facts dd {
  font-size: 13.5px;
  line-height: 1.45;
}

.docs-facts__figure {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
}

/* Previous and next: two plates at the foot of the page. */
.docs-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
  max-width: 960px;
  margin-top: var(--space-3xl);
}

.docs-pager__link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px var(--space-md);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-box);
  color: var(--ink);
  text-decoration: none;
}

.docs-pager__link:hover {
  border-color: var(--primary);
}

.docs-pager__link--next {
  grid-column: 2;
  text-align: right;
}

.docs-pager__dir {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-pager__link--prev .docs-pager__dir::before {
  content: "← ";
}

.docs-pager__link--next .docs-pager__dir::after {
  content: " →";
}

.docs-pager__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.docs-foot {
  margin-top: var(--space-2xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--muted);
}

.docs-toc {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  padding: var(--space-2xl) var(--space-md) var(--space-lg) 0;
  font-size: 12.5px;
}

.docs-toc__title {
  margin-bottom: var(--space-sm);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-toc ul {
  list-style: none;
  border-left: 1px solid var(--rule);
  counter-reset: docs-toc;
}

.docs-toc li {
  counter-increment: docs-toc;
}

.docs-toc a {
  display: flex;
  gap: 8px;
  margin-left: -1px;
  padding: 3px 0 3px 12px;
  border-left: 1px solid transparent;
  color: var(--muted);
  line-height: 1.4;
  text-decoration: none;
}

/* The section numbers match the page's h2s. */
.docs-toc a::before {
  content: counter(docs-toc, decimal-leading-zero);
  flex: none;
  padding-top: 2px;
  font: 400 10px/1.4 var(--font-data);
  letter-spacing: 0.08em;
  color: var(--muted);
}

.docs-toc a:hover {
  color: var(--primary);
}

/* The section in view (docs.js): `--ink` text on a `--primary` stretch of the
   guide, as the active tab's underline. */
.docs-toc a[aria-current="true"] {
  border-left-color: var(--primary);
  color: var(--ink);
  font-weight: 500;
}

.docs-nav__link:focus-visible,
.docs-toc a:focus-visible,
.docs-header__section:focus-visible,
.docs-code__copy:focus-visible,
.docs-menu__summary:focus-visible,
.docs-nav__more-summary:focus-visible,
.docs-entry:focus-visible,
.docs-pager__link:focus-visible,
.docs-skip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .docs-nav__link,
  .docs-toc a,
  .docs-header__section,
  .docs-code__copy,
  .docs-entry,
  .docs-pager__link,
  .docs-nav__more-summary {
    transition: background-color var(--t-ui), border-color var(--t-ui), color var(--t-ui);
  }
}

@media (max-width: 1099px) {
  .docs {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .docs-toc {
    display: none;
  }
}

@media (max-width: 899px) {
  .docs {
    display: block;
  }

  .docs-sidebar {
    display: none;
  }

  .docs-menu {
    display: block;
    border-bottom: 1px solid var(--rule);
  }

  .docs-menu__summary {
    display: flex;
    gap: var(--space-sm);
    padding: 12px var(--space-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }

  .docs-menu__summary {
    align-items: center;
    list-style: none;
  }

  .docs-menu__summary::-webkit-details-marker {
    display: none;
  }

  .docs-menu__summary::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    margin-right: 2px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
  }

  .docs-menu[open] > .docs-menu__summary::before {
    transform: rotate(45deg);
  }

  .docs-menu__current {
    min-width: 0;
    overflow: hidden;
    font-weight: 400;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .docs-menu__current::before {
    content: "· ";
  }

  .docs-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .docs-body h2 {
    font-size: 24px;
  }

  .docs-menu .docs-nav {
    padding: 0 var(--space-md) var(--space-md);
  }

  .docs-main {
    padding: var(--space-xl) var(--space-md) var(--space-2xl);
  }

  .docs-header .docs-header__section {
    font-size: 13px;
  }
}

@media (max-width: 599px) {
  /* On a phone the ways in are a compact two-column index: number, section
     and title; the descriptions are the pages' own ledes. */
  .docs-entries {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
    margin-top: var(--space-lg);
  }

  .docs-entry {
    gap: var(--space-xs);
    padding: 12px;
  }

  .docs-entry__section,
  .docs-entry__body,
  .docs-entry__path {
    display: none;
  }

  .docs-entry__title {
    font-size: 15px;
  }

  .docs-entry__icon {
    width: 28px;
    height: 28px;
  }

  .docs-entry:last-child:nth-child(odd) {
    grid-column: span 2;
  }

  .docs-pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .docs-pager__link--next {
    grid-column: 1;
  }
}

@media (max-width: 420px) {
  .docs-header__brand {
    gap: 12px;
  }

  .docs-header__section {
    padding-left: 12px;
  }
}

@media print {
  .docs-header,
  .docs-menu,
  .docs-sidebar,
  .docs-toc,
  .docs-markdown,
  .docs-code__copy,
  .docs-pager,
  .docs-foot {
    display: none;
  }

  .docs {
    display: block;
  }

  .docs-main,
  .docs-main * {
    color: black !important;
  }
}
