/* ══════════════════════════════════════════════════════════════════════
   whitepaper.css — LrForge field-paper reading layer.

   Loaded on top of the page's inline base (tokens, nav, article typography,
   footer) which is shared-by-copy with lrforge.html. This file adds only the
   long-read scientific-paper furniture: a reading-progress bar, a sticky
   table-of-contents rail, figure plates, stat callouts, pull quotes, a
   JSON/code block, a two-promise contrast, and table refinements.

   Every colour is read from the page's CSS custom properties, so light/dark
   theming is inherited for free.
══════════════════════════════════════════════════════════════════════ */

/* Belt-and-suspenders: the wide data tables scroll inside their own
   .table-wrap; below the TOC breakpoint the 640px tables can still nudge the
   root into sideways scroll (body's overflow-x:hidden alone doesn't clip the
   root), so clip it here. Scoped below 1180px because clipping the root also
   makes position:sticky fail — and the sticky TOC only exists at ≥1180px. */
@media (max-width: 1179px) {
  html { overflow-x: hidden; }
}

/* ── Reading-progress bar ───────────────────────────────────────────── */
.wp-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--orange), var(--teal));
  z-index: 200;
  pointer-events: none;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .wp-progress { transition: none; }
}

/* ── Header refinements ─────────────────────────────────────────────── */
.paper__badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
  background: color-mix(in srgb, var(--teal) 9%, transparent);
  border-radius: 100px;
  padding: 5px 12px;
  margin-bottom: 18px;
}
.paper__badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal);
  flex: none;
}

/* Header lead paragraph — a touch larger than body, sets the voice */
.paper__lead {
  font-size: clamp(17px, 1.9vw, 20px);
  line-height: 1.66;
  color: var(--ink);
  margin-top: 4px;
}

/* ── Two-column body: sticky TOC rail + article ─────────────────────── */
.wp-body {
  display: block;
}
.wp-article-col {
  max-width: 768px;
  margin-inline: auto;
}
.wp-toc { display: none; }

@media (min-width: 1180px) {
  .wp-body {
    display: grid;
    grid-template-columns: 236px minmax(0, 768px);
    justify-content: center;
    gap: clamp(36px, 4.2vw, 84px);
    align-items: start;
  }
  .wp-article-col { margin-inline: 0; }
  .wp-toc {
    display: block;
    position: sticky;
    top: 92px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 8px;
    /* thin, self-effacing scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--rule) transparent;
  }
  .wp-toc::-webkit-scrollbar { width: 6px; }
  .wp-toc::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }
}

.wp-toc__label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-xlight);
  margin-bottom: 14px;
  padding-left: 13px;
}
.wp-toc__list { list-style: none; margin: 0; padding: 0; }
.wp-toc__list a {
  display: block;
  position: relative;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-xlight);
  text-decoration: none;
  padding: 6px 0 6px 13px;
  border-left: 2px solid var(--rule-light);
  transition: color 0.16s ease, border-color 0.16s ease;
}
.wp-toc__list a:hover { color: var(--ink-light); border-color: var(--ink-xlight); }
.wp-toc__list a.is-active {
  color: var(--orange);
  border-color: var(--orange);
  font-weight: 600;
}

/* ── Figure plates ──────────────────────────────────────────────────── */
.wp-figure {
  margin: clamp(30px, 4vw, 44px) 0;
}
.wp-figure__frame {
  background: #fff;               /* charts are rendered on white — keep them on white */
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: clamp(12px, 2vw, 20px);
  box-shadow: 0 1px 2px rgba(45,52,54,0.04), 0 10px 30px rgba(45,52,54,0.06);
}
:root[data-theme="dark"] .wp-figure__frame,
.wp-figure__frame { }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wp-figure__frame {
    box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 34px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] .wp-figure__frame {
  box-shadow: 0 1px 2px rgba(0,0,0,0.4), 0 12px 34px rgba(0,0,0,0.5);
}
.wp-figure__frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.wp-figure__cap {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-xlight);
}
.wp-figure__num {
  flex: none;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--orange);
  padding-top: 2px;
  white-space: nowrap;
}
.wp-figure__cap strong { color: var(--ink-light); font-weight: 600; }

/* ── Stat callout row ───────────────────────────────────────────────── */
.wp-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  margin: clamp(28px, 3.5vw, 40px) 0;
}
.wp-stat {
  background: var(--white);
  padding: 22px 20px;
}
.wp-stat__num {
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.wp-stat__num .unit {
  font-size: 0.5em;
  color: var(--orange);
  font-weight: 600;
  letter-spacing: 0;
}
.wp-stat__label {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-xlight);
  margin-top: 10px;
}
.wp-stat--teal .wp-stat__num { color: var(--teal); }
.wp-stat--teal .wp-stat__num .unit { color: var(--teal); }

/* ── Pull quote ─────────────────────────────────────────────────────── */
.wp-pullquote {
  margin: clamp(34px, 4.5vw, 52px) 0;
  padding-left: clamp(20px, 3vw, 30px);
  border-left: 3px solid var(--orange);
}
.wp-pullquote p {
  font-family: var(--serif);
  font-size: clamp(21px, 2.6vw, 29px);
  font-weight: 300;
  font-style: italic;
  line-height: 1.34;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
.wp-pullquote cite {
  display: block;
  margin-top: 16px;
  font-family: var(--sans);
  font-style: normal;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-xlight);
}

/* ── Key-findings / conclusions grid ────────────────────────────────── */
.wp-findings {
  list-style: none;
  margin: clamp(24px, 3vw, 34px) 0 26px;
  padding: 0;
  display: grid;
  gap: 14px;
}
.wp-findings > li {
  position: relative;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 22px 18px 58px;
  font-size: 15.5px;
  line-height: 1.62;
  color: var(--ink-light);
  margin: 0;
}
.wp-findings > li::before {
  counter-increment: wp-find;
  content: counter(wp-find);
  position: absolute;
  left: 18px;
  top: 17px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--orange);
  border: 1px solid color-mix(in srgb, var(--orange) 40%, transparent);
  border-radius: 50%;
}
.wp-findings { counter-reset: wp-find; }
.wp-findings > li strong { color: var(--ink); font-weight: 600; }

/* ── JSON / code block ──────────────────────────────────────────────── */
.wp-code {
  margin: 0 0 24px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wp-code code {
  font-family: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-light);
  white-space: pre;
}

/* ── Inline code ────────────────────────────────────────────────────── */
.article code {
  font-family: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
  font-size: 0.86em;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border: 1px solid var(--rule-light);
  border-radius: 4px;
  padding: 1px 5px;
  word-break: break-word;
}
.wp-code code { background: none; border: none; padding: 0; }

/* ── Two-promise contrast ───────────────────────────────────────────── */
.wp-promise {
  display: grid;
  gap: 16px;
  margin: clamp(26px, 3vw, 36px) 0;
}
@media (min-width: 620px) {
  .wp-promise { grid-template-columns: 1fr 1fr; }
}
.wp-promise__card {
  border-radius: 12px;
  padding: 24px 24px 26px;
  border: 1px solid var(--rule);
  background: var(--white);
}
.wp-promise__tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
.wp-promise__card p {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}
.wp-promise--say {
  border-color: color-mix(in srgb, var(--teal) 40%, transparent);
  background: color-mix(in srgb, var(--teal) 7%, var(--white));
}
.wp-promise--say .wp-promise__tag { color: var(--teal); }
.wp-promise--wont .wp-promise__tag { color: var(--ink-xlight); }
.wp-promise--wont p {
  color: var(--ink-xlight);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--orange) 60%, transparent);
  text-decoration-thickness: 1.5px;
}

/* ── Section eyebrow that precedes major H2 parts ───────────────────── */
.wp-part {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--orange);
  margin: clamp(52px, 6vw, 78px) 0 -6px;
  padding-top: clamp(30px, 3.6vw, 44px);
  border-top: 2px solid var(--ink);
}
.wp-part + .article__h2-first,
.wp-part + h2 {
  border-top: none !important;
  padding-top: 6px !important;
  margin-top: 4px !important;
}

/* ── Table refinements layered on the base .article table ───────────── */
.article .table-wrap { position: relative; }
.article table.wp-numeric td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}
.article thead th { position: sticky; top: 0; }
.article tbody tr:hover td { background: color-mix(in srgb, var(--orange) 4%, transparent); }
/* winner / caution emphasis cells */
.article td .good { color: var(--teal); font-weight: 600; }
.article td .bad  { color: var(--orange); font-weight: 600; }

/* Footnote / disclosure aside inside the article */
.wp-note {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-xlight);
  border-top: 1px solid var(--rule-light);
  padding-top: 14px;
  margin: -6px 0 24px;
}

/* ── Mobile: give figures & tables breathing room, kill any h-scroll ── */
@media (max-width: 560px) {
  .wp-figure__frame { padding: 10px; }
  .wp-stat { padding: 18px 16px; }
}
