:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --line: #e8e8e8;
  --accent: var(--blue); /* same blue as the Substack tag */
  --accent-strong: #174a82; /* darker blue, for hover */
  --accent-soft: var(--blue-soft);
  --gold: #8a6a12;
  --gold-soft: #f7efd6;
  --blue: #1f5fa6;
  --blue-soft: #e7f0fb;
  --chocolate: #5b3a24;
  --chocolate-soft: #ecdfd3;
  --grey: #4b5563;
  --grey-soft: #eef0f2;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1c1f23;
    --text: #e6e6e3;
    --muted: #9aa1a9;
    --line: #2d3137;
    --accent: var(--blue);
    --accent-strong: #b3d1f5;
    --accent-soft: var(--blue-soft);
    --gold: #e2c46a;
    --gold-soft: #3a3220;
    --blue: #8cb9ee;
    --blue-soft: #1c2a3c;
    --chocolate: #e0b896;
    --chocolate-soft: #3a2a1f;
    --grey: #c4c9cf;
    --grey-soft: #2a2e33;
  }
}

* { box-sizing: border-box; }

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

.page {
  max-width: 840px;
  margin: 0 auto;
  padding: 56px 20px 24px;
}

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

p { margin: 0 0 0.8em; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.2rem; margin: 0 0 4px; }
h2 {
  font-size: 1.45rem;
  margin: 0 0 18px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
h3 { font-size: 1.15rem; margin: 0 0 8px; }

section { margin-top: 48px; }

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

/* Header */

.hero {
  display: flex;
  align-items: center;
  gap: 28px;
}

.avatar {
  flex: none;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), var(--gold-soft));
  border: 1px solid var(--line);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 600;
  overflow: hidden;
}

.avatar img, .avatar canvas { width: 100%; height: 100%; object-fit: cover; }

.tagline { color: var(--muted); font-size: 1.05rem; margin-bottom: 12px; }

.links { display: flex; flex-wrap: nowrap; gap: 6px 16px; font-size: 0.95rem; white-space: nowrap; }

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

/* Shown only without JavaScript, when the Email link jumps to it */
.email-riddle { display: none; margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); }
.email-riddle:target { display: block; }

/* Section tabs: a hint of what's on the page; scrolling still reaches everything.
   They stick to the top of the screen once scrolled past. */

html { scroll-behavior: smooth; }
section { scroll-margin-top: 64px; } /* clear the sticky tabs */

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  display: flex;
  gap: 28px;
  margin-top: 32px;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow-x: auto; /* fallback for very narrow screens; the labels fit on one line otherwise */
  scrollbar-width: none;
}

.tabs a {
  padding: 8px 0;
  margin-bottom: -1px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.tabs a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

#about { margin-top: 28px; font-size: 1.05rem; }

/* Item lists (papers & posts) */

.items { list-style: none; padding: 0; margin: 0; }
.items li { margin-bottom: 20px; }
.items p { margin: 0; }

.item-title { font-weight: 600; }
.item-title-plain { color: var(--accent); } /* unlinked titles match linked ones */
.item-authors { font-size: 0.93rem; }
.item-blurb { font-size: 0.95rem; }
.item-quote { font-size: 0.9rem; font-style: italic; color: var(--muted); }
.item-quote a { color: inherit; }

.item-meta { font-size: 0.9rem; color: var(--muted); }

.item-year { font-weight: 400; color: var(--muted); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  vertical-align: 2px;
  background: var(--gold-soft);
  color: var(--gold);
  white-space: nowrap;
}

.badge:hover { color: var(--gold); }

.badge-grey { background: var(--grey-soft); color: var(--grey); }

.badge-featured, .badge-featured:hover { background: var(--blue-soft); color: var(--blue); }

.badge-chocolate { background: var(--chocolate-soft); color: var(--chocolate); }

/* Tooltips that appear instantly on hover, or on tap/focus on touch screens */
.has-tip { position: relative; }
.has-tip:not(a) { cursor: help; }

.tip {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 10;
  width: max-content;
  max-width: min(300px, 80vw);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  text-align: left;
}

.has-tip:hover .tip, .has-tip:focus .tip, .has-tip:focus-visible .tip { display: block; }

a.badge:hover { text-decoration: none; filter: brightness(0.95); }

/* Illustrations, on a white tile so line drawings stay visible in dark mode */

.item-figure { margin: 12px 0 0; text-align: center; }

.item-figure img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 180px;
  width: auto;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
}

/* Photos are opaque, so they skip the white tile */
.item-figure img[src$=".jpg"] { padding: 0; background: none; }

.item-figure-small img { max-height: 135px; }
.item-figure-large img { max-height: 240px; }

.item-figure figcaption { margin-top: 6px; font-size: 0.85rem; font-style: italic; color: var(--muted); }

.more { font-size: 0.95rem; margin-top: 4px; }

.footer {
  max-width: 840px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Below this width, stack the avatar above the name so the links row keeps the full width. */
@media (max-width: 780px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 16px; }
}

/* Phones are too narrow for the expanded links row at a readable size, so let it wrap. */
@media (max-width: 620px) {
  .links { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .page { padding-top: 32px; padding-left: 16px; padding-right: 16px; }
  .avatar { width: 96px; height: 96px; font-size: 2rem; }
  h1 { font-size: 1.8rem; }
  .tabs { gap: 20px; }
}
