/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --fg: #141414;
  --muted: #6b6b6b;
  --rule: #e8e8e8;
  --accent: #7cedd3;          /* the site's mint */
  --accent-ink: #0a6b57;      /* mint dark enough for text */
  --link-hover: #04b4ee;
  --sans: system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sidebar-w: 14.5rem;
  --measure: 40rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121514;
    --fg: #e9ebea;
    --muted: #9aa19e;
    --rule: #2a2f2d;
    --accent-ink: #7cedd3;
    --link-hover: #5fd0f5;
    color-scheme: dark;
  }
}

/* ---------- Page transitions (no JS) ----------
   Supporting browsers keep the sidebar in place and cross-fade only <main>
   when moving between pages. Others just navigate normally. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
main     { view-transition-name: main; }
::view-transition-old(main) { animation: 90ms ease-out both vt-out; }
::view-transition-new(main) { animation: 160ms ease-out both vt-in; }
@keyframes vt-out { to   { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--sans);
}
img { max-width: 100%; height: auto; }
a { color: inherit; }
a:hover { color: var(--link-hover); }

/* ---------- Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, var(--measure));
  gap: clamp(2.5rem, 6vw, 5rem);
  max-width: calc(var(--sidebar-w) + var(--measure) + 5rem);
  margin: 0 auto;
  padding: 4.5rem 2rem 6rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  scrollbar-width: thin;
}
.identity {
  display: block;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  text-decoration: none;
  margin-bottom: 1.75rem;
}
.identity:hover { color: inherit; }

.nav, .subnav { list-style: none; margin: 0; padding: 0; }
.nav > li { margin: .1rem 0; }
.nav > li > a {
  display: inline-block;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  padding: .1rem .45rem;
  margin-left: -.45rem;
  border-radius: 3px;
  transition: background-color .15s;
}
.nav > li > a:hover { background: var(--accent); color: #000; }
.nav > li > a[aria-current="page"],
.nav > li > a.in-section { background: var(--accent); color: #000; }

.subnav {
  margin: .35rem 0 .6rem .1rem;
  padding-left: .8rem;
  border-left: 1px solid var(--rule);
}
.subnav a {
  display: block;
  font-size: .86rem;
  line-height: 1.35;
  color: var(--muted);
  text-decoration: none;
  padding: .22rem 0;
}
.subnav a:hover { color: var(--fg); }
.subnav a[aria-current="page"] { color: var(--fg); font-weight: 600; }

.contact {
  margin-top: 2rem;
  font-size: .85rem;
  color: var(--muted);
  display: grid;
  gap: .3rem;
}
.social { display: flex; gap: .9rem; }
.social a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--rule); }
.social a:hover { border-color: var(--link-hover); }

.tag {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent-ink);
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 0 .3em;
  vertical-align: .1em;
}

/* ---------- Content ---------- */
main { min-width: 0; padding-top: .3rem; }
.section-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 2.5rem 0 .75rem;
}
section:first-of-type .section-label { margin-top: 0; }

.bio { font-size: 1.15rem; line-height: 1.7; }
.bio p:first-child { margin-top: 0; }
.bio a { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; }
.pubs > li {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.pubs .year { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; padding-top: .15rem; }
.pubs p { margin: 0; }
.pub-title { font-weight: 600; line-height: 1.4; }
.pub-title a { text-decoration: none; }
.authors { font-size: .85rem; color: var(--muted); margin-top: .3rem !important; line-height: 1.5; }
.authors b { color: var(--fg); }
.venue { font-size: .85rem; margin-top: .15rem !important; }

/* Writing lists */
.post-list, .press-list { list-style: none; margin: 0; padding: 0; }
.post-list li {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
  padding: .55rem 0;
  border-top: 1px solid var(--rule);
}
.post-list time { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.post-list a { font-weight: 600; text-decoration: none; }
.press-list li { padding: .6rem 0; border-top: 1px solid var(--rule); }
.press-list a { font-weight: 600; text-decoration: none; display: block; line-height: 1.4; }
.press-list .source { font-size: .84rem; color: var(--muted); }

/* Projects */
.project {
  display: block;
  text-decoration: none;
  padding: 1.25rem 0 1.5rem 1rem;
  margin-left: -1rem;
  border-left: 3px solid transparent;
  transition: border-color .15s;
}
.project + .project { border-top: 1px solid var(--rule); }
.project:hover { border-left-color: var(--link-hover); color: inherit; }
.project-title { display: block; font-weight: 700; font-size: 1.1rem; }
.project-desc { display: block; color: var(--muted); margin-bottom: .9rem; }
.project img { border: 1px solid var(--rule); border-radius: 4px; }

/* ---------- Essay ---------- */
.post-head h1 {
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0 0 .4rem;
}
.post-head .meta { color: var(--muted); font-size: .9rem; margin: 0 0 2.25rem; }

.prose {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.75;
}
.prose p { margin: 0 0 1.35em; }
.prose h2, .prose h3 { font-family: var(--sans); line-height: 1.3; margin: 2em 0 .5em; }
.prose h2 { font-size: 1.2rem; }
.prose h3 { font-size: 1.05rem; }
.prose a { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.prose blockquote {
  margin: 1.6em 0;
  padding: .1em 0 .1em 1.2em;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}
.prose hr { border: 0; text-align: center; margin: 2.2em 0; }
.prose hr::after { content: "· · ·"; color: var(--muted); letter-spacing: .4em; }
.prose code { font-size: .88em; background: var(--rule); padding: .1em .3em; border-radius: 3px; }
.prose pre { overflow-x: auto; background: var(--rule); padding: 1rem; border-radius: 4px; font-size: .85rem; }
.prose pre code { background: none; padding: 0; }
.prose img { display: block; margin: 1.5em auto; border-radius: 4px; }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}
.post-nav a { text-decoration: none; font-weight: 600; line-height: 1.35; }
.post-nav span { display: block; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.post-nav .newer { grid-column: 2; text-align: right; }

/* ---------- Narrow screens: sidebar becomes a header ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 2rem; padding: 1.5rem 1.25rem 4rem; }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--rule);
  }
  .identity { margin-bottom: .75rem; }
  .nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
  .nav > li > a { margin-left: 0; }
  .subnav { display: none; }
  .contact { margin-top: .75rem; }
  .contact .email { display: none; }
}
