/* Mechbase Manual — tokens follow mechbase-web DESIGN.md: Inter + Roboto Mono,
   Arpedon Blue for links and focus, Arpedon Red for the logo only, hairline
   rules, no decorative colour. One stylesheet, no framework. */

@font-face {
  font-family: "InterVariable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "Roboto Mono"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("fonts/RobotoMono-VariableFont_wght.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --font-body: "InterVariable", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --paper: oklch(98% 0.004 250);
  --surface: oklch(100% 0 0);
  --surface-sunk: oklch(96% 0.003 252);
  --ink: oklch(26% 0.05 264);
  --ink-soft: oklch(45% 0.02 262);
  --ink-mute: oklch(58% 0.012 260);
  --rule: oklch(90% 0.005 254);
  --rule-soft: oklch(94% 0.004 254);
  --rule-strong: oklch(26% 0.05 264);
  --primary: #1b3a6a;
  --on-primary: #fff;
  --accent: #cf2f3b;
  --warn: oklch(78% 0.16 85);
  --ok: oklch(65% 0.12 155);

  --side: 16rem;
  --toc: 14rem;
  --measure: 46rem;
  --top: 3.5rem;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: oklch(17% 0.015 245);
    --surface: oklch(22% 0.012 248);
    --surface-sunk: oklch(20% 0.012 248);
    --ink: oklch(90% 0.005 260);
    --ink-soft: oklch(72% 0.008 258);
    --ink-mute: oklch(56% 0.006 256);
    --rule: oklch(30% 0.01 252);
    --rule-soft: oklch(26% 0.01 250);
    --rule-strong: oklch(80% 0.005 260);
    --primary: oklch(72% 0.09 258);
    --on-primary: oklch(17% 0.015 245);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 1rem); }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1rem/1.65 var(--font-body);
  font-feature-settings: "cv11", "ss01"; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: .5rem; z-index: 10; background: var(--surface); padding: .5rem .75rem; }

/* Eyebrow / section marker: Roboto Mono, uppercase, tracked, ink. */
.side__caption, .brand__eyebrow, .pager small, .prose th, figcaption, .callout > div > p:first-child > strong:first-child {
  font-family: var(--font-mono); font-weight: 700; font-size: .6875rem;
  letter-spacing: .16em; text-transform: uppercase;
}

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 5; height: var(--top);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: color-mix(in oklch, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; flex: none; }
.brand__mark { width: 1.6rem; height: 1.6rem; }
.brand__name { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.brand__eyebrow { color: var(--ink-mute); padding-left: .55rem; border-left: 1px solid var(--rule); }
.top__search {
  display: flex; align-items: center; gap: .6rem; flex: 1; max-width: 26rem; margin-left: auto;
  height: 2.25rem; padding: 0 .75rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-mute); font: inherit; font-size: .875rem; cursor: pointer; text-align: left;
}
.top__search svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
.top__search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top__search:hover { border-color: var(--ink-mute); }
.top__links { display: flex; align-items: center; gap: 1rem; font-size: .875rem; }
.top__links a { color: var(--ink-soft); text-decoration: none; font-weight: 500; }
.top__links a:hover, .top__links a[aria-current] { color: var(--ink); }
.langs { display: flex; gap: .75rem; }
.langs a[aria-current] { font-weight: 700; }
.top__pdf { border: 1px solid var(--rule); border-radius: var(--radius); padding: .2rem .55rem; }
.top__menu { display: none; font: inherit; font-size: .875rem; font-weight: 500; color: var(--ink); background: none; border: 1px solid var(--rule); border-radius: var(--radius); padding: .3rem .6rem; }

kbd {
  font: 500 .75em var(--font-mono); padding: .05em .4em; border: 1px solid var(--rule);
  border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--ink-soft); white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */
.shell {
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr) var(--toc);
  gap: 3rem; max-width: 90rem; margin: 0 auto; padding: 0 1.5rem;
}
.side, .toc {
  position: sticky; top: var(--top); align-self: start; max-height: calc(100dvh - var(--top));
  overflow-y: auto; padding: 1.5rem 0 3rem; font-size: .875rem; overscroll-behavior: contain; scrollbar-width: thin;
}
.side__caption { color: var(--ink); margin: 1.5rem 0 .4rem; }
.side__caption:first-child { margin-top: 0; }
.side ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.side a {
  display: block; padding: .28rem .6rem; margin-left: -.6rem; border-radius: 4px;
  color: var(--ink-soft); text-decoration: none; line-height: 1.35;
}
.side a:hover { color: var(--ink); background: var(--surface-sunk); }
.side a[aria-current] { color: var(--ink); background: color-mix(in srgb, var(--primary) 9%, transparent); font-weight: 600; }

main { min-width: 0; padding: 2.25rem 0 4rem; }
.prose { max-width: var(--measure); }

/* "On this page": hide the page title entry and anything below h3. */
.toc > ul > li > a { display: none; }
.toc ul ul ul ul { display: none; }
.toc ul ul ul { padding-left: .75rem; }
.toc a { display: block; padding: .2rem 0; color: var(--ink-mute); text-decoration: none; line-height: 1.35; }
.toc a:hover, .toc a.is-active { color: var(--ink); }

/* ---------------------------------------------------------------- prose */
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--ink); line-height: 1.2; letter-spacing: -.02em; text-wrap: balance; }
.prose h1 { font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.5rem); font-weight: 700; margin: 0 0 1.25rem; letter-spacing: -.03em; }
.prose h2 { font-size: 1.45rem; font-weight: 700; margin: 3rem 0 .75rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.prose h3 { font-size: 1.1rem; font-weight: 650; margin: 2rem 0 .5rem; }
.prose h4 { font-size: 1rem; font-weight: 650; margin: 1.5rem 0 .4rem; }
.prose h1 + p { font-size: 1.125rem; color: var(--ink-soft); }
.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin: .25rem 0; }
.prose li::marker { color: var(--ink-mute); }
.prose strong { font-weight: 650; }
.prose code {
  font: .875em var(--font-mono); background: var(--surface-sunk); border: 1px solid var(--rule-soft);
  border-radius: 4px; padding: .08em .35em; overflow-wrap: anywhere;
}
.prose pre {
  font: .8125rem/1.6 var(--font-mono); background: var(--surface-sunk); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: .9rem 1rem; overflow-x: auto; margin: 0 0 1.25rem;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }
.prose div.highlight { margin: 0; }
.headerlink { margin-left: .4rem; color: var(--ink-mute); text-decoration: none; opacity: 0; font-weight: 400; }
:is(h1, h2, h3, h4):hover > .headerlink, .headerlink:focus { opacity: 1; }

/* Datasheet tables */
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.5rem; font-size: .875rem; display: block; overflow-x: auto; }
.prose th { color: var(--ink-soft); text-align: left; padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.prose td { padding: .5rem .75rem .5rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.prose table p { margin: 0; }

/* Screenshots */
.prose figure { margin: 1.5rem 0 2rem; }
.prose figure img, .prose .shot img {
  display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface);
}
.prose a.shot { display: block; }
.prose figcaption { margin-top: .6rem; color: var(--ink-mute); line-height: 1.5; text-transform: none; letter-spacing: .02em; font-weight: 500; font-size: .75rem; }
/* Phone screenshots: keep them phone-sized. */
.prose figure:has(img[src*="07-ios"]), .prose figure:has(img[src*="07-android"]) { max-width: 18rem; }

/* Callouts: full hairline border + tint; the label is the eyebrow. Never a side stripe. */
.prose blockquote { margin: 1.5rem 0; padding: .9rem 1.1rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote > div > p:first-child > strong:first-child { display: block; margin-bottom: .25rem; color: var(--ink); }
.callout--note { --c: var(--primary); }
.callout--tip { --c: var(--ok); }
.callout--warn { --c: var(--warn); }
.prose .callout { border-color: color-mix(in srgb, var(--c) 45%, var(--rule)); background: color-mix(in srgb, var(--c) 6%, var(--surface)); }

/* Landing "cards" lists */
.prose ul.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; }
.prose ul.cards li { margin: 0; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); padding: .9rem 1rem; font-size: .875rem; color: var(--ink-soft); position: relative; }
.prose ul.cards li:hover { border-color: var(--ink-mute); }
.prose ul.cards li a { display: block; font-weight: 650; font-size: 1rem; color: var(--ink); text-decoration: none; margin-bottom: .2rem; }
.prose ul.cards li a::after { content: ""; position: absolute; inset: 0; }
.prose ul.cards li > p { margin: 0; }
.prose ul.cards li > p > a:first-child + * { display: none; }

/* ---------------------------------------------------------------- pager & footer */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: var(--measure); margin-top: 3.5rem; }
.pager a { display: block; border: 1px solid var(--rule); border-radius: var(--radius); padding: .75rem 1rem; text-decoration: none; color: var(--ink); font-weight: 600; background: var(--surface); }
.pager a:hover { border-color: var(--ink-mute); }
.pager small { display: block; color: var(--ink-mute); margin-bottom: .2rem; }
.pager__next { grid-column: 2; text-align: right; }
.meta { max-width: var(--measure); margin-top: 1.5rem; font-size: .8125rem; color: var(--ink-mute); }
.meta a { color: var(--ink-mute); }
.foot {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; justify-content: space-between;
  max-width: 90rem; margin: 0 auto; padding: 1.5rem; border-top: 1px solid var(--rule); font-size: .8125rem; color: var(--ink-mute);
}
.foot a { color: var(--ink-mute); text-decoration: none; }
.foot__arpedon { display: inline-flex; align-items: center; gap: .4rem; color: var(--ink) !important; font-weight: 600; }
.foot__arpedon svg { width: 1.25rem; height: 1.1rem; color: var(--primary); }

/* ---------------------------------------------------------------- root landing */
.is-root .shell { grid-template-columns: minmax(0, 1fr); max-width: 52rem; }
.is-root main { padding-top: 12vh; }
.is-root .prose h1 { font-size: 2.75rem; }

/* ---------------------------------------------------------------- search dialog */
.search {
  width: min(42rem, calc(100vw - 2rem)); max-height: min(80dvh, 44rem); margin: 10vh auto auto; padding: 0;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px -16px oklch(20% 0.03 260 / .35);
}
.search mark { background: color-mix(in srgb, var(--primary) 16%, transparent); color: inherit; border-radius: 2px; }
.search::backdrop { background: oklch(20% 0.03 260 / .35); }
.search__box { padding: 1rem; --pagefind-ui-primary: var(--primary); --pagefind-ui-text: var(--ink); --pagefind-ui-background: var(--surface); --pagefind-ui-border: var(--rule); --pagefind-ui-tag: var(--surface-sunk); --pagefind-ui-border-width: 1px; --pagefind-ui-border-radius: 6px; --pagefind-ui-font: var(--font-body); --pagefind-ui-scale: .85; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 75rem) {
  .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 56rem) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; gap: 0; }
  .top { gap: .6rem; }
  .brand__eyebrow, .top__search span, .top__search kbd { display: none; }
  .top__search { flex: none; width: 2.25rem; padding: 0; justify-content: center; }
  .top__menu { display: block; }
  .side {
    display: none; position: fixed; inset: var(--top) 0 0; max-height: none; z-index: 4;
    align-self: stretch; /* "start" (from the desktop sidebar) shrinks a fixed box to its content and shifts it under the top bar */
    background: var(--paper); padding: 1rem 1.25rem 3rem;
  }
  .side.is-open { display: block; }
  main { padding-top: 1.5rem; }
}

@media print {
  .top, .side, .toc, .pager, .meta, .foot, .search { display: none !important; }
  .shell { display: block; }
}
