/* Spectral, self-hosted (SIL Open Font License) */
@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-latin-300-normal.woff2") format("woff2");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Spectral";
  src: url("fonts/spectral-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #fbfbf9;
  --ink: #1b1c20;
  --muted: #62646c;
  --accent: #002fa7; /* International Klein Blue */
  --faint: #e6e6ea;
  color-scheme: light dark;
}

/* Dark theme: follows the system unless the toggle has picked one */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #141519;
  --ink: #e4e5ea;
  --muted: #9a9ca6;
  --accent: #8aa4ff; /* lighter ultramarine, readable on dark */
  --faint: #272930;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141519;
    --ink: #e4e5ea;
    --muted: #9a9ca6;
    --accent: #8aa4ff;
    --faint: #272930;
  }
}

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

html {
  font-size: 112.5%; /* 18px */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Spectral", Georgia, serif;
  font-weight: 400;
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

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

p {
  margin: 0;
}

/* Links: ink-colored text, Klein blue underline only */
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Running text */
.prose p + p {
  margin-top: 0.9rem;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Page grid: a narrow margin column for labels, a reading column for content */
main {
  position: relative;
  max-width: 53rem;
  margin: 0 auto;
  padding: 6rem 1.5rem 4rem;
}

/* Theme toggle: a small half-filled circle in the top corner */
.theme-toggle {
  position: absolute;
  top: 2rem;
  right: 1.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0.35rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
}

.theme-toggle svg {
  display: block;
  width: 100%;
  height: 100%;
}

.row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  column-gap: 2.5rem;
}

.row + .row {
  margin-top: 3.75rem;
}

/* Intro: photo, name and links in the margin column; "About me" beside them */
.intro {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "photo text"
    "name  text"
    "links text";
  column-gap: 2.5rem;
  margin-bottom: 3.75rem;
}

.intro .photo {
  grid-area: photo;
}

.name {
  grid-area: name;
  margin: 1rem 0 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

.intro-text {
  grid-area: text;
}

.links {
  grid-area: links;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.8;
}

.photo {
  width: 7.5rem;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
}

.photo-placeholder {
  display: grid;
  place-items: center;
  background: var(--faint);
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Section labels: in the margin column, or above the text in the intro */
.row > h2,
.intro-text > h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  line-height: 1.6;
}

.intro-text > h2 {
  margin-bottom: 0.5rem;
}

/* Papers */
.papers {
  list-style: none;
  margin: 0;
  padding: 0;
}

.papers li {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  column-gap: 1.5rem;
  align-items: start;
}

.paper-thumb {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0.3rem;
  border-radius: 2px;
}

/* Figures are mostly white; take the glare off them in the dark theme */
:root[data-theme="dark"] .paper-thumb {
  filter: brightness(0.85);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .paper-thumb {
    filter: brightness(0.85);
  }
}

.papers li + li {
  margin-top: 1.9rem;
}

.paper-title {
  font-weight: 500;
  line-height: 1.45;
}

.authors {
  margin-top: 0.2rem;
  color: var(--muted);
}

.authors .me {
  color: var(--ink);
  font-weight: 500;
}

.meta {
  margin-top: 0.2rem;
  display: flex;
  flex-wrap: wrap;
  column-gap: 1.1rem;
}

.meta .venue {
  font-style: italic;
}

.note {
  margin-top: 1.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

footer {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Medium screens: smaller figures so the paper text keeps its room */
@media (max-width: 56rem) {
  .papers li {
    grid-template-columns: 11rem minmax(0, 1fr);
    column-gap: 1.25rem;
  }
}

/* Small screens: one column, labels above content */
@media (max-width: 40rem) {
  main {
    padding: 3.5rem 1.25rem 3rem;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
  }

  .intro {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
      "photo"
      "name"
      "links"
      "text";
    margin-bottom: 3rem;
  }

  .links {
    display: flex;
    flex-wrap: wrap;
    column-gap: 1.25rem;
    margin-top: 0.4rem;
    font-size: 1rem;
  }

  .intro-text {
    margin-top: 2.5rem;
  }

  .row + .row {
    margin-top: 3rem;
  }

  .row > h2 {
    margin-bottom: 0.75rem;
  }

  .photo {
    width: 6rem;
  }

  .papers li {
    grid-template-columns: minmax(0, 1fr);
  }

  .paper-thumb {
    max-width: 24rem;
    margin: 0 0 0.75rem;
  }

  .theme-toggle {
    top: 1rem;
    right: 0.75rem;
  }
}
