/* ============================================================
   DuitnSen BLOG — stylesheet
   Ported from duitnsen.com's shared stylesheet (Warm Editorial
   article-page direction). Same palette, fonts, ledger details.
   Display: Fraunces · Body: Plus Jakarta Sans · Data: IBM Plex Mono
   ============================================================ */

:root {
  --ink:      #1c1c1c;   /* charcoal                         */
  --ink-2:    #2a2a2a;
  --pine:     #143028;   /* deep pine — hero/footer          */
  --paper:    #faf8f3;   /* warm linen                       */
  --card:     #ffffff;
  --line:     #ddd8cc;
  --line-ink: rgba(255,255,255,.12);

  --grow:     #1f7a5a;   /* sage green — primary accent      */
  --grow-dk:  #165640;
  --gold:     #b8902f;   /* burnished gold                   */
  --sp:       #3f6ea5;
  --crash:    #b24a36;

  --tx:       #1c1c1c;
  --tx-soft:  #5a5a5a;
  --tx-faint: #8a8a8a;

  --display: "Fraunces", Georgia, serif;
  --body:    "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --maxw: 760px;
  --wide: 1080px;
  --r:  14px;
  --r-s: 9px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  font-family: var(--body);
  background: var(--paper);
  color: var(--tx);
  font-size: 18px;
  line-height: 1.7;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--grow-dk); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--gold); }
::selection { background: var(--gold); color: #fff; }

/* ---------- skip link ---------- */
.skip {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ============================================================
   TOP NAV — warm linen + subtle gold border (article style)
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250,248,243,.97);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid rgba(184,144,47,.32);
  color: var(--tx);
}
.nav-inner {
  max-width: var(--wide); margin: 0 auto;
  display: flex; align-items: center; gap: 18px;
  padding: 13px 24px;
}
.brand-group { display: inline-flex; align-items: baseline; gap: 7px; white-space: nowrap; }
.brand {
  font-family: var(--display);
  font-weight: 700; font-size: 1.22rem; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: baseline; gap: 2px;
}
.brand .sen { color: var(--grow); }
.brand:hover { color: var(--ink); }
.brand-blog {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .04em;
  color: var(--gold); text-decoration: none; font-weight: 600;
}
.brand-blog:hover { color: var(--grow-dk); }
.back-book {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .04em;
  color: var(--tx-faint); text-decoration: none; white-space: nowrap;
}
.back-book:hover { color: var(--grow-dk); }
.nav-links {
  margin-left: auto;
  display: flex; gap: 4px; overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  font-family: var(--mono);
  font-size: .73rem; letter-spacing: .03em; text-transform: uppercase;
  color: var(--tx-soft); text-decoration: none; white-space: nowrap;
  padding: 7px 12px; border-radius: 7px;
  transition: background .15s, color .15s;
}
.nav-links a:hover { color: var(--ink); background: rgba(0,0,0,.05); }
.nav-links a.active { color: #fff; background: var(--grow); }

/* ============================================================
   LAYOUT SHELLS
   ============================================================ */
.shell { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }
.read  { max-width: var(--maxw); margin-inline: auto; }
.section { padding: 64px 0 72px; }

.eyebrow {
  font-family: var(--mono);
  font-size: .73rem; font-weight: 500;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--gold);
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0 0 20px;
}
.eyebrow::before {
  content: ""; width: 24px; height: 2px; background: var(--gold); display: inline-block;
}

h1, h2, h3, h4 { font-family: var(--display); color: var(--ink); line-height: 1.1; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 1.75rem; margin: 1.6em 0 .5em; }
h3 { font-size: 1.38rem; letter-spacing: -.012em; margin: 1.8em 0 .4em; }
h1 em, h2 em { font-style: italic; color: var(--grow); font-weight: 600; }
p { margin: 0 0 1.1em; }
.muted { color: var(--tx-soft); }

/* ============================================================
   PAGE HEADER (linen, Warm Editorial)
   ============================================================ */
.page-header {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 64px 0 44px;
}
.page-header h1 {
  font-size: clamp(2.1rem, 5.5vw, 3.4rem);
  font-weight: 700; letter-spacing: -.025em; line-height: 1.08;
  color: var(--ink); margin: 0 0 .4em;
}
.page-header h1 em { color: var(--grow); }
.page-header-sub { font-size: 1.1rem; color: var(--tx-soft); max-width: 56ch; line-height: 1.7; }

.post-meta {
  font-family: var(--mono); font-size: .78rem; color: var(--tx-soft);
  margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
}
.post-meta .sep { color: var(--tx-faint); }
.post-meta .meta-date time { color: var(--ink); font-weight: 600; }
.post-meta .meta-updated time { color: var(--grow-dk); font-weight: 600; }

.tag-chip {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; text-transform: uppercase;
  background: rgba(31,122,90,.1); color: var(--grow-dk);
  padding: 2px 10px; border-radius: 999px; text-decoration: none;
  display: inline-block; margin-right: 6px;
}
.tag-chip:hover { background: var(--grow); color: #fff; }
.lang-chip {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .08em;
  background: rgba(184,144,47,.15); color: var(--gold);
  padding: 2px 8px; border-radius: 999px;
}

/* ============================================================
   HOME — POST LIST (ledger style, text-first)
   ============================================================ */
.post-list-section { padding-top: 44px; }
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item {
  border-bottom: 1px solid var(--line);
  padding: 30px 0 28px;
}
.post-item:last-child { border-bottom: 0; }
.post-item-meta {
  font-family: var(--mono); font-size: .74rem; color: var(--tx-soft);
  margin: 0 0 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.post-item-meta time { color: var(--gold); font-weight: 600; }
.post-item-meta .sep { color: var(--tx-faint); }
.post-item-title { font-size: 1.42rem; margin: 0 0 .3em; line-height: 1.2; }
.post-item-title a { color: var(--ink); text-decoration: none; }
.post-item-title a:hover { color: var(--grow-dk); }
.post-item-desc { font-size: .98rem; color: var(--tx-soft); margin: 0 0 .7em; max-width: 62ch; }
.post-item-tags { margin: 0; }

/* ============================================================
   TAG CLOUD
   ============================================================ */
.tag-cloud { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.tag-big { font-size: .82rem; padding: 8px 18px; }
.tag-count { color: var(--gold); margin-left: 4px; }

/* ============================================================
   POST BODY
   ============================================================ */
.post-body { padding-top: 44px; }
.post-body .lede { font-size: 1.2rem; color: var(--tx-soft); line-height: 1.7; }
.post-body ul, .post-body ol { margin: 0 0 1.2em; padding-left: 1.4em; }
.post-body li { margin-bottom: .4em; }
.post-body blockquote {
  font-family: var(--display); font-style: italic; font-size: 1.15rem;
  border-left: 3px solid var(--gold); margin: 1.6em 0; padding: 4px 0 4px 22px;
  color: var(--ink-2);
}
.post-body hr { border: none; border-top: 1px solid var(--line); margin: 2.4em 0; }

/* code — ledger mono on pine ink */
code {
  font-family: var(--mono); font-size: .86em;
  background: rgba(31,122,90,.08); color: var(--grow-dk);
  padding: 1px 6px; border-radius: 5px;
}
pre {
  font-family: var(--mono);
  background: var(--pine); color: #dfe9e2;
  border-radius: var(--r); padding: 20px 22px;
  overflow-x: auto; margin: 1.6em 0;
  font-size: .84rem; line-height: 1.6;
  border: 1px solid rgba(184,144,47,.25);
}
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* tables — factsheet style */
table {
  width: 100%; border-collapse: collapse; font-size: .93rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); margin: 1.6em 0;
  display: block; overflow-x: auto;
}
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-family: var(--mono); font-size: .71rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--tx-soft); background: rgba(0,0,0,.025); font-weight: 500;
}
tbody tr:last-child td { border-bottom: 0; }

.ticker, .tk {
  font-family: var(--mono); font-weight: 600; font-size: .9em;
  background: rgba(31,122,90,.1); color: var(--grow-dk);
  padding: 1px 7px; border-radius: 5px; white-space: nowrap;
}

/* images + captions */
figure { margin: 1.8em 0; }
figure img {
  width: 100%; display: block; margin: 0 auto;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
}
figcaption { font-size: .86rem; color: var(--tx-faint); font-style: italic; text-align: center; margin-top: 12px; }
.post-body > p > img {
  display: block; margin: 1.6rem auto;
  border-radius: 12px; border: 1px solid var(--line); background: #fff;
}

/* ============================================================
   CALLOUTS + STALE BANNER
   ============================================================ */
.callout {
  border-left: 3px solid var(--gold);
  background: var(--card); border-radius: 0 var(--r-s) var(--r-s) 0;
  padding: 20px 22px; margin: 1.6em 0;
}
.callout .label { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); display: block; margin-bottom: 6px; }
.callout p:last-child { margin-bottom: 0; }
.callout.grow { border-color: var(--grow); }
.callout.grow .label { color: var(--grow-dk); }
.callout.crash { border-color: var(--crash); }
.callout.crash .label { color: var(--crash); }

.stale-banner {
  border-color: var(--gold);
  background: rgba(184,144,47,.07);
  margin: 0 0 2.2em;
}
.stale-banner p { font-size: .95rem; color: var(--ink-2); }

/* ============================================================
   SOURCES
   ============================================================ */
.sources { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 34px; }
.sources h2 {
  font-family: var(--display); font-weight: 700;
  font-size: 1.4rem; color: var(--ink); margin: 0 0 .8em;
}
.sources ol { padding-left: 1.4em; margin: 0; }
.sources ol li {
  font-size: .9rem; color: var(--tx-soft); line-height: 1.65;
  margin-bottom: .7em; padding-left: .2em;
}
.sources ol li a { color: var(--grow-dk); word-break: break-word; }

/* ============================================================
   DISCLAIMER
   ============================================================ */
.disclaimer {
  background: rgba(178,74,54,.06); border: 1px solid rgba(178,74,54,.2);
  border-radius: var(--r); padding: 20px 22px; font-size: .91rem; color: #74463c;
  margin: 1.6em 0;
}
.disclaimer b { color: var(--crash); }

/* ============================================================
   NEWSLETTER — identical treatment to the book
   ============================================================ */
.nl-section { background: transparent; padding: 34px 0 8px; }
.nl-section .shell.read {
  background: linear-gradient(157deg, #17362b 0%, var(--ink) 62%);
  color: #eaf0ec;
  border-radius: 22px;
  padding: 44px clamp(26px, 5vw, 52px) 42px;
  box-shadow: 0 26px 60px -24px rgba(20,48,40,.45);
  position: relative; overflow: hidden;
}
.nl-section .shell.read::before {
  content: ""; position: absolute; top: -45%; right: -8%;
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(201,168,76,.18), transparent 70%);
  pointer-events: none;
}
.nl-section .eyebrow { color: var(--gold); position: relative; }
.nl-section .eyebrow::before { background: var(--gold); }
.nl-section h2 { color: #fff; font-size: clamp(1.5rem, 3.2vw, 2rem); margin: 0 0 .4em; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; position: relative; }
.nl-section p { color: rgba(234,240,236,.72); max-width: 46ch; margin: 0 0 1.5em; line-height: 1.65; position: relative; }
.nl-form { display: flex; gap: 10px; max-width: 470px; flex-wrap: wrap; position: relative; }
.nl-form input[type=email] {
  flex: 1; min-width: 220px;
  border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
  padding: 13px 20px; font-family: var(--body); font-size: .96rem;
  background: rgba(255,255,255,.07); color: #fff; outline: none;
  transition: border-color .15s, background .15s;
}
.nl-form input[type=email]::placeholder { color: rgba(255,255,255,.34); }
.nl-form input[type=email]:focus { border-color: var(--gold); background: rgba(255,255,255,.1); }
.nl-submit {
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  background: var(--gold); color: var(--ink);
  border: none; border-radius: 999px; padding: 13px 26px;
  cursor: pointer; white-space: nowrap;
  transition: transform .15s, background .15s;
}
.nl-submit:hover { transform: translateY(-1px); background: #d8b752; }
.nl-note { font-size: .82rem; color: rgba(255,255,255,.42); margin-top: 14px; position: relative; }

/* ============================================================
   PREV / NEXT
   ============================================================ */
.chapter-nav { background: transparent; padding-bottom: 30px; }
.chapter-nav .cn-inner {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding: 24px 0 12px;
}
.chapter-nav .cn-inner::before {
  content: attr(data-label);
  grid-column: 1 / -1;
  font-family: var(--mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--tx-soft); padding-left: 2px;
}
.cn-link {
  display: flex; flex-direction: column; gap: 8px;
  padding: 22px 24px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--card);
  text-decoration: none;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.cn-link:hover { border-color: var(--grow); transform: translateY(-3px); box-shadow: 0 14px 34px -12px rgba(20,48,40,.22); }
.cn-dir { font-family: var(--mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--tx-soft); }
.cn-title { font-family: var(--display); font-weight: 600; font-size: 1.16rem; color: var(--ink); line-height: 1.25; }
.cn-prev { align-items: flex-start; text-align: left; }
.cn-next {
  align-items: flex-end; text-align: right;
  border-color: var(--grow);
  background: linear-gradient(180deg, #eef7f1, var(--card) 85%);
}
.cn-next .cn-dir, .cn-next .cn-title { color: var(--grow-dk); }
.cn-empty { border: none; background: transparent; box-shadow: none; }
.cn-empty:hover { transform: none; box-shadow: none; border: none; }
@media (max-width: 620px) {
  .chapter-nav .cn-inner { grid-template-columns: 1fr; }
  .cn-next { order: 1; align-items: flex-start; text-align: left; }
  .cn-prev { order: 2; }
  .cn-empty { display: none; }
}

/* ============================================================
   FOOTER — pine ink, same as the book
   ============================================================ */
.foot { background: var(--ink); color: rgba(255,255,255,.52); padding: 64px 0 48px; }
.foot h3 { color: #fff; font-size: 1.45rem; margin: 0 0 .35em; }
.foot .foot-blog { font-family: var(--mono); font-size: .85rem; color: var(--gold); font-weight: 400; }
.foot p { font-size: .93rem; max-width: 56ch; line-height: 1.7; }
.foot a { color: var(--gold); }
.foot-disclaimer {
  background: rgba(255,255,255,.04); border-color: var(--line-ink); color: #c4d2c9;
  max-width: 62ch;
}
.foot-row { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; margin-top: 24px; font-family: var(--mono); font-size: .78rem; }
.foot-row .sep { color: rgba(255,255,255,.18); }
.handle { color: var(--gold); }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  body { font-size: 17px; }
  .section { padding: 48px 0 56px; }
  .nav-inner { padding: 11px 16px; gap: 12px; }
  .nav-links { gap: 2px; }
  .back-book { display: none; }
  .shell { padding: 0 16px; }
  .page-header { padding: 48px 0 36px; }
}
