/* ──────────────────────────────────────────────────────────────
   recursive.engineering — research paper stylesheet
   editorial template, paper sheet, charts, page chrome
   ────────────────────────────────────────────────────────────── */

:root {
  --paper: #efece4;
  --paper-warm: #e8e4d8;
  --ink: #15140f;
  --ink-soft: #4a4842;
  --ink-faint: #b0aa9c;
  --rule-soft: #d6d1c2;
  --rule-strong: #8a8470;
  --accent: #c0581f;
  --accent-soft: rgba(192, 88, 31, 0.12);
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --font-serif: 'Fraunces', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: #2a2620;
  color: var(--ink);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ─── page-stage: dark backdrop with the sheet floating on it ─── */
.page-stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px 80px;
}

.page-nav {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(239,236,228,0.7);
}
.page-nav a { color: rgba(239,236,228,0.7); }
.page-nav a:hover { color: var(--accent); text-decoration: none; }
.page-nav .center { color: rgba(239,236,228,0.5); letter-spacing: 0.3em; }
.page-nav .nav-arrow.disabled { color: rgba(239,236,228,0.2); pointer-events: none; }

/* Paper sheet */
.sheet {
  background: var(--paper);
  width: 100%;
  max-width: 1100px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35), 0 4px 12px rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
  padding: 70px 80px 80px;
}
.sheet::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(0,0,0,0.018) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(0,0,0,0.022) 0%, transparent 50%);
}

/* Top header strip */
.sheet-header {
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 22px;
  margin-bottom: 36px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sheet-header .brand { display: flex; align-items: center; gap: 10px; }
.sheet-header .mark { width: 14px; height: 14px; }
.sheet-header .mark rect { fill: none; stroke: currentColor; stroke-width: 0.8; }
.sheet-header .mark rect.accent { stroke: var(--accent); }
.sheet-header .center { text-align: center; }

/* Footer row */
.sheet-footer {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--rule-soft);
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ─── Title block (used on page 1) ─── */
.title-block { text-align: center; padding: 24px 0 40px; }
.field {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.title-block h1 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  margin: 0 0 22px;
  text-wrap: balance;
}
.title-block h1 em { font-style: italic; font-weight: 400; }

.authors {
  font-family: var(--font-serif);
  font-size: 17px;
  color: var(--ink-soft);
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
}
.authors .name { color: var(--ink); }
.authors .aff { font-style: italic; }
.submitted {
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* Abstract */
.abstract {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  border-left: 2px solid var(--accent);
  padding: 6px 24px 6px 22px;
  max-width: 800px;
  margin: 0 auto 50px;
  text-align: justify;
  hyphens: auto;
}
.abstract::before {
  content: 'Abstract.';
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--accent);
  display: block; margin-bottom: 8px;
}

/* ─── Section page header (used on pages 2+) ─── */
.section-head {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.section-head .title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-style: italic;
  font-size: 28px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.section-head .title strong { font-style: normal; font-weight: 400; }
.section-head .meta {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--ink-faint);
}
.section-head .meta .accent { color: var(--accent); }

/* ─── Two-column body ─── */
.columns {
  column-count: 2;
  column-gap: 36px;
  column-rule: 1px solid var(--rule-soft);
  font-family: var(--font-serif);
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
}
.columns h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent);
  margin: 4px 0 14px;
  break-after: avoid;
}
.columns h2.continued::before { content: '↳ '; color: var(--ink-faint); }
.columns h2 .num { color: var(--ink-faint); margin-right: 10px; }
.columns h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  color: var(--ink);
  margin: 22px 0 8px;
  break-after: avoid;
}
.columns h4 {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 16px 0 6px;
  break-after: avoid;
}
.columns p { margin: 0 0 12px; }

.columns p.lede:first-of-type::first-letter,
.columns p.dropcap::first-letter {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 400;
  float: left;
  line-height: 0.9;
  margin: 6px 8px -4px 0;
  color: var(--accent);
}

/* Single column body (for pages where two cols don't fit) */
.single {
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
  max-width: 720px;
  margin: 0 auto;
}
.single h2 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent);
  margin: 32px 0 14px;
}
.single h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 18px;
  margin: 22px 0 8px;
}

/* Math block */
.math {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  text-align: center;
  margin: 12px 0 14px;
  color: var(--ink);
  break-inside: avoid;
}
.math .var { font-style: italic; }

/* ─── Code blocks ─── */
.code {
  break-inside: avoid;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  background: rgba(21,20,15,0.04);
  border-left: 2px solid var(--ink);
  padding: 12px 14px;
  margin: 14px 0;
  white-space: pre-wrap;
  color: var(--ink);
}
.code .ln { color: var(--ink-faint); user-select: none; margin-right: 12px; display: inline-block; width: 18px; text-align: right; }
.code .com { color: var(--ink-soft); font-style: italic; }
.code .kw { color: var(--accent); }
.caption-code {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: -6px;
  margin-bottom: 14px;
  break-inside: avoid;
}
.caption-code .lbl {
  font-family: var(--font-mono); font-style: normal;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent); margin-right: 8px;
}

/* ─── Figure container ─── */
.figure {
  break-inside: avoid;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--rule-soft);
  background: rgba(255,255,255,0.4);
}
.figure.full { margin: 24px 0; }
.figure svg { display: block; width: 100%; height: auto; }
.figure .caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 12px;
  line-height: 1.5;
}
.figure .caption .lbl {
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent);
  margin-right: 8px;
}

/* Table */
table.tbl {
  break-inside: avoid;
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
  margin: 14px 0;
}
table.tbl caption {
  font-family: var(--font-mono);
  font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent);
  text-align: left;
  margin-bottom: 6px;
}
table.tbl th, table.tbl td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule-soft);
}
table.tbl th {
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--ink);
}
table.tbl tbody tr:last-child td { border-bottom: 1px solid var(--ink); }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td .accent { color: var(--accent); }

/* Small notes */
.note {
  break-inside: avoid;
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--ink);
}
.note .lbl {
  font-size: 9px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

/* References */
.refs {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.65;
  color: var(--ink);
  column-count: 2;
  column-gap: 36px;
  column-rule: 1px solid var(--rule-soft);
}
.refs ol { list-style: none; padding: 0; margin: 0; counter-reset: ref; }
.refs li {
  counter-increment: ref;
  margin: 0 0 12px;
  padding-left: 32px;
  position: relative;
  break-inside: avoid;
}
.refs li::before {
  content: '[' counter(ref) ']';
  position: absolute;
  left: 0;
  color: var(--accent);
}
.refs li em { font-style: italic; color: var(--ink-soft); }

/* Author/email line */
.author-emails {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 16px;
  letter-spacing: 0.04em;
}
.author-emails a { color: var(--ink-soft); }

/* ─── Chart primitives (used inside <svg>) ─── */
.chart-bg { fill: rgba(0,0,0,0.015); }
.chart-grid { stroke: var(--rule-soft); stroke-width: 0.5; stroke-dasharray: 2 3; fill: none; }
.chart-axis { stroke: var(--ink); stroke-width: 0.8; fill: none; }
.chart-tick { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-soft); letter-spacing: 0.04em; }
.chart-label { font-family: var(--font-mono); font-size: 10px; fill: var(--ink); letter-spacing: 0.18em; text-transform: uppercase; }
.chart-line { stroke: var(--ink); stroke-width: 1; fill: none; }
.chart-line-soft { stroke: var(--ink-soft); stroke-width: 0.8; fill: none; }
.chart-line-accent { stroke: var(--accent); stroke-width: 1.4; fill: none; }
.chart-band { fill: rgba(192, 88, 31, 0.08); stroke: var(--accent); stroke-width: 0.6; stroke-dasharray: 3 3; }
.chart-band-ink { fill: rgba(21, 20, 15, 0.06); stroke: var(--ink-soft); stroke-width: 0.5; stroke-dasharray: 3 3; }
.chart-dot { fill: var(--ink); }
.chart-dot-accent { fill: var(--accent); stroke: var(--paper); stroke-width: 1.2; }
.chart-cluster-a { fill: var(--ink-soft); }
.chart-cluster-b { fill: var(--ink); }
.chart-cluster-c { fill: var(--rule-strong); }
.chart-anomaly { fill: var(--accent); }
.chart-text-mono { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-soft); }
.chart-text-num { font-family: var(--font-serif); font-size: 24px; font-weight: 300; fill: var(--accent); letter-spacing: -0.02em; }
.chart-arrow { stroke: var(--accent); stroke-width: 1; fill: none; marker-end: url(#arr); }
.chart-arrow-ink { stroke: var(--ink); stroke-width: 0.8; fill: none; marker-end: url(#arrInk); }

/* For figure-style charts that need a frame */
.chart-frame { fill: none; stroke: var(--ink); stroke-width: 0.8; }
.chart-frame-soft { fill: none; stroke: var(--rule-strong); stroke-width: 0.5; }

/* Pull-quote / hero figures */
.figure.full svg { max-height: 360px; }

/* Responsive guard — sheets stay single-column on narrow viewports */
@media (max-width: 760px) {
  .sheet { padding: 40px 28px 50px; }
  .columns { column-count: 1; }
  .refs { column-count: 1; }
  .title-block h1 { font-size: 38px; }
}
