/* -> Fonts
   Two typefaces, self-hosted from fonts/:
   Alegreya Sans for body text, Lato for headings.
   font-display: "block" keeps text invisible until they load.
   I did't like how "swap" option looks. */

@font-face {
  font-family: "Alegreya Sans"; font-style: normal; font-weight: 400;
  font-display: block;
  src: url("fonts/AlegreyaSans-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Alegreya Sans"; font-style: italic; font-weight: 400;
  font-display: block;
  src: url("fonts/AlegreyaSans-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Lato"; font-style: normal; font-weight: 700;
  font-display: block;
  src: url("fonts/Lato-Bold.woff2") format("woff2");
}
@font-face {
  font-family: "Lato"; font-style: normal; font-weight: 800;
  font-display: block;
  src: url("fonts/Lato-ExtraBold.woff2") format("woff2");
}


/* -> Colours and font stacks
   Named values, used below as var(--name).
   The dark set applies automatically when the visitor's system is in dark mode. */

:root {
  color-scheme: light dark;
  --fg:     #404040;   /* body text */
  --strong: #1c1c1c;   /* headings, names, titles */
  --muted:  #6f6f6f;   /* secondary text: dates, venues, notes */
  --bg:     #f9f9f9;   /* page background */
  --rule:   #e0e0e0;   /* hairlines under headings and around the nav */
  --link:   #296acc;
  --sans: "Alegreya Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --head: "Lato", var(--sans);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg:     #cfcfcf;
    --strong: #f2f2f2;
    --muted:  #949494;
    --bg:     #1b1b1b;
    --rule:   #343434;
    --link:   #7fb0f5;
  }
}


/* -> Page */

/* Sizes are in rem, i.e. multiples of the root font size set under "Page".
   Change that one number to scale everything; change a rem value to adjust
   one thing. Colours are named once under "Colours" and used by name. */

*, *::before, *::after { box-sizing: border-box }

/* The root font size: every rem in this file is a multiple of it.
   141% of the browser default (16px) is about 22.5px. Alegreya Sans has a
   small x-height, so it needs to be set larger than usual to read the same. */
:root { font-size: 141% }

body {
  max-width: 33rem;              /* about 72 characters per line */
  margin: 0 auto;                /* centred */
  padding: 3rem 1.25rem 5rem;    /* top, sides, bottom */
  background: var(--bg);
  color: var(--fg);
  font: 1.0625rem/1.45 var(--sans);   /* size/line-height family */
  -webkit-text-size-adjust: 100%;     /* stop iOS enlarging text on its own */
  font-kerning: normal;
  font-variant-ligatures: common-ligatures contextual;
  text-wrap: pretty;             /* avoid a lone word on the last line */
}

a { color: var(--link); text-decoration: none }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 2px }

p { margin: 0 0 1rem }


/* -> Header: photo, name, job title */

header {
  display: flex;             /* photo and text side by side */
  align-items: center;
  gap: 1.15rem;
  margin-bottom: 2rem;
}

.avatar { width: 4.9rem; height: 4.9rem; flex: none }

h1 {
  font: 800 1.9rem/1.15 var(--head);
  text-wrap: balance;
  letter-spacing: -0.015em;
  color: var(--strong);
  margin: 0 0 0.35rem;
}

header .role { margin: 0; color: var(--muted) }


/* -> Nav: the row of section links under the header */

nav.top {
  display: flex;
  flex-wrap: wrap;           /* links wrap onto a second line if needed */
  gap: 0.3rem 1.15rem;       /* between rows, between links */
  margin: 1.5rem 0 2.5rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font: 700 0.9rem/1.4 var(--head);
  letter-spacing: 0.01em;
}


/* -> Intro */

/* The opening line: larger than body text, quieter than a heading. */
.motto {
  text-wrap: balance;
  margin: 0 0 1.6rem;
  font: 700 1.28rem/1.4 var(--head);
  letter-spacing: -0.015em;
  color: var(--strong);
}

/* The row of profile links (Email · GitHub · ...): a dot between links. */
.elsewhere a + a::before { content: " · "; color: var(--muted) }


/* -> Section headings */

h2 {
  font: 800 1.25rem/1.2 var(--head);
  text-wrap: balance;
  color: var(--strong);
  text-transform: lowercase;
  letter-spacing: -0.01em;
  margin: 3rem 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 1rem;   /* breathing room when a nav link jumps here */
}
h2:first-of-type { margin-top: 0 }


/* -> Entries: one paper, talk, job or project
   Every entry is a .item with a title (.t) and a muted line of details (.m).
   Papers and talks add a row of small links (.refs). Jobs add a date range
   (.when), the roles held there (.roles, .role) and a tools line (.stack). */

.item { margin: 0 0 1.35rem }
.item .gap { display: none }     /* only for text browsers, see pollen.rkt */
.item .t { color: var(--strong); font: 700 1em/1.35 var(--head) }
.item a.t { color: var(--link) }                 /* project names are links */
.item .m { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 0.1rem }

/* A job description can hold several paragraphs and a list. */
.m p { margin: 0 0 0.5rem }
.m ul { margin: 0 0 0.5rem; padding-left: 1.2rem }
.m li + li { margin-top: 0.15rem }
.m > :last-child { margin-bottom: 0 }

/* The link row under a paper or talk: DOI · arXiv · PDF */
.refs { display: block; font-size: 0.88rem; margin-top: 0.15rem }
.refs a + a::before { content: " · "; color: var(--muted) }

/* Year markers between groups of papers. */
.year {
  margin: 1.9rem 0 0.65rem;
  font: 700 0.78rem/1 var(--head);
  letter-spacing: 0.09em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.year:first-child { margin-top: 0 }

/* Date ranges on jobs and education. */
.when { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums }

/* Jobs: the organisation name is slightly larger, and the roles held there
   are listed under it behind a hairline on the left. */
.item > .hd > .t { font-size: 1.06em }
.roles {
  margin: 0.5rem 0 0;
  padding-left: 1.05rem;
  border-left: 1px solid var(--rule);
}
.role + .role { margin-top: 1.1rem }
.role .when { font-size: 0.82rem }
.rt { color: var(--strong); font-weight: 600 }    /* role title */

/* The tools line at the end of a job (TLA+ · Event-B · ...). */
.stack {
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}


/* -> Footer */

footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.88rem;
}
footer p { margin: 0 }


/* -> Phones: narrow screens
   Smaller root size (so more characters fit on a line), tighter spacing. */

@media (max-width: 34rem) {
  :root { font-size: 106% }
  body { padding: 2rem 1rem 3.5rem; font-size: 1rem; line-height: 1.55 }
  header { gap: 0.9rem }
  .avatar { width: 4rem; height: 4rem }
  h1 { font-size: 1.6rem }
  nav.top { gap: 0.25rem 0.9rem }
  .motto { font-size: 1.12rem }
  h2 { margin-top: 2.4rem }
}


/* -> Print */

@media print {
  :root { --fg: #000; --strong: #000; --muted: #444; --bg: #fff; --link: #000; --rule: #bbb }
  body { max-width: none; font-size: 10.5pt; padding: 0 }
  nav.top, footer { display: none }
  h2 { margin-top: 1.4rem }
  .item { break-inside: avoid }   /* keep an entry on one page */
}
