:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --rule: #e4e4e4;
  --link: #1a1a1a;
  --accent: #2b57c3;
  --max: 920px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111213;
    --fg: #e9e9e9;
    --muted: #9a9a9a;
    --rule: #2a2c2e;
    --link: #e9e9e9;
    --accent: #8fb0ff;
  }
}

:root[data-theme="dark"] {
  --bg: #111213;
  --fg: #e9e9e9;
  --muted: #9a9a9a;
  --rule: #2a2c2e;
  --link: #e9e9e9;
  --accent: #8fb0ff;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

#theme-toggle:hover {
  color: var(--fg);
  border-color: var(--muted);
}

#theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Light: offer the moon. Dark: offer the sun. */
.icon-sun { display: none; }
.icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 4rem 16px 1.75rem;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px 5rem;
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 3rem;
  align-items: start;
  border-top: 1px solid var(--rule);
  padding-top: 2.5rem;
}

.portrait img {
  display: block;
  width: 100%;
  /* Fixed frame so swapping in a photo of another shape doesn't shift the page.
     Portrait ratio, to suit a headshot. */
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center;
  border-radius: 3px;
  transition: opacity 0.14s ease;
  /* No grey flash on tap, and no 300ms delay. */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* iOS Safari only dispatches click on a non-interactive element if it looks
   clickable. On touch devices no cursor is drawn, so this stays invisible. */
@media (hover: none) {
  .portrait img { cursor: pointer; }
}

h2 {
  margin: 2.5rem 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.content > h2:first-child { margin-top: 0; }

h3 {
  margin: 1.6rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

p { margin: 0 0 0.6rem; }

ul.papers,
ul.bio {
  margin: 0;
  padding: 0;
  list-style: none;
}

ul.papers li {
  margin-bottom: 0.4rem;
  padding-left: 1rem;
  position: relative;
}

ul.papers li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.68em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: border-color 0.15s ease, color 0.15s ease;
}

a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.paper-icon {
  border: 0;
  margin-left: 0.35em;
  font-size: 0.85em;
  text-decoration: none;
  white-space: nowrap;
}

.pending { color: var(--muted); font-style: italic; }

ul.bio li {
  margin-bottom: 0.9rem;
  padding-left: 0;
}

.when {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.links {
  margin-top: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.links a {
  font-size: 0.9rem;
}

@media (max-width: 720px) {
  header { padding-top: 2.5rem; }
  h1 { font-size: 1.5rem; }
  .layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  /* Cap the photo, not the column, so the links row can use the full width. */
  .portrait img {
    max-width: 200px;
    margin: 0 auto;
  }
  .links {
    flex-direction: row;
    justify-content: center;
    gap: 1.25rem;
  }
}

/* ---------- Gallery page ---------- */

.page {
  border-top: 1px solid var(--rule);
  padding-top: 2.5rem;
}

.page-title {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 .home-link {
  color: inherit;
  border-bottom: 0;
}

h1 .home-link:hover { color: var(--accent); }

.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3rem;
}

.gallery figure {
  margin: 0;
}

.gallery a {
  display: block;
  border-bottom: 0;
}

.gallery img {
  display: block;
  width: 100%;
  /* No forced crop: one photo per row, so each keeps its own shape. */
  height: auto;
  border-radius: 3px;
  transition: opacity 0.15s ease;
}

.gallery a:hover img { opacity: 0.82; }

.gallery figcaption {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}

.empty-note {
  margin-top: 2.5rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
}

.links.back {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  flex-direction: row;
}

@media (max-width: 720px) {
  .gallery { gap: 2rem; }
  .links.back { justify-content: flex-start; }
}
