/* Plotline explainer pack: shared styles.
   Look follows the ResearchAgent explainers (theFastandtheFungible gh-pages): light paper, Bricolage + Geist,
   white "instrument" panels that animate a real result, bold for emphasis (no marker highlight).
   Data hues follow Plotline's design/DESIGN.md meanings, darkened for a light page. One meaning per hue. */
:root {
  color-scheme: light;
  --paper: #EDF0E3; --sheet: #F9FAF3; --mist: #E3E8D8; --rule: #D6DCC8; --rule-2: #C0C8AD;
  --ink: #0F1222; --ink-2: #2B3046; --muted: #555B70; --faint: #8A90A3;
  --pen: #2F45FF; --pen-deep: #1E2FD0; --pen-wash: #ECEEFF; --pen-wash-2: #D7DCFF;
  --hi: #FFE45C; --hi-wash: #FFF4B8;
  --ok: #0B7A50; --ok-bright: #12B76A; --ok-wash: #E3F5EC;
  --bad: #C8312B; --bad-wash: #FDECEA;

  /* data meanings (from Plotline) */
  --loss: #E8590C;  --loss-wash: #FFE8DA;    /* tree-cover loss after the cut-off */
  --loss-past: #C9A08A;                       /* loss before the cut-off (context only) */
  --forest: #15803D; --forest-wash: #DCF5E4;  /* JRC 2020 forest */
  --canopy-0: #F1F5EF; --canopy-100: #2F6B47; /* treecover2000 ramp */
  --water: #2B6CB0; --water-wash: #E1EEFA;
  --declared: #7A5AF8; --declared-wash: #EFEAFF; /* what the supplier said */
  --proof: #4D7C0F; --proof-wash: #EEF7D9;    /* same answer / exact match */
  --review: #B7791F; --review-wash: #FFF3D6;  /* a question for a human reviewer */
  --unknown: #8A90A3; --unknown-wash: #EEF0F5;

  --f-display: 'Bricolage Grotesque', 'Geist', system-ui, -apple-system, sans-serif;
  --f-ui: 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --col: 1040px; --prose: 700px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 19px/1.6 var(--f-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--pen); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 6px; }
code, .mono { font-family: var(--f-mono); font-size: .9em; }
:not(pre) > code { background: var(--mist); border: 1px solid var(--rule); border-radius: 5px; padding: 1px 5px; }
:not(pre) > code { overflow-wrap: anywhere; }
img { max-width: 100%; }
svg { display: block; max-width: 100%; height: auto; }
svg text { font-family: var(--f-mono); }

/* masthead */
.mast { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.mast-in { max-width: var(--col); margin: 0 auto; padding: 10px 16px; display: flex; gap: 16px; align-items: center; justify-content: space-between; font: 500 13px/1.3 var(--f-mono); color: var(--muted); }
.mast b { color: var(--ink); font-weight: 600; }
.mast a { color: inherit; text-decoration: none; }
.mast a:hover { color: var(--pen); }
.mast .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--forest); margin-right: 8px; vertical-align: 1px; }
.mast .where { display: flex; gap: 14px; align-items: center; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--pen); width: 0; transition: width .1s linear; }

/* page */
.wrap { padding-inline: 16px; padding-block: 0 96px; }
main { max-width: var(--col); margin: 0 auto; }
section { padding-top: 72px; scroll-margin-top: 56px; }
.prose { max-width: var(--prose); }
.kick { font: 600 12.5px/1.2 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--pen); }
h1, h2, h3, h4 { font-family: var(--f-display); text-wrap: balance; margin: 0; letter-spacing: -.02em; }
h1 { font-size: clamp(44px, 7vw, 84px); line-height: .98; font-weight: 800; margin-top: 14px; }
h2 { font-size: clamp(32px, 4.4vw, 50px); line-height: 1.04; font-weight: 750; margin-top: 10px; }
h3 { font-size: 23px; line-height: 1.2; font-weight: 700; margin-top: 30px; }
h4 { font-size: 18px; font-weight: 700; margin-top: 20px; }
.lede { font-size: 21px; color: var(--ink-2); margin: 16px 0 0; }
.lede strong { color: var(--ink); }
p { margin: 14px 0 0; }
ul, ol { margin: 14px 0 0; padding-left: 1.3em; }
li { margin-top: 6px; }
.muted { color: var(--muted); }
.small { font-size: 15.5px; }

/* hero */
.hero { padding: 64px 0 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 22px; font: 500 13px/1.3 var(--f-mono); color: var(--muted); }
.meta span::before { content: "·"; margin-right: 18px; color: var(--rule-2); }
.meta span:first-child::before { content: none; margin: 0; }
.tldr { margin-top: 28px; padding: 18px 22px; background: var(--sheet); border: 1px solid var(--rule); border-left: 5px solid var(--hi); border-radius: 12px; max-width: var(--prose); }
.tldr b.lab { display: block; font: 600 11.5px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.tldr ul { margin: 0; }

/* instrument panels */
.panel { margin-top: 28px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 1px 0 var(--rule), 0 18px 40px -28px rgba(15, 18, 34, .28); overflow: hidden; }
.panel-in { padding: 22px 24px 20px; }
.ph { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline; justify-content: space-between; }
.tag { font: 600 11.5px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.tag .chip { color: var(--pen-deep); border: 1px solid var(--pen-wash-2); background: var(--pen-wash); border-radius: 999px; padding: 4px 9px; margin-right: 10px; letter-spacing: .1em; }
.tag .chip.syn { color: var(--review); border-color: color-mix(in srgb, var(--review) 40%, transparent); background: var(--review-wash); }
.replay, .btn { font: 600 14px var(--f-mono); color: var(--ink); background: var(--mist); border: 1px solid var(--rule-2); border-radius: 8px; padding: 9px 16px; cursor: pointer; }
.replay:hover, .btn:hover { background: var(--pen-wash); border-color: var(--pen-wash-2); }
.btn.on { background: var(--pen); border-color: var(--pen); color: #fff; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.foot { border-top: 1px solid var(--rule); padding: 14px 24px 16px; margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.foot b { color: var(--ink-2); font-weight: 600; }
.well { background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; }
.say { font: 650 21px/1.3 var(--f-display); letter-spacing: -.01em; min-height: 56px; margin-top: 14px; }
.say small { display: block; font: 500 13px/1.4 var(--f-mono); color: var(--muted); letter-spacing: 0; margin-bottom: 4px; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; }
.steps button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--rule-2); background: var(--sheet); font: 600 12px var(--f-mono); color: var(--muted); cursor: pointer; }
.steps button.on { background: var(--pen); border-color: var(--pen); color: #fff; }
.steps button.done { background: var(--pen-wash); color: var(--pen-deep); border-color: var(--pen-wash-2); }

/* big numbers */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 22px 32px; margin-top: 22px; }
.big .num { display: block; font: 800 clamp(42px, 6vw, 72px)/.95 var(--f-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.big .cap { display: block; margin-top: 8px; font: 500 12px/1.35 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.big.proof .num { color: var(--proof); } .big.loss .num { color: var(--loss); } .big.pen .num { color: var(--pen); } .big.forest .num { color: var(--forest); }

/* bars */
.bars { display: grid; gap: 10px; margin-top: 16px; }
.brow { display: grid; grid-template-columns: minmax(120px, 230px) minmax(0, 1fr) 90px; gap: 12px; align-items: center; font: 500 14px var(--f-mono); }
.brow .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brow .track { position: relative; height: 22px; border-radius: 6px; background: var(--mist); overflow: hidden; }
.brow .track i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--pen); border-radius: 6px; transition: width 1.1s var(--ease); }
.brow .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* callouts */
.note { margin-top: 22px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--rule); background: var(--sheet); display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; font-size: 17px; line-height: 1.5; max-width: var(--prose); }
.note > b:first-child { font: 700 11.5px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; border-radius: 6px; padding: 7px 9px; margin-top: 2px; background: var(--pen-wash); color: var(--pen-deep); }
.note.warn > b:first-child { background: var(--bad-wash); color: var(--bad); }
.note.unknown > b:first-child { background: var(--review-wash); color: var(--review); }
.note.ok > b:first-child { background: var(--proof-wash); color: var(--proof); }
.note.say-it > b:first-child { background: var(--hi); color: #5c4a00; }
.st { display: inline-block; font: 600 12px var(--f-mono); padding: 3px 8px; border-radius: 999px; background: var(--mist); color: var(--muted); white-space: nowrap; }
.st.ok { background: var(--ok-wash); color: var(--ok); } .st.bad { background: var(--bad-wash); color: var(--bad); }
.st.review { background: var(--review-wash); color: var(--review); } .st.declared { background: var(--declared-wash); color: var(--declared); }
.st.loss { background: var(--loss-wash); color: var(--loss); } .st.forest { background: var(--forest-wash); color: var(--forest); }

/* tables */
.tbl { margin-top: 18px; overflow-x: auto; }
.dt { width: 100%; border-collapse: collapse; font: 500 14px/1.4 var(--f-mono); font-variant-numeric: tabular-nums; }
.dt th { text-align: left; font: 600 11px var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 8px 10px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.dt td { padding: 9px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.dt td .t { display: block; font: 400 13.5px/1.4 var(--f-ui); color: var(--muted); }
.dt tr.pick td { background: var(--hi-wash); }
.dt td.r, .dt th.r { text-align: right; }

/* cards and grids */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 22px; }
.card { --c: var(--pen); position: relative; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }
.card .who { font: 600 11.5px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--c); }
.card h3, .card h4 { margin-top: 8px; }
.card p { font-size: 16.5px; color: var(--ink-2); margin-top: 8px; }

/* deeper / details */
details.deeper { margin-top: 22px; max-width: var(--prose); background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
details.deeper > summary { cursor: pointer; list-style: none; padding: 14px 18px; font: 600 15px var(--f-mono); color: var(--ink-2); display: flex; justify-content: space-between; gap: 12px; }
details.deeper > summary::-webkit-details-marker { display: none; }
details.deeper > summary::after { content: "+"; color: var(--pen); font-weight: 700; }
details.deeper[open] > summary::after { content: "−"; }
details.deeper > summary .lvl { font-weight: 500; color: var(--muted); }
details.deeper > .body { padding: 0 18px 18px; font-size: 17px; }

pre.code { margin: 14px 0 0; padding: 16px 18px; font: 500 13.5px/1.7 var(--f-mono); overflow-x: auto; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; color: var(--ink-2); }
kbd { font: 600 11px var(--f-mono); border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; background: var(--sheet); color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; font: 500 13px var(--f-mono); color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c, var(--pen)); }

/* table of contents (wide screens) */
.toc { position: fixed; top: 92px; right: 18px; width: 200px; display: none; font: 500 13px/1.3 var(--f-ui); }
.toc b { display: block; font: 600 11px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); padding: 0 10px 8px; }
.toc a { display: block; padding: 5px 10px; color: var(--muted); text-decoration: none; border-left: 2px solid var(--rule); }
.toc a.on { color: var(--ink); border-left-color: var(--pen); font-weight: 600; }
@media (min-width: 1480px) { .toc { display: block; } }

/* pager */
.pager { margin-top: 88px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pager a { display: block; padding: 18px 20px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 14px; text-decoration: none; color: var(--ink); transition: transform .3s var(--ease), border-color .3s; }
.pager a:hover { transform: translateY(-3px); border-color: var(--pen-wash-2); }
.pager small { display: block; font: 600 11.5px var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pager span { display: block; margin-top: 6px; font: 700 22px/1.2 var(--f-display); }
.pager .next { text-align: right; grid-column: 2; }
.endnote { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--rule); font: 500 13px/1.6 var(--f-mono); color: var(--muted); }

/* motion */
.rv { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.rv.in { opacity: 1; transform: none; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .panel-in { padding: 18px 16px; }
  .brow { grid-template-columns: 110px minmax(0, 1fr) 70px; font-size: 12.5px; }
  .pager { grid-template-columns: 1fr; } .pager .next { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rv { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print { .mast, .toc, .pager, .replay { display: none; } .rv { opacity: 1; transform: none; } }

/* persistent QR code (every page); shown only where the margin has room */
.qr-fixed { position: fixed; z-index: 40; right: 18px; bottom: 112px; display: none; width: 200px; padding: 10px; background: #fff; border: 1px solid var(--rule-2); border-radius: 14px; box-shadow: 0 10px 30px -18px rgba(15, 18, 34, .35); }
.qr-fixed img { display: block; width: 100%; height: auto; }
@media (min-width: 1500px) { .qr-fixed { display: block; } }
@media print { .qr-fixed { display: block; } }

/* card outline: a short bar at the top-left traces the whole border on hover, and unwinds on exit */
.edge { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.edge rect { x: 2px; y: 2px; width: calc(100% - 4px); height: calc(100% - 4px); fill: none; stroke: var(--c); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 7 93; transition: stroke-dasharray 1.15s cubic-bezier(.65, 0, .35, 1); }
.hcard:hover .edge rect, .hcard:focus-visible .edge rect, .card:hover .edge rect, a.card:focus-visible .edge rect { stroke-dasharray: 100 0; }
@media (prefers-reduced-motion: reduce) { .edge rect { transition: none; } }

