/* =========================================================================
   Atlas — research.css (magazine+ layout)
   Cover (with optional cover.svg) + sticky tabs + 2-col Findings
   (TOC rail + article) + Citations + Raw .md, plus dark provenance band.
   Palette-aware via --pal-* vars; Fraunces for display, system for chrome.
   ========================================================================= */

html:has(body.research-page) { overflow-x: clip; }
body.research-page {
  margin: 0;
  overflow-x: clip;
  background: var(--pal-bg);
  color: var(--pal-fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
}

.research-back {
  position: fixed; top: 16px; left: 18px; z-index: 50;
  font-size: 12px;
  color: var(--pal-fg);
  text-decoration: none;
  background: color-mix(in srgb, var(--pal-surface) 80%, transparent);
  padding: 6px 10px; border-radius: 4px;
  backdrop-filter: blur(4px);
  border: 1px solid var(--pal-border);
}
.research-back:hover { background: var(--pal-surface); color: var(--pal-accent); }

/* =========================================================================
   Cover
   --cover-img is set per-page via inline style on the .research-cover element.
   Three layers: title-side fade, SVG illustration on the right, base gradient.
   ========================================================================= */
.research-cover {
  --cover-bg-top: var(--pal-surface);
  --cover-bg-bottom: var(--pal-bg);
  background:
    linear-gradient(to right,
      var(--cover-bg-top) 0%,
      var(--cover-bg-top) 22%,
      transparent 58%),
    var(--cover-img, none) center center / cover no-repeat,
    linear-gradient(to bottom, var(--cover-bg-top), var(--cover-bg-bottom));
  height: 70vh;
  min-height: 480px;
  padding: 0 8vw 56px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 1px solid var(--pal-border);
  position: relative;
  overflow: hidden;
  font-family: 'Fraunces', Georgia, serif;
}
.research-cover-text { max-width: 58%; position: relative; z-index: 1; }

/* Bare cover — when the page has no cover.svg, mirror the dark-green
   hero from the 1-magazine wireframe: solid green gradient + radial
   light glow + 45° crosshatch overlay. Light text on dark bg. */
.research-cover-bare {
  background:
    radial-gradient(ellipse at 30% 30%, rgba(220, 229, 209, .15), transparent 60%),
    linear-gradient(160deg, #2b4326 0%, #1a2e1f 50%, #0d1810 100%);
  color: var(--pal-surface);
  height: 78vh;
  min-height: 520px;
}
.research-cover-bare::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(45deg,  transparent 0 18px, rgba(220, 229, 209, .04) 18px 19px),
    repeating-linear-gradient(-45deg, transparent 0 18px, rgba(220, 229, 209, .04) 18px 19px);
  pointer-events: none;
}
.research-cover-bare .research-kicker        { color: #c9d8b8; }
.research-cover-bare .research-kicker .kicker-site { color: #dce5d1; }
.research-cover-bare .research-kicker time   { color: #c9d8b8; }
.research-cover.research-cover-bare h1       { color: #fff; }
.research-cover-bare .research-summary       { color: #dce5d1; }
.research-cover-bare .research-stack         { color: #dce5d1; }
.research-cover-bare .research-stack b       { color: #faf6ea; }
.research-cover-bare .research-topic         { color: #c9d8b8; }
.research-cover-bare .research-back {
  color: rgba(255, 255, 255, .85);
  background: rgba(0, 0, 0, .35);
  border-color: transparent;
}
.research-cover-bare .research-back:hover { background: rgba(0, 0, 0, .55); color: #fff; }

.research-kicker {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  color: var(--pal-fg-muted);
  margin-bottom: 14px;
}
.research-kicker .kicker-site {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 600;
  color: var(--pal-accent);
}
.research-kicker time { font-variant-numeric: tabular-nums; }

.research-cover h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: clamp(34px, 5.4vw, 72px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  max-width: 18ch;
  color: var(--pal-fg);
}
.research-summary {
  font-family: 'Fraunces', Georgia, serif;
  font-size: clamp(15px, 1.4vw, 19px);
  line-height: 1.5;
  color: var(--pal-fg-muted);
  margin: 0 0 22px;
  max-width: 52ch;
}
.research-stack {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  color: var(--pal-fg-muted);
  display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: center;
}
.research-stack b { color: var(--pal-fg); font-weight: 600; }
.research-tags-inline { color: var(--pal-fg-faint); }

/* View switcher — pill row in the cover stack. Renders only when at
   least one alternate view exists under <page-dir>/views/. */
.view-switcher {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.view-switcher .view-lbl {
  font: 600 10px/1 'JetBrains Mono', ui-monospace, Menlo, monospace;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pal-fg-faint);
  margin-right: 4px;
}
.view-switcher .view-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font: 500 12px/1.4 -apple-system, BlinkMacSystemFont, sans-serif;
  border: 1px solid var(--pal-border);
  color: var(--pal-fg-muted);
  background: transparent;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.view-switcher .view-pill:hover {
  color: var(--pal-fg);
  border-color: var(--pal-accent);
}
.view-switcher .view-pill.is-active {
  background: var(--pal-fg);
  color: var(--pal-accent-fg);
  border-color: var(--pal-fg);
}
/* Bare cover (no SVG hero) overrides: the cover is dark, so flip pill
   colors so they read against the dark green background. */
.research-cover-bare .view-switcher .view-lbl { color: #c9d8b8; }
.research-cover-bare .view-switcher .view-pill {
  border-color: rgba(255, 255, 255, 0.25);
  color: #dce5d1;
}
.research-cover-bare .view-switcher .view-pill:hover {
  border-color: #faf6ea;
  color: #faf6ea;
}
.research-cover-bare .view-switcher .view-pill.is-active {
  background: #faf6ea;
  color: #1a2e1f;
  border-color: #faf6ea;
}

@media (max-width: 760px) {
  .research-cover {
    height: auto;
    min-height: 0;
    padding: clamp(260px, 56vw, 360px) 16px 28px;
    background:
      var(--cover-img, none) center 70px / 80% auto no-repeat,
      linear-gradient(to bottom, var(--cover-bg-top), var(--cover-bg-bottom));
  }
  .research-cover-text { max-width: 100%; }
  .research-cover h1 { max-width: none; }
}

/* =========================================================================
   Tabs
   ========================================================================= */
.research-tabs-wrap {
  background: var(--pal-bg);
  border-bottom: 1px solid var(--pal-border);
  position: sticky; top: 0; z-index: 20;
}
.research-tabs {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex; gap: 0;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.research-tabs::-webkit-scrollbar { display: none; }
.research-tab {
  padding: 14px 20px;
  cursor: pointer;
  color: var(--pal-fg-muted);
  border: none; background: none;
  font: inherit; font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
}
.research-tab .tab-count {
  background: var(--pal-surface-tint);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--pal-fg-muted);
}
.research-tab:hover { color: var(--pal-fg); }
.research-tab.is-active {
  color: var(--pal-fg);
  font-weight: 600;
  border-bottom-color: var(--pal-accent);
}

.research-panel { display: none; }
.research-panel.is-active { display: block; }

/* =========================================================================
   Findings: 2-col layout (TOC rail + article)
   ========================================================================= */
.research-findings-layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 24px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
}
.research-findings-layout.has-children-rail {
  max-width: 1380px;
  grid-template-columns: 200px minmax(0, 1fr) 260px;
  gap: 48px;
}

.children-rail {
  align-self: start;
  position: sticky;
  top: 70px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  max-height: calc(100vh - 90px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.research-toc {
  align-self: start;
  position: sticky;
  top: 70px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

:is(.research-toc, .children-rail) .sibling-list {
  list-style: none;
  /* Right gutter accommodates the 2px hover translateX so the right border
     stays visible inside the rail's overflow-x: hidden clip. */
  padding: 0 4px 0 0;
  margin: 0 0 22px;
}
:is(.research-toc, .children-rail) .sibling-card { margin-bottom: 6px; position: relative; }
:is(.research-toc, .children-rail) .sibling-card > .view-badges {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
}
:is(.research-toc, .children-rail) .sibling-card .view-badge {
  padding: 1px 6px;
  font-size: 9px;
  letter-spacing: 0.06em;
}
/* Reserve right gutter inside the card so the title doesn't run under the
   absolutely-positioned view-badge. */
:is(.research-toc, .children-rail) .sibling-card:has(> .view-badges) > a {
  padding-right: 78px;
}
:is(.research-toc, .children-rail) .sibling-card a {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
:is(.research-toc, .children-rail) .sibling-card a:hover {
  border-color: var(--pal-accent);
  transform: translateX(2px);
}
:is(.research-toc, .children-rail) .sibling-card .num {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--pal-fg-faint);
  line-height: 1;
  width: 22px;
  flex-shrink: 0;
}
:is(.research-toc, .children-rail) .sibling-card .sc-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
:is(.research-toc, .children-rail) .sibling-card .sc-ttl {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--pal-fg);
}
:is(.research-toc, .children-rail) .sibling-card .sc-meta {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  color: var(--pal-fg-faint);
}
:is(.research-toc, .children-rail) .sibling-card.active a {
  border-color: var(--pal-accent);
  background: color-mix(in srgb, var(--pal-accent) 12%, var(--pal-surface));
}
:is(.research-toc, .children-rail) .sibling-card.active .num,
:is(.research-toc, .children-rail) .sibling-card.active .sc-ttl { color: var(--pal-accent); }

:is(.research-toc, .children-rail) .sibling-parent { margin-bottom: 12px; }
:is(.research-toc, .children-rail) .sibling-parent .num {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 20px;
  color: var(--pal-fg-muted);
}
:is(.research-toc, .children-rail) .sibling-parent .sc-tag {
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--pal-fg-faint);
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  margin-bottom: 1px;
}
:is(.research-toc, .children-rail) .toc-label {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--pal-fg-faint);
  margin: 0 0 12px;
}
.research-toc .toc-list {
  list-style: none;
  padding: 0; margin: 0 0 28px;
  font-size: 13.5px;
  counter-reset: toc;
}
.research-toc .toc-list > li {
  padding: 0;
  border-left: 2px solid transparent;
  counter-increment: toc;
}
.research-toc .toc-list > li > a {
  display: block;
  padding: 5px 8px;
  color: var(--pal-fg-muted);
  text-decoration: none;
  transition: color .12s;
}
.research-toc .toc-list > li > a::before {
  content: counter(toc) ". ";
  color: var(--pal-fg-faint);
}
.research-toc .toc-list > li > a:hover { color: var(--pal-fg); }
.research-toc .toc-list > li.is-active {
  border-left-color: var(--pal-accent);
  background: color-mix(in srgb, var(--pal-accent) 14%, transparent);
  border-radius: 0 3px 3px 0;
}
.research-toc .toc-list > li.is-active > a {
  color: var(--pal-fg);
  font-weight: 600;
}
.research-toc .toc-list > li.sub {
  counter-increment: none;
  padding-left: 18px;
  font-size: 12.5px;
}
.research-toc .toc-list > li.sub > a::before { content: '— '; }

.research-progress {
  background: var(--pal-surface-tint);
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
}
.research-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--pal-accent);
  transition: width .15s ease;
}
.research-progress-text {
  font-size: 11px;
  color: var(--pal-fg-faint);
  margin-top: 6px;
}

@media (max-width: 920px) {
  .research-findings-layout,
  .research-findings-layout.has-children-rail {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 28px;
  }
  .research-toc {
    position: static;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--pal-border);
  }
  .children-rail { display: none; }
}

@media (max-width: 760px) {
  .research-toc { display: none; }
  .research-findings-layout { padding: 28px 16px; }

  .research-provenance { padding: 36px 16px; }
  .research-provenance h3 { font-size: 22px; margin-bottom: 18px; }
  .pcell .val { font-size: 22px; }

  .citations-wrap,
  .raw-wrap { padding: 32px 16px 60px; }
}

/* =========================================================================
   Article (magazine column)
   ========================================================================= */
.research-article {
  display: grid;
  grid-template-columns:
    [full-start] minmax(0, 1fr)
    [content-start] min(680px, 100%) [content-end]
    minmax(0, 1fr) [full-end];
  font-family: 'Fraunces', Georgia, serif;
  font-size: 19px;
  line-height: 1.7;
  color: var(--pal-fg);
}
/* min-width: 0 keeps grid items from blowing the content track wider than
   its declared track size — without it, a <pre> with a long unbreakable
   line (Dockerfiles, log lines) expands the track past 100% on mobile and
   triggers document-level horizontal scroll. */
.research-article > * { grid-column: content; min-width: 0; }
.research-article > table { grid-column: full; }
.research-article > p { margin: 0 0 22px; }

/* Drop cap on the very first paragraph */
.research-article > p:first-of-type::first-letter {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  float: left;
  font-size: 86px;
  line-height: .85;
  padding: 8px 12px 0 0;
  color: var(--pal-accent);
}

.research-article h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 56px 0 18px;
  scroll-margin-top: 80px;
}
.research-article h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  margin: 36px 0 12px;
  scroll-margin-top: 80px;
}

.research-article a {
  color: var(--pal-accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--pal-accent) 35%, transparent);
}
.research-article a:hover { border-bottom-color: var(--pal-accent); }

.research-article code {
  background: var(--pal-surface-tint);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.78em;
}
.research-article pre {
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.research-article pre code { background: none; padding: 0; font-size: inherit; }

.research-article blockquote {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 26px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--pal-accent);
  border: none;
  margin: 40px -16px;
  padding: 0 16px;
  text-align: center;
  letter-spacing: -0.005em;
}
.research-article blockquote::before {
  content: '“';
  display: block;
  font-size: 56px;
  color: var(--pal-border);
  line-height: .55;
  margin-bottom: 6px;
}
.research-article blockquote p { margin: 0 0 8px; }
.research-article blockquote :last-child { margin-bottom: 0; }

.research-article table {
  width: 100%;
  margin: 28px 0;
  border-collapse: collapse;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
}
.research-article th,
.research-article td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--pal-border);
  text-align: left;
  vertical-align: top;
}
.research-article th {
  background: var(--pal-surface-tint);
  font-weight: 600;
}
.research-article ul,
.research-article ol {
  font-size: 17px;
  padding-left: 26px;
  margin: 0 0 22px;
}
.research-article li { margin-bottom: 6px; }
.research-article hr {
  border: none;
  border-top: 1px solid var(--pal-border);
  margin: 40px auto;
  width: 60%;
}

@media (max-width: 920px) {
  .research-article { font-size: 17px; }
  .research-article blockquote { font-size: 22px; margin: 30px 0; }
}

/* Mobile card view for tables (markup injected by table-cards.js) */
.research-article .table-cards { display: none; }
.table-card {
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  border-left: 4px solid var(--pal-accent);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  row-gap: 6px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}
.table-card dt {
  color: var(--pal-fg-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  align-self: start;
  padding-top: 2px;
  margin: 0;
}
.table-card dd { margin: 0; }
.table-card dd:first-of-type {
  font-weight: 600;
  font-size: 15px;
  color: var(--pal-fg);
}
@media (max-width: 760px) {
  .research-article table { display: none; }
  .research-article .table-cards { display: block; }
}

/* =========================================================================
   Provenance band (dark) at end of Findings
   ========================================================================= */
/* Sibling pager — prev/next cards above the provenance footer on
   sub-topic pages. Hidden on top-level research pages and orphans. */
.research-pager {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 0;
}
.research-pager-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.research-pager-card {
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  border-radius: 10px;
  padding: 18px 22px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: border-color .15s ease, transform .15s ease;
  min-width: 0;
}
.research-pager-card:hover {
  border-color: var(--pal-accent);
  transform: translateY(-2px);
}
.research-pager-card.prev { grid-column: 1; }
.research-pager-card.next { grid-column: 2; flex-direction: row-reverse; text-align: right; }
.research-pager-card.up   { display: none; }
.research-pager-card .rp-arrow {
  font-size: 28px;
  line-height: 1;
  color: var(--pal-accent);
  font-family: 'Fraunces', Georgia, serif;
  flex-shrink: 0;
}
.research-pager-card .rp-body { flex: 1; min-width: 0; }
.research-pager-card .rp-lbl {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--pal-fg-faint);
  margin-bottom: 4px;
}
.research-pager-card h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
  line-height: 1.25;
  color: var(--pal-fg);
}
.research-pager-card p {
  font-size: 12.5px;
  color: var(--pal-fg-muted);
  margin: 0;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 720px) {
  .research-pager-row { grid-template-columns: 1fr; }
  .research-pager-card.prev,
  .research-pager-card.next,
  .research-pager-card.up { grid-column: 1; }
  .research-pager-card.next { flex-direction: row; text-align: left; }
  .research-pager-card.up { display: flex; }
}

/* "Green thing" footer — full sage-on-deep-green palette from the
   1-magazine wireframe. All colors hardcoded so the footer reads the
   same way on any palette (rust/paper/cartography/midnight/...) —
   var(--pal-fg) was rendering black on rust where the wireframe
   wanted dark green. No inner max-width: content spans the section's
   full padding, matching the wireframe's edge-to-edge layout. */
.research-provenance {
  background: #1a2e1f;
  color: #dce5d1;
  margin-top: 80px;
  padding: 60px 8vw;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.provenance-inner { margin: 0 auto; }
.research-provenance h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 28px;
  margin: 0 0 24px;
  color: #dce5d1;
}
.research-provenance .pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 28px 36px;
  margin-bottom: 36px;
}
.pcell .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #9bb38f;
  margin-bottom: 6px;
}
.pcell .val {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 26px;
  color: #faf6ea;
}
.research-provenance .prompt-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #9bb38f;
  margin: 28px 0 8px;
}
.research-provenance .prompt-block {
  background: rgba(255, 255, 255, .06);
  border-left: 3px solid var(--pal-accent);
  padding: 18px 20px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.6;
  color: #dce5d1;
  font-style: italic;
  white-space: pre-line;
}
.research-provenance .ribbon {
  margin-top: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 28px;
  border-top: 1px solid #2a3d2e;
  font-size: 13px;
  color: #9bb38f;
}
.research-provenance .ribbon a {
  color: #dce5d1;
  text-decoration: underline;
}
.research-provenance .ribbon-links {
  display: inline-flex;
  gap: 18px;
  flex-wrap: wrap;
}

/* =========================================================================
   Citations panel
   ========================================================================= */
.citations-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.citations-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.citations-head h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 28px;
  margin: 0;
}
.citations-filter {
  padding: 8px 12px;
  border: 1px solid var(--pal-border);
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  background: var(--pal-surface);
  color: var(--pal-fg);
  min-width: 280px;
}
.citation-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 720px) { .citation-list { grid-template-columns: 1fr; } }
.citation-card {
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  border-radius: 6px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s;
  /* Grid items default to min-width: min-content; without this a long URL in
     .ttl pushes the column wider than 1fr and triggers horizontal overflow. */
  min-width: 0;
}
.citation-card:hover { border-color: var(--pal-accent); }
.citation-card .num {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--pal-accent);
  font-weight: 600;
  font-size: 13px;
}
.citation-card .ttl {
  color: var(--pal-fg);
  font-size: 14px;
  margin: 2px 0 4px;
  line-height: 1.3;
  /* Citations from Scout have no `title` field, so .ttl falls back to the
     full URL — break it instead of overflowing the card. */
  overflow-wrap: anywhere;
}
.citation-card .src {
  color: var(--pal-fg-faint);
  font-size: 11px;
  word-break: break-all;
}
.citation-loading {
  grid-column: 1 / -1;
  color: var(--pal-fg-muted);
  font-style: italic;
  margin: 0;
}


/* =========================================================================
   Expedition layout — parent overview + children grid
   ========================================================================= */

/* Synthesis prose container — sits between cover and children grid.
   When synthesis is present, the inner .research-findings-layout owns
   width/padding so the TOC + article distribution matches detail pages.
   The empty-state variant keeps a tight, centered container. */
.expedition-synthesis { margin: 0; padding: 0; max-width: none; }
.expedition-synthesis-empty {
  color: var(--pal-fg-muted);
  font-style: italic;
  max-width: 1080px;
  margin: 56px auto 40px;
  padding: 0 6vw;
}
.expedition-synthesis .research-article {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  line-height: 1.65;
}
.expedition-synthesis .research-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 15px;
}
.expedition-synthesis .research-article th,
.expedition-synthesis .research-article td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--pal-border);
}
.expedition-synthesis .research-article th {
  font-weight: 600;
  color: var(--pal-fg);
  background: var(--pal-surface-tint);
}

/* Header chip showing N angles — also the anchor link to the sub-topics
   grid below (mobile users especially: this is a one-tap jump). */
.angles-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 11px/1.4 ui-monospace, Menlo, monospace;
  color: var(--d-expedition);
  background: var(--d-expedition-bg);
  border: 1px solid color-mix(in srgb, var(--d-expedition) 30%, transparent);
  text-decoration: none;
  transition: background .12s ease, transform .12s ease;
}
a.angles-badge:hover {
  background: color-mix(in srgb, var(--d-expedition) 22%, transparent);
  transform: translateY(1px);
}

/* Smooth scroll + anchor offset for the angles-badge → sub-topics jump. */
html { scroll-behavior: smooth; }
.expedition-children { scroll-margin-top: 16px; }

/* Children grid section. */
.expedition-children {
  background: color-mix(in srgb, var(--pal-surface) 60%, var(--pal-bg));
  padding: 48px 8vw 64px;
  border-top: 1px solid var(--pal-border);
}
.expedition-children-inner { max-width: 1100px; margin: 0 auto; }
.expedition-children h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 24px;
  color: var(--pal-fg);
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.child-card-wrap { position: relative; display: flex; }
.child-card-wrap > .child-card { flex: 1; min-width: 0; }
.child-card-wrap > .view-badges {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
}
/* Reserve right gutter on the meta row so depth-badge / sources / min chips
   don't slide under the absolutely-positioned view-badge. */
.child-card-wrap:has(> .view-badges) > .child-card .child-card-meta {
  padding-right: 90px;
}

.child-card {
  display: block;
  padding: 18px;
  background: var(--pal-surface);
  border: 1px solid var(--pal-border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.child-card-success:hover {
  transform: translateY(-2px);
  border-color: var(--pal-accent);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--pal-fg) 8%, transparent);
}
.child-card-failed {
  opacity: 0.6;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--pal-surface-tint) 50%, var(--pal-surface));
}
.child-card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
  font-size: 11px;
}
.child-card-title {
  margin: 0 0 8px;
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  line-height: 1.25;
  color: var(--pal-fg);
  font-weight: 600;
}
.child-card-summary {
  margin: 0;
  color: var(--pal-fg-muted);
  font-size: 13.5px;
  line-height: 1.45;
}
.depth-faded { opacity: 0.55; }
.failed-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 10.5px/1.4 ui-monospace, Menlo, monospace;
  background: #b91c1c;
  color: #fff;
}
.child-card-warning {
  border-color: #d97706;
  border-left: 3px solid #d97706;
}
.warning-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
}
.child-card-warning-reason {
  margin: 8px 0 0;
  padding: 6px 8px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  line-height: 1.4;
}

/* Home-grid card chip when an entry has children (a parent expedition).
   Lives inside .card-top alongside the depth-badge so positioning stays
   consistent with non-expedition cards. */
/* (.angles-chip and .card-expedition moved to base.css — those styles
   need to load on the home grid too, where research.css isn't pulled.) */
