/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:       #141414;
  --mid:       #505050;
  --muted:     #909090;
  --rule:      #e2e2de;
  --accent:    #1a4480;
  --accent2:   #8a5a34;
  --bg:        #ffffff;
  --bg-alt:    #f7f7f5;
  --text:      #282828;
  --text-soft: #333333;
  --card-bg:   #fafaf8;
  --shadow:    0 2px 20px rgba(0,0,0,0.10);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.07);
  --nav-bg:    rgba(255,255,255,0.96);
  --nav-h:  60px;
  --max-w:  860px;
  --serif:  'EB Garamond', Georgia, serif;
  --sans:   'Source Sans 3', system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #ece9e2;
    --mid:       #b7b2a7;
    --muted:     #837e73;
    --rule:      #2d2c28;
    --accent:    #6f9bdb;
    --bg:        #121110;
    --bg-alt:    #1a1917;
    --text:      #d8d4cb;
    --text-soft: #c9c5bb;
    --card-bg:   #1c1b18;
    --shadow:    0 2px 24px rgba(0,0,0,0.55);
    --shadow-hover: 0 4px 24px rgba(0,0,0,0.5);
    --nav-bg:    rgba(18,17,16,0.92);
  }
}

:root[data-theme="dark"] {
  --ink:       #ece9e2;
  --mid:       #b7b2a7;
  --muted:     #837e73;
  --rule:      #2d2c28;
  --accent:    #6f9bdb;
  --bg:        #121110;
  --bg-alt:    #1a1917;
  --text:      #d8d4cb;
  --text-soft: #c9c5bb;
  --card-bg:   #1c1b18;
  --shadow:    0 2px 24px rgba(0,0,0,0.55);
  --shadow-hover: 0 4px 24px rgba(0,0,0,0.5);
  --nav-bg:    rgba(18,17,16,0.92);
}

html { scroll-behavior: smooth; font-size: 18px; }

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

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

/* ── Layout ───────────────────────────────────────────────────── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

section { padding: 4.5rem 0; }
#education { background: var(--bg-alt); }

/* ── Navigation ───────────────────────────────────────────────── */
#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  height: var(--nav-h);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.6rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.nav-links a {
  color: var(--mid);
  transition: color .15s ease;
  padding-bottom: 3px;
  border-bottom: 1.5px solid transparent;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; border-bottom-color: transparent; }
.nav-links a.active { color: var(--accent); border-bottom-color: var(--accent); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--mid);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-moon { display: none; fill: currentColor; stroke: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ── About / Hero ─────────────────────────────────────────────── */
#about {
  position: relative;
  isolation: isolate;
  padding-top: 5rem;
  padding-bottom: 5rem;
}

/* Close-packed dot lattice, after the FCC aluminium matrix this research
   is about — barely visible, texture rather than decoration. */
#about::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle, var(--ink) 1px, transparent 1.5px),
    radial-gradient(circle, var(--ink) 1px, transparent 1.5px);
  background-size: 34px 34px;
  background-position: 0 0, 17px 17px;
  opacity: 0.05;
  pointer-events: none;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 3rem;
  align-items: start;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.subtitle {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--mid);
  margin-bottom: 1.5rem;
  letter-spacing: 0.025em;
  font-weight: 500;
}

.bio { margin-bottom: 1.1rem; color: var(--text); font-variant-numeric: oldstyle-nums; }

/* On hover, scatter a few dots outward — literally illustrating the
   solute clustering the phrase names, rather than a generic flourish. */
.key-term {
  position: relative;
  border-bottom: 1px dotted var(--accent2);
}

.key-term::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow:
    9px  -7px 0 -0.5px var(--accent2),
    -10px -4px 0 -0.5px var(--accent2),
     3px -11px 0 -1px   var(--accent2),
    -5px  -9px 0 -1px   var(--accent2),
    13px   2px 0 -1px   var(--accent2);
  opacity: 0;
  transform: translate(-50%, 0) scale(0.2);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

.key-term:hover::after {
  opacity: 0.9;
  transform: translate(-50%, 0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .key-term::after { transition: none; }
}

.links-row {
  margin-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}
.links-row a { color: var(--accent); font-weight: 500; }
.links-row a:hover { text-decoration: underline; text-underline-offset: 2px; }
.sep { color: var(--muted); margin: 0 0.4rem; }

/* Profile photo */
.profile-photo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow);
  display: block;
  margin: 1rem auto 0;
}

/* ── Section Headings ─────────────────────────────────────────── */
h2 {
  font-size: 1.45rem;
  margin-bottom: 1.6rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.section-subtitle {
  margin-top: 3rem;
  font-size: 1.35rem;
}

.section-note {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: -1rem;
  margin-bottom: 1.5rem;
}

/* ── Research Grid ────────────────────────────────────────────── */
.research-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 0.5rem;
}

.research-card {
  border: none;
  border-left: 3px solid var(--accent);
  padding: 1.1rem 1.3rem;
  border-radius: 0 5px 5px 0;
  background: var(--card-bg);
  transition: box-shadow .2s ease, transform .2s ease;
}

.research-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.research-card h3 {
  font-size: 1rem;
  margin-bottom: 0.45rem;
  color: var(--ink);
}

.research-card p {
  font-size: 0.88rem;
  color: var(--mid);
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
}

/* ── Project List ─────────────────────────────────────────────── */
.project-list { display: flex; flex-direction: column; gap: 1.5rem; }

.project-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1rem;
}

.project-year {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 0.3rem;
  white-space: nowrap;
}

.project-body h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.project-body p {
  font-size: 0.88rem;
  color: var(--mid);
  line-height: 1.6;
  font-variant-numeric: oldstyle-nums;
}

/* ── Publications ─────────────────────────────────────────────── */
.pub-list {
  list-style: decimal;
  padding-left: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.pub-item { line-height: 1.65; }

.pub-authors { font-size: 0.9rem; }
.pub-title {
  display: block;
  font-size: 0.95rem;
  margin: 0.1rem 0;
  font-variant-numeric: oldstyle-nums;
}
.pub-venue {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--mid);
}

/* ── Talks ────────────────────────────────────────────────────── */
.talk-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.talk-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1rem;
  align-items: start;
}

.talk-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding-top: 0.15rem;
}

.talk-type {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent2);
  color: #fff;
  padding: 0.18rem 0.5rem;
  border-radius: 3px;
}

.talk-year {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
}

.talk-body { font-size: 0.9rem; line-height: 1.6; font-variant-numeric: oldstyle-nums; }
.talk-title { font-weight: 600; display: inline; }

/* ── News list ────────────────────────────────────────────────── */
/* Timeline motif: a node per entry connected by a running line, echoing
   the kinetics/age-hardening curves this news is largely reporting on. */
.news-list { list-style: none; padding: 0; margin: 0; }

.news-item { border-bottom: 1px solid var(--rule); }
.news-item:first-child { border-top: 1px solid var(--rule); }

.news-link {
  display: grid;
  grid-template-columns: 80px 18px 1fr;
  column-gap: 1rem;
  padding: 0.9rem 0.6rem;
  margin: 0 -0.6rem;
  color: inherit;
  text-decoration: none;
  border-radius: 3px;
  transition: background 0.12s ease;
}

.news-link:hover { background: var(--bg-alt); text-decoration: none; }

.news-date {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 0.15rem;
  white-space: nowrap;
  font-variant-numeric: lining-nums;
}

.news-node { position: relative; }

.news-node::before {
  content: '';
  position: absolute;
  top: 0.35rem;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateX(-50%);
  z-index: 1;
}

.news-node::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: -1px;
  left: 50%;
  width: 1px;
  background: var(--rule);
  transform: translateX(-50%);
}

.news-item:last-child .news-node::after { display: none; }

.news-body { font-size: 0.9rem; line-height: 1.6; font-variant-numeric: oldstyle-nums; }

/* ── News article page ────────────────────────────────────────── */
.news-back {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--mid);
  margin-bottom: 2rem;
  text-decoration: none;
}
.news-back:hover { color: var(--accent); text-decoration: none; }

.news-article-date {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

#article h1 {
  font-size: 1.7rem;
  margin-bottom: 2rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
}

#article p { margin-bottom: 1rem; color: var(--text); font-size: 0.95rem; line-height: 1.75; font-variant-numeric: oldstyle-nums; }

/* ── Education ────────────────────────────────────────────────── */
.edu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.edu-item {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  padding-bottom: 1.4rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.edu-item:last-child {
  padding-bottom: 0;
  border-bottom: none;
  margin-bottom: 0;
}

.edu-year {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: 0.2rem;
  white-space: nowrap;
}

/* ── Skills ───────────────────────────────────────────────────── */
.skills-block { margin-bottom: 1.3rem; }

.skills-block h4 {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.skills-block p { font-size: 0.9rem; color: var(--text-soft); line-height: 1.55; font-variant-numeric: oldstyle-nums; }

/* ── Contact ──────────────────────────────────────────────────── */
#contact p { margin-bottom: 0.6rem; font-size: 0.95rem; color: var(--text-soft); font-variant-numeric: oldstyle-nums; }

/* ── Footer ───────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--rule);
  padding: 2rem 0;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 680px) {
  html { font-size: 16px; }

  /* Tighter section spacing */
  section { padding: 3rem 0; }
  #about { padding-top: 2.5rem; padding-bottom: 3rem; }

  /* Nav wraps to 2 rows: name on top, links below */
  #navbar { height: auto; min-height: var(--nav-h); }
  .nav-inner { flex-wrap: wrap; padding: 0.7rem 1.5rem; gap: 0.35rem; height: auto; }
  .nav-right { width: 100%; justify-content: space-between; }
  .nav-links { gap: 0.85rem; font-size: 0.72rem; }

  /* About stacked */
  .about-grid { grid-template-columns: 1fr; }
  .about-photo { order: -1; text-align: center; }
  .profile-photo { width: 110px; height: 110px; margin: 0 auto 1.5rem; }
  h1 { font-size: 1.9rem; }

  /* Links row wraps gracefully */
  .links-row { line-height: 2.2; }

  /* Grids collapse */
  .research-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; gap: 2rem; }

  /* List item columns tighten */
  .talk-item { grid-template-columns: 75px 1fr; }
  .project-item { grid-template-columns: 65px 1fr; }
  .edu-item { grid-template-columns: 65px 1fr; }
  .news-link { grid-template-columns: 1fr; }
  .news-node { display: none; }
}
