/* PlotGTM blog — static, crawlable pages generated by script/build-blog.ts */
:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-2: #f4f4f6;
  --border: #e8e8ec;
  --text: #171717;
  --muted: #5f5f66;
  --primary: #4f46e5;
  --primary-ink: #4338ca;
  --primary-soft: rgba(79, 70, 229, 0.08);
  --primary-ring: rgba(79, 70, 229, 0.28);
  --code-bg: #f5f5fb;
  --code-border: #e3e2f5;
  --radius: 12px;
  --content: 720px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #171717;
    --surface-2: #1c1c1f;
    --border: #2a2a2e;
    --text: #f5f5f5;
    --muted: #a3a3ab;
    --primary: #8b85ff;
    --primary-ink: #a5a0ff;
    --primary-soft: rgba(139, 133, 255, 0.1);
    --primary-ring: rgba(139, 133, 255, 0.35);
    --code-bg: #1a1a24;
    --code-border: #2c2b45;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; display: block; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand svg { width: 30px; height: 30px; flex: none; }
.brand b { font-size: 15px; letter-spacing: -0.01em; }
.brand small { display: block; white-space: nowrap; font-size: 11px; color: var(--muted); margin-top: -2px; font-weight: 400; }
.nav { display: flex; align-items: center; gap: 4px; font-size: 14px; }
.nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); }
.nav a.nav-cta { background: var(--primary); color: #fff; }
.nav a.nav-cta:hover { background: var(--primary-ink); color: #fff; }

/* ---------- reading progress ---------- */
.progress {
  position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 30;
  background: transparent; pointer-events: none;
}
.progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width 80ms linear; }
.read-left {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
  font-variant-numeric: tabular-nums;
  opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s;
}
.read-left.show { opacity: 1; transform: none; }
.read-left i { display: inline-block; width: 46px; height: 4px; border-radius: 4px; background: var(--surface-2); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.read-left i b { display: block; height: 100%; width: 0; background: var(--primary); }

/* ---------- article ---------- */
.wrap { max-width: var(--content); margin: 0 auto; padding: 0 20px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 32px 0 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.kicker { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--primary-ink); margin-bottom: 10px; }
h1.post-title { font-size: clamp(30px, 4.4vw, 42px); line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 16px; font-weight: 750; text-wrap: balance; }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 22px; line-height: 1.55; }
.byline { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.byline img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.byline .who { color: var(--text); font-weight: 600; text-decoration: none; }
.byline .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.byline .dot { opacity: .5; }

.toc { margin: 22px 0 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 15px; }
.toc summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "+"; color: var(--muted); font-weight: 400; }
.toc[open] summary::after { content: "–"; }
.toc ol { margin: 0; padding: 0 16px 14px 36px; }
.toc li { margin: 4px 0; line-height: 1.45; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }

.prose { margin-top: 18px; }
.prose > * { margin-top: 0; margin-bottom: 1.1em; }
.prose h2 { font-size: 26px; line-height: 1.25; letter-spacing: -0.02em; margin: 2.1em 0 .6em; font-weight: 700; scroll-margin-top: 80px; }
.prose h3 { font-size: 20px; line-height: 1.35; letter-spacing: -0.01em; margin: 1.7em 0 .5em; font-weight: 650; scroll-margin-top: 80px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 650; }
.prose blockquote {
  margin: 1.4em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--primary);
  font-size: 19px; font-weight: 550; line-height: 1.5; color: var(--text);
}
.prose blockquote p { margin: 0; }
.prose em { color: var(--muted); }
.prose a.xlink { font-weight: 500; }

/* formulas and worked calculations */
.prose pre.formula {
  margin: 1.3em 0; padding: 16px 18px; border-radius: 10px;
  background: var(--code-bg); border: 1px solid var(--code-border); border-left: 3px solid var(--primary);
  overflow-x: auto;
}
.prose pre.formula code {
  font-family: var(--mono); font-size: 14.5px; line-height: 1.75; color: var(--text);
  white-space: pre-wrap; word-break: normal; overflow-wrap: anywhere;
}
/* diagrams (decision trees, journey flows): keep alignment, scroll on small screens */
.prose pre.formula.tree code { white-space: pre; overflow-wrap: normal; font-size: 13.5px; line-height: 1.6; }
.prose :not(pre) > code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--code-border); padding: 1px 5px; border-radius: 5px; }

/* tables */
.table-wrap { margin: 1.4em 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.prose th, .prose td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; font-size: 13.5px; }
.prose tr:last-child td { border-bottom: 0; }
.prose td { font-variant-numeric: tabular-nums; }

/* CTA */
.cta {
  margin: 2.2em 0; padding: 22px 24px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-soft), transparent 70%), var(--surface);
  border: 1px solid var(--primary-ring);
  display: grid; grid-template-columns: 1fr auto; gap: 14px 22px; align-items: center;
}
.cta .label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-ink); margin: 0 0 4px; }
.cta h2, .cta .cta-title { color: var(--text); font-size: 19px; line-height: 1.3; margin: 0 0 6px; letter-spacing: -0.01em; font-weight: 700; }
.cta p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  background: var(--primary); color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 11px 18px; border-radius: 10px;
}
.btn:hover { background: var(--primary-ink); color: #fff; text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.cta-end { margin-top: 2.6em; }
@media (max-width: 640px) { .cta { grid-template-columns: 1fr; } .btn { justify-content: center; } }

/* author */
.author-card {
  margin: 2.6em 0 0; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
  display: grid; grid-template-columns: 76px 1fr; gap: 18px; align-items: start;
}
.author-card img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; }
.author-card .label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 2px; }
.author-card .name { font-size: 18px; font-weight: 700; margin: 0; }
.author-card .name a { color: var(--text); text-decoration: none; }
.author-card p.desc { margin: 4px 0 10px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.author-card .links { display: flex; flex-wrap: wrap; gap: 8px; }
.author-card .links a { font-size: 13.5px; font-weight: 500; text-decoration: none; border: 1px solid var(--border); background: var(--bg); padding: 5px 11px; border-radius: 999px; color: var(--text); display: inline-flex; gap: 6px; align-items: center; }
.author-card .links a:hover { border-color: var(--primary-ring); }
.author-card .links svg { width: 13px; height: 13px; }

/* related */
.related { margin: 3em 0 0; }
.related h2 { font-size: 20px; margin: 0 0 14px; letter-spacing: -0.01em; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--bg);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--primary-ring); transform: translateY(-1px); text-decoration: none; }
.card .cat { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--primary-ink); }
.card h3 { margin: 0; font-size: 17px; line-height: 1.35; letter-spacing: -0.01em; font-weight: 650; }
.card p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--muted); }
.card .mins { margin-top: auto; font-size: 13px; color: var(--muted); padding-top: 4px; }

/* blog index */
.hero { max-width: 1120px; margin: 0 auto; padding: 52px 20px 18px; }
.hero h1 { font-size: clamp(32px, 4.6vw, 46px); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 12px; font-weight: 750; }
.hero p { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0; line-height: 1.55; }
.index { max-width: 1120px; margin: 0 auto; padding: 8px 20px 20px; }
.index section { margin-top: 34px; }
.index h2 { font-size: 15px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.featured { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--surface); text-decoration: none; color: var(--text); }
.featured:hover { border-color: var(--primary-ring); text-decoration: none; }
.featured .txt { padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.featured h3 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
.featured p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.featured .art { background: linear-gradient(135deg, var(--primary-soft), transparent), var(--surface-2); display: grid; place-items: center; min-height: 220px; border-left: 1px solid var(--border); }
.featured .art svg { width: 72%; max-width: 320px; height: auto; color: var(--primary); }
@media (max-width: 760px) { .featured { grid-template-columns: 1fr; } .featured .art { border-left: 0; border-top: 1px solid var(--border); min-height: 160px; } }
.index .cta { max-width: 1120px; }

/* footer */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); }
.site-footer .inner { max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; font-size: 13.5px; color: var(--muted); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .site-header, .progress, .read-left, .cta, .related { display: none !important; } }

@media (max-width: 480px) { .brand small { display: none; } .nav a { padding: 7px 10px; } }
