/* ---- tokens ---- */
:root {
  --text:   #141414;
  --muted:  #7c7c7c;
  --faint:  #b3b3b3;
  --accent: #000000;
  --accent-bg: #e8e8e8;
  --bg:     #ffffff;
  --rule:   #e0e0e0;
  --chip:   #f2f2f2;
  /* Helvetica Neue Light on Apple devices; Inter 300 is the fallback elsewhere,
     since Windows/Android ship no light-weight Helvetica or Arial.
     To restore serif headings: set --display to var(--serif) and re-add
     Newsreader to the Google Fonts <link> in each page. */
  --serif:   'Newsreader', 'Tiempos', 'Times New Roman', Times, serif;
  --sans:    'Helvetica Neue', 'Inter', Helvetica, Arial, sans-serif;
  --display: var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text:   #e4e4e4;
    --muted:  #8d8d8d;
    --faint:  #686868;
    --accent: #ffffff;
    --accent-bg: #2e2e2e;
    --bg:     #171717;
    --rule:   #303030;
    --chip:   #232323;
  }
}
:root[data-theme="dark"] {
  --text:#e4e4e4; --muted:#8d8d8d; --faint:#686868; --accent:#ffffff;
  --accent-bg:#2e2e2e; --bg:#171717; --rule:#303030; --chip:#232323;
}

/* ---- base ---- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  max-width: 800px;
  margin: 64px auto 96px;
  padding: 0 16px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 18.5px;
  font-weight: 300;
  line-height: 1.62;
  letter-spacing: 0.004em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 {
  font-family: var(--display);
  font-size: 56px;
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.028em;
  margin: 0 0 22px;
}

h2 {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.012em;
  margin: 2.3em 0 0.55em;
}
h2:first-of-type { margin-top: 0; }

h3 {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2em 0 0.8em;
}

p { margin: 0 0 1em; }

a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
a:hover { color: var(--accent); border-bottom-color: var(--accent); }

em, i { font-style: italic; }

hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 2.5em 0;
}

sup { vertical-align: top; position: relative; top: -0.25em; font-size: 0.72em; }

/* ---- nav ---- */
nav ul {
  list-style: none;
  padding: 0;
  margin: 0 0 42px;
}
nav li { display: inline-block; margin: 0 24px 10px 0; }
nav a {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
nav a.active { color: var(--text); border-bottom-color: var(--accent); }
nav a:hover { color: var(--accent); }

/* ---- about ---- */
.drop-cap::first-letter {
  font-family: var(--display);
  font-size: 3.2em;
  font-weight: 300;
  float: left;
  line-height: 0.92;
  margin: 0.04em 0.09em -0.06em 0;
  color: var(--text);
}

.portrait {
  width: 300px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center 16%;
  float: left;
  margin: 6px 30px 18px 0;
  border-radius: 2px;
  filter: grayscale(100%);
}

.clear { clear: both; }

/* ---- chips / small links ---- */
.chip {
  display: inline-block;
  font-weight: 400;
  font-size: 0.78em;
  letter-spacing: 0.03em;
  background: var(--chip);
  color: var(--muted);
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 0.45em;
  white-space: nowrap;
  border-bottom: 0;
}
.chip:hover { background: var(--accent-bg); color: var(--accent); border-bottom: 0; }

/* ---- publications ---- */
ol.pubs { padding-left: 1.5em; margin: 0 0 1.5em; }
ol.pubs li { font-weight: 300; }
ol.pubs li { margin-bottom: 1.25em; padding-left: 0.2em; }
ol.pubs li::marker { color: var(--faint); font-size: 0.9em; }
ol.pubs p { margin: 0 0 0.4em; }
.me { font-weight: 600; color: var(--text); }
.venue { font-style: italic; }

.footnote { font-size: 0.86em; font-weight: 400; color: var(--muted); }

/* ---- research / teaching entries ---- */
.entry { margin-bottom: 2.4em; }
.entry .meta {
  font-weight: 400;
  font-size: 0.82em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 0.5em;
}

.figure-row { display: flex; flex-direction: column; gap: 1em; margin: 1.4em 0; }
.figure-row img { width: 100%; max-width: 460px; height: auto; border-radius: 2px; filter: grayscale(100%); }
/* Opt out when colour carries meaning (e.g. colour-coded subunits in a schematic) */
.figure-row img.keep-color { filter: none; }
.legend { font-size: 0.86em; font-weight: 400; color: var(--muted); max-width: 440px; }

/* ---- contact ---- */
dl.contact { margin: 0; }
dl.contact dt {
  font-weight: 400;
  font-size: 0.82em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 1.3em;
}
dl.contact dd { margin: 0.15em 0 0; }
dl.contact dd a { color: var(--text); }
dl.contact dd a:hover { color: var(--accent); }

/* ---- responsive ---- */
@media (min-width: 900px) {
  .figure-row { flex-direction: row; align-items: flex-start; }
  .figure-row .legend { margin-top: 0.2em; }
}

@media (max-width: 620px) {
  body { margin: 40px auto 64px; font-size: 17.5px; line-height: 1.6; }
  h1 { font-size: 40px; letter-spacing: -0.022em; }
  h2 { font-size: 21px; }
  .portrait {
    float: none;
    display: block;
    width: 230px;
    margin: 0 0 26px;
  }
  nav li { margin-right: 18px; }
}

/* Multi-panel figures: full column width, legend underneath */
.figure-row.wide { flex-direction: column; }
.figure-row.wide img { max-width: 100%; }
.figure-row.wide .legend { max-width: none; }
