/* ==========================================================================
   The Pocket Coding Agent | blog series design system
   PaperMod bones, own identity: forest green + burnt sienna accents, light/dark.
   ========================================================================== */

/* ----- Theme tokens ------------------------------------------------------ */
:root {
  --max:        46rem;        /* ~736px reading measure */
  --max-wide:   60rem;        /* hero / leaderboard breakout */

  /* light (default) */
  --bg:         #ffffff;
  --surface:    #f6f7f8;
  --surface-2:  #eef0f2;
  --text:       #1f2328;
  --muted:      #5b626b;
  --faint:      #8a929c;
  --border:     #e4e7ea;
  --border-strong: #d3d8dd;

  --teal:       #2f6f4e;
  --teal-soft:  #2f6f4e16;
  --rust:       #a8551f;
  --rust-soft:  #a8551f14;
  --gold:       #b07d18;

  --code-bg:    #f6f7f8;
  --code-text:  #2b3138;
  --shadow:     0 1px 2px rgba(16,22,28,.04), 0 8px 24px rgba(16,22,28,.06);

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg:         #18191b;
  --surface:    #202225;
  --surface-2:  #26292d;
  --text:       #dce0e4;
  --muted:      #9aa1a9;
  --faint:      #6f767e;
  --border:     #2c2f34;
  --border-strong: #383c42;

  --teal:       #6cae8e;
  --teal-soft:  #6cae8e1c;
  --rust:       #d98a5a;
  --rust-soft:  #d98a5a1c;
  --gold:       #e0b54a;

  --code-bg:    #1f2124;
  --code-text:  #c9ced4;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

/* ----- Reset / base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .2s ease, color .2s ease;
}
img { max-width: 100%; height: auto; display: block; }
::selection { background: var(--teal-soft); }

/* ----- Header / nav ------------------------------------------------------ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: .85rem 1.5rem;
  display: flex; align-items: center; gap: 1.25rem;
}
.nav__brand {
  font-weight: 650; letter-spacing: -.01em;
  color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: .55rem;
}
.nav__brand .dot {
  width: .58rem; height: .58rem; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px var(--teal-soft);
}
.nav__spacer { flex: 1; }
.nav__links { display: flex; gap: 1.1rem; align-items: center; }
.nav__links a {
  color: var(--muted); text-decoration: none; font-size: .94rem;
  transition: color .15s ease;
}
.nav__links a:hover { color: var(--text); }
.theme-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 8px; cursor: pointer;
  width: 36px; height: 32px; display: grid; place-items: center;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

/* ----- Layout ------------------------------------------------------------ */
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }
.wrap--wide { max-width: var(--max-wide); }
main { padding: 3rem 0 4rem; }
.breakout {
  max-width: var(--max-wide);
  margin-left: 50%; transform: translateX(-50%);
  width: 92vw;
}

/* ----- Typography -------------------------------------------------------- */
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.018em; font-weight: 680; }
h1 { font-size: 2.3rem; margin: 0 0 .6rem; }
h2 {
  font-size: 1.5rem; margin: 2.8rem 0 1rem;
  padding-top: .4rem;
}
h3 { font-size: 1.18rem; margin: 2rem 0 .6rem; }
p { margin: 0 0 1.15rem; }
a { color: var(--teal); text-decoration: none; border-bottom: 1px solid var(--teal-soft); transition: border-color .15s ease; }
a:hover { border-bottom-color: var(--teal); }
strong { font-weight: 660; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
.lead { font-size: 1.18rem; color: var(--muted); line-height: 1.6; }
.eyebrow {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--teal); font-weight: 600;
  margin: 0 0 .9rem;
}

/* post meta line under title */
.post-meta {
  font-size: .9rem; color: var(--faint); font-style: italic;
  margin: 0 0 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border);
}
.post-meta a { color: var(--muted); border: none; text-decoration: underline; text-decoration-color: var(--border-strong); }

/* ----- Code & transcripts ------------------------------------------------ */
code {
  font-family: var(--mono); font-size: .86em;
  background: var(--surface-2); color: var(--code-text);
  padding: .12em .38em; border-radius: 5px;
}
pre {
  font-family: var(--mono);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-size: .855rem; line-height: 1.6;
  margin: 1.6rem 0;
  box-shadow: var(--shadow);
}
pre code { background: none; padding: 0; font-size: inherit; color: var(--code-text); }

/* annotated transcript blocks (the agent traces) */
.transcript {
  position: relative;
}
.transcript .ok    { color: var(--teal); }
.transcript .bad   { color: var(--rust); }
.transcript .note  { color: var(--faint); }
.transcript .arrow { color: var(--faint); }
.transcript b { color: var(--text); font-weight: 600; }
.transcript .label {
  display: inline-block; font-family: var(--mono); font-size: .7rem;
  letter-spacing: .05em; text-transform: uppercase; font-weight: 600;
  padding: .12em .5em; border-radius: 5px; margin-bottom: .4rem;
}
.transcript .label.ok  { background: var(--teal-soft); color: var(--teal); }
.transcript .label.bad { background: var(--rust-soft); color: var(--rust); }

/* ----- Metric chips ------------------------------------------------------ */
.chips { display: inline-flex; gap: .4rem; flex-wrap: wrap; vertical-align: middle; }
.chip {
  display: inline-flex; align-items: baseline; gap: .4rem;
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  padding: .2em .6em; border-radius: 7px;
  border: 1px solid var(--border-strong); background: var(--surface);
  white-space: nowrap;
}
.chip .k { color: var(--faint); font-weight: 500; text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; }
.chip--raw  .v { color: var(--rust); }
.chip--full .v { color: var(--teal); }
.chip--best { border-color: var(--teal); background: var(--teal-soft); }
.chip--best .v { color: var(--teal); }

/* ----- Figures ----------------------------------------------------------- */
figure {
  margin: 2rem 0; padding: 0;
}
figure img {
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg); box-shadow: var(--shadow);
}
figcaption {
  margin-top: .7rem; font-size: .88rem; color: var(--muted);
  text-align: center; line-height: 1.5;
}
figcaption b { color: var(--text); }

/* ----- Callout / aside --------------------------------------------------- */
.callout {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 10px; padding: 1.05rem 1.25rem;
  margin: 1.8rem 0; font-size: .98rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout .callout__title { font-weight: 660; color: var(--text); }
.callout--rust { border-left-color: var(--rust); }

/* ----- Leaderboard / data tables ----------------------------------------- */
.table-scroll { overflow-x: auto; margin: 1.8rem 0; }
table.data {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
table.data thead th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 600; font-size: .8rem; letter-spacing: .02em;
  text-transform: uppercase; text-align: left;
  padding: .7rem 1rem; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
table.data tbody td {
  padding: .7rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); font-size: .88rem; }
table.data .stage { font-weight: 600; }
table.data .modelid { font-family: var(--mono); font-size: .8rem; color: var(--faint); }
table.data tr.is-best { background: var(--teal-soft); }
table.data tr.is-best:hover { background: color-mix(in srgb, var(--teal-soft) 70%, var(--surface)); }
table.data tr.is-best .stage::after {
  content: "BEST"; font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; color: var(--bg); background: var(--teal);
  padding: .1em .45em; border-radius: 4px; margin-left: .55rem; vertical-align: middle;
}
table.data tr.is-nogo .stage::after {
  content: "NO-GO"; font-family: var(--mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .06em; color: var(--bg); background: var(--rust);
  padding: .1em .45em; border-radius: 4px; margin-left: .55rem; vertical-align: middle;
}
.delta-up   { color: var(--teal); }
.delta-down { color: var(--rust); }

/* mini inline bar inside table cells */
.bar { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: .3rem; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--teal); }

/* ----- Pipeline hero ----------------------------------------------------- */
.hero {
  text-align: center; padding: 1rem 0 .5rem;
}
.hero h1 { font-size: 2.8rem; margin-bottom: 1rem; }
@media (max-width: 640px){ .hero h1 { font-size: 2.1rem; } }
.hero .lead { max-width: 38rem; margin: 0 auto 2rem; }
.pipeline {
  display: flex; align-items: stretch; justify-content: center;
  gap: 0; flex-wrap: wrap; margin: 2.5rem auto 1rem; max-width: 56rem;
}
.pstage {
  flex: 1 1 0; min-width: 120px;
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem .6rem; position: relative;
}
.pstage:not(:last-child)::after {
  content: "→"; position: absolute; right: -.4rem; top: 1.4rem;
  color: var(--faint); font-size: 1.1rem;
}
.pstage .pname { font-weight: 650; font-size: .98rem; margin-bottom: .15rem; }
.pstage .pscore { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; color: var(--teal); }
.pstage .psub { font-size: .76rem; color: var(--faint); margin-top: .15rem; }
.pstage.is-peak .pscore { color: var(--teal); }
.pstage.is-base .pscore { color: var(--rust); }
@media (max-width: 560px){
  .pipeline { flex-direction: column; }
  .pstage:not(:last-child)::after { content: "↓"; right: auto; top: auto; bottom: -.2rem; }
}

/* ----- Post list (index) ------------------------------------------------- */
.postlist { display: grid; gap: 1rem; margin: 2rem 0; }
.postcard {
  display: block; text-decoration: none; border: 1px solid var(--border);
  border-radius: 14px; padding: 1.3rem 1.4rem; background: var(--bg);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.postcard:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.postcard__top { display: flex; align-items: center; gap: .7rem; margin-bottom: .5rem; }
.postcard__num {
  font-family: var(--mono); font-size: .76rem; font-weight: 700; color: var(--teal);
  background: var(--teal-soft); padding: .2em .55em; border-radius: 6px;
}
.postcard__status {
  margin-left: auto; font-family: var(--mono); font-size: .7rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--faint);
  border: 1px solid var(--border); padding: .15em .5em; border-radius: 999px;
}
.postcard__status.live { color: var(--rust); border-color: var(--rust); }
.postcard__title { font-size: 1.22rem; font-weight: 660; color: var(--text); margin: 0 0 .25rem; letter-spacing: -.01em; }
.postcard__desc { color: var(--muted); font-size: .96rem; margin: 0; }
.postcard.is-todo { opacity: .62; pointer-events: none; }

/* ----- TOC --------------------------------------------------------------- */
.toc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.25rem; margin: 0 0 2.5rem;
  font-size: .92rem;
}
.toc__label { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: .5rem; }
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin: .25rem 0; }
.toc a { color: var(--muted); border: none; }
.toc a:hover { color: var(--teal); }

/* ----- Post nav (prev/next) ---------------------------------------------- */
.postnav { display: flex; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.postnav a, .postnav .is-todo {
  flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1.1rem;
  text-decoration: none; transition: border-color .15s ease, background .15s ease;
}
.postnav a:hover { border-color: var(--border-strong); background: var(--surface); }
.postnav .is-todo { opacity: .55; pointer-events: none; }
.postnav .dir { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-family: var(--mono); }
.postnav .ttl { color: var(--text); font-weight: 600; font-size: .95rem; margin-top: .2rem; }
.postnav .next { text-align: right; }

/* ----- Footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--border); margin-top: 4rem;
  padding: 2rem 0; color: var(--faint); font-size: .88rem;
}
.site-footer .wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer .nav__spacer { flex: 1; }

/* ----- Misc -------------------------------------------------------------- */
ul, ol { padding-left: 1.3rem; }
li { margin: .35rem 0; }
blockquote {
  margin: 1.5rem 0; padding: .2rem 0 .2rem 1.2rem;
  border-left: 3px solid var(--border-strong); color: var(--muted);
}
.center { text-align: center; }
.muted { color: var(--muted); }

/* ----- Inline charts (native SVG / CSS) ---------------------------------- */
.chart {
  margin: 1.8rem 0; padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.chart__title { font-weight: 640; font-size: .98rem; margin: 0 0 .15rem; }
.chart__sub { color: var(--muted); font-size: .86rem; margin: 0 0 1rem; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg text { font-family: var(--mono); fill: var(--muted); }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .line-teal { fill: none; stroke: var(--teal); stroke-width: 2.5; }
.chart .line-rust { fill: none; stroke: var(--rust); stroke-width: 2.5; }
.chart .dot-teal { fill: var(--teal); }
.chart .dot-rust { fill: var(--rust); }
.chart .lbl-teal { fill: var(--teal); font-weight: 600; }
.chart .lbl-rust { fill: var(--rust); font-weight: 600; }
.chart__legend { display: flex; gap: 1.2rem; margin-top: .8rem; font-size: .82rem; font-family: var(--mono); color: var(--muted); }
.chart__legend .key { display: inline-flex; align-items: center; gap: .4rem; }
.chart__legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* horizontal CSS bar list (e.g. prompt gradient) */
.barlist { margin: 1.8rem 0; }
.barlist__row { display: grid; grid-template-columns: 9rem 1fr auto; align-items: center; gap: .8rem; margin: .55rem 0; }
.barlist__name { font-family: var(--mono); font-size: .82rem; color: var(--muted); text-align: right; }
.barlist__track { background: var(--surface-2); border-radius: 6px; height: 1.4rem; position: relative; overflow: hidden; }
.barlist__fill { position: absolute; inset: 0 auto 0 0; background: var(--teal); border-radius: 6px; }
.barlist__fill.is-peak { background: var(--teal); }
.barlist__fill.is-low  { background: var(--rust); }
.barlist__val { font-family: var(--mono); font-size: .82rem; font-weight: 600; min-width: 3.2rem; }

/* key takeaway box */
.takeaway {
  border: 1px solid var(--teal); background: var(--teal-soft);
  border-radius: 12px; padding: 1.1rem 1.3rem; margin: 2rem 0;
}
.takeaway .takeaway__k { font-family: var(--mono); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); font-weight: 700; margin-bottom: .35rem; }
.takeaway p:last-child { margin-bottom: 0; }
