/* ==========================================================================
   Site styles. Colors are defined once here; the dark-mode block below
   swaps them when a visitor's device is set to dark mode.
   ========================================================================== */

:root {
  --bg: #fdfcfa;
  --surface: #f3f1ec;
  --text: #1c2026;
  --muted: #5b6370;
  --line: #e3dfd6;
  --accent: #1e407c;
  --accent-strong: #11295a;
  --accent-soft: #e7edf7;
  --link-line: #b9c6dd;
  --on-accent: #ffffff;
  --award: #8a6400;

  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --measure: 47.5rem;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121519;
    --surface: #1a1e24;
    --text: #e6e8eb;
    --muted: #a1a9b5;
    --line: #2b3038;
    --accent: #a3bdf0;
    --accent-strong: #c9d8f7;
    --accent-soft: #1d2940;
    --link-line: #3d4f72;
    --on-accent: #0e1520;
    --award: #e6c065;
  }
}

/* ---- Base ---------------------------------------------------------------- */

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

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--accent-strong); text-decoration-thickness: 2px; }

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

img { max-width: 100%; height: auto; }

[id] { scroll-margin-top: 1.25rem; }

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
}
.skip-link:focus { left: 0.75rem; }

/* ---- Header and footer --------------------------------------------------- */

.site-header { border-bottom: 1px solid var(--line); }

.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.site-name {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}
.site-name:hover { color: var(--accent); }

.site-header nav ul {
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  display: block;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}
.site-header nav a:hover { color: var(--text); }
.site-header nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main { padding-top: 3.25rem; padding-bottom: 4.5rem; }

.site-footer { border-top: 1px solid var(--line); }

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer p { margin: 0; }
.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--accent); }

/* ---- Buttons --------------------------------------------------------------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 2.25rem 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}
.button:hover { background: var(--accent-soft); color: var(--accent-strong); }

.button.primary { background: var(--accent); color: var(--on-accent); }
.button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.file-type {
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* ---- Home page --------------------------------------------------------------- */

.intro {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2.25rem;
}

.portrait {
  flex: none;
  width: 11rem;
  height: auto;
  aspect-ratio: 5 / 6;
  border-radius: 12px;
  object-fit: cover;
  object-position: 50% 25%;
}

.name {
  margin: 0 0 0.65rem;
  font-size: clamp(2.25rem, 1.7rem + 2.4vw, 3.1rem);
  letter-spacing: -0.02em;
}

.role, .affiliation { margin: 0; font-size: 1.15rem; line-height: 1.45; }
.affiliation { color: var(--muted); }

.bio { font-size: 1.125rem; line-height: 1.75; }
.bio p { margin: 0 0 1.15rem; }
.bio p:last-child { margin-bottom: 0; }

/* ---- Research page ----------------------------------------------------------- */

.page-title {
  margin: 0 0 1.25rem;
  font-size: clamp(2rem, 1.6rem + 1.8vw, 2.6rem);
  letter-spacing: -0.02em;
}

.toc ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc a {
  display: block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 1.1rem;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
}
.toc a:hover { border-color: var(--accent); color: var(--accent); }

.research-area { margin-top: 3.5rem; }

.research-area > h2 {
  margin: 0;
  padding-bottom: 0.7rem;
  border-bottom: 2px solid var(--text);
  font-size: 1.5rem;
}

.paper {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--line);
}
.paper:last-child { border-bottom: 0; }
.paper::after { content: ""; display: table; clear: both; }

.paper-title {
  margin: 0 0 0.35rem;
  font-size: 1.22rem;
  line-height: 1.35;
}
.paper-title a {
  color: var(--text);
  text-decoration-color: var(--link-line);
}
.paper-title a:hover { color: var(--accent); text-decoration-color: currentColor; }

.paper-authors { margin: 0; font-size: 0.98rem; }

.paper-venue {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}
.paper-venue cite { font-style: italic; }

.status {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.1rem 0.55rem;
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Each paper's picture sits top right in a white frame of the same size for
   every paper, so the page lines up. The whole picture always shows. */
.paper-figure {
  float: right;
  width: 15rem;
  margin: 0.3rem 0 1rem 2rem;
}
.paper-figure a { display: block; cursor: zoom-in; }
.paper-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}
.paper-figure a:hover img { border-color: var(--accent); }

/* Abstract toggle */
.abstract { margin-top: 1rem; }

.abstract summary {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.abstract summary::-webkit-details-marker { display: none; }
.abstract summary:hover { border-color: var(--accent); }
.abstract summary::after {
  content: "";
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  margin-left: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  vertical-align: 0.2em;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.abstract[open] summary::after { transform: translateY(0.15em) rotate(-135deg); }

.abstract-body {
  margin-top: 0.9rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
  line-height: 1.7;
}
.abstract-body p { margin: 0 0 0.8rem; }
.abstract-body p:last-child { margin-bottom: 0; }

/* Supporting materials, awards, media. On wider screens the label sits in a
   narrow left-hand column; on phones it sits above the list. */
.paper-block { margin-top: 1rem; }

@media (min-width: 40.01rem) {
  .paper-block {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    column-gap: 1rem;
    align-items: baseline;
  }
  .paper-block > .label { grid-column: 1; margin: 0; }
  .paper-block > :not(.label) { grid-column: 2; }
}

.label {
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.note { margin: 0 0 0.6rem; font-size: 0.97rem; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.8rem;
  border-radius: 1rem;
  background: var(--accent-soft);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}
.chip::before {
  content: "";
  width: 0.95em;
  height: 0.95em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5M9 13h6M9 17h6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chip:hover { background: var(--accent); color: var(--on-accent); }

.media, .awards {
  margin: 0;
  padding: 0;
  list-style: none;
}
.media li, .awards li {
  position: relative;
  margin: 0.3rem 0;
  padding-left: 1.15rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.media li::before {
  content: "";
  position: absolute;
  left: 0.2rem;
  top: 0.62em;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: var(--muted);
}
.awards li::before {
  content: "\2605";
  position: absolute;
  left: 0;
  top: 0.05em;
  color: var(--award);
  font-size: 0.85rem;
}
.outlet { font-style: italic; }

/* ---- Small screens ----------------------------------------------------------- */

@media (max-width: 40rem) {
  main { padding-top: 2.25rem; padding-bottom: 3.5rem; }
  .intro { flex-direction: column; align-items: flex-start; gap: 1.25rem; }
  .portrait { width: 9rem; }
  .research-area { margin-top: 2.75rem; }

  /* On phones the picture goes under the title, authors and journal. */
  .paper.has-figure { display: flex; flex-direction: column; }
  .paper.has-figure > * { order: 3; }
  .paper.has-figure > .paper-title,
  .paper.has-figure > .paper-authors,
  .paper.has-figure > .paper-venue { order: 1; }
  .paper.has-figure > .paper-figure {
    order: 2;
    float: none;
    width: 100%;
    max-width: 24rem;
    margin: 1rem 0 0.25rem;
  }
}
