/* Site styles for the homepage and Notes (default layout).
   Older pages (investing, lifestyle, topic visualizations) keep their own stylesheets. */

@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/fonts/newsreader-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400 600;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --paper: #f7f5f0;
  --ink: #1b2726;
  --ink-soft: #374541;
  --muted: #5a6560;
  --hairline: #dcded7;
  --accent: #a75135;
  --accent-light: #e7d6cc;
  --white: #fcfbf8;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --header-h: 72px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --paper: #161d1c;
  --ink: #ece9e1;
  --ink-soft: #c9cdc6;
  --muted: #a3aca6;
  --hairline: #2a3332;
  --accent: #d9906f;
  --accent-light: #4a3027;
  --white: #1c2423;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --paper: #161d1c;
    --ink: #ece9e1;
    --ink-soft: #c9cdc6;
    --muted: #a3aca6;
    --hairline: #2a3332;
    --accent: #d9906f;
    --accent-light: #4a3027;
    --white: #1c2423;
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html {
  background: var(--paper);
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 20px);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: var(--serif); font-weight: 400; }
img { max-width: 100%; height: auto; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 2px; }
::selection { background: var(--accent-light); color: var(--ink); }

/* Skip link sits on the only dark (inverted) surface, so it gets its own colors. */
.skip { position: absolute; left: 16px; top: -60px; padding: 10px 15px; background: var(--ink); color: var(--paper); z-index: 100; text-decoration: none; }
.skip:focus { top: 15px; }
.skip:hover, .skip:focus, .skip:focus-visible { color: var(--paper); background: var(--ink); text-decoration: underline; outline-color: var(--ink); }

.wrap { width: min(1100px, calc(100% - 88px)); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--hairline); position: sticky; top: 0; z-index: 30; background: var(--paper); }
.site-header .wrap { min-height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { text-decoration: none; font-size: 16px; font-weight: 650; letter-spacing: -.035em; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; align-items: center; gap: clamp(13px, 2.3vw, 31px); }
.nav a, .theme-toggle { font-size: 12px; color: var(--ink-soft); text-decoration: none; white-space: nowrap; }
.nav a[aria-current] { color: var(--ink); }
.nav a:hover, .theme-toggle:hover { color: var(--accent); }
.theme-toggle { font-family: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; line-height: inherit; color: var(--muted); text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* ---------- Hero ---------- */
.hero { padding-top: 104px; padding-bottom: 100px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 850px) 240px; justify-content: space-between; column-gap: 56px; align-items: start; }
h1 { font-size: clamp(54px, 7vw, 88px); line-height: 1.06; letter-spacing: -.045em; margin-bottom: 18px; max-width: 850px; }
.role { margin: 26px 0 0; font-size: 13px; line-height: 1.5; font-weight: 500; color: var(--muted); }
.hero-copy { max-width: 710px; color: var(--ink-soft); font-size: 17px; line-height: 1.77; }
.hero-copy p { margin-bottom: 20px; }
.hero-copy p:last-child { margin-bottom: 0; }
.hero-copy .hero-lead { color: var(--ink); font: 400 clamp(22px, 2.55vw, 29px)/1.48 var(--serif); letter-spacing: -.015em; max-width: 700px; margin-bottom: 22px; text-wrap: balance; }
.hero-copy .hero-second { max-width: 580px; }
.portrait { display: block; width: 100%; max-width: 240px; height: auto; border-radius: 2px; margin-top: 14px; background: var(--hairline); }

/* ---------- Links ---------- */
.text-link, .notes-bottom a, .note-footer a { color: var(--ink); display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 650; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 6px; }
.text-link:hover, .notes-bottom a:hover, .note-footer a:hover { color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding-top: 78px; padding-bottom: 82px; border-top: 1px solid var(--hairline); }
.section-head, .two-col { display: grid; grid-template-columns: 192px minmax(0, 1fr); column-gap: 30px; }
.section-head { margin-bottom: 46px; }
h2 { letter-spacing: -.03em; font-size: clamp(37px, 4.6vw, 56px); line-height: 1.18; margin-bottom: 0; max-width: 750px; }

.bio-content p { max-width: 550px; color: var(--ink-soft); font-size: 16px; line-height: 1.9; margin: 0 0 24px; }
.bio-content p:first-child { color: var(--ink); }
.bio-content .personal { color: var(--muted); font-size: 14px; margin-top: 28px; }

/* Work */
.work-list { margin-left: 222px; }
.work-item { display: grid; grid-template-columns: 54px minmax(0, 1fr); column-gap: 21px; border-top: 1px solid var(--hairline); padding: 30px 0 36px; }
.work-number { color: var(--accent); font: italic 400 22px/1.3 var(--serif); }
h3 { font-size: 24px; line-height: 1.3; letter-spacing: -.025em; font-weight: 550; margin: 0 0 14px; text-wrap: balance; }
.work-item p { max-width: 520px; font-size: 15px; line-height: 1.75; color: var(--ink-soft); margin: 0; }
.work-item p + p { margin-top: 16px; }

/* Background */
.timeline { margin-top: 22px; }
.job { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 18px; border-top: 1px solid var(--hairline); padding: 21px 0 22px; }
.job strong { display: block; font-size: 15px; font-weight: 590; }
.job time { font-size: 12px; text-align: right; color: var(--muted); padding-top: 2px; }
.education { display: flex; flex-wrap: wrap; gap: 25px 50px; margin-top: 35px; }
.education > div { border-left: 2px solid var(--hairline); padding-left: 14px; }
.education strong { display: block; font-size: 13px; }
.education p { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Research */
.research-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; color: var(--muted); font-size: 12px; margin: 16px 0 29px; }
.pub { border-top: 1px solid var(--hairline); display: grid; grid-template-columns: 1fr 180px; gap: 12px; padding: 16px 0; }
.pub b { font-size: 14px; font-weight: 570; }
.pub span { font-size: 12px; color: var(--muted); text-align: right; }
.research-link { margin-top: 24px; }

/* Notes list (homepage and /notes/) */
.notes-section { padding-bottom: 60px; }
.note-recent { margin: 4px 0 0; padding: 0; list-style: none; }
.note-recent-row { display: flex; align-items: baseline; justify-content: space-between; gap: 25px; padding: 13px 0; border-bottom: 1px solid var(--hairline); }
.note-recent-row:first-child { border-top: 1px solid var(--hairline); }
.note-recent-row:last-child { border-bottom: 0; }
.note-recent-row a { font-size: 15px; line-height: 1.5; }
.pub a, .note-recent-row a { text-decoration: underline; text-decoration-color: var(--hairline); text-decoration-thickness: 1px; text-underline-offset: 4px; }
.pub a:hover, .note-recent-row a:hover { text-decoration-color: currentColor; color: var(--accent); }
.note-recent-row time { flex-shrink: 0; font-size: 12px; color: var(--muted); }
.notes-bottom { padding-top: 24px; margin: 0; }

/* Contact */
.contact { padding-bottom: 113px; }
.contact-lead { font: 400 clamp(23px, 3.1vw, 35px)/1.4 var(--serif); letter-spacing: -.02em; max-width: 690px; margin: 0 0 10px; text-wrap: balance; }
.contact-sub { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0 0 30px; }
.contact-links { display: flex; flex-wrap: wrap; gap: 22px; font-size: 14px; }
.contact-links a { text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 5px; white-space: nowrap; }

/* Footer */
.site-footer { padding: 24px 0 35px; border-top: 1px solid var(--hairline); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 15px; font-size: 12px; color: var(--muted); }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- Notes pages ---------- */
/* Same box as .wrap; the column starts where homepage section content starts (192px + 30px gap). */
.note-page { width: min(1100px, calc(100% - 88px)); margin-inline: auto; padding: 72px 0 88px 222px; }
.note-page > * { max-width: 620px; }
.note-page h1 { font-size: clamp(38px, 5.4vw, 52px); line-height: 1.12; letter-spacing: -.03em; margin-bottom: 14px; text-wrap: balance; }
.note-page .meta, .note-page .intro { color: var(--muted); font-size: 14px; margin: 0 0 40px; }
.note-page .intro { font-size: 17px; line-height: 1.6; }
.note-page .note-recent-row a { font-size: 17px; }
.note-body { font-size: 18px; line-height: 1.72; color: var(--ink); }
.note-body p { margin: 0 0 1.25em; text-wrap: pretty; }
.note-body h2 { font-size: 28px; line-height: 1.25; letter-spacing: -.02em; margin: 1.8em 0 .6em; }
.note-body h3 { font-size: 20px; margin: 1.6em 0 .5em; }
.note-body a { text-decoration: underline; color: var(--ink); }
.note-body a:hover { color: var(--accent); }
.note-body blockquote { margin: 1.5em 0; padding-left: 18px; border-left: 2px solid var(--accent-light); color: var(--ink-soft); }
.note-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--white); border: 1px solid var(--hairline); padding: 1px 5px; border-radius: 2px; }
.note-body pre { background: var(--white); border: 1px solid var(--hairline); padding: 14px 16px; overflow-x: auto; border-radius: 2px; }
.note-body pre code { background: none; border: 0; padding: 0; }
.note-body hr { border: 0; border-top: 1px solid var(--hairline); margin: 2em 0; }
.note-body ul, .note-body ol { padding-left: 1.3em; margin: 0 0 1.25em; }
.note-footer { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--hairline); display: flex; gap: 22px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .wrap { width: min(100% - 48px, 700px); }
  .note-page { width: min(100% - 48px, 700px); padding-top: 56px; padding-left: 0; }
  .hero { padding-top: 80px; padding-bottom: 84px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); row-gap: 40px; }
  .portrait { order: -1; width: 140px; max-width: 140px; margin-top: 0; }
  .section { padding-top: 74px; padding-bottom: 78px; }
  .section-head, .two-col { grid-template-columns: minmax(0, 1fr); }
  .section-head > div:first-child:empty, .two-col > div:first-child:empty { display: none; }
  .section-head { margin-bottom: 34px; }
  .work-list { margin-left: 0; }
}
@media (max-width: 530px) {
  :root { --header-h: 92px; }
  .wrap, .note-page { width: calc(100% - 32px); }
  .site-header .wrap { min-height: 0; align-items: flex-start; padding: 15px 0 12px; flex-direction: column; gap: 10px; }
  .nav { width: 100%; flex-wrap: wrap; justify-content: flex-start; gap: 9px 18px; }
  .hero { padding-top: 56px; padding-bottom: 70px; }
  h1 { font-size: clamp(46px, 13vw, 62px); }
  .hero-copy { font-size: 15px; }
  .hero-copy .hero-lead { font-size: 24px; }
  .section { padding-top: 60px; padding-bottom: 64px; }
  h2 { font-size: 38px; }
  .bio-content p { font-size: 15px; }
  .work-item { grid-template-columns: 36px minmax(0, 1fr); column-gap: 12px; }
  h3 { font-size: 21px; }
  .work-item p { font-size: 14px; }
  .job { grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
  .pub { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .pub span { text-align: left; }
  .note-recent-row { flex-direction: column; gap: 4px; }
  .note-body { font-size: 17px; }
  .site-footer .wrap { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
