/* Self-hosted, so a cold load needs no third-party round trip before text can
   be styled. Latin subsets as served by Google Fonts; Archivo is one variable
   file covering 400–700. All three families are SIL OFL — see fonts/README.md. */
@font-face {
  font-family: Archivo;
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/archivo-latin-var.woff2") format("woff2");
}

@font-face {
  font-family: Newsreader;
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("fonts/newsreader-latin-300.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/plex-mono-latin-400.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/plex-mono-latin-500.woff2") format("woff2");
}

:root {
  --paper: #f4f1e8;
  --ink: #171612;
  --ink-70: #3c3830;
  --ink-50: #6d675a;

  /* Webfont first, then a full system stack — the fallback is what renders
     during the swap, so it needs to stand on its own. */
  --sans: Archivo, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --serif: Newsreader, Georgia, "Times New Roman", ui-serif, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;

  --pad-x: clamp(20px, 5vw, 76px);
  --content-max: 60rem;
  --gap-role: clamp(46px, 6vw, 88px);
  --nav-lift: clamp(96px, calc(50svh - 220px), 280px);
  --nav-height: 76px;
  --section-heading-gap: clamp(40px, 4.5vw, 64px);

  --t-name: clamp(38px, 5.6vw, 78px);
  --t-lede: clamp(19px, 2.5vw, 30px);
  --t-company: clamp(22px, 2.9vw, 34px);
  --t-body: clamp(15px, 1.8vw, 18px);
  --t-meta: clamp(12px, 1.4vw, 14px);

  /* One text column shared by role copy and the right-hand date column, so
     dates land on the same edge the prose does. */
  --measure: calc(44 * var(--t-body));
}

* {
  box-sizing: border-box;
}

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

@keyframes page-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* One short fade over the whole page. Being pure CSS it can't strand the
     content the way a JS-gated reveal can, and it covers the webfont swap on a
     cold load. */
  body {
    animation: page-in 420ms ease-out both;
  }

  /* Held behind a class the script adds on load. The nav links leave #work or
     #contact in the URL, and if smooth is already active when the page loads
     with a fragment the browser *animates* the jump to it — so every refresh
     replayed a long scroll from the top. Deferring it keeps the initial jump
     instant and only makes in-page clicks smooth. */
  html.is-ready {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

a:hover {
  color: var(--ink-50);
}

a:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

.body {
  width: 100%;
  max-width: calc(var(--content-max) + var(--pad-x) + var(--pad-x));
  margin-inline: auto;
  padding: clamp(30px, 5vw, 76px) var(--pad-x);
}

.intro {
  display: flex;
  align-items: center;
  min-height: 100svh;
  padding-block: clamp(48px, 8vh, 96px);
}

/* Without this the flex item shrink-wraps to the lede's measure and the
   portrait floats short of the content edge every other section aligns to. */
.intro-content {
  width: 100%;
}

.intro-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(24px, 5vw, 72px);
}

.name {
  margin: 0;
  font-size: var(--t-name);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.94;
}

.portrait {
  width: clamp(88px, 11vw, 160px);
  height: auto;
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
}

.lede {
  max-width: 27em;
  margin: 34px 0 0;
  font-family: var(--serif);
  font-size: var(--t-lede);
  font-weight: 300;
  line-height: 1.55;
}

.note {
  max-width: 43em;
  margin: 32px 0 0;
  color: var(--ink-70);
  font-family: var(--mono);
  font-size: var(--t-meta);
  line-height: 2.1;
}

.site-flow {
  margin-top: calc(-1 * var(--nav-lift));
}

.site-nav {
  position: sticky;
  z-index: 10;
  top: 0;
  height: var(--nav-height);
  margin-bottom: calc(var(--nav-lift) - var(--nav-height));
  background: var(--paper);
}

.site-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: calc(var(--content-max) + var(--pad-x) + var(--pad-x));
  height: 100%;
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

.menu-links {
  display: flex;
  gap: 32px;
}

.nav-link {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

/* visibility keeps it out of the tab order while hidden, and transitioning it
   alongside opacity lets the fade-out finish before it disappears. */
.home-link {
  width: 44px;
  height: 44px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 240ms ease, visibility 240ms;
}

.site-nav.is-docked .home-link {
  opacity: 1;
  visibility: visible;
}

.home-link img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.section-label {
  margin: 0;
  color: var(--ink-70);
  font-family: var(--mono);
  font-size: clamp(15px, 1.4vw, 17px);
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

#work,
#contact {
  scroll-margin-top: var(--nav-height);
}

.roles {
  display: flex;
  flex-direction: column;
  padding-block: clamp(52px, 7vw, 104px) clamp(72px, 9vw, 132px);
}

.roles .section-label {
  margin-bottom: var(--section-heading-gap);
}

.role + .role {
  margin-top: var(--gap-role);
}

.role-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 18px;
  max-width: var(--measure);
}

.company,
.school h3 {
  margin: 0;
  font-size: var(--t-company);
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Nine underlined headings in a row is a lot of texture; keep the affordance
   for hover and keyboard focus instead. */
.company a {
  text-decoration: none;
}

.company a:hover,
.company a:focus-visible {
  text-decoration: underline;
}

.title,
.years {
  font-family: var(--mono);
  font-size: 12px;
}

.title {
  color: var(--ink-70);
}

.years {
  margin-left: auto;
  color: var(--ink-50);
  font-variant-numeric: tabular-nums;
}

.role p {
  max-width: var(--measure);
  margin: 16px 0 0;
  font-size: var(--t-body);
  line-height: 1.6;
}

.role p.stack {
  max-width: none;
  margin: 14px 0 0;
  color: var(--ink-50);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.school {
  padding-block: clamp(76px, 9vw, 128px);
}

.school h3 {
  margin-top: var(--section-heading-gap);
}

/* One row per programme, dates in the same right-hand column the work entries
   use — the two used to share a single dense line. */
.programmes {
  max-width: var(--measure);
  margin: 26px 0 0;
  padding: 0;
  font-size: var(--t-body);
  list-style: none;
}

.programmes li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  line-height: 1.6;
}

.programmes li + li {
  margin-top: 12px;
}

/* Same prose treatment as the work entries — an institution is the same tier of
   information as an employer, so it shouldn't read as metadata. */
.school p {
  max-width: var(--measure);
  margin: 30px 0 0;
  font-size: var(--t-body);
  line-height: 1.6;
}

.contact {
  display: flex;
  flex-direction: column;
  padding-block: clamp(76px, 9vw, 128px);
}

.contact .section-label {
  margin-bottom: var(--section-heading-gap);
}

.contact .links {
  margin-top: 28px;
}

.contact p {
  max-width: 29em;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(18px, 2.2vw, 25px);
  font-weight: 300;
  line-height: 1.55;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  font-family: var(--mono);
  font-size: 12px;
}

/* 768, not 640: below this the three-column role head no longer fits and the
   date wraps to a line of its own. */
@media (max-width: 767px) {
  :root {
    --gap-role: 68px;
    --nav-lift: clamp(64px, calc(50svh - 224px), 190px);
    --nav-height: 64px;
    --pad-x: 28px;
    --section-heading-gap: 38px;
  }

  .body {
    padding-inline: 28px;
  }

  .intro {
    padding-block: 40px;
  }

  .portrait {
    width: clamp(76px, 24vw, 96px);
  }

  .name {
    font-size: 42px;
  }

  .lede {
    margin-top: 48px;
    font-size: 21px;
    line-height: 1.5;
  }

  .note {
    margin-top: 38px;
    font-size: 13px;
    line-height: 1.95;
  }

  .nav-link {
    font-size: 14px;
  }

  .home-link {
    width: 40px;
    height: 40px;
  }

  .roles {
    padding-block: 50px 92px;
  }

  .role-head {
    display: block;
  }

  .role-head .title,
  .role-head .years {
    display: block;
    margin-top: 8px;
  }

  .role p {
    margin-top: 20px;
  }

  /* The date drops onto its own line here, so each programme needs more room
     around it to stay readable as one unit. */
  .programmes li + li {
    margin-top: 26px;
  }

  .school p {
    margin-top: 36px;
  }

  .school,
  .contact {
    padding-block: 68px 88px;
  }

  .years {
    width: 100%;
    margin-left: 0;
  }
}

@media print {
  :root {
    --paper: #fff;
  }

  @page {
    margin: 12mm;
  }

  body {
    font-size: 10pt;
  }

  .body {
    padding: 8mm 10mm;
  }

  .intro {
    display: block;
    min-height: 0;
    padding-block: 12mm;
  }

  .site-nav {
    display: none;
  }

  .site-flow {
    margin-top: 0;
  }

  .role + .role {
    margin-top: 8mm;
  }

  .role,
  .school,
  .contact {
    break-inside: avoid;
  }

  a {
    text-decoration: none;
  }
}
