/* ---------- colours and type ---------- */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1b19;
  --soft: #3b3a37;
  --muted: #716d66;
  --rule: #e5e1d9;
  --accent: #ed1b2f;   /* McGill red, for decoration */
  --link: #c4122a;     /* slightly deeper red, readable as text */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 46rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151516;
    --surface: #1d1d1f;
    --text: #eceae5;
    --soft: #cbc8c1;
    --muted: #98948c;
    --rule: #2f2f32;
    --accent: #ff4a5c;
    --link: #ff7382;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.65 var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[id] { scroll-margin-top: 5rem; }

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: text-decoration-color 0.15s, color 0.15s;
}
a:hover { text-decoration-color: currentColor; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  backdrop-filter: saturate(1.5) blur(12px);
}
.topbar-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0.8rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font: 500 1rem/1.2 var(--sans);
}
.brand { font: 600 1.2rem/1.2 var(--serif); color: var(--text); text-decoration: none; }
.navlinks { display: flex; gap: 1.6rem; }
.navlinks a { color: var(--muted); text-decoration: none; }
.navlinks a:hover { color: var(--link); }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2.5rem;
  padding: 3.5rem 0 1.75rem;
}
.hero h1 {
  margin: 0 0 0.7rem;
  font: 600 clamp(2.3rem, 7vw, 3.1rem)/1.08 var(--serif);
  letter-spacing: -0.015em;
}
.role { margin: 0 0 1.25rem; font: 400 1rem/1.55 var(--sans); color: var(--muted); }
.role strong { font-weight: 600; color: var(--text); }
.role a { color: inherit; text-decoration-color: var(--rule); }
.role a:hover { color: var(--link); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; }
.btn {
  padding: 0.42rem 0.95rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 500 0.85rem/1.4 var(--sans);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--link); }

.portrait {
  width: 15rem;
  height: 15rem;
  border-radius: 50%;
  border: 3px solid var(--accent);   /* solid red ring, touching the photo */
  object-fit: cover;
  background: var(--rule);
}

/* ---------- bio ---------- */
.bio p { margin: 0 0 1rem; }
.bio p:last-child { margin-bottom: 0; }

/* ---------- section blocks ---------- */
.block { margin-top: 3.5rem; }
.block > h2 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.5rem;
  font: 600 0.78rem/1 var(--sans);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--link);
}
.block > h2::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* ---------- latest drafts ---------- */
.updates { list-style: none; margin: 0; padding: 0; }
.updates li {
  display: grid;
  grid-template-columns: 5.25rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
}
.updates li:first-child { border-top: 0; padding-top: 0; }
.updates li:last-child { padding-bottom: 0; }
.updates time {
  font: 500 0.78rem/1.4 var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.u-title { font-weight: 600; color: var(--text); text-decoration: none; }
.u-title:hover { color: var(--link); }
.u-co { font-size: 0.92em; color: var(--muted); }

.pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: 600 0.68rem/1.2 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--link);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pill:hover { background: var(--link); border-color: var(--link); color: var(--bg); }

/* ---------- papers ---------- */
.paper { padding-bottom: 2.25rem; margin-bottom: 2.25rem; border-bottom: 1px solid var(--rule); }
.paper:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }

.paper h3 { margin: 0 0 0.45rem; font: 600 1.4rem/1.28 var(--serif); letter-spacing: -0.005em; }
.paper h3 a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
.paper h3 a:hover { color: var(--link); text-decoration-color: currentColor; }

.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.65rem;
  margin: 0 0 0.9rem;
  font: 400 0.875rem/1.5 var(--sans);
  color: var(--muted);
}
.meta > span + span::before { content: "·"; margin-right: 0.65rem; }
.meta a:not(.pill) { color: inherit; }
.meta a:not(.pill):hover { color: var(--link); }

.abstract { font-size: 1rem; line-height: 1.68; color: var(--soft); }
.paper h3 + .abstract { margin-top: 0.75rem; }
.abstract p { margin: 0 0 0.8rem; }
.abstract > :last-child { margin-bottom: 0; }

.paper figure { margin: 1.4rem 0 0; }
.paper figure a { display: block; cursor: zoom-in; }
.paper figure img {
  display: block;
  width: 100%;         /* every figure spans the text column; click opens it full size */
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}
.paper figcaption { margin-top: 0.55rem; font: 400 0.82rem/1.5 var(--sans); color: var(--muted); text-align: center; }

.comments {
  margin-top: 1.25rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  font: 400 0.9rem/1.6 var(--sans);
  color: var(--muted);
}
.comments p, .comments ul, .comments ol { margin: 0 0 0.6rem; }
.comments > :last-child { margin-bottom: 0; }

/* a paper reached from "Latest drafts" lights up briefly */
@keyframes arrive { from { background: color-mix(in srgb, var(--accent) 12%, transparent); } to { background: transparent; } }
.paper:target h3 { animation: arrive 1.8s ease-out; border-radius: 4px; }

/* ---------- teaching ---------- */
.course { border-top: 1px solid var(--rule); }
.course:first-of-type { border-top: 0; }
.course summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.9rem;
  padding: 0.8rem 0 0.8rem 1.6rem;
  position: relative;
  cursor: pointer;
  list-style: none;
}
.course:first-of-type summary { padding-top: 0; }
.course summary::-webkit-details-marker { display: none; }
.course summary::before {
  content: "+";
  position: absolute;
  left: 0.1rem;
  font: 400 1.15rem/1.45 var(--sans);
  color: var(--link);
}
.course[open] summary::before { content: "–"; }
.c-title { font-weight: 600; }
.c-desc { font: 400 0.875rem/1.5 var(--sans); color: var(--muted); }
.c-body { padding: 0 0 1.1rem 1.6rem; font-size: 0.97rem; color: var(--soft); }
.c-body p { margin: 0 0 0.7rem; }
.c-body ul, .c-body ol { margin: 0 0 0.7rem; padding-left: 1.25rem; }
.c-body li { margin: 0.2rem 0; }
.c-body h1, .c-body h2, .c-body h3 {
  margin: 1.4rem 0 0.5rem;
  font: 600 0.72rem/1.4 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.c-body > :first-child { margin-top: 0.2rem; }
/* a long list (the chapters of a course) set in two columns: add {: .cols} under the list */
.c-body .cols { columns: 2; column-gap: 2.25rem; }
.c-body .cols li { break-inside: avoid; margin: 0; padding: 0.2rem 0; }

/* ---------- footer ---------- */
.footer { margin-top: 4.5rem; padding-bottom: 2.5rem; font: 400 0.8rem/1.5 var(--sans); color: var(--muted); }
.footer p { margin: 0; padding-top: 1.5rem; border-top: 1px solid var(--rule); }

/* ---------- "page moved" ---------- */
.notfound { padding-top: 5rem; }
.notfound h1 { font: 600 2rem/1.2 var(--serif); margin: 0 0 0.75rem; }

/* ---------- small screens ---------- */
@media (max-width: 600px) {
  body { font-size: 1rem; }
  .brand { display: none; }
  .topbar-inner { justify-content: center; }
  .navlinks { gap: 1.15rem; }
  .hero { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 2.25rem; }
  .portrait { order: -1; width: 10rem; height: 10rem; }
  .block { margin-top: 2.75rem; }
  .paper h3 { font-size: 1.25rem; }
  .c-body .cols { columns: 1; }
  .updates li { grid-template-columns: 1fr auto; gap: 0.1rem 1rem; }
  .updates time { grid-column: 1 / -1; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .actions { display: none; }
  body { background: #fff; font-size: 11pt; }
  .paper { break-inside: avoid; }
  .course > .c-body { display: block; }
}
