/* =====================================================================
   v3 prose — shared rendered-content styling (`.v3-prose`)
   ---------------------------------------------------------------------
   ONE source of truth for long-form / markdown content, loaded by BOTH
   the static pages (build-pages.ts) and the blog (build-blog.ts) — so the
   two prose surfaces can't drift. Token-driven; loaded after the reset
   (v3-reset.css) so `.v3-prose <el>` (0,1,1) beats the reset's
   bare-element rules (0,0,1).

   Covers everything `marked` can emit: p, h2–h4, ul/ol (+ nested), li,
   blockquote, a, strong/em, code/pre, hr, img, table. Body ink kept at
   #2f3b4f to match the established page look (tokenizing that hex is a
   tracked backlog item, not a visual change).
   ===================================================================== */

/* Type comes from the BODY role (v3-layout.css groups '.v3-prose p' + li);
   only the paragraph rhythm lives here. */
.v3-prose p {
  margin: 0 0 var(--space-5);
}

/* Headings LEFT-aligned — explicit so prose headings read left regardless of
   the container's alignment (e.g. a prose block inside a centered band). */
.v3-prose h1, .v3-prose h2, .v3-prose h3,
.v3-prose h4, .v3-prose h5, .v3-prose h6 { text-align: left; }

/* ── Headings ─────────────────────────────────────────────────────── */
/* h1 = a markdown doc's leading `# Title` (handbook). Without this it falls
   through to the reset's bare `h1` (v3-reset.css, 67px). Pages that render their
   own title chrome (blog) keep it OUTSIDE .v3-prose, so they're unaffected. */
.v3-prose h1 {
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  color: var(--color-ink);
  font-size: var(--text-h2);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 var(--space-4);
}
.v3-prose h2 {
  font-family: var(--font-display);
  font-weight: var(--weight-light);
  color: var(--color-ink);
  font-size: var(--text-3xl);
  line-height: var(--leading-snug);
  margin: var(--space-12) 0 var(--space-4);
}
.v3-prose h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-normal);
  color: var(--color-ink);
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
  margin: var(--space-8) 0 var(--space-3);
}
.v3-prose h4 {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  color: var(--color-ink);
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
  margin: var(--space-6) 0 var(--space-2);
}

/* ── Lists ────────────────────────────────────────────────────────── */
/* Override the reset's (v3-reset.css) `list-style-position: inside` (markers
   hang in the text flow) → outside markers with a real indent + rhythm. */
.v3-prose ul,
.v3-prose ol {
  margin: 0 0 var(--space-6);
  padding-left: 1.5em;
}
.v3-prose ul { list-style: disc outside; }
.v3-prose ol { list-style: decimal outside; }
.v3-prose li {
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
  color: #2f3b4f;
  padding-left: 0.2em;
}
.v3-prose li::marker { color: var(--color-brand-soft); }
/* Nested lists: indent step + tighter spacing, different marker shape */
.v3-prose li > ul,
.v3-prose li > ol { margin: var(--space-3) 0 0; }
.v3-prose ul ul { list-style: circle outside; }
.v3-prose ol ol { list-style: lower-alpha outside; }

/* ── Blockquote ───────────────────────────────────────────────────── */
.v3-prose blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 4px solid var(--color-brand);
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--color-ink-subtle);
  font-style: italic;
}
.v3-prose blockquote p { margin: 0; color: inherit; }

/* ── Links + emphasis ─────────────────────────────────────────────── */
/* Prose text links underline; anchor-COMPONENTS placed in prose (a .btn, a
   related-services .v3-tcard, a .v3-cta) keep their own look — excluded here so
   we don't have to "undo" the underline on them elsewhere. */
.v3-prose a:not(.btn):not(.v3-tcard):not(.v3-cta) {
  color: var(--color-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.v3-prose a:not(.btn):not(.v3-tcard):not(.v3-cta):hover { color: var(--color-brand-deep); }
.v3-prose strong { font-weight: var(--weight-bold); color: var(--color-ink); }
.v3-prose em { font-style: italic; }

/* ── Code ─────────────────────────────────────────────────────────── */
.v3-prose code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
}
.v3-prose pre {
  background: var(--color-bg-invert);
  color: var(--color-ink-invert);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
  margin: 0 0 var(--space-5);
  line-height: 1.5;
}
.v3-prose pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 0.9em; }

/* ── Rule + media + tables ────────────────────────────────────────── */
.v3-prose hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  max-width: 200px;
  margin: var(--space-12) auto;
}
.v3-prose img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  margin: var(--space-6) 0;
}
/* Tables break out wider than the narrow prose column on large screens, and
   scroll instead of squishing when they overflow. marked emits a bare <table>;
   build-blog / build-handbook wrap each one in .v3-table-wrap. The column stays
   centered, so margin-left:50% + translateX(-50%) re-centers the wider wrap on
   the viewport. Mobile: no breakout — the wrap is just a scroll container. */
.v3-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 var(--space-6);
}
@media (min-width: 1080px) {
  .v3-table-wrap {
    width: min(var(--w-wide), 92vw);
    margin-left: 50%;
    transform: translateX(-50%);
  }
}
.v3-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: var(--text-sm);
}
.v3-prose th,
.v3-prose td {
  border: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}
.v3-prose th {
  background: var(--color-bg-alt);
  font-family: var(--font-sans);
  font-weight: var(--weight-semibold);
  color: var(--color-ink);
}
