/* ============================================================
   STYLE
   1. Design tokens   colours, fonts, spacing (change the look here)
   2. Base            page, links
   3. Navigation
   4. Pages           title, home hero, label + content rows
   5. Content blocks  papers / institutions, course lists, references
   6. Footer
   7. Small screens and motion

   Layout: a wide column with an 11rem gutter on the left (section labels, and the round
   headshot on Home) and a readable measure on the right. The nav sits on one hairline;
   sections are separated by space alone, with no boxes, cards or fills.
   ============================================================ */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  color-scheme: light;

  /* Neutrals: a near-white paper with a faint warm (not yellow) cast, and matching greys */
  --paper: #fcfbf9;
  --fg: #1f1e1c;
  --soft: #45433f;
  --muted: #6b6965;
  --rule: #e8e6e1;

  /* Accent: deep teal. The title and nav underline use the lighter of the two;
     labels and links use a deeper shade so small text stays legible. */
  --title: #277279;   /* big page titles */
  --label: #1d5f66;   /* small section labels */
  --accent: #1d5f66;  /* links */
  --mark: #277279;    /* active menu underline */
  --tint: #cde2de;    /* soft fill: text selection, link underline, headshot placeholder */

  /* Fonts. Headings use Optima, which ships with Apple devices;
     elsewhere the free look-alike Belleza (loaded in index.html) is used. */
  --font-heading: Optima, "Belleza", Candara, "Segoe UI", sans-serif;
  --heading-weight: 400;
  --heading-tracking: 0;
  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Layout */
  --gutter: 11rem;
  --gap: 3rem;
}

/* Dark mode: follows the visitor's system setting */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #171514;
    --fg: #efebe7;
    --soft: #cdc8c3;
    --muted: #9a958f;
    --rule: #2b2826;
    --title: #83b7bb;
    --label: #83b7bb;
    --accent: #83b7bb;
    --mark: #83b7bb;
    --tint: #2f5256;
  }
}

/* ---------- 2. BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.65;
  padding-inline: clamp(1.25rem, 6vw, 3.5rem);
  padding-block: 1.75rem 3rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; }
::selection { background: var(--tint); }

.wrap { max-width: 52rem; margin-inline: auto; }

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: var(--tint); }
a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; }
ul, ol { margin: 0; padding: 0; }

/* ---------- 3. NAVIGATION ---------- */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0 2rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding-block: 0.25rem 0.9rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--fg); }
.site-nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--mark); }

/* ---------- 4. PAGES ---------- */
main { padding-block: 4.5rem 5.5rem; }
.page { display: none; }
.page.is-active { display: block; animation: rise 0.35s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.stack { display: flex; flex-direction: column; gap: 3.5rem; }
.head { display: flex; flex-direction: column; gap: 0.75rem; }

.title {
  color: var(--title);
  font-family: var(--font-heading);
  font-size: clamp(2.6rem, 6.5vw, 4rem);
  font-weight: var(--heading-weight);
  line-height: 1.1;
  letter-spacing: var(--heading-tracking);
  text-wrap: balance;
}
.lede { font-family: var(--font-ui); font-size: 0.98rem; color: var(--muted); }

/* Home: round headshot in the left gutter, name and the line beneath it beside it. */
.hero {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  column-gap: var(--gap);
  row-gap: 1.75rem;
  align-items: center;
}
.portrait {
  width: var(--gutter);
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--tint);
}
.portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.portrait svg { display: block; width: 100%; height: 100%; }
.portrait svg * { fill: var(--paper); }

/* A row is a label in the left gutter and its content on the right.
   A row without a label puts its content on the right. */
.row {
  display: grid;
  grid-template-columns: var(--gutter) minmax(0, 1fr);
  column-gap: var(--gap);
  row-gap: 0.75rem;
  align-items: baseline;
}
.row > .label { grid-column: 1; }
.row > .content { grid-column: 2; max-width: 40rem; min-width: 0; }
#page-home .row > .content { max-width: 36rem; }

.label {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
}

/* ---------- 5. CONTENT BLOCKS ---------- */
.content { display: flex; flex-direction: column; gap: 1.1rem; }
.content.has-items { gap: 2.9rem; }

.prose { color: var(--soft); }
.prose, .item-text { text-align: justify; hyphens: auto; }
.note { font-family: var(--font-ui); font-size: 0.86rem; color: var(--muted); }
.note em, .item-meta em { font-style: normal; }
.big-link { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; font-size: 1.5rem; }

/* An item: a paper, or an institution in Teaching (starts at a "###" heading) */
.item { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.item-title { font-family: var(--font-heading); font-size: 1.4rem; font-weight: var(--heading-weight); line-height: 1.3; color: var(--fg); text-wrap: balance; }
.item-meta { font-family: var(--font-ui); font-size: 0.86rem; color: var(--muted); }
.item-text { font-size: 1.1rem; color: var(--soft); }
.item-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 0.3rem; font-family: var(--font-ui); font-size: 0.86rem; }
.group-label { margin-top: 0.7rem; font-family: var(--font-ui); font-size: 0.8rem; font-weight: 500; letter-spacing: 0.06em; color: var(--muted); }

/* Course lists: code in the left column, title on the right */
.course-list { list-style: none; display: grid; gap: 0.55rem; }
.course-list li { display: block; }
.course-list li.has-code { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0 1.5rem; align-items: baseline; }
.course-code { font-family: var(--font-ui); font-size: 0.84rem; font-weight: 400; color: var(--muted); }
.course-title { font-size: 1.12rem; color: var(--fg); }

/* Plain lists */
.bullets { display: grid; gap: 0.6rem; padding-left: 1.2rem; list-style: disc; color: var(--soft); }
ol.bullets { list-style: decimal; }
.bullets li::marker, .refs li::marker { color: var(--muted); }

/* Reference-style lists: bold name first, then details underneath */
.refs { display: grid; gap: 1rem; padding-left: 1.2rem; list-style: disc; font-family: var(--font-ui); font-size: 0.86rem; color: var(--muted); }
.refs li > strong:first-child { display: block; font-family: var(--font-display); font-size: 1.2rem; font-weight: 400; color: var(--fg); }

.load-error { font-family: var(--font-ui); font-size: 0.9rem; color: var(--muted); max-width: 40rem; }

/* ---------- 6. FOOTER ---------- */
.site-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
}
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--fg); }

/* ---------- 7. SMALL SCREENS AND MOTION ---------- */
@media (max-width: 48rem) {
  .row, .hero { grid-template-columns: minmax(0, 1fr); }
  .row > .label, .row > .content { grid-column: 1; }
  .portrait { width: 8.5rem; }
}
@media (max-width: 30rem) {
  .course-list li.has-code { grid-template-columns: minmax(0, 1fr); }
  main { padding-block: 3rem 4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .page.is-active { animation: none; }
}
