/* Production content accents, scoped away from Zensical's runtime chrome. */

.md-typeset table thead th {
  background-color: var(--brand-surface);
  color: var(--md-default-fg-color);
}

/* Source-row links preserve the visible [SNN] grammar while each identity
   remains its own native, keyboard-focusable link. */

.md-typeset a.source-citation::before {
  content: "[";
}

.md-typeset a.source-citation::after {
  content: "]";
}

/* Static reference structure. Markdown keeps headings, links and tables native. */
.md-typeset :is(h2, h3).section-heading {
  padding: .65rem .85rem;
  border: var(--component-border-width) solid var(--border);
  border-radius: var(--component-radius);
  background: var(--brand-surface);
  color: var(--text);
}

/* Long reference entries stay in one column and remain fully visible. */
.md-typeset .reference-entry {
  min-width: 0;
  margin-block: 1.1rem;
  padding: 0 1rem 1rem;
  border: var(--component-border-width) solid var(--border);
  border-radius: var(--component-radius);
  background: var(--surface);
  color: var(--text);
}

.md-typeset .reference-entry > :is(h2, h3) {
  margin: 0 -1rem .85rem;
  padding: .65rem 1rem;
  border-block-end: var(--component-border-width) solid var(--border);
  border-start-start-radius: calc(var(--component-radius) - var(--component-border-width));
  border-start-end-radius: calc(var(--component-radius) - var(--component-border-width));
  background: var(--brand-surface);
  color: var(--text);
}

.md-typeset .reference-entry > :last-child,
.md-typeset .reference-link > :last-child {
  margin-block-end: 0;
}

/* Only concise reading routes use a grid. Each ordinary link stays independent. */
.md-typeset .reference-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.5rem), 1fr));
  gap: .75rem;
  margin-block: 1rem;
}

.md-typeset .reference-link {
  min-width: 0;
  padding: .85rem 1rem;
  border: var(--component-border-width) solid var(--border);
  border-radius: var(--component-radius);
  background: var(--surface);
  color: var(--text);
}

.md-typeset .reference-link > :first-child {
  margin-block-start: 0;
}

.md-typeset .reference-link:focus-within {
  border-color: var(--focus);
}

/* Source records keep their native six-column table and exact row anchors. */
.md-typeset .source-register {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

/* The register itself owns scrolling; remove the renderer's nested scroll
   rail and negative margins so only one horizontal control is required. */
.md-typeset .source-register .md-typeset__scrollwrap {
  margin-inline: 0;
  overflow: visible;
}

.md-typeset .source-register .md-typeset__table {
  display: block;
  padding: 0;
  overflow: visible;
}

.md-typeset .source-register table:not([class]) {
  display: table;
  width: 100%;
  min-width: 44rem;
  table-layout: fixed;
}

.md-typeset .source-register table:not([class]) th {
  min-width: 0;
  box-sizing: border-box;
}

.md-typeset .source-register :is(th, td) {
  padding-inline: .65em;
}

.md-typeset .source-register th:nth-child(1) { width: 5.5%; }
.md-typeset .source-register th:nth-child(2) { width: 22.5%; }
.md-typeset .source-register th:nth-child(3) { width: 12%; }
.md-typeset .source-register th:nth-child(4) { width: 13%; }
.md-typeset .source-register th:nth-child(5) { width: 11%; }
.md-typeset .source-register th:nth-child(6) { width: 36%; }

.md-typeset .source-register :is(th, td):is(:first-child, :nth-child(5)) {
  white-space: nowrap;
}

@media screen and (max-width: 44.984375em) {
  .md-typeset .reference-entry {
    padding-inline: .75rem;
  }

  .md-typeset .reference-entry > :is(h2, h3) {
    margin-inline: -.75rem;
    padding-inline: .75rem;
  }

  .md-typeset .reference-links {
    grid-template-columns: minmax(0, 1fr);
  }

  .md-typeset .reference-link {
    padding-inline: .75rem;
  }
}

@media print {
  .md-typeset .source-register {
    overflow: visible;
  }

  .md-typeset .source-register table:not([class]) {
    min-width: 0;
    table-layout: auto;
  }

  .md-typeset .source-register :is(th, td):is(:first-child, :nth-child(5)) {
    white-space: normal;
  }

  .md-typeset .reference-links {
    display: block;
  }

  .md-typeset .reference-entry,
  .md-typeset .reference-link {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #000;
    box-shadow: none;
    break-inside: auto;
  }

  .md-typeset :is(h2, h3).section-heading,
  .md-typeset .reference-entry > :is(h2, h3) {
    margin-inline: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #000;
    break-after: avoid;
    break-inside: avoid;
  }

  .md-typeset .reference-link {
    margin-block: .85rem;
    break-inside: avoid;
  }

  .md-typeset :is(.reference-entry, .reference-link) p {
    orphans: 3;
    widows: 3;
  }

  .md-typeset :is(.reference-entry, .reference-link, .section-heading) a {
    color: inherit !important;
  }
}
