/* ──────────────────────────────────────────────────────────────
   trace-mcp docs — Nothing design system
   Replaces the stock GitHub Pages Primer sheet (76.5 KB, no dark
   mode, zebra tables, system fonts). Tokens are kept identical to
   docs/index.html by hand; see docs/DESIGN-WEB.md.
   ────────────────────────────────────────────────────────────── */

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

/* ── Fonts (self-hosted, same files the landing page uses) ── */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url(/fonts/space-grotesk-variable-latin.woff2) format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/fonts/space-mono-400-latin.woff2) format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Mono";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/space-mono-700-latin.woff2) format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Metric-matched fallbacks so first paint does not reflow. */
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial");
  ascent-override: 98.4%;
  descent-override: 29.2%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Space Mono Fallback";
  src: local("Courier New");
  ascent-override: 112%;
  descent-override: 36.1%;
  line-gap-override: 0%;
}

/* ── Tokens ── */
:root,
:root[data-theme="dark"] {
  --black: #000000;
  --surface: #111111;
  --surface-raised: #1a1a1a;
  --border: #222222;
  --border-visible: #333333;
  --text-disabled: #666666;
  --text-secondary: #999999;
  --text-primary: #e8e8e8;
  --text-display: #ffffff;
  --accent: #d71921;
  --accent-subtle: rgba(215, 25, 33, 0.15);

  --nav-bg: rgba(0, 0, 0, 0.85);
  --dot-color: var(--border);
  --color-scheme: dark;

  --font-body: "Space Grotesk", "Space Grotesk Fallback", system-ui, sans-serif;
  --font-mono: "Space Mono", "Space Mono Fallback", "JetBrains Mono", monospace;

  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

:root[data-theme="light"] {
  --black: #f5f5f5;
  --surface: #ffffff;
  --surface-raised: #f0f0f0;
  --border: #e8e8e8;
  --border-visible: #cccccc;
  --text-disabled: #6d6d6d; /* 4.75:1 on #F5F5F5, 4.54:1 on #F0F0F0 — #767676 was 4.17:1 */
  --text-secondary: #595959;
  --text-primary: #1a1a1a;
  --text-display: #000000;
  --accent: #b3151c; /* 6.3:1 on #F5F5F5, 6.9:1 on #FFFFFF — the landing keeps #D71921 */
  --accent-subtle: rgba(215, 25, 33, 0.12);

  --nav-bg: rgba(245, 245, 245, 0.85);
  --dot-color: var(--border-visible);
  --color-scheme: light;
}

html {
  color-scheme: var(--color-scheme);
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition:
    background-color 240ms var(--ease),
    color 240ms var(--ease);
}

/* Dot grid — the same 24px lattice as the landing page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) 0.5px, transparent 0.5px);
  background-size: 24px 24px;
  pointer-events: none;
  opacity: 0.25;
  z-index: 0;
}

/* ── Skip link ── */
.skip-link {
  position: absolute;
  left: -9999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.skip-link:focus {
  left: 16px;
  top: 12px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--text-display);
  color: var(--black);
}

/* ── Nav ── */
.docs-header {
  position: sticky;
  top: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: background-color 240ms var(--ease);
}
.docs-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 16px;
}
.nav-brand {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-display);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.nav-brand .bracket {
  color: var(--text-disabled);
}
.nav-brand:hover .bracket {
  color: var(--accent);
}

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 32px;
  position: relative;
  z-index: 1;
}
.docs-header .container {
  max-width: 1280px;
}
@media (max-width: 600px) {
  .container {
    padding: 0 20px;
  }
}

main {
  padding: 64px 0 96px;
}

/* ── Theme toggle (shared component with the landing page) ── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px;
  background: transparent;
  border: 1px solid var(--border-visible);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 200ms var(--ease);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover {
  border-color: var(--text-display);
}
.theme-toggle:focus-visible {
  outline: 1px solid var(--text-display);
  outline-offset: 2px;
}
.theme-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--text-secondary);
  transition:
    background-color 200ms var(--ease),
    color 200ms var(--ease);
}
.theme-seg .seg-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  transition: opacity 200ms var(--ease);
}
.theme-toggle[data-active="dark"] .theme-seg[data-mode="dark"],
.theme-toggle[data-active="light"] .theme-seg[data-mode="light"] {
  background: var(--text-display);
  color: var(--black);
}
.theme-toggle[data-active="dark"] .theme-seg[data-mode="dark"] .seg-dot,
.theme-toggle[data-active="light"] .theme-seg[data-mode="light"] .seg-dot {
  opacity: 1;
}
@media (max-width: 800px) {
  .theme-toggle {
    font-size: 9px;
    padding: 2px;
  }
  .theme-seg {
    padding: 4px 8px;
    gap: 5px;
  }
}
@media (max-width: 480px) {
  .theme-seg .label-text {
    display: none;
  }
  .theme-seg {
    padding: 5px;
  }
  .theme-seg .seg-dot {
    width: 6px;
    height: 6px;
  }
}

/* ── Prose ──
   Three layers: h1 is the one display element, body is Space Grotesk,
   every service label (h2 eyebrow, table head, caption) is Space Mono caps. */
.prose > * + * {
  margin-top: 20px;
}

.prose h1 {
  font-family: var(--font-body);
  font-size: clamp(38px, 6vw, 56px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-display);
  margin: 0 0 32px;
}
.prose h2 {
  font-family: var(--font-body);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-display);
  margin: 80px 0 0; /* "new group starts here" */
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.prose h3 {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-display);
  margin: 48px 0 0;
}
.prose h4,
.prose h5,
.prose h6 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 40px 0 0;
}
.prose p {
  color: var(--text-primary);
}
.prose strong {
  font-weight: 700;
  color: var(--text-display);
}
.prose em {
  font-style: italic;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  transition: text-decoration-color 150ms var(--ease);
}
.prose a:hover {
  text-decoration-color: var(--accent);
}
/* Scroll regions are tab stops too. Left out, they fall through to Chrome's
   own ring — blue in the light theme, which is a second accent colour. */
:where(a, button, summary, .table-scroll, .prose pre):focus-visible {
  outline: 1px solid var(--text-display);
  outline-offset: 2px;
}

.prose ul,
.prose ol {
  padding-left: 22px;
}
.prose li + li {
  margin-top: 8px;
}
.prose li::marker {
  color: var(--text-disabled);
}

/* ── Code ── */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-display);
}
.prose pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}
.prose pre code {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  font-size: inherit;
  color: var(--text-primary);
}
/* Highlighted tokens — opacity/weight, not a rainbow. */
.prose .highlight .c,
.prose .highlight .c1,
.prose .highlight .cm {
  color: var(--text-disabled);
}
.prose .highlight .k,
.prose .highlight .kd,
.prose .highlight .kn,
.prose .highlight .nt {
  color: var(--text-display);
  font-weight: 700;
}
.prose .highlight .s,
.prose .highlight .s1,
.prose .highlight .s2,
.prose .highlight .na {
  color: var(--text-secondary);
}

/* ── Tables ──
   No zebra striping. Rows separate on a hairline; the head is a
   Space Mono caps label, not a bold band. */
.prose .table-scroll {
  overflow-x: auto;
}
/* Instrument label for a region that has more to the right — same voice as
   the thead label it sits above. The script adds .is-visible only while the
   region is actually scrollable and not yet at its end. */
.prose .scroll-hint {
  display: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-disabled);
  text-align: right;
  margin-bottom: 10px;
}
.prose .scroll-hint.is-visible {
  display: block;
}
/* The label belongs to the region under it: 10px, not the 20px paragraph gap.
   Hidden, it contributes no margin and the region keeps its own 20px. */
.prose .scroll-hint.is-visible + .table-scroll,
.prose .scroll-hint.is-visible + pre {
  margin-top: 0;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.prose thead th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-align: left;
  padding: 0 16px 10px 0;
  border-bottom: 1px solid var(--border-visible);
  white-space: nowrap;
}
.prose tbody td,
.prose tbody th {
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  font-weight: 400;
}
.prose tbody tr:last-child td,
.prose tbody tr:last-child th {
  border-bottom: 0;
}
.prose tbody th {
  color: var(--text-display);
}
.prose td:last-child,
.prose th:last-child {
  padding-right: 0;
}

/* Capability marks. The comparison tables used ✅/❌ — emoji as UI, and a
   green that is a second accent colour. The mark is now plain ✓/✗ text, and
   yes/no separate on opacity, which is how this system encodes state.
   `font-variant-emoji: text` keeps a platform from re-colouring them. */
.prose .mark {
  font-variant-emoji: text;
}
.prose .mark-yes {
  color: var(--text-display);
}
.prose .mark-no {
  color: var(--text-disabled);
}

.prose blockquote {
  padding-left: 20px;
  border-left: 1px solid var(--accent);
  color: var(--text-secondary);
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 64px 0;
}
/* Most doc pages write `---` immediately before a `##`. The h2 already draws
   its own top rule, so the pair rendered as two hairlines around an empty
   band. Let the heading own the break. */
.prose hr + h2 {
  margin-top: 32px;
  padding-top: 0;
  border-top: 0;
}
.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
img,
svg {
  max-width: 100%;
  height: auto;
}

/* ── Footer ── */
.docs-footer {
  margin-top: 96px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 2.2;
  color: var(--text-secondary);
}
.docs-footer .label {
  display: block;
  text-transform: uppercase;
  color: var(--text-disabled);
  margin-bottom: 8px;
}
.docs-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}
.docs-footer a:hover {
  color: var(--accent);
}
/* One cell per link. `auto-fill` rather than a fixed count so the column
   number falls out of the width — 4 at 1440px, 1 below 600px — and no label
   ever wraps mid-phrase the way the old inline strip did. */
.footer-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 32px;
  margin-top: 4px;
}
.footer-links a {
  display: block;
  padding: 2px 0;
}
.page-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-disabled);
  margin-top: 64px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
