/* Fonts: AvenirNext-Regular 400 -> Montserrat 400, AvenirNext-Bold 700 -> Montserrat 700,
   AvenirNext-DemiBold 600 -> Montserrat 600 (TOC), AvenirNext-Italic -> Montserrat 400i,
   Muli-Light 300 -> Mulish 300, Muli-Bold 700 -> Mulish 700 (table labels),
   Bicyclette -> Montserrat (cover title, callout numbers); same mapping as pirate-midi-bridge4 */
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,600;0,700;1,400&family=Mulish:wght@300;400;700&display=swap");

:root {
  --ink: #070707;    /* body text */
  --accent: #ee576e; /* the cover gradient's midpoint */
  --grad-from: #f15a5b;
  --grad-to: #ef527f;
  --rule: #221e1f;   /* table grid */
  --paper: #dcdddf;  /* tech-info tiles and callouts */
  --muted: #555658;
  --link: #0000ee;
  --body-font: "Montserrat", 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; }
h3 { font-size: 1.4em; margin-bottom: 0.4em; }
h4 { font-size: 1.12em; margin-bottom: 0.3em; }
/* front-matter titles are set in caps, chapter titles in title case */
h2.caps { text-transform: uppercase; }
#side-nav h4 { font-weight: 600; font-size: 0.95em; }
#toc-mobile h4 { font-weight: 600; margin-bottom: 0.45em; }

/* MASTHEAD: the cover's photo, white mark strip, red-to-pink title panel */
#masthead { max-width: 44em; padding: 2em 3em 0; }
#masthead .photo { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0; }
.masthead-mark {
  display: flex; align-items: center; gap: 1.5em;
  padding: 1em 2em; background: #fff;
}
.masthead-mark img { height: 2.2em; width: auto; margin: 0; filter: invert(1); }
.masthead-mark span, .masthead-title p {
  font-weight: 300; text-transform: uppercase; letter-spacing: 2px;
}
.masthead-mark span { font-size: 0.8em; white-space: nowrap; }
.masthead-title {
  background: linear-gradient(90deg, var(--grad-from), var(--grad-to));
  color: #fff; padding: 1.4em 2em 1.8em;
}
.masthead-title h1 { color: #fff; font-size: 2.6em; text-transform: uppercase; margin: 0; }
.masthead-title h1 small { font-size: 0.5em; }
.masthead-title p { margin: 0; font-size: 1.1em; line-height: 1.5; }

.lead { font-weight: 700; font-size: 1.15em; }
.overview-body { font-family: "Mulish", sans-serif; font-weight: 300; font-size: 1.05em; }

/* TECH INFO: grey tiles, small caps labels */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: 0.8em; margin-bottom: 1em; }
.tile { background: var(--paper); padding: 0.8em 1em; }
.tile.wide { grid-column: 1 / -1; }
.tile h3 { font-size: 0.8em; text-transform: uppercase; color: var(--muted); letter-spacing: 1px; margin-bottom: 0.3em; }
.tile p, .tile ul { margin: 0; }
.tile ul { padding-left: 1.2em; }

/* HARDWARE: each photo above its numbered list */
.hw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(24em, 100%), 1fr)); column-gap: 3em; }
.hw-grid img { width: 100%; }
.hw-list { padding-left: 2.2em; }
.hw-list li { margin-bottom: 0.9em; padding-left: 0.3em; }
.hw-list li::marker { content: counter(list-item) "  "; font-size: 1.5em; }

/* CALLOUTS: grey box with a red tab (Quick Start), icon + italic note (p13) */
.callout { border-left: 0; border-top: 6px solid var(--grad-from); }
.icon-note { display: flex; gap: 1em; align-items: flex-start; margin-bottom: 1em; }
.icon-note img { width: 50px; margin: 0; flex: none; }
.icon-note p { margin: 0; }
.icon-note em { display: block; }
.coffee { text-align: center; font-style: italic; margin: 2em 0; }
.coffee img { display: block; width: 64px; margin: 0 auto 0.5em; }

.power-icons { display: flex; flex-wrap: wrap; gap: 1em 3em; align-items: center; margin-bottom: 1em; }
.power-icons figure { display: flex; align-items: center; gap: 0.8em; margin: 0; font-size: 0.85em; }
.power-icons img { height: 2em; width: auto; margin: 0; }

.screenshot { max-width: min(36em, 100%); }
.screenshot.phone { max-width: min(16em, 100%); }

/* passages from the maker's newer online documentation */
.web-note { border-left: 3px solid var(--accent); padding-left: 0.75em; }
.doc-update { background: #f1f1f1; border-left: 4px solid var(--accent); padding: 1em 1.25em; margin-bottom: 1.5em; }
.doc-update > strong { display: block; text-transform: uppercase; }

/* MIDI table: dark grid, grey header, pale group rows */
.doc-table thead th { background: #cfcfcf; color: var(--ink); font-family: "Mulish", sans-serif; font-weight: 700; text-transform: uppercase; }
.doc-table tr.group td { background: #f1f1f1; font-family: "Mulish", sans-serif; font-weight: 700; }

.made-in { text-align: center; font-weight: 700; text-transform: uppercase; }
.made-in img { display: block; width: 120px; margin: 0 auto 0.3em; }
code { font-size: 0.95em; }
footer { color: var(--muted); font-size: 0.85em; }

@media (max-width: 900px) {
  #masthead { padding: 1em 1em 0; }
  .masthead-title h1 { font-size: 2em; }
}
.doc-table tr.web-row td:first-child { box-shadow: inset 3px 0 var(--accent); }
.web-tag { color: var(--muted); font-size: 0.85em; }
/* printed URLs are long unbroken strings */
a { overflow-wrap: anywhere; }

.topic + .topic { margin-top: 1.5em; }
#masthead + section { margin-top: 3em; }
/* each example's Setup / Action / Result reads as one unit */
.examples .topic ul { break-inside: avoid; }
.callout-icon { width: 28px; display: block; margin-bottom: 0.4em; }
.downloads h3 { font-size: 0.95em; text-transform: uppercase; }
.doc-table td:nth-child(n+2), .doc-table th { white-space: nowrap; }
/* a single-column topic keeps a readable measure */
.topic.no-columns { max-width: 48em; }
