/* Keep the handbook readable in both Material palettes and on small screens. */
:root {
  --handbook-radius: 0.65rem;
  --handbook-radius-small: 0.35rem;
  --handbook-text-small: 0.75rem;
  --handbook-space: 1.25rem;
}
[data-md-color-scheme="slate"][data-md-color-primary] {
  --md-typeset-a-color: #a7b8ff;
  --md-accent-fg-color: #c0cbff;
}
.md-typeset {
  font-size: 0.8rem;
  line-height: 1.7;
}
.md-typeset h1 {
  color: var(--md-default-fg-color);
  font-weight: 600;
  letter-spacing: -0.035em;
  margin-bottom: 0.8em;
}
.md-typeset h2 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 1.8em;
}
.md-typeset h3 {
  font-weight: 600;
}
.md-typeset :is(h1, h2, h3) .headerlink {
  font-weight: 400;
}
.md-typeset table:not([class]) {
  width: 100%;
  font-size: var(--handbook-text-small);
  line-height: 1.6;
  border-radius: var(--handbook-radius-small);
}
.md-typeset table:not([class]) th {
  background: var(--md-code-bg-color);
}
.md-typeset pre > code {
  border-radius: var(--handbook-radius-small);
}
.md-typeset img {
  display: block;
  height: auto;
  border-radius: var(--handbook-radius);
}
/* Shared figures: source images retain their original aspect ratios and labels. */
.md-typeset figure.handbook-figure {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: var(--handbook-space) 0 1.75rem;
  text-align: left;
}
.md-typeset .handbook-figure > p {
  margin: 0;
}
.md-typeset .handbook-figure img {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--md-default-fg-color--lightest);
}
.md-typeset .handbook-figure figcaption {
  max-width: 100%;
  margin: 0.65rem 0 0;
  color: var(--md-default-fg-color--light);
  font-size: var(--handbook-text-small);
  font-style: normal;
  line-height: 1.6;
}
.md-typeset .handbook-figure figcaption p {
  margin: 0.4rem 0 0;
}
.md-typeset .handbook-figure .figure-links {
  font-size: var(--handbook-text-small);
}
/* Same spacing and readable type for reference tables, code, and callouts. */
.md-typeset .md-typeset__table {
  display: block;
}
.md-typeset table:not([class]) :is(th, td) {
  padding: 0.7em 0.9em;
  vertical-align: top;
}
.md-typeset :is(.highlight, pre, .admonition, details) {
  margin-top: var(--handbook-space);
  margin-bottom: var(--handbook-space);
}
.md-typeset .highlight pre {
  margin: 0;
}
.md-typeset :is(.admonition, details) {
  font-size: var(--handbook-text-small);
  line-height: 1.65;
  border-radius: var(--handbook-radius-small);
  box-shadow: none;
}
.md-typeset :is(.admonition-title, summary) {
  font-weight: 600;
}
.md-typeset .project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.6rem 0 2rem;
}
.md-typeset .project-card {
  display: flex;
  flex-direction: column;
  padding: 1.35rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: var(--handbook-radius);
  background: var(--md-code-bg-color);
}
.md-typeset .project-card h2 {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.35rem;
}
.md-typeset .project-card h2 a {
  color: var(--md-default-fg-color);
}
.md-typeset .project-card h2 a:hover {
  color: var(--md-accent-fg-color);
}
.md-typeset .project-card > p {
  margin: 0.4rem 0;
}
.md-typeset .project-card > .project-kind {
  color: var(--md-default-fg-color--light);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.md-typeset .project-card > p:last-child {
  margin-top: auto;
  padding-top: 1rem;
}
.md-typeset .project-link {
  font-weight: 600;
}
.md-typeset a:focus-visible {
  outline: 2px solid var(--md-accent-fg-color);
  outline-offset: 4px;
}
@media (max-width: 60em) {
  .md-typeset .project-grid {
    grid-template-columns: 1fr;
  }
  .md-typeset .project-card {
    padding: 1rem;
  }
}

/* One handbook-wide sidebar, with a clear marker for the current page. */
.md-nav--primary a.md-nav__link--active {
  padding: 0.35rem 0.5rem;
  border-radius: var(--handbook-radius-small);
  background: var(--md-accent-fg-color--transparent);
  box-shadow: inset 3px 0 0 var(--md-typeset-a-color);
  color: var(--md-typeset-a-color);
  font-weight: 600;
}
.md-nav--primary a:focus-visible {
  outline: 2px solid var(--md-typeset-a-color);
  outline-offset: 2px;
}
@media screen and (min-width: 76.25em) {
  .md-nav--primary .md-nav__item--section > .md-nav__link {
    margin-top: 1.1rem;
    color: var(--md-default-fg-color);
    font-weight: 650;
  }
  .md-nav--primary .md-nav__link {
    font-size: 0.68rem;
    line-height: 1.4;
  }
  .md-nav--primary .md-nav__item {
    padding-right: 0.3rem;
  }
}

/* Tables remain readable and scroll within their own region on narrow screens. */
.md-typeset table:not([class]) {
  display: table;
  min-width: 100%;
  width: max-content;
  max-width: 100%;
  overflow: visible;
}
.md-typeset table:not([class]) :is(th, td) {
  min-width: 0;
  overflow-wrap: break-word;
}
.md-typeset table:not([class]) th {
  white-space: nowrap;
}
.md-typeset .md-typeset__scrollwrap {
  overflow-x: auto;
}

/* Connection maps use the same type and palette as the equipment lists. */
.md-typeset .connection-map {
  margin: 1.25rem 0;
}
.md-typeset .connection-hub,
.md-typeset .connection-branch {
  padding: 0.85rem 1rem;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: var(--handbook-radius-small);
}
.md-typeset .connection-hub {
  background: var(--md-code-bg-color);
}
.md-typeset .connection-branches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 0.65rem;
}
.md-typeset .connection-branch--pending {
  border-style: dashed;
}
.md-typeset .connection-map p {
  margin: 0 0 0.4rem;
}
.md-typeset .connection-map p:last-child,
.md-typeset .connection-map ul {
  margin-bottom: 0;
}
.md-typeset .connection-map ul {
  margin-top: 0.4rem;
}
@media screen and (max-width: 40em) {
  .md-typeset .connection-branches {
    grid-template-columns: 1fr;
  }
  .md-typeset table:not([class]) {
    min-width: 100%;
    width: 100%;
  }
  .md-typeset table:not([class]) th {
    white-space: normal;
  }
  .md-typeset table:not([class]):has(tr > :nth-child(3)) {
    min-width: 30rem;
  }
  .md-typeset .md-typeset__scrollwrap:has(tr > :nth-child(3))::before {
    content: "Scroll table →";
    display: block;
    padding: 0 0.8rem 0.35rem;
    font-size: 0.65rem;
    color: var(--md-default-fg-color--light);
  }
}
@media print {
  @page { margin: 14mm; }
  body[data-md-color-scheme] {
    background: white !important;
    --md-default-bg-color: white !important;
    --md-default-fg-color: #111 !important;
    --md-default-fg-color--light: #444 !important;
    --md-default-fg-color--lightest: #ccc !important;
    --md-code-bg-color: #f4f4f4 !important;
  }
  .headerlink, .md-footer, .md-header,
  .md-sidebar, .md-tabs, .md-top, .md-dialog {
    display: none !important;
  }
  .md-main__inner, .md-content, .md-content__inner {
    margin: 0 !important;
    padding: 0 !important;
  }
  .md-typeset {
    font-size: 9pt;
    line-height: 1.4;
    color: #111;
  }
  .md-typeset table:not([class]) {
    width: 100%;
    min-width: 0;
    font-size: 9pt;
  }
  .md-typeset table:not([class]) :is(th, td) {
    padding: 0.45em 0.55em;
  }
  .md-typeset .md-typeset__scrollwrap {
    overflow: visible;
    margin: 0;
  }
  .md-typeset .md-typeset__table {
    padding: 0;
  }
  .md-typeset tr, .md-typeset .connection-map {
    break-inside: avoid;
  }
}

/* Keep the complete handbook outline visible in the mobile drawer too. */
@media screen and (max-width: 76.234375em) {
  .md-nav--primary {
    overflow-y: auto;
  }
  .md-nav--primary > .md-nav__list {
    overflow: visible;
    flex-shrink: 0;
    scroll-snap-type: none;
  }
  .md-nav--primary .md-nav[data-md-level="1"] {
    display: block;
    position: static;
    height: auto;
    opacity: 1;
    transform: none;
    visibility: visible;
    transition: none;
  }
  .md-nav--primary .md-nav[data-md-level="1"] > .md-nav__title {
    display: none;
  }
  .md-nav--primary .md-nav[data-md-level="1"] > .md-nav__list {
    overflow: visible;
    box-shadow: none;
  }
  .md-nav--primary .md-nav__item--section > .md-nav__link {
    margin-top: 0.65rem;
    color: var(--md-default-fg-color);
    font-weight: 600;
    pointer-events: none;
  }
  .md-nav--primary .md-nav__item--section > .md-nav__link .md-nav__icon {
    display: none;
  }
  .md-nav--primary .md-nav--secondary {
    position: static;
    height: auto;
    transform: none;
    transition: none;
  }
  .md-nav--primary .md-nav__toggle ~ .md-nav--secondary,
  .md-nav--primary .md-nav--secondary > .md-nav__title {
    display: none;
  }
  .md-nav--primary .md-nav__toggle:checked ~ .md-nav--secondary {
    display: block;
    opacity: 1;
  }
}
