/* paper.css — long-form research reading, on top of site.css's tokens.
   Loaded only by research.html. Optimised for one thing: reading 1500 lines of argument without
   fatigue, so measure is capped near 68 characters and body text is larger than the marketing page's. */

.paper {
  max-width: 78rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  grid-template-areas: "head head" "toc body";
  column-gap: 3rem;
  align-items: start;
}

.paper-head { grid-area: head; margin-bottom: 3rem; max-width: 52rem; }
.paper-eyebrow {
  font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 0.9rem;
}
.paper-head h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); line-height: 1.15; margin-bottom: 1rem; }
.paper-sub { font-size: 1.1rem; color: var(--text-muted); line-height: 1.5; }

/* ── contents rail ─────────────────────────────────────────────────────────────────────────────── */
.paper-toc {
  grid-area: toc;
  position: sticky; top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  font-size: 0.88rem;
  border-left: 1px solid var(--border-muted);
  padding-left: 1rem;
}
.paper-toc-title {
  font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 0.7rem;
}
.paper-toc ol { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; }
.paper-toc a { color: var(--text-muted); text-decoration: none; }
.paper-toc a:hover { color: var(--gold); }

/* ── the paper itself ──────────────────────────────────────────────────────────────────────────── */
.paper-body {
  grid-area: body;
  max-width: 44rem;
  font-size: 1.02rem;
  line-height: 1.72;
  color: var(--text);
}
.paper-body > * + * { margin-top: 1.15rem; }

.paper-body h2 {
  margin-top: 3.2rem; padding-top: 1.4rem;
  border-top: 1px solid var(--border-muted);
  font-size: 1.5rem; line-height: 1.25;
}
.paper-body h3 { margin-top: 2.2rem; font-size: 1.18rem; color: var(--text); }
.paper-body h4 { margin-top: 1.8rem; font-size: 1rem; color: var(--text-muted); }

.paper-body a { color: var(--gold); text-decoration: none; border-bottom: 1px solid transparent; }
.paper-body a:hover { border-bottom-color: currentColor; }

.paper-body strong { color: #fff; }
.paper-body em { color: var(--text-muted); }

.paper-body ul, .paper-body ol { padding-left: 1.4rem; }
.paper-body li + li { margin-top: 0.45rem; }

.paper-body blockquote {
  border-left: 3px solid var(--border-strong);
  padding: 0.2rem 0 0.2rem 1.1rem;
  color: var(--text-muted);
}

.paper-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: rgba(40, 29, 87, 0.7);
  border: 1px solid var(--border-muted);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
}
.paper-body pre {
  background: rgba(22, 15, 48, 0.75);
  border: 1px solid var(--border-base);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  overflow-x: auto;          /* long lines scroll INSIDE the block; the page never scrolls sideways */
  font-size: 0.86rem;
  line-height: 1.55;
}
.paper-body pre code { background: none; border: none; padding: 0; font-size: inherit; }

/* Tables carry most of the measurements in this paper, so they get real treatment rather than
   inheriting prose defaults — and they scroll inside their own box on narrow screens. */
/* Tables get a WRAPPER, not clever table CSS — the same `.tablewrap` idea index.html already uses.
   Two recipes were tried on the table itself and both failed, measured rather than assumed: with
   `display:block; width:100%` and again with `width:max-content; max-width:100%`, the computed width
   stayed 672px inside a 591px column and pushed the whole PAGE sideways. Chromium will not clamp a
   table's min-content width with max-width. A plain div honours max-width and scrolls normally, so the
   generator wraps every table in one. */
.paper-tablewrap {
  overflow-x: auto;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border-muted);
}
.paper-body .paper-tablewrap table {
  width: 100%;
  min-width: 34rem;      /* below this a data table is unreadable; the wrapper scrolls instead */
  border-collapse: collapse;
  font-size: 0.9rem;
  background: rgba(32, 23, 72, 0.4);
}
.paper-body th, .paper-body td {
  border: 1px solid var(--border-muted);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
.paper-body th { background: rgba(40, 29, 87, 0.6); color: var(--text); font-weight: 600; }

.paper-body hr { border: none; border-top: 1px solid var(--border-muted); margin: 2.5rem 0; }
.paper-body img { max-width: 100%; height: auto; border-radius: 10px; }

/* ── narrow screens: drop the rail, keep the reading column ────────────────────────────────────── */
@media (max-width: 900px) {
  .paper {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "toc" "body";
    row-gap: 2rem;
  }
  .paper-toc { position: static; max-height: none; border-left: none; padding-left: 0; }
  .paper-body { max-width: none; }
}
