/* ============================================================
   Colours — edit here. Dark values are repeated twice: once for
   visitors whose system is in dark mode, once for the toggle.
   ============================================================ */
:root {
  --bg: #ffffff;
  --text: #15181d;
  --muted: #5a626e;
  --faint: #8a919b;
  --line: #e7e9ec;
  --accent: #005799;
  --pill-border: #d8dce1;
  --warm-bg: #fbf0dc;
  --warm-text: #8a520c;
  --maxw: 680px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101216;
    --text: #e6e8eb;
    --muted: #a3aab4;
    --faint: #767e89;
    --line: #262a31;
    --accent: #6fb3ea;
    --pill-border: #353a43;
    --warm-bg: #3a2a12;
    --warm-text: #f3c27a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101216;
  --text: #e6e8eb;
  --muted: #a3aab4;
  --faint: #767e89;
  --line: #262a31;
  --accent: #6fb3ea;
  --pill-border: #353a43;
  --warm-bg: #3a2a12;
  --warm-text: #f3c27a;
  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Links: an underline slides in from the left on hover */
a {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-position: 0 100%;
  background-repeat: no-repeat;
  background-size: 0% 1px;
  transition: background-size 0.25s ease, color 0.15s;
}
a:hover { background-size: 100% 1px; }
.pill, .site-name { background-image: none; }
@media (prefers-reduced-motion: reduce) {
  a { transition: none; }
}

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

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}
.site-name:hover { text-decoration: none; }

.site-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.95rem;
}
.site-nav a { color: var(--text); }
.site-nav a:hover,
.site-nav a.active { color: var(--accent); text-decoration: none; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: -6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }

/* ============================================================
   About
   ============================================================ */
main { padding-top: 40px; }

section { scroll-margin-top: 72px; }

.about {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 40px;
  align-items: start;
  padding-bottom: 56px;
}
.about-text p { margin: 0 0 14px; }

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.portrait {
  width: 160px;
  height: 200px;
  margin-top: 6px;
  object-fit: cover;
  object-position: 50% 35%;
  border-radius: 50%;
  filter: grayscale(1);
}

/* ============================================================
   Papers
   ============================================================ */
.papers-section { padding-bottom: 40px; }
.papers-section .subsection { margin-top: 40px; }

.paper { padding: 14px 0; }
.paper + .paper { border-top: 1px solid var(--line); }

.paper-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.paper-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
}

.paper-links {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  justify-content: flex-end;
  gap: 6px;
  max-width: 50%;
}

.paper-authors {
  margin: 3px 0 0;
  font-size: 0.925rem;
  font-style: italic;
  color: var(--muted);
}

.paper-note {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  /* a step lighter than the author line, still readable (>= 4.5:1 contrast) */
  color: color-mix(in srgb, var(--muted) 60%, var(--faint));
}

.status {
  display: inline-block;
  margin-top: 7px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--warm-text);
  background: var(--warm-bg);
}

.paper-abstract { margin-top: 5px; }
.paper-abstract summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}
.paper-abstract summary::-webkit-details-marker { display: none; }
.paper-abstract summary::before {
  content: "\203A";
  display: inline-block;
  font-size: 1.1em;
  transition: transform 0.15s;
}
.paper-abstract[open] summary::before { transform: rotate(90deg); }
.paper-abstract summary:hover { color: var(--text); }
.paper-abstract p {
  margin: 10px 0 0;
  font-size: 0.9rem;
  line-height: 1.65;
}

/* Small outlined buttons: paper links and contact links */
.pill {
  display: inline-block;
  padding: 4px 9px;
  border: 1px solid var(--pill-border);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text);
  white-space: nowrap;
}
.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 40px;
  font-size: 0.8rem;
  color: var(--faint);
}
.site-footer p { margin: 0; }

/* ============================================================
   Phones
   ============================================================ */
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .site-nav { gap: 16px; }
  main { padding-top: 24px; }

  .about {
    grid-template-columns: 1fr;
    gap: 20px;
    padding-bottom: 40px;
  }
  .portrait {
    order: -1;
    width: 120px;
    height: 150px;
  }

  .paper-head { flex-direction: column; gap: 10px; }
  .paper-links { justify-content: flex-start; max-width: none; }
}
