/* Fonts: no PDF exists; the maker's online manual (wiki.two-notes.com) sets
   body and headings in "Nunito Sans" 400/700. Palette: ink #404040 and
   hairline #e1e4e5 from the wiki, purple from the Two notes logo, black
   from the enclosure. */
@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,wght@0,400;0,700;1,400&display=swap");

:root {
  --ink: #404040;    /* body text */
  --accent: #5a3a8c; /* Two notes purple: rules, links, table heads */
  --band: #111;      /* the enclosure: title bar */
  --rule: #e1e4e5;   /* hairlines */
  --paper: #f3f1f7;  /* tint behind callouts */
  --muted: #6b6b6b;
  --link: #5a3a8c;
  --body-font: "Nunito Sans", system-ui, sans-serif;
  --head-font: var(--body-font);
}

/* ---- structure: keep as is, restyle below the brand line ---- */

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

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family: var(--body-font);
  font-size: 1rem;
  line-height: 1.6;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--head-font); line-height: 1.2; }

main { margin-left: 20vw; padding-bottom: 3em; }
footer { margin-left: 20vw; padding: 1.6em 3em; }

a { color: var(--link); }

img { max-width: 100%; height: auto; margin-bottom: 0.75em; }
.topic > img, li > img, figure > img { display: block; }
figure { margin: 0 0 1em; }

/* NAV */
#side-nav {
  position: fixed; top: 0; left: 0;
  width: 20vw; height: 100%;
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--rule);
  z-index: 5;
}
.nav-container { display: flex; flex-direction: column; margin: 1.5em 1em; }
#side-nav h4, #side-nav h5 { font-weight: 400; margin-bottom: 0.45em; }
#side-nav h4 { font-weight: 700; }
#side-nav h5 { font-size: 0.9em; margin-left: 1em; }
#side-nav a, #toc-mobile a { color: inherit; text-decoration: none; }
#side-nav a:hover, #toc-mobile a:hover { text-decoration: underline; }

/* SECTIONS */
section + section { margin-top: 3em; }
.flex-container { display: flex; padding-left: 2em; }
.half-container { width: 100%; padding: 0 1em; container-type: inline-size; }
.half-container > header { column-span: all; }
.flow > * + * { margin-bottom: 1em; }

/* One .topic per heading carries the columns, so no column runs taller than
   one topic. 63rem below = the two-column threshold of `columns: 2 30rem`. */
.topic { columns: 2 30rem; column-gap: 3em; }
.no-columns { columns: auto !important; }

/* COLUMN BREAKS. A paragraph, list item, figure, table or callout is never
   cut by the gutter. Chrome's balancer drops `break-after: avoid` when it
   gets in the way, so it is only a hint: what keeps a heading off a column's
   foot is a .keep-together holding the heading and its first block. */
p, li, figure, table, .table-scroll, .keep-together, .callout, .grid-wrapper {
  break-inside: avoid;
}
h2, h3, h4, h5, h6 { break-after: avoid; }
/* a lead-in ending in ":" stays with what it introduces */
:has(+ p > .menu-path:only-child) { break-after: avoid; }
@container (min-width: 63rem) {
  .column-end { break-after: column; }
}

/* Figure rows: the max stays indefinite, or auto-fit counts its tracks off
   it and stacks one figure per row in a narrow column. */
.grid-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(8em, 100%), 1fr));
  gap: 1em;
}
.grid-wrapper img { width: 100%; }

/* TABLES */
.table-scroll { overflow-x: auto; margin-bottom: 1em; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.doc-table th, .doc-table td {
  padding: 0.4em 0.6em;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--rule);
}
.doc-table thead th { background: var(--accent); color: #fff; }

.callout {
  background: var(--paper);
  border-left: 4px solid var(--accent);
  padding: 0.7em 1em;
  margin-bottom: 1em;
}
.callout > :last-child { margin-bottom: 0; }

@media (max-width: 900px) {
  .flex-container { flex-direction: column; padding-left: 0; }
  .half-container { padding: 0 1em; }
  nav { display: none; }
  main, footer { margin: 0 auto; }
  footer { padding: 1.6em 1em; }
  #toc-mobile { display: block; }
  /* a diagram with small labels scrolls instead of shrinking */
  .wide-figure { overflow-x: auto; }
  .wide-figure img { min-width: 700px; }
}
/* 901, not 900: at exactly 900px both queries match and the mobile TOC
   would vanish together with the nav */
@media (min-width: 901px) { #toc-mobile { display: none; } }

/* ---- brand: masthead, heading treatment, callouts, from this manual ---- */

h1, h2, h3, h4 { font-weight: 700; color: var(--ink); }
h2 { font-size: 2em; margin-bottom: 0.6em; padding-bottom: 0.25em; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.4em; margin-bottom: 0.4em; }
h4 { font-size: 1.12em; margin-bottom: 0.3em; }
.topic.level-3 { padding-top: 0.6em; }
#side-nav h4 { font-size: 0.95em; }
#toc-mobile h4 { margin-bottom: 0.45em; }

/* MASTHEAD: logo and the enclosure's white-on-black label beside the render */
#masthead {
  display: flex; align-items: center; gap: 2em; flex-wrap: wrap;
  max-width: 60em; padding: 2em 3em 1em;
}
#masthead .mark { flex: 1 1 18em; }
#masthead .logo { width: 16em; margin-bottom: 1.2em; }
.title-band { background: var(--band); color: #fff; padding: 1em 1.4em 1.2em; }
.title-band h1 { color: #fff; font-size: 2.6em; margin: 0; }
.title-band p { margin: 0; font-size: 1.1em; }
.title-band .doc { text-transform: uppercase; letter-spacing: 2px; font-size: 0.85em; opacity: 0.8; }
/* min-width 0: the img width attribute would otherwise stop it shrinking and wrap the row */
#masthead .render { flex: 0 1 20em; min-width: 0; margin: 0; }

.doc-update {
  background: var(--paper);
  border-left: 4px solid var(--accent);
  padding: 1em 1.25em;
}

/* WARNINGS: the wiki's triangle pictogram beside bold text */
.callout.warn { display: grid; grid-template-columns: 3em 1fr; gap: 1em; align-items: start; }
.callout.warn img { width: 3em; margin: 0; }
.callout.warn p { margin: 0; }
.callout.bold p { font-weight: 700; }
.note { font-style: italic; }

.marks { display: flex; gap: 1.5em; align-items: center; }
.marks img { height: 4em; width: auto; margin: 0; }

/* diagrams with small printed labels keep their native width */
.diagram { max-width: min(50em, 100%); }
.diagram img { width: 100%; }
.panel-list { padding-left: 1.6em; }
.support-address p { margin: 0; }
.doc-table .group td { font-weight: 700; }
.spec dt { font-weight: 700; }
.spec dd { margin: 0 0 0.6em; }

@media (max-width: 900px) {
  #masthead { padding: 1.5em 1em 0.5em; }
  .title-band h1 { font-size: 2em; }
}
/* front and rear panel sit side by side under one heading */
.panel-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 1em 3em; }
/* A topic's own heading runs over both columns, so the right column reads
   as the second half of that topic rather than as a row beside it. */
.topic > h3, .topic > h4 { column-span: all; }
/* a wiring diagram needs the full width to keep its labels legible */
.topic > .span-all { column-span: all; }
