:root {
  --text:    #222;
  --bg:      #fff;
  --muted:   #666;
  --detail:  #484848;
  --link:    #1f5c99;
  --border:  #e3e3e3;
  --code-bg: #f4f4f4;

  --font: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --text:    #ddd;
  --bg:      #1a1a1a;
  --muted:   #9a9a9a;
  --detail:  #bdbdbd;
  --link:    #7db3e8;
  --border:  #333;
  --code-bg: #262626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}

.wrap {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 1.75rem 0 1rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.site-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.site-name:hover { text-decoration: none; }

.site-head-right { display: flex; align-items: baseline; }

.site-nav a { color: var(--text); margin-left: 1.25rem; }
.site-nav a:first-child { margin-left: 0; }
.site-nav a:hover { color: var(--link); text-decoration: none; }

.theme-toggle {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 1.25rem;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--link); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

/* Headings */
h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.3rem;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.lede {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

html { scroll-behavior: smooth; }
h2[id] { scroll-margin-top: 1.5rem; }

/* Intro with photo */
.intro {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}
.intro-text { flex: 1; }
.intro-text p { margin: 0 0 1rem; }
.intro-links { margin-top: 1.25rem; }

.photo {
  flex: 0 0 170px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  object-fit: cover;
}

/* Publications and blog list */
.entry { margin: 0 0 1.5rem; }
.entry p { margin: 0; }
.entry-title { font-weight: 700; font-size: 1.05rem; }
.entry-meta { color: var(--muted); font-size: 0.95rem; }
.entry-note { font-size: 0.95rem; }

.note { color: var(--muted); }

/* Experience, talks, teaching: compact timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0 1rem;
  margin: 0 0 0.8rem;
}
.tl-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-body p { margin: 0; }
.tl-aside,
.tl-note,
.tl-sub { color: var(--detail); font-size: 0.95rem; }
.tl-sub { margin: 0.1rem 0 0; padding-left: 1.1rem; }

/* Blog posts */
.post-date { color: var(--muted); margin: 0 0 1.5rem; }
.post pre {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
}
.post :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.post blockquote {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.back { margin-top: 2.5rem; }

/* Footer */
.site-foot {
  margin: 4rem 0 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}
.foot-links a { color: var(--muted); }
.foot-links a:hover { color: var(--link); }

/* Back to top, next to section headings */
h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.to-top {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  white-space: nowrap;
}
.to-top:hover { color: var(--link); text-decoration: none; }

@media (max-width: 34rem) {
  body { font-size: 16px; }
  h1 { font-size: 1.7rem; }
  .intro { flex-direction: column-reverse; gap: 1.25rem; }
  .photo { flex-basis: 120px; width: 120px; height: 120px; }
  .timeline > li { grid-template-columns: 1fr; }
  .tl-date { font-size: 0.9rem; }
}
