/*
 * Whitepaper styling — shared across all whitepapers under docs/whitepapers/
 *
 * Originally extracted from the Beyond RAG / KAS whitepaper. This is the canonical
 * stylesheet for whitepaper HTML renders. New whitepapers reference it as:
 *
 *   <link rel="stylesheet" href="../_assets/whitepaper.css">
 *
 * The /whitepaper skill's WP-7 (HTML render) phase reuses this file rather than
 * inlining a fresh copy.
 *
 * The :root variables can be overridden inline per-document if a single
 * whitepaper needs a different accent or background.
 */

:root {
  --color-bg: #fdfdfb;
  --color-bg-soft: #f5f4ef;
  --color-bg-callout: #eef2f8;
  --color-text: #1a1a1a;
  --color-text-muted: #555555;
  --color-text-faint: #8a8a8a;
  --color-border: #e6e3dc;
  --color-border-strong: #cfcbc1;
  --color-accent: #1f3a5f;
  --color-accent-soft: #5b7da1;
  --color-accent-faint: #c8d3e4;
  --color-warn: #8b5a2b;
  --color-warn-soft: #d4b896;
  --color-good: #2e6b4f;
  --color-good-soft: #b8d4c5;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Consolas", "Liberation Mono", monospace;

  --content-max: 720px;
  --toc-width: 240px;
  --gutter-wide: 80px;

  --leading-body: 1.65;
  --leading-heading: 1.25;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- Layout ---------- */

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 64px 24px 96px 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: var(--toc-width) minmax(0, var(--content-max)) 1fr;
    gap: var(--gutter-wide);
    padding: 64px 48px 96px 48px;
  }
}

.toc {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

@media (min-width: 1024px) {
  .toc {
    position: sticky;
    top: 32px;
    align-self: start;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    padding-right: 12px;
  }
}

.toc-title {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  margin: 0 0 12px 0;
  font-weight: 600;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc > ol > li {
  margin-bottom: 4px;
}

.toc ol ol {
  padding-left: 16px;
  margin-top: 4px;
  margin-bottom: 4px;
  border-left: 1px solid var(--color-border);
}

.toc ol ol li {
  margin-bottom: 2px;
}

.toc a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: block;
  padding: 2px 0;
  border-radius: 2px;
  transition: color 0.15s;
}

.toc a:hover {
  color: var(--color-accent);
}

.content {
  max-width: var(--content-max);
}

/* ---------- Typography ---------- */

.meta {
  color: var(--color-text-faint);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
}

h1 {
  font-size: 38px;
  line-height: 1.15;
  margin: 0 0 16px 0;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.subtitle {
  font-size: 20px;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin: 0 0 8px 0;
  font-weight: 400;
}

.credit {
  color: var(--color-text-faint);
  font-size: 14px;
  margin: 0 0 64px 0;
}

h2 {
  font-size: 28px;
  line-height: var(--leading-heading);
  margin: 64px 0 16px 0;
  letter-spacing: -0.01em;
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
}

h3 {
  font-size: 21px;
  line-height: 1.3;
  margin: 40px 0 12px 0;
  font-weight: 600;
}

h4 {
  font-size: 18px;
  line-height: 1.4;
  margin: 28px 0 10px 0;
  font-weight: 600;
}

p {
  margin: 0 0 1em 0;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--color-accent-faint);
  transition: border-color 0.15s, color 0.15s;
}

a:hover {
  border-bottom-color: var(--color-accent);
}

ul, ol {
  margin: 0 0 1em 0;
  padding-left: 24px;
}

li { margin-bottom: 4px; }

strong { font-weight: 600; }

em { font-style: italic; }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-soft);
  padding: 1px 5px;
  border-radius: 3px;
}

pre {
  background: var(--color-bg-soft);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  margin: 24px 0;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

/* ---------- Callouts ---------- */

.callout {
  background: var(--color-bg-callout);
  border-left: 3px solid var(--color-accent);
  padding: 20px 24px;
  margin: 32px 0;
  border-radius: 2px;
  font-size: 17px;
  line-height: 1.55;
}

.callout strong:first-child {
  color: var(--color-accent);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.callout-thesis {
  background: transparent;
  border-left: none;
  border-top: 2px solid var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
  padding: 24px 0;
  margin: 32px 0;
  text-align: center;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--color-text);
  font-style: italic;
}

blockquote {
  margin: 24px 0;
  padding: 0 0 0 24px;
  border-left: 3px solid var(--color-accent-faint);
  color: var(--color-text-muted);
  font-style: italic;
}

blockquote strong {
  color: var(--color-text);
}

/* ---------- Tables ---------- */

.table-wrap {
  margin: 24px 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-border-strong);
  background: var(--color-bg-soft);
  font-size: 14px;
  letter-spacing: 0.01em;
}

td code {
  font-size: 13px;
}

/* ---------- Figures (SVG) ---------- */

figure {
  margin: 40px -16px;
  padding: 24px 16px;
  background: var(--color-bg-soft);
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

figure svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

figcaption {
  margin-top: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
  text-align: center;
  font-style: italic;
}

/* ---------- Section dividers ---------- */

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 56px 0;
}

/* ---------- References ---------- */

.references {
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.references p {
  margin-bottom: 12px;
  padding-left: 32px;
  text-indent: -32px;
}

/* ---------- Anchor offset for sticky ToC ---------- */

:target {
  scroll-margin-top: 24px;
}

/* ---------- Print ---------- */

@media print {
  .toc { display: none; }
  .layout {
    display: block;
    max-width: 100%;
    padding: 0;
  }
  .content { max-width: 100%; }
  figure {
    page-break-inside: avoid;
    margin: 24px 0;
  }
  h2 { page-break-before: auto; page-break-after: avoid; }
  h3 { page-break-after: avoid; }
  body { font-size: 11pt; }
}
