/* ============================================================
   tjhedin.com — shared stylesheet
   Palette: warm cream ground, ink-blue accent
   Type:    EB Garamond throughout, set at 19px because it runs small
            IBM Plex Mono for small caps labels and figure numbers
   ============================================================ */

:root {
  /* light (default) */
  --paper:       #F4EEE0;
  --raised:      #EBE3D1;
  --ink:         #211F1A;
  --muted:       #6B6455;
  --faint:       #928A78;
  --hair:        #DCD2BC;
  --accent:      #2B4E60;
  --accent-soft: #6E93A4;

  --maxw:  720px;
  /* Single face throughout, the way a paper is set. EB Garamond runs small,
     so the base size is 19px rather than the 17px a sans would want. The
     mono is kept for small caps labels — it gives the page its structure. */
  --serif: "EB Garamond", Garamond, "Palatino Linotype", Palatino, Georgia, serif;
  --sans:  var(--serif);
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* The cream is the site, so it's the default for everyone — the OS dark
   preference deliberately does NOT switch the page. Dark is opt-in via the
   toggle, which sets data-theme on the root and is remembered per browser.
   (To go back to following the OS, wrap the dark block below in
   @media (prefers-color-scheme: dark) as well, and change the fallback in
   activeTheme() in site.js from 'light' back to the matchMedia check.)

   Dark isn't black: a warm near-black keeps the same character as the cream
   and avoids the halation pure white on pure black causes with a light
   serif. Ink on ground measures 14.2:1, about the same as the light theme. */
:root[data-theme="light"] {
  --paper: #F4EEE0; --raised: #EBE3D1; --ink: #211F1A; --muted: #6B6455;
  --faint: #928A78; --hair: #DCD2BC; --accent: #2B4E60; --accent-soft: #6E93A4;
}
:root[data-theme="dark"] {
  --paper: #1C1814; --raised: #262019; --ink: #EDE6D6; --muted: #9E9583;
  --faint: #6F6757; --hair: #362E24; --accent: #8FB4C4; --accent-soft: #52757F;
}

/* Figures keep a light ground in BOTH themes. Stata bakes its axis labels in
   as black/grey, which would be unreadable on a dark card — so the figure
   panel stays a light sheet the way a printed plate would. These three are
   deliberately not redefined in the dark blocks. */
:root {
  --figure-ground:  #F1EAD9;
  --figure-edge:    #DDD3BD;
  --figure-caption: #6B6455;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--paper);
  padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- top bar ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--hair);
}
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 20px; padding: 16px 28px; max-width: var(--maxw); margin: 0 auto;
}
.wordmark {
  font-family: var(--serif); font-size: 21px; font-weight: 500;
  letter-spacing: .01em; color: var(--ink);
}
.wordmark:hover { text-decoration: none; }

nav.tabs { display: flex; gap: 22px; margin-left: auto; }
nav.tabs a {
  padding: 4px 0;
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1.5px solid transparent;
  transition: color .15s ease;
}
nav.tabs a:hover { color: var(--ink); text-decoration: none; }
nav.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* Sits apart from the section links — it changes how the page looks, not
   where you are, so a hairline divides it from the nav. */
.theme-toggle {
  flex: none; position: relative; margin-left: 26px;
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--hair); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: .05em; text-transform: uppercase; line-height: 1;
  transition: color .15s ease, border-color .15s ease;
}
.theme-toggle::before {
  content: ""; position: absolute; left: -14px; top: 50%;
  transform: translateY(-50%);
  width: 1px; height: 20px; background: var(--hair);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--faint); }
.tt-icon {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
@media (max-width: 520px) {
  .theme-toggle { margin-left: 0; }
  .theme-toggle::before { display: none; }
}

@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 14px 20px; }
  nav.tabs { gap: 18px; }
}

/* ---------- page furniture ---------- */
main { padding: 64px 0 96px; }

.eyebrow {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 18px;
}
h1.name {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(44px, 8vw, 64px); line-height: 1.02; letter-spacing: -.01em;
  margin: 0 0 10px; text-wrap: balance;
}
.role { color: var(--muted); font-size: 20px; margin: 0 0 40px; }

h2.section {
  font-family: var(--serif); font-weight: 500; font-size: 35px;
  margin: 0 0 6px; text-wrap: balance;
}
.section-note { color: var(--muted); font-size: 16.5px; margin: 0 0 44px; }
/* When a heading runs straight into content with no note under it, the
   note's bottom margin has to come from somewhere. */
h2.section + .group { margin-top: 40px; }

/* ---------- home ---------- */
.intro { display: grid; grid-template-columns: 168px 1fr; gap: 34px; align-items: start; }
@media (max-width: 560px) { .intro { grid-template-columns: 1fr; } }

.portrait {
  width: 168px; border-radius: 3px; display: block;
  border: 1px solid var(--hair); box-shadow: 0 1px 0 var(--hair);
}
.intro p { margin: 0 0 16px; }
.intro p:first-child { margin-top: -4px; }
.intro p:last-child { margin-bottom: 0; }

.jobmarket {
  margin: 30px 0 0; padding: 16px 20px; border-radius: 4px;
  background: var(--raised); border: 1px solid var(--hair);
  border-left: 3px solid var(--accent);
  display: flex; flex-direction: column; gap: 7px;
}
.jm-headline { margin: 0; font-weight: 600; font-size: 17.5px; }
.jm-paper { margin: 0; font-size: 16.5px; color: var(--muted); }

.links-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 40px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border: 1px solid var(--hair); border-radius: 999px;
  font-size: 15.5px; color: var(--muted); background: var(--paper);
  transition: color .15s ease, border-color .15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--faint); text-decoration: none; }
.chip svg { width: 15px; height: 15px; flex: none; }

/* ---------- research ---------- */
.group { margin-bottom: 64px; }
.group:last-child { margin-bottom: 0; }
.group > h3.group-title {
  font-family: var(--mono); font-size: 15px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 4px; padding-bottom: 12px; border-bottom: 1px solid var(--hair);
}

/* The job market paper is the reason a committee opens this page, so the
   whole section sits in a tinted card and its heading abandons the label
   convention: display serif, accent colour, no rule. */
.group.jmp-group {
  background: none;                 /* same ground as the page */
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--hair));
  border-radius: 6px;
  padding: 26px 30px 28px;
  margin-bottom: 60px;
}
.group.jmp-group > h3.group-title.jmp {
  font-family: var(--serif);
  font-size: clamp(28px, 4.8vw, 34px);
  font-weight: 600;
  letter-spacing: -.01em;
  text-transform: none;
  color: var(--accent);
  margin: 0 0 16px;
  padding-bottom: 0;
  border-bottom: none;
}
.group.jmp-group .paper { border-top: none; padding: 0; }
.group.jmp-group .paper h4 { font-size: 26px; margin-bottom: 8px; }
@media (max-width: 560px) { .group.jmp-group { padding: 22px 20px 24px; } }

.paper { padding: 30px 0; border-top: 1px solid var(--hair); }
.group > h3.group-title + .paper { border-top: none; }

.paper h4 {
  font-family: var(--serif); font-weight: 500; font-size: 23px;
  line-height: 1.3; margin: 0 0 6px; color: var(--ink);
  text-wrap: pretty;
}
/* The title is the download link: accent colour carries that on its own,
   no rule underneath. Hover underlines it as the interaction affordance. */
.paper h4 a {
  color: var(--accent);
  text-decoration: none;
}
.paper h4 a:hover { text-decoration: underline; text-underline-offset: 4px; }

.meta { font-size: 16px; color: var(--muted); margin: 0 0 3px; }
.venue { font-size: 16px; color: var(--muted); margin: 0 0 3px; }
.altlinks { font-size: 15.5px; margin: 0 0 3px; }
.altlinks a { color: var(--muted); }
.altlinks a:hover { color: var(--accent); }
.meta em { font-style: italic; }
.status {
  display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent); vertical-align: middle; white-space: nowrap;
}
/* A state, not an accolade — reads quieter than the accent pill next to it. */
.status.status-soon {
  background: none;
  border: 1px solid var(--hair);
  color: var(--faint);
}

/* Abstract / Cite toggles */
.actions { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 12px; }
.act {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s ease;
}
.act:hover { color: var(--ink); }
.act .pm {
  display: inline-grid; place-items: center;
  width: 15px; height: 15px; border-radius: 2px;
  border: 1px solid currentColor;
  font-size: 12px; line-height: 1;
}
.act .pm::before { content: "+"; }
.act[aria-expanded="true"] .pm::before { content: "\2212"; }  /* true minus */

.panel { margin-top: 14px; }
.panel .body {
  font-size: 18px; color: var(--muted); line-height: 1.62;
  margin: 0 0 14px; max-width: 62ch;
}

/* BibTeX block */
.bibwrap { position: relative; }
.bib {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--raised); border: 1px solid var(--hair); border-radius: 5px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  color: var(--ink); tab-size: 2;
}
.bib code { font: inherit; color: inherit; white-space: pre; }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: var(--paper); color: var(--muted);
  border: 1px solid var(--hair); border-radius: 3px;
  padding: 5px 11px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase;
  transition: color .15s ease, border-color .15s ease;
}
.copy-btn:hover { color: var(--ink); border-color: var(--faint); }
.copy-btn.is-copied { color: var(--accent); border-color: var(--accent); }

figure.chart {
  margin: 2px 0 16px; padding: 18px 18px 12px;
  border: 1px solid var(--figure-edge); border-radius: 5px;
  background: var(--figure-ground);
  overflow-x: auto;
}
figure.chart img,
figure.chart svg { display: block; width: 100%; height: auto; }
figure.chart figcaption {
  font-family: var(--serif); font-size: 14.5px; line-height: 1.55;
  color: var(--figure-caption); margin-top: 12px;
  padding-top: 10px; border-top: 1px solid var(--figure-edge);
  font-variant-numeric: tabular-nums; max-width: 68ch;
}
figure.chart figcaption .fig-label {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent-soft); margin-right: 8px;
}

.paper-links { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 14px; font-size: 14px; }
.paper-links a { color: var(--muted); }
.paper-links a:hover { color: var(--accent); }

/* ---------- cv ---------- */
.cv-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 48px; }

.cv-section { margin-bottom: 44px; }
.cv-section:last-child { margin-bottom: 0; }
.cv-section > h3 {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--hair);
}
.cv-note { font-size: 15px; color: var(--faint); margin: -6px 0 16px; }

/* Two columns: the entry, and the date rail on the right. */
.cv-entry {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px 28px; align-items: baseline; margin-bottom: 18px;
}
.cv-entry:last-child { margin-bottom: 0; }
.cv-entry .what { display: flex; flex-direction: column; gap: 2px; }
.cv-entry .when {
  font-family: var(--mono); font-size: 12.5px; color: var(--faint);
  white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums;
}
.cv-title { font-size: 18px; font-weight: 600; color: var(--ink); }
.cv-title a { color: inherit; text-decoration: none; }
.cv-title a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cv-sub { font-size: 16px; color: var(--muted); line-height: 1.5; }
ul.cv-list {
  margin: 5px 0 0; padding-left: 18px;
  font-size: 15.5px; color: var(--muted); line-height: 1.7;
}

/* Publication-style entries run as a paragraph: title then citation. */
.cv-pub { margin: 0 0 18px; font-size: 17.5px; line-height: 1.55; }
.cv-pub:last-child { margin-bottom: 0; }
.cv-pub .t { display: block; color: var(--ink); font-weight: 600; }
.cv-pub a.t { color: var(--accent); text-decoration: none; }
.cv-pub a.t:hover { text-decoration: underline; text-underline-offset: 3px; }
.cv-pub .v { display: block; font-size: 16px; color: var(--muted); margin-top: 2px; }

@media (max-width: 560px) {
  .cv-entry { grid-template-columns: 1fr; gap: 2px; }
  .cv-entry .when { text-align: left; margin-top: 4px; }
}

/* ---------- footer ---------- */
footer {
  border-top: 1px solid var(--hair); padding: 28px 0 60px;
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
}
