:root {
  color-scheme: light dark;

  /* --- Paper & ink (light) — warm greige surfaces, low-chroma warm neutrals --- */
  --bg:           oklch(97.5% 0.007 78);
  --bg-subtle:    oklch(95%   0.008 78);
  --bg-code:      oklch(94.5% 0.011 80);
  --surface:      oklch(99%   0.005 78);

  --border:       oklch(86% 0.010 80);
  --border-light: oklch(92% 0.008 80);

  /* Ink tinted toward the accent hue for subconscious cohesion */
  --text:           oklch(22% 0.015 150);
  --text-secondary: oklch(42% 0.013 150);
  --text-tertiary:  oklch(52% 0.012 150);

  /* Forest — deep, slightly desaturated; organic not tech-green */
  --accent:         oklch(42% 0.090 155);
  --accent-hover:   oklch(36% 0.095 155);
  --accent-visited: oklch(42% 0.040 155);
  --accent-bg:      oklch(94% 0.028 155);
  --accent-border:  oklch(84% 0.055 155);

  /* Warm amber for the draft notice — paper-and-ink register */
  --warn-bg:     oklch(93% 0.070 82);
  --warn-border: oklch(70% 0.140 72);
  --warn-text:   oklch(38% 0.100 55);
  --warn-strong: oklch(30% 0.090 45);

  /* Code / schema accents — distinct from the primary accent, all warm */
  --code-type:       oklch(44% 0.050 90);   /* muted olive for type names */
  --code-constraint: oklch(52% 0.130 60);   /* burnt amber for constraints */
  --code-string:     oklch(48% 0.090 180);  /* muted teal for strings */
  --code-number:     oklch(52% 0.130 60);   /* ochre for numbers */
  --code-punc:       oklch(55% 0.015 80);   /* warm gray */
  --code-comment:    oklch(62% 0.018 80);   /* lighter warm gray */

  /* Legacy aliases — old rules still reference these names */
  --green:  var(--code-type);
  --orange: var(--code-constraint);
  --blue:   var(--code-string);

  /* Type families */
  --font-text: 'Literata', Georgia, 'Times New Roman', Cambria, serif;
  --font-display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Red Hat Mono', 'SF Mono', ui-monospace, Menlo, Consolas, monospace;

  /* Legacy aliases — used by a handful of rules that want the display/mono face */
  --mono: var(--font-mono);
  --sans: var(--font-display);

  /* Type scale — 1.25 ratio, 17px base for reading */
  --fs-xs:  0.75rem;    /* 12px — captions, microcopy */
  --fs-sm:  0.875rem;   /* 14px — small labels */
  --fs-md:  1.0625rem;  /* 17px — body */
  --fs-lg:  1.1875rem;  /* 19px — lede, h4 */
  --fs-xl:  1.4375rem;  /* 23px — h3 */
  --fs-2xl: 1.75rem;    /* 28px — h2 */
  --fs-3xl: clamp(2.25rem, 1.4rem + 3.2vw, 3rem); /* h1 fluid for marketing hero */

  /* Line heights */
  --lh-tight:  1.08;
  --lh-snug:   1.22;
  --lh-normal: 1.45;
  --lh-body:   1.6;

  /* Letter spacing */
  --tracking-tight:  -0.015em;
  --tracking-normal: 0;
  --tracking-wide:   0.08em;

  /* Motion — natural deceleration; never bounce/elastic */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);

  /* Spacing scale — 4pt progression, semantic names */
  --space-3xs: 0.25rem;   /*  4px — hairline gaps */
  --space-2xs: 0.5rem;    /*  8px — tight pairs */
  --space-xs:  0.75rem;   /* 12px — chip padding */
  --space-sm:  1rem;      /* 16px — paragraph gap */
  --space-md:  1.5rem;    /* 24px — block gap, card padding */
  --space-lg:  2rem;      /* 32px — section-desc gap */
  --space-xl:  3rem;      /* 48px — subsection rhythm */
  --space-2xl: 4rem;      /* 64px — section padding */
  --space-3xl: clamp(4rem, 3rem + 3vw, 6rem); /* fluid section top/bottom */

  /* Content measure — reading width caps */
  --measure-prose: 70ch;
  --measure-page:  860px;
}

/* --- Paper & ink (dark) — warm near-black surfaces, same hue family --- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           oklch(18% 0.008 78);
    --bg-subtle:    oklch(22% 0.010 78);
    --bg-code:      oklch(24% 0.012 80);
    --surface:      oklch(22% 0.009 78);

    --border:       oklch(32% 0.012 80);
    --border-light: oklch(26% 0.010 80);

    --text:           oklch(94% 0.012 82);
    --text-secondary: oklch(78% 0.012 82);
    --text-tertiary:  oklch(62% 0.014 82);

    --accent:         oklch(74% 0.130 155);
    --accent-hover:   oklch(80% 0.125 155);
    --accent-visited: oklch(74% 0.060 155);
    --accent-bg:      oklch(28% 0.040 155);
    --accent-border:  oklch(40% 0.075 155);

    --warn-bg:     oklch(26% 0.055 70);
    --warn-border: oklch(55% 0.150 65);
    --warn-text:   oklch(86% 0.110 82);
    --warn-strong: oklch(92% 0.100 82);

    --code-type:       oklch(78% 0.080 95);
    --code-constraint: oklch(76% 0.150 65);
    --code-string:     oklch(78% 0.090 180);
    --code-number:     oklch(76% 0.150 65);
    --code-punc:       oklch(68% 0.015 80);
    --code-comment:    oklch(58% 0.018 80);
  }

  /* Light-on-dark reads lighter — add small leading for long-form comfort */
  body { line-height: 1.65; }
}

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

/* Sticky nav occludes anchor targets; push them down so in-page jumps land below it */
:target,
h1[id], h2[id], h3[id], h4[id] {
  scroll-margin-top: calc(56px + var(--space-md));
}

/* Motion is opt-in — respect prefers-reduced-motion strictly */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus system — only show on keyboard navigation. In modern browsers, outlines automatically follow the element's border-radius. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
a:focus-visible,
.hero-badge:focus-visible,
.topnav-links a:focus-visible {
  outline-offset: 3px;
}
.guide-card:focus-visible,
.card:focus-visible,
.lexicon-block:focus-visible,
.callout:focus-visible,
.trust-list li:focus-visible {
  outline-offset: 4px;
}

/* Screen-reader-only — preserves semantic info for AT without visual duplication */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — invisible until focused, then pinned top-left */
.skip-link {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  z-index: 1000;
  transform: translateY(-200%);
  transition: transform 0.1s var(--ease-out-quart);
}
.skip-link:focus-visible {
  transform: translateY(0);
  outline-offset: 2px;
}

body {
  font-family: var(--font-text);
  font-size: var(--fs-md);
  font-feature-settings: "kern", "liga", "onum";
  background: var(--bg);
  color: var(--text);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Display face covers nav, headings, labels, chips — anywhere the voice is "interface" rather than "prose" */
h1, h2, h3, h4,
.topnav-logo, .topnav-links a, .hero-badge,
.lexicon-tag, .sub-heading, .code-label,
.schema-table th, .field-name, .field-type,
.card h4, .guide-card h4, .guide-card .guide-arrow,
.draft-banner, .hero-sm .breadcrumb, footer p, footer a {
  font-family: var(--font-display);
  font-feature-settings: "kern", "ss01";
}

/* Pull lexicon-name back to mono — identifiers deserve a mono face */
.lexicon-name,
code, pre, .field-name, .field-type {
  font-family: var(--font-mono);
  font-feature-settings: "kern";
}

/* Italic emphasis is a serif strength — keep strong & em in the text face */
strong { font-weight: 600; }
em, i, cite { font-family: var(--font-text); font-style: italic; }

/* Top nav bar */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-md);
}

.topnav-inner {
  max-width: 1100px; /* wider than --measure-page so nav breathes into the side margins */
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: var(--space-md);
}

/* Flex-child escape hatch: without min-width: 0 the nav element expands to fit all
   six links intrinsically, pushing the whole page wider than the mobile viewport.
   Constraining it lets .topnav-links' overflow-x: auto do its job. */
.topnav-inner > nav {
  min-width: 0;
  flex: 1 1 auto;
}

.topnav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}

.topnav-logo span { color: var(--accent); }

.topnav-links {
  display: flex;
  gap: var(--space-2xs); /* link padding extends hit area; tight gap keeps visual rhythm */
  list-style: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.topnav-links::-webkit-scrollbar { display: none; }

.topnav-links li {
  display: flex; /* let the anchor fill the nav's full 56px height */
}

.topnav-links a {
  display: flex;
  align-items: center;
  padding: 0 var(--space-2xs); /* 8px inside each link extends the touch hit area */
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s var(--ease-out-quart);
  white-space: nowrap;
}

.topnav-links a:hover { color: var(--accent); }
.topnav-links a.active { color: var(--accent); }

/* Hero — editorial masthead, left-aligned, asymmetric composition */
.hero {
  padding: var(--space-3xl) var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border-light);
}

.hero-inner {
  max-width: var(--measure-page);
  margin: 0 auto;
}

.hero h1 {
  font-size: var(--fs-3xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  max-width: 14ch; /* forces a 2-line break that makes the title feel composed */
  margin-bottom: var(--space-md);
  text-wrap: balance;
}

.hero h1 span { color: var(--accent); }

.hero .subtitle {
  font-family: var(--font-text);
  font-size: var(--fs-lg);
  font-style: italic;
  color: var(--text-secondary);
  max-width: 48ch;
  margin: 0 0 var(--space-lg);
  padding-left: clamp(1rem, 4vw, 3.5rem); /* block-indent pullquote register */
  line-height: var(--lh-normal);
  text-wrap: pretty;
  border-left: 1px solid var(--accent-border); /* hairline — 1px is allowed; not a BAN 1 violation */
}

.hero-badges {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  align-items: center;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
  max-width: 520px; /* colophon row — narrower than the subtitle measure; hairline reads as a rule, not a border */
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) 0; /* vertical touch hit area without pill chrome */
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s var(--ease-out-quart);
}

.hero-badge:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.hero-badge svg {
  width: 14px;
  height: 14px;
  opacity: 0.75;
}

/* Small hero for sub-pages */
.hero-sm {
  text-align: left;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.hero-sm .hero-inner {
  max-width: var(--measure-page);
  margin: 0 auto;
}

.hero-sm h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  margin-bottom: 10px;
  text-wrap: balance;
}

.hero-sm h1 span { color: var(--accent); }

.hero-sm .subtitle {
  font-family: var(--font-text);
  font-size: var(--fs-lg);
  font-style: italic;
  color: var(--text-secondary);
  max-width: 60ch;
  line-height: var(--lh-normal);
  margin: 0;
}

.hero-sm .breadcrumb {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-sm);
}

.hero-sm .breadcrumb a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.hero-sm .breadcrumb a:hover { color: var(--accent); }

/* Main content */
.container {
  max-width: var(--measure-page);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

section {
  padding: var(--space-3xl) 0;
}

section + section {
  border-top: 1px solid var(--border-light);
}

h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-snug);
  margin-bottom: 14px;
  text-wrap: balance;
}

.section-desc {
  font-family: var(--font-text);
  font-size: var(--fs-lg);
  font-style: italic;
  color: var(--text-secondary);
  line-height: var(--lh-normal);
  margin-bottom: var(--space-lg);
  max-width: 60ch;
  text-wrap: pretty;
}

h3 {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: var(--lh-snug);
  margin-bottom: var(--space-2xs);
  margin-top: var(--space-lg);
  text-wrap: balance;
}

h3:first-child,
section > h3:first-of-type { margin-top: 0; }

/* Looser break between peer subsection headings (worked examples, scenario steps) */
.mt-xl { margin-top: var(--space-xl); }

h4 {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: var(--lh-snug);
  margin-bottom: 6px;
}

p {
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  max-width: var(--measure-prose);
  text-wrap: pretty;
  hyphens: auto;
}

li { text-wrap: pretty; }

/* Content lists — restore a sane indent so bullets sit inside the text column instead of
   hanging in the container padding. Structural lists with classes (.topnav-links, .steps,
   .trust-list) opt out via their own padding-left rules. */
ul:not([class]),
ol:not([class]) {
  padding-left: 1.5em;
  max-width: var(--measure-prose);
  margin-bottom: var(--space-sm);
}

ul:not([class]) li,
ol:not([class]) li {
  margin-bottom: var(--space-3xs);
}
ul:not([class]) li::marker,
ol:not([class]) li::marker {
  color: var(--text-tertiary);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Visited — desaturated forest signals "already seen" while staying in-palette (browser default is purple, which clashes with the greige + forest palette). */
a:visited { color: var(--accent-visited); }

/* Navigation and site-identity are wayfinding, not citations — visited shouldn't mute them. */
.topnav-logo:visited { color: var(--text); }
.topnav-links a:visited { color: var(--text-secondary); }
.topnav-links a:visited:hover,
.topnav-links a.active:visited,
.topnav-links a[aria-current="page"]:visited { color: var(--accent); }

/* Skip link is an action target, not a reference. */
.skip-link:visited { color: var(--accent); }

/* Lexicon-name headers stay full-contrast — hover underline already signals "clickable". */
.lexicon-name:visited { color: var(--text); }

/* Mermaid */
.mermaid-wrapper {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-lg) var(--space-sm);
  margin: var(--space-lg) 0;
  overflow-x: auto;
  min-height: 220px; /* reserve space so lazy render doesn't shift layout (CLS) */
}

/* Hide mermaid DSL source text until the library has processed it into SVG.
   A <noscript><style> in each diagram page overrides this for no-JS users. */
.mermaid:not([data-processed="true"]) {
  visibility: hidden;
}

/* Feature columns — flat, top-ruled, no chrome */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  column-gap: var(--space-xl);
  row-gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.card {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: var(--space-sm) 0 0;
  transition: border-top-color 0.2s var(--ease-out-quart);
}

.card:hover {
  border-top-color: var(--accent);
}

.card h4 {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: var(--lh-snug);
  margin-bottom: var(--space-2xs);
  color: var(--text);
}

.card p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: var(--lh-normal);
  max-width: none;
}

/* Guide index — numbered table-of-contents register, hairline-ruled rows, no card chrome */
.guide-grid {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-md);
  counter-reset: guide;
}

.guide-card {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  column-gap: var(--space-md);
  row-gap: var(--space-3xs);
  align-items: baseline;
  padding: var(--space-md) 0;
  border-top: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  counter-increment: guide;
  transition: background-color 0.15s var(--ease-out-quart);
}

.guide-card:last-of-type {
  border-bottom: 1px solid var(--border-light);
}

.guide-card::before {
  content: counter(guide, decimal-leading-zero);
  grid-column: 1;
  grid-row: 1 / 3;
  align-self: start;
  padding-top: 0.2em; /* optical baseline with title */
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.guide-card h4 {
  grid-column: 2;
  grid-row: 1;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  margin: 0;
}

.guide-card p {
  grid-column: 2;
  grid-row: 2;
  font-family: var(--font-text);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
  max-width: 58ch;
  margin: 0;
}

.guide-card .guide-arrow {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-tertiary);
  margin: 0;
  opacity: 0;
  transform: translateX(-6px);
  transition:
    opacity 0.18s var(--ease-out-quart),
    transform 0.18s var(--ease-out-quart),
    color 0.18s var(--ease-out-quart);
  white-space: nowrap;
}

.guide-card:hover,
.guide-card:focus-visible {
  background: color-mix(in oklch, var(--accent-bg) 55%, transparent);
  text-decoration: none;
}

.guide-card:hover .guide-arrow,
.guide-card:focus-visible .guide-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* Lexicon blocks */
.lexicon-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.lexicon-header {
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

.lexicon-tag {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 3px 9px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.lexicon-name {
  display: block; /* now an <a>; keep block layout so margin-bottom applies */
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-all;
  letter-spacing: -0.005em;
  text-decoration: none;
  transition: color 0.15s var(--ease-out-quart);
}

.lexicon-name:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.lexicon-desc {
  font-family: var(--font-text);
  font-size: var(--fs-md);
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: var(--lh-normal);
  max-width: 62ch;
}

.lexicon-body {
  padding: 0 var(--space-lg) var(--space-md);
}

/* Schema table */
.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  margin: 20px 0 0;
  font-variant-numeric: tabular-nums;
}

.schema-table th {
  text-align: left;
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.schema-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.schema-table tr:last-child td { border-bottom: none; }

.field-name {
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--accent);
  white-space: nowrap;
}

.field-type {
  font-size: var(--fs-sm);
  color: var(--green);
  white-space: nowrap;
}

.field-type .constraint {
  color: var(--orange);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.field-desc {
  font-family: var(--font-text);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

/* Inline code — mono rendered at ~0.9em tracks well next to serif body */
code {
  font-size: 0.9em;
  background: var(--bg-code);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  font-weight: 500;
}

/* Code blocks */
.code-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: var(--space-md) 0;
}

.code-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

pre {
  padding: 18px;
  font-size: 0.8125rem; /* 13px — mono reads smaller than serif at same metric size */
  line-height: 1.65;
  overflow-x: auto;
  background: var(--bg-code);
  margin: 0;
}

.hl-key { color: var(--accent); }
.hl-str { color: var(--code-string); }
.hl-num { color: var(--code-number); }
.hl-punc { color: var(--code-punc); }
.hl-comment { color: var(--code-comment); font-style: italic; }

/* Info callout — subtle tinted block, no border chrome */
.callout {
  background: var(--accent-bg);
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-md) 0;
}

/* Stacked callouts tighten up; callout paragraphs get a small gap */
.callout + .callout { margin-top: var(--space-sm); }
.callout p + p { margin-top: var(--space-xs); }

/* A callout after a card-grid gets a little extra breathing room */
.card-grid + .callout { margin-top: var(--space-lg); }

.callout p {
  font-family: var(--font-text);
  font-size: var(--fs-md);
  color: var(--text-secondary);
  line-height: var(--lh-body);
  margin-bottom: 0;
  max-width: 62ch;
}
.callout strong { color: var(--text); font-weight: 600; }

/* Steps */
.steps {
  counter-reset: step;
  padding-left: 0;
  list-style: none;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 2.5rem;
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--fs-md);
  line-height: var(--lh-body);
  max-width: 68ch;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--fs-md); /* match body size so numeral and text first-line baselines align */
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: inherit;
}

/* Trust model list — hairline-ruled rows, editorial register matching guide index */
.trust-list {
  list-style: none;
  margin-top: var(--space-sm);
}

.trust-list li {
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--border-light);
  background: transparent;
}

.trust-list li:last-child {
  border-bottom: 1px solid var(--border-light);
}

.trust-list li strong {
  color: var(--text);
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-md);
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: -0.005em;
}

.trust-list li span {
  font-family: var(--font-text);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}

/* Section sub-heading helper — small-caps label above a block of content */
.sub-heading {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-tertiary);
  margin: var(--space-md) 0 var(--space-3xs);
}

/* Draft banner */
.draft-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  padding: var(--space-sm) var(--space-md);
  text-align: center;
}

.draft-banner p {
  color: var(--warn-text);
  font-size: var(--fs-sm);
  font-weight: 500;
  margin: 0 auto;
  max-width: 720px; /* banner text measure — narrower than page cap so it reads as a centered notice */
  line-height: var(--lh-normal);
}

.draft-banner strong {
  color: var(--warn-strong);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: var(--space-xl) var(--space-md);
  text-align: center;
}

footer p {
  font-size: var(--fs-sm);
  color: var(--text-tertiary);
  max-width: none;
}

footer a { color: var(--text-tertiary); }
footer a:hover { color: var(--accent); }

/* Responsive */
@media (max-width: 640px) {
  .hero { padding: var(--space-xl) var(--space-md) var(--space-lg); }
  .hero h1 { max-width: none; } /* let the 2-line break fall naturally on narrow viewports */
  .hero .subtitle { font-size: var(--fs-md); padding-left: var(--space-sm); }
  .lexicon-block { overflow: visible; }
  .lexicon-header, .lexicon-body { padding-left: var(--space-sm); padding-right: var(--space-sm); }
  .lexicon-name { font-size: var(--fs-sm); overflow-wrap: break-word; word-break: break-word; }
  .topnav-links { gap: var(--space-3xs); } /* link padding provides hit area; tight gap fits all 6 nav items */
  .topnav-links a { font-size: var(--fs-xs); letter-spacing: 0.01em; }

  /* Guide index — tighten numeral column on narrow screens */
  .guide-card { grid-template-columns: 2.25rem 1fr; column-gap: var(--space-sm); }

  /* Stack schema tables on mobile */
  .schema-table thead { display: none; }
  .schema-table, .schema-table tbody { display: block; }
  .schema-table tr {
    display: block;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
  }
  .schema-table tr:last-child { border-bottom: none; }
  .schema-table td {
    display: block;
    padding: 2px 0;
    border-bottom: none;
  }
  .field-name { font-size: var(--fs-sm); }
  .field-type { white-space: normal; font-size: var(--fs-xs); }
  .field-desc { font-size: var(--fs-sm); margin-top: 6px; }
}

/* Touch devices — hover-reveal patterns don't work; show the cue by default on smaller screens, hide entirely on larger touch surfaces where the row itself is obvious */
@media (hover: none) {
  .guide-card .guide-arrow {
    display: none; /* no hover, no reveal — the row is itself the tappable surface */
  }

  /* Touch users can't preview hover state; make links visually distinct enough that taps don't feel ambiguous */
  a:active {
    opacity: 0.7;
  }
}

/* Print — ink-economy palette, hide interactive chrome, keep content legible */
@media print {
  :root {
    --bg:             #ffffff;
    --bg-subtle:      #f6f5f2;
    --bg-code:        #f2f1ed;
    --surface:        #ffffff;
    --border:         #c7c3b9;
    --border-light:   #dcd8cf;
    --text:           #1a1a1a;
    --text-secondary: #2f2f2f;
    --text-tertiary:  #555555;
    --accent:         #2f5f40;
    --accent-hover:   #2f5f40;
    --accent-bg:      #eaf1eb;
    --accent-border:  #b9d1bb;
    --warn-bg:        #f6efde;
    --warn-border:    #c9a24e;
    --warn-text:      #5c3f14;
    --warn-strong:    #3e290a;
  }

  body { font-size: 10.5pt; line-height: 1.5; }

  /* Hide interactive / navigational chrome that doesn't belong in the printed record */
  .topnav, .hero-badges, .guide-card .guide-arrow, .skip-link { display: none; }

  /* Relax the sticky-nav scroll offset on print */
  :target, h1[id], h2[id], h3[id], h4[id] { scroll-margin-top: 0; }

  /* Collapse hero padding — print doesn't need the atmospheric space */
  .hero, .hero-sm { padding: 0 0 var(--space-md); border-bottom: 1px solid var(--border); }
  .hero .subtitle, .hero-sm .subtitle { margin-bottom: 0; }

  /* Let content use the full page width */
  .container { max-width: none; padding: 0; }
  section { padding: var(--space-md) 0; }

  /* Pretty URL printing for external links — context matters in archived specs */
  main a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--text-tertiary);
    word-break: break-all;
  }

  /* Force code tints to actually print (most printers strip backgrounds by default) */
  code, pre, .code-label, .mermaid-wrapper, .callout, .lexicon-block, .draft-banner {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Keep structural content blocks from splitting across pages */
  .lexicon-block,
  .mermaid-wrapper,
  .code-block,
  .callout,
  .guide-card,
  .trust-list li {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  h1, h2, h3, h4 {
    page-break-after: avoid;
    break-after: avoid-page;
  }

  /* No hover-reveal tricks in print */
  .guide-card { background: transparent !important; }
}
