/* Thoughts: the archive and post pages. Same ink and accent as the homepage, on its paper. */
:root {
  --fg: #1d1d1f;
  --fg-soft: #424245;
  --fg-mute: #6e6e73;
  --accent: #0066cc;
  --line: rgba(0, 0, 0, 0.09);
  --paper: #fbfaf6;
  --wash: #f1efe7;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --gutter: max(16px, 5vw);
  --measure: 680px;
  /* Space at the bottom for the system UI: the iPhone home indicator, or Android's navigation bar when Chrome draws the page behind it (viewport-fit=cover). Chrome's inset shrinks while you scroll, so fixed things use the larger of it and its steady maximum. */
  --sys-bottom: max(env(safe-area-inset-bottom, 0px), env(safe-area-max-inset-bottom, 0px));
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--fg); background: var(--paper); -webkit-font-smoothing: antialiased; line-height: 1.5; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -48px; padding: 8px 12px; background: #fff; border-radius: 8px; z-index: 20; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* The nav. Its frosted background is a pseudo-element, not the bar itself: a backdrop-filter on
   the bar would trap the phone tab bar (position: fixed, below) inside it. */
nav.site-nav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px var(--gutter); border-bottom: 1px solid var(--line); }
nav.site-nav::before { content: ""; position: absolute; inset: 0; z-index: -1; background: rgba(251, 250, 246, .88); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px); }
nav .name { position: relative; display: inline-flex; align-items: center; padding-right: 15px; font-weight: 650; font-size: 16px; letter-spacing: -.02em; text-decoration: none; white-space: nowrap; }
/* The name takes off: a contrail fades in under it and climbs into a small plane after it. */
nav .name .trail, nav .name .plane { position: absolute; color: var(--nav-mark, #0066cc); pointer-events: none; }
nav .name .trail { left: 0; right: 10px; top: calc(50% + 4.5px); width: auto; height: 10px; overflow: visible; }
nav .name .plane { right: 0; top: calc(50% - 4.5px); width: 13px; height: 13px; transition: transform .35s cubic-bezier(.3, 1.4, .5, 1); }
nav .name:hover .plane, nav .name:focus-visible .plane { transform: translate(2px, -2px); }   /* the plane climbs a little */
@media (prefers-reduced-motion: reduce) { nav .name .plane { transition: none; } }
nav .links { display: flex; gap: 22px; }
nav .links a { font-size: 13px; text-decoration: none; opacity: .72; white-space: nowrap; }
nav .links a:hover, nav .links a[aria-current="page"] { opacity: 1; }
nav .links a[aria-current="page"] { color: var(--accent); }
nav .links .ic, nav .links .home { display: none; }

/* Phones: the links float at the bottom as a tab bar, like a native app's. It tucks away while you
   scroll down and comes back when you scroll up (the page's script sets .tuck). */
@media (max-width: 640px) {
  nav.site-nav { padding: 12px var(--gutter); }
  nav .links { position: fixed; left: 50%; bottom: max(24px, calc(12px + var(--sys-bottom))); z-index: 40; gap: 2px; padding: 5px; border-radius: 28px; background: rgba(251, 250, 246, .8); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); box-shadow: 0 12px 32px rgba(20, 32, 56, .18), 0 2px 6px rgba(20, 32, 56, .08), 0 0 0 .5px rgba(0, 0, 0, .1), inset 0 1px 0 rgba(255, 255, 255, .9); transform: translateX(-50%); transition: transform .45s cubic-bezier(.3, 1.25, .45, 1), opacity .3s; }
  nav .links a, nav .links .home { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 70px; height: 50px; padding: 0 10px; border-radius: 23px; font-size: 10.5px; font-weight: 600; letter-spacing: .01em; opacity: 1; color: var(--fg-soft); -webkit-tap-highlight-color: transparent; transition: background-color .2s, color .2s, transform .15s; }
  nav .links .ic { display: block; width: 23px; height: 23px; }
  nav .links a[aria-current="page"] { color: var(--accent); background: rgba(0, 102, 204, .1); }
  nav .links a:active { transform: scale(.92); }
  nav.tuck .links { transform: translate(-50%, calc(100% + 28px)); opacity: 0; }
  nav.site-nav:focus-within .links { transform: translateX(-50%); opacity: 1; }   /* keyboard focus brings it back */
}
@media (prefers-reduced-motion: reduce) { nav .links { transition: none; } }

main { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 56px var(--gutter) 24px; }
.kicker { margin: 0 0 14px; font: 600 12px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.kicker a { text-decoration: none; }
.kicker a:hover { text-decoration: underline; }

/* ---- archive ---- */
.intro h1 { margin: 0; font-size: clamp(34px, 6vw, 52px); line-height: 1.04; letter-spacing: -.035em; font-weight: 700; }
.lede { margin: 18px 0 0; font-size: 18px; line-height: 1.55; color: var(--fg-soft); max-width: 600px; }
.search { position: relative; margin-top: 28px; }
.search input { width: 100%; font: 16px var(--sans); color: var(--fg); padding: 13px 92px 13px 16px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .14); background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .04); -webkit-appearance: none; appearance: none; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 102, 204, .14); }
#count { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font: 600 12px var(--mono); color: var(--fg-mute); pointer-events: none; }
.jump { margin: 14px 0 0; font-size: 13px; color: var(--fg-mute); }
.jump a { color: var(--fg-soft); }

.long, .year { margin-top: 56px; }
.long h2, .year h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; display: flex; align-items: baseline; gap: 10px; }
.year h2 small { font: 500 12px var(--mono); color: var(--fg-mute); letter-spacing: .04em; }
.long { padding: 22px 22px 10px; margin-left: -22px; margin-right: -22px; background: var(--wash); border-radius: 16px; }
.month h3 { margin: 26px 0 2px; font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-mute); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.month .list li:first-child { border-top: 0; }
.list a { display: grid; grid-template-columns: 92px 1fr; gap: 16px; padding: 11px 0; text-decoration: none; }
.long .list a { grid-template-columns: 112px 1fr; }
.list time, .list .m { font: 500 13px/1.55 var(--mono); color: var(--fg-mute); white-space: nowrap; }
.list .t { font-size: 16px; line-height: 1.45; }
.list a:hover .t { color: var(--accent); }
.none { margin-top: 40px; color: var(--fg-mute); }
.year[id], .month[id] { scroll-margin-top: 70px; }

/* ---- a post ---- */
.post h1 { margin: 0; font-size: clamp(28px, 4.4vw, 42px); line-height: 1.12; letter-spacing: -.03em; font-weight: 700; text-wrap: balance; overflow-wrap: anywhere; }
.prose { margin-top: 30px; font-size: 18px; line-height: 1.7; color: var(--fg); overflow-wrap: break-word; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose figure { margin: 0 0 1.1em; }
.prose h2 { margin: 1.8em 0 .5em; font-size: 22px; letter-spacing: -.02em; line-height: 1.3; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--fg-mute); }
.prose a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose blockquote { padding: 2px 0 2px 18px; border-left: 3px solid rgba(0, 102, 204, .35); color: var(--fg-soft); font-style: italic; }
.prose blockquote + blockquote { margin-top: -.4em; }
.prose blockquote p { margin: 0; }
.prose figure { margin: 1.6em 0; }
.prose img { display: block; width: auto; max-width: 100%; height: auto; max-height: 80vh; margin: 0 auto; border-radius: 10px; box-shadow: 0 0 0 1px var(--line), 0 6px 24px rgba(20, 40, 80, .08); }
.series { margin-top: 24px; padding: 14px 16px; border-radius: 12px; background: var(--wash); font-size: 14px; }
.series p { margin: 0 0 8px; font-weight: 600; }
.series ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.series a, .series span { display: inline-block; padding: 5px 11px; border-radius: 999px; font-size: 13px; text-decoration: none; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.series a:hover { color: var(--accent); }
.series [aria-current] { background: var(--accent); color: #fff; box-shadow: none; }
.disclose { margin: 28px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--fg-mute); }

.pager { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; padding: 0; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.pager a { display: block; padding: 14px 16px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); text-decoration: none; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.pager a:hover { box-shadow: inset 0 0 0 1px rgba(0, 102, 204, .4); }
.pager small { display: block; margin-bottom: 4px; font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.pager .newer { text-align: right; }
.back { margin: 28px 0 0; font-size: 14px; }
.back a { color: var(--fg-soft); }

footer { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 48px auto 0; padding: 22px var(--gutter) calc(40px + var(--sys-bottom)); border-top: 1px solid var(--line); font-size: 13px; color: var(--fg-mute); }
footer p { margin: 0 0 6px; }
footer .note { font-size: 12px; }
footer a { color: var(--fg-soft); }
/* Phones: room under the footer for the floating tab bar (24px up, about 60px tall), so its last links stay tappable.
   Here, after the footer's own rule: placed earlier, the base padding won and the bar covered the links. */
@media (max-width: 640px) { footer { padding-bottom: calc(108px + var(--sys-bottom)); } }

@media (max-width: 560px) {
  main { padding-top: 36px; }
  .list a, .long .list a { grid-template-columns: 1fr; gap: 2px; padding: 12px 0; }
  .long { margin-left: -12px; margin-right: -12px; padding: 18px 12px 8px; }
  .prose { font-size: 17px; }
  .pager { grid-template-columns: 1fr; }
  .pager .newer { text-align: left; }
}

/* ---- standalone pages: the guide and unlisted pages ---- */
.page .intro h1 { margin: 0; font-size: clamp(32px, 5.4vw, 48px); line-height: 1.08; letter-spacing: -.035em; font-weight: 700; text-wrap: balance; }
.page .intro { margin-bottom: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 11px 18px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 600; text-decoration: none; box-shadow: 0 4px 14px rgba(0, 102, 204, .22); }
.btn:hover { background: #0058b0; }
.btn.ghost { background: #fff; color: var(--fg); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.aside { margin: 22px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--wash); font-size: 14px; line-height: 1.55; color: var(--fg-soft); }
.toc { position: static; display: block; margin: 36px 0 0; padding: 18px 20px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; scroll-margin-top: 70px; }
.toc h2 { margin: 0 0 8px; font: 600 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-mute); }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: ch; columns: 2; column-gap: 28px; }
.toc li { counter-increment: ch; break-inside: avoid; }
.toc a { display: flex; gap: 10px; padding: 6px 0; text-decoration: none; font-size: 16px; }
.toc a::before { content: counter(ch, decimal-leading-zero); font: 500 13px/1.6 var(--mono); color: var(--accent); }
.toc a:hover { color: var(--accent); }
.numbered { counter-reset: chapter; }
.numbered h2 { counter-increment: chapter; margin-top: 2.4em; padding-top: 1.2em; border-top: 1px solid var(--line); font-size: 28px; scroll-margin-top: 70px; }
.numbered h2::before { content: counter(chapter, decimal-leading-zero); display: block; margin-bottom: 6px; font: 600 13px var(--mono); letter-spacing: .08em; color: var(--accent); }
.prose h3 { margin: 1.6em 0 .4em; font-size: 19px; letter-spacing: -.01em; line-height: 1.35; }
.prose h4 { margin: 1.4em 0 .3em; font-size: 15px; letter-spacing: .01em; text-transform: uppercase; color: var(--fg-soft); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose img[style*="--w"] { width: max(var(--w), 72px); }
.prose figure.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 22px; }
.prose figure.row img { margin: 0; flex: 0 1 auto; max-height: 160px; object-fit: contain; }
.prose figure.row img, .prose img[style*="--w:1"], .prose img[style*="--w:2"] { box-shadow: none; border-radius: 6px; }

/* charts drawn from the guide's numbers */
.chart table { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart caption { text-align: left; margin-bottom: 6px; font: 600 12px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-mute); }
.chart th { width: 34%; padding: 6px 12px 6px 0; text-align: left; font-weight: 500; vertical-align: middle; }
.chart td { padding: 6px 0; }
.chart .bar { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.chart .bar i { display: block; height: 14px; min-width: 2px; border-radius: 3px; background: var(--accent); }
.chart .bar.k1 i { background: #9cbfe3; }
.chart .bar b { font: 500 12px var(--mono); color: var(--fg-soft); white-space: nowrap; }
.chart .legend { display: flex; gap: 16px; margin: 0 0 8px; font-size: 13px; color: var(--fg-soft); }
.chart .legend .k::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; background: var(--accent); }
.chart .legend .k1::before { background: #9cbfe3; }

@media (max-width: 560px) {
  .toc ol { columns: 1; }
  .numbered h2 { font-size: 24px; }
  .chart th { width: 40%; font-size: 13px; }
}

/* the guide's PDF: printed from /personal-finance/ */
@media print {
  @page { size: Letter; margin: 18mm 18mm 20mm; }
  body { background: #fff; font-size: 11pt; }
  nav:not(.toc), .skip, footer, .actions, .back, .gate { display: none !important; }
  main { padding: 0; max-width: none; }
  .page .intro { min-height: 230mm; display: flex; flex-direction: column; justify-content: center; break-after: page; }
  .page .intro h1 { font-size: 40pt; }
  .toc { box-shadow: none; padding: 0; break-after: page; }
  .toc ol { columns: 1; }
  .numbered h2 { break-before: page; border-top: 0; padding-top: 0; margin-top: 0; }
  .prose { font-size: 11pt; line-height: 1.55; }
  .prose a { color: inherit; }
  .prose img { box-shadow: none; max-height: 120mm; }
  .chart, figure, .prose blockquote, .prose ul, .prose ol { break-inside: avoid; }
  .prose h2, .prose h3, .prose h4 { break-after: avoid; }
  .chart .bar i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.byline { margin: 14px 0 0; font: 500 13px var(--mono); color: var(--fg-mute); }

/* password screen for private pages */
.page.locked { max-width: 460px; margin: 8vh auto 0; }
.page.locked h1 { margin: 0; font-size: clamp(28px, 5vw, 38px); line-height: 1.1; letter-spacing: -.03em; }
.unlock { display: flex; gap: 10px; margin-top: 24px; }
.unlock input { flex: 1; min-width: 0; font: 16px var(--sans); padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .16); background: #fff; color: var(--fg); }
.unlock input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 102, 204, .14); }
.unlock .btn { border: 0; cursor: pointer; font-family: var(--sans); }
.unlock .btn:disabled { opacity: .7; cursor: progress; }
.pw-err { margin: 12px 0 0; font-size: 14px; color: #b42318; }

/* ---- the ebook's email wall (build_pages.py guide(), app/api/ebook) ----
   The gated chapters stay in the page; while locked (.ebook-locked, set before paint) they fade
   out under the form. Signing up sets .ebook-open for good in that browser. */
.ebook-locked .gated { position: relative; max-height: 360px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 20%, transparent 92%); mask-image: linear-gradient(#000 20%, transparent 92%); pointer-events: none; user-select: none; }
.gate { position: relative; margin: -24px 0 0; padding: 28px 26px 24px; border-radius: 20px; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 16px 44px rgba(20, 32, 56, .13); }
.gate .gate-title { margin: 0 0 10px; font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; color: var(--fg); }
.gate p { margin: 0 0 12px; font-size: 16px; line-height: 1.55; color: var(--fg-soft); }
.gate .kicker { margin-bottom: 10px; }
.gate-form { display: flex; gap: 10px; margin: 18px 0 12px; }
.gate-form input[type="email"] { flex: 1; min-width: 0; font: 16px var(--sans); color: var(--fg); padding: 12px 18px; border-radius: 999px; border: 1px solid rgba(0, 0, 0, .16); background: var(--paper); -webkit-appearance: none; appearance: none; }
.gate-form input[type="email"]:focus { outline: 2px solid transparent; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(0, 102, 204, .14); }
.gate-form .btn { border: 0; cursor: pointer; font-family: var(--sans); white-space: nowrap; }
.gate-form .btn:disabled { opacity: .7; cursor: progress; }
.gate .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.gate .gate-err { font-size: 14px; color: #b42318; }
.gate .fine { margin: 0; font-size: 12.5px; color: var(--fg-mute); }
.gate .fine a { color: inherit; }
.gate .got { display: none; outline: none; }
.ebook-open .gate { margin-top: 48px; }
.ebook-open .gate .ask { display: none; }
.ebook-open .gate .got { display: block; }
.ebook-no-pdf .actions [data-ebook-pdf], .ebook-no-pdf .gate .got-pdf { display: none; }
.gate .got .gate-title:focus { outline: none; }
/* Without script nothing is locked, so there's no wall to show (and no form to send an email in a URL). */
html:not(.ebook-locked):not(.ebook-open) .gate, html:not(.ebook-locked):not(.ebook-open) .actions [data-ebook-pdf] { display: none; }
.ebook-open .lock-note, html:not(.ebook-locked) .lock-note { display: none; }
.ebook-open .gate .got p:last-child { margin: 16px 0 0; }
.ebook-just-opened .gated { animation: unveil .9s cubic-bezier(.2, .8, .3, 1); }
.ebook-just-opened .gate .got { animation: got-in .5s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes unveil { from { opacity: .35; filter: blur(3px); } }
@keyframes got-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.when-open { display: none; }
.ebook-open .when-locked { display: none; }
.ebook-open .when-open { display: inline; }
.toc .gated-ch a::after { content: ""; flex: none; align-self: center; width: 12px; height: 12px; margin-left: 2px; background: var(--fg-mute); opacity: .6;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1Zm2 0h6V7a3 3 0 0 0-6 0v3Z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h1Zm2 0h6V7a3 3 0 0 0-6 0v3Z'/%3E%3C/svg%3E") center / contain no-repeat; }
.ebook-open .toc .gated-ch a::after, html:not(.ebook-locked) .toc .gated-ch a::after { display: none; }
@media (max-width: 560px) {
  .gate { padding: 24px 18px 20px; }
  .gate .gate-title { font-size: 23px; }
  .gate-form { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .ebook-just-opened .gated, .ebook-just-opened .gate .got { animation: none; } }
