/* vnx.tools — a field-survey reference: spruce ink on cool paper, a trail-marker
   amber for the pre-release band and for highlights, a narrow reading column
   with the section list to its left on wide screens. System fonts only, because
   the site's security policy loads nothing from other hosts. */
:root {
  --paper: #f6f8f7;
  --paper-2: #e9eeec;
  --ink: #16211e;
  --ink-2: #4a5a55;
  --rule: #cfd8d4;
  --spruce: #1f5c4e;
  --link: #1b5e8c;
  --amber: #f2b53a;
  --amber-ink: #3d2a00;
  --hl-a: #c4570f;
  --hl-b: #1b6fb0;
  --code-bg: #eef2f0;

  --f-head: "Avenir Next", "Segoe UI Variable Display", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --f-body: "Charter", "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --f-ui: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --measure: 44rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101715; --paper-2: #18221f; --ink: #e3ebe7; --ink-2: #9fb0aa; --rule: #2c3a36;
    --spruce: #7cc2ad; --link: #86bde6; --amber: #f2b53a; --amber-ink: #2b1d00;
    --hl-a: #f08a4b; --hl-b: #6cb2ea; --code-bg: #17201d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #101715; --paper-2: #18221f; --ink: #e3ebe7; --ink-2: #9fb0aa; --rule: #2c3a36;
  --spruce: #7cc2ad; --link: #86bde6; --amber: #f2b53a; --amber-ink: #2b1d00;
  --hl-a: #f08a4b; --hl-b: #6cb2ea; --code-bg: #17201d;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.6 var(--f-body);
}
.wrap {
  max-width: 76rem;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Pre-release band */
.prerelease {
  background: var(--amber);
  color: var(--amber-ink);
  font: 500 0.82rem/1.3 var(--f-ui);
}
.prerelease .wrap { padding-block: 0.3rem; }
.prerelease strong { text-transform: uppercase; letter-spacing: 0.06em; margin-right: 0.35rem; font-weight: 700; }

/* Header */
header.site { border-bottom: 1px solid var(--rule); background: var(--paper); }
header.site .wrap { display: flex; align-items: center; gap: 0.5rem 1.5rem; padding-block: 0.55rem; position: relative; }
.brand { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ink); text-decoration: none; font: 700 1.1rem/1 var(--f-head); letter-spacing: 0.04em; flex: none; }
.brand svg { width: 1.8rem; height: 1.1rem; }
.brand path { fill: none; stroke: var(--hl-a); stroke-width: 2.5; stroke-linecap: round; }
.brand circle { fill: var(--spruce); }
nav.primary { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; font: 500 0.95rem/1.4 var(--f-ui); }
nav.primary a { color: var(--ink-2); text-decoration: none; padding-block: 0.25rem; border-bottom: 2px solid transparent; }
nav.primary a:hover { color: var(--ink); }
nav.primary a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--hl-a); }

/* The phone menu: a disclosure in place of the inline links */
.menu { display: none; margin-left: auto; font: 500 0.95rem/1.4 var(--f-ui); }
.menu summary { list-style: none; cursor: pointer; padding: 0.3rem 0.75rem; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--paper-2); }
.menu nav { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(100% - 0.2rem); z-index: 5; display: grid; min-width: 12rem; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 0.4rem; box-shadow: 0 6px 24px rgb(0 0 0 / 0.12); }
.menu nav a { padding: 0.5rem 0.7rem; color: var(--ink); text-decoration: none; border-radius: 4px; }
.menu nav a[aria-current="page"] { background: var(--paper-2); font-weight: 600; }
@media (max-width: 48rem) {
  nav.primary { display: none; }
  .menu { display: block; }
}

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; padding-block: 1.5rem 4rem; }
.layout.has-toc { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 64rem) {
  .layout.has-toc { grid-template-columns: 15rem minmax(0, var(--measure)); justify-content: start; gap: 3.5rem; }
  .layout:not(.has-toc) main { max-width: var(--measure); margin-inline: auto; }
  .toc { position: sticky; top: 1rem; align-self: start; max-height: calc(100vh - 2rem); overflow-y: auto; }
}
.toc-inline { display: none; }
@media (max-width: 63.99rem) {
  .toc-side { display: none; }
  .toc-inline { display: block; border: 1px solid var(--rule); border-radius: 6px; padding: 0.55rem 0.9rem; background: var(--paper-2); margin: 0 0 1.2rem; }
  .toc-inline summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
  .toc-inline ol { margin-top: 0.6rem; max-height: 18rem; overflow-y: auto; }
}
main { min-width: 0; }
.toc { font: 0.875rem/1.45 var(--f-ui); }
.toc-title { margin: 0 0 0.5rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--ink-2); }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.toc li.l3 { padding-left: 0.9rem; }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--link); }

/* Prose */
.prose { max-width: var(--measure); }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--f-head); line-height: 1.2; text-wrap: balance; scroll-margin-top: 1rem; position: relative; }
.prose h1 { font-size: clamp(1.7rem, 1.3rem + 1.8vw, 2.4rem); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.9rem; }
.prose h2 { font-size: 1.6rem; font-weight: 700; margin: 2.8rem 0 0.8rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.25rem; font-weight: 650; margin: 2rem 0 0.6rem; }
.prose h4 { font-size: 1.05rem; font-weight: 650; margin: 1.6rem 0 0.5rem; }
.prose .anchor { position: absolute; left: -1.1em; color: var(--rule); text-decoration: none; font-weight: 400; opacity: 0; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor, .prose .anchor:focus { opacity: 1; }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li { margin-bottom: 0.3rem; }
.prose li > p { margin-bottom: 0.4rem; }
.lede { color: var(--ink-2); font-family: var(--f-ui); font-size: 0.95rem; }
a { color: var(--link); text-underline-offset: 0.15em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--hl-b); outline-offset: 2px; border-radius: 2px; }
strong { font-weight: 700; }

code { font-family: var(--f-mono); font-size: 0.86em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--rule); border-radius: 6px; padding: 0.9rem 1rem; overflow-x: auto; line-height: 1.5; margin: 0 0 1.2rem; }
pre code { background: none; padding: 0; font-size: 0.84rem; overflow-wrap: normal; }

.table { overflow-x: auto; margin: 0 0 1.4rem; border: 1px solid var(--rule); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font: 0.92rem/1.45 var(--f-ui); }
th, td { text-align: left; vertical-align: top; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--rule); }
th { background: var(--paper-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td code, th code { font-size: 0.85em; }

blockquote { margin: 0 0 1rem; padding: 0.2rem 1rem; border-left: 3px solid var(--spruce); color: var(--ink-2); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* Cards on the home page */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0.9rem; margin: 0 0 1.5rem; }
.cards p { margin: 0; display: contents; }
.card { display: flex; flex-direction: column; gap: 0.35rem; padding: 1rem 1.1rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-2); text-decoration: none; color: var(--ink); }
.card strong { font: 650 1.05rem/1.3 var(--f-head); color: var(--ink); }
.card span { font: 0.9rem/1.45 var(--f-ui); color: var(--ink-2); }
.card:hover { border-color: var(--hl-a); }

/* Network diagram */
.diagram { margin: 1.5rem 0 1.8rem; padding: 1rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-2); }
.diagram svg { display: block; width: 100%; height: auto; max-width: 100%; }
.diagram figcaption { font: 0.9rem/1.45 var(--f-ui); color: var(--ink-2); margin-top: 0.6rem; }
.d-arc path { fill: none; stroke: var(--ink-2); stroke-width: 3; }
.d-hl path { fill: none; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 10 6; }
.d-hl-a path { stroke: var(--hl-a); }
.d-hl-b path { stroke: var(--hl-b); }
.d-node circle { fill: var(--paper); stroke: var(--ink); stroke-width: 3; }
.d-label text, .d-key text { fill: var(--ink); font: 13px var(--f-mono); }
@media (max-width: 40rem) { .d-label text, .d-key text { font-size: 20px; } .diagram { padding: 0.6rem; } }
.d-key text { font-family: var(--f-ui); }
.d-key-a { fill: var(--hl-a); }
.d-key-b { fill: var(--hl-b); }

footer.site { border-top: 1px solid var(--rule); color: var(--ink-2); font: 0.875rem/1.5 var(--f-ui); }
footer.site .wrap { padding-block: 1.5rem 2.5rem; }
footer.site p { margin: 0; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media (max-width: 30rem) {
  body { font-size: 1rem; }
  .prose h2 { font-size: 1.4rem; }
}
