/* ── Tokens ──────────────────────────────────────────────────────── */

:root {
  color-scheme: light dark;
  --bg: #f6f4ef;
  --bg-elevated: #fffefb;
  --bg-card: #ffffff;
  --text: #1a1d24;
  --text-muted: #5c6270;
  --border: rgba(26, 29, 36, 0.1);
  --accent: #2d6a7a;
  --accent-strong: #1f4d5a;
  --accent-dim: rgba(45, 106, 122, 0.12);
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 12px;
  --shadow: 0 20px 60px rgba(26, 29, 36, 0.08);
  --header-h: 4rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c10;
  --bg-elevated: #12151c;
  --bg-card: #161a22;
  --text: #eceef2;
  --text-muted: #949aa8;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #7eb8c9;
  --accent-strong: #a8dce8;
  --accent-dim: rgba(126, 184, 201, 0.14);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

/* ── Reset ───────────────────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background 0.35s ease, color 0.35s ease;
}

/* ── Skip link ───────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  z-index: 100;
}

.skip-link:focus {
  left: 0.75rem;
}

/* ── Header ──────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 1.25rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--accent);
}

/* ── Theme toggle ────────────────────────────────────────────────── */

.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

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

.theme-toggle__icon {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: radial-gradient(
    circle at 70% 30%,
    #ffd88a,
    #e8a838
  );
}

[data-theme="dark"] .theme-toggle__icon {
  background: radial-gradient(
    circle at 30% 30%,
    var(--accent-strong),
    var(--accent)
  );
  box-shadow: inset 0 0 0 2px var(--bg);
}

/* ── Hero ────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  display: flex;
  align-items: center;
  padding: 4rem 1.5rem 5rem;
  overflow: hidden;
}

.hero__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(
    ellipse 70% 60% at 50% 40%,
    black 20%,
    transparent 100%
  );
  opacity: 0.45;
  pointer-events: none;
}

.hero__content {
  position: relative;
  max-width: 52rem;
  margin: 0 auto;
  text-align: center;
}

.hero__content--academic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* ── Headshot ────────────────────────────────────────────────────── */

.headshot-wrapper {
  position: relative;
  width: 300px;
  height: 300px;
}

.hero__backdrop {
  position: absolute;
  inset: 0;
  background: url("/backdrop.svg") center / cover no-repeat;
  opacity: 0.45;
  mask-image: radial-gradient(circle, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(circle, black 40%, transparent 80%);
  pointer-events: none;
}

[data-theme="dark"] .hero__backdrop {
  opacity: 0.35;
}

.headshot {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
}

/* ── Hero text ───────────────────────────────────────────────────── */

.hero__text {
  text-align: center;
}

.eyebrow {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.hero__title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.25rem, 5.5vw, 3.5rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.hero__name {
  background: linear-gradient(
    120deg,
    var(--text) 0%,
    var(--accent-strong) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="dark"] .hero__name {
  background: linear-gradient(
    120deg,
    var(--text) 0%,
    var(--text-muted) 45%,
    var(--accent-strong) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lede {
  margin: 0 auto 1.5rem;
  max-width: 34rem;
  font-size: 1.0625rem;
  color: var(--text-muted);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid transparent;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
}

.btn--primary:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.btn--ghost {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--small {
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  vertical-align: middle;
  margin-left: 0.75rem;
}

/* ── Sections (shared) ───────────────────────────────────────────── */

.section {
  padding: 4rem 1.5rem;
  border-top: 1px solid var(--border);
}

.section__inner {
  max-width: 52rem;
  margin: 0 auto;
}

.section__inner--narrow {
  max-width: 40rem;
}

.section__heading {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.section__sub {
  margin: -0.5rem 0 1.75rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ── Prose ───────────────────────────────────────────────────────── */

.prose p {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

.prose p:last-child {
  margin-bottom: 0;
}

.inline-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-link:hover {
  color: var(--accent-strong);
}

/* ── Publications ────────────────────────────────────────────────── */

.pub-list__loading {
  color: var(--text-muted);
  font-style: italic;
}

.pub-list__error {
  color: var(--text-muted);
}

.pub-year-group {
  margin-bottom: 2rem;
}

.pub-year-group__heading {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.pub-item {
  padding: 0.6rem 0;
  line-height: 1.55;
}

.pub-item + .pub-item {
  border-top: 1px solid var(--border);
}

.pub-item__title {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.pub-item__title:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pub-item__authors {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.pub-item__authors strong {
  color: var(--text);
  font-weight: 600;
}

.pub-item__meta {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.pub-item__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  background: var(--accent-dim);
  color: var(--accent-strong);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

/* ── CV ──────────────────────────────────────────────────────────── */

.cv-block {
  margin-bottom: 2rem;
}

.cv-block__title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.cv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cv-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
}

.cv-list--plain li {
  display: list-item;
  list-style: disc inside;
  border-bottom: none;
  padding: 0.25rem 0;
  color: var(--text-muted);
}

.cv-list__main {
  color: var(--text);
}

.cv-list__aside {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.875rem;
}

/* ── Talks table ─────────────────────────────────────────────────── */

.talks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.talks-table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.5rem 0;
  border-bottom: 2px solid var(--border);
}

.talks-table td {
  padding: 0.65rem 0.75rem 0.65rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

.talks-table td:first-child {
  color: var(--text);
  font-weight: 500;
}

/* ── Card grid (software) ────────────────────────────────────────── */

.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .card-grid--2col {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card {
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.card__title {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

.card__link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
}

.card__link:hover {
  text-decoration: underline;
}

.card__body {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.55;
  flex: 1;
}

.card__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  background: var(--accent-dim);
  color: var(--accent-strong);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  width: fit-content;
}

/* ── News feed ───────────────────────────────────────────────────── */

.news-feed {
  margin: 0;
  padding: 0;
}

.news-feed__item {
  display: flex;
  gap: 1.25rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.news-feed__date {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 5.5rem;
  flex-shrink: 0;
}

.news-feed__text {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text);
}

/* ── Contact ─────────────────────────────────────────────────────── */

.section--contact .prose {
  font-size: 1.0625rem;
}

/* ── Footer ──────────────────────────────────────────────────────── */

.site-footer {
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.footer-links__item {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links__item:hover {
  color: var(--accent);
}

.footer__copy {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .nav {
    gap: 0.75rem;
  }

  .nav a {
    font-size: 0.8125rem;
  }

  .hero {
    padding: 2.5rem 1.25rem 3rem;
  }

  .headshot-wrapper {
    width: 225px;
    height: 225px;
  }

  .talks-table th:nth-child(4),
  .talks-table td:nth-child(4) {
    display: none;
  }

  .cv-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .news-feed__item {
    flex-direction: column;
    gap: 0.25rem;
  }
}
