/* ============================================================
   Theme — Apple-inspired (light + dark)
   ============================================================ */

:root {
  --font-sans:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display:
    -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --radius:     18px;
  --radius-sm:  12px;
  --radius-pill: 980px;

  --maxw: 980px;
  --maxw-prose: 680px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

[data-mode="light"] {
  --bg:         #ffffff;
  --surface:    #f5f5f7;
  --surface-2:  #fbfbfd;
  --text:       #1d1d1f;
  --muted:      #6e6e73;
  --subtle:     #86868b;
  --accent:     #0066cc;
  --accent-hov: #0077ed;
  --border:     #d2d2d7;
  --divider:    #e8e8ed;
  --shadow:     0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
  --header-bg:  rgba(251, 251, 253, .8);
  --avatar-ring: rgba(0,0,0,.06);
}

[data-mode="dark"] {
  --bg:         #000000;
  --surface:    #1d1d1f;
  --surface-2:  #161617;
  --text:       #f5f5f7;
  --muted:      #a1a1a6;
  --subtle:     #86868b;
  --accent:     #2997ff;
  --accent-hov: #5aaeff;
  --border:     #2a2a2c;
  --divider:    #232325;
  --shadow:     0 1px 2px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.4);
  --header-bg:  rgba(22, 22, 23, .72);
  --avatar-ring: rgba(255,255,255,.08);
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -.022em;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}

::selection { background: var(--accent); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--text); color: var(--bg);
  padding: .5rem 1rem; z-index: 100;
  border-radius: var(--radius-sm);
}
.skip:focus { left: 1rem; top: 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s var(--ease);
}
a:hover {
  color: var(--accent-hov);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--text);
}

h1 {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.025em;
  margin: 0 0 1rem;
}

h2 {
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.018em;
  margin: 0 0 .5rem;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.005em;
  margin: 0 0 1rem;
  color: var(--muted);
  text-transform: uppercase;
  font-feature-settings: "ss01";
}

p { margin: 0 0 1rem; }

.eyebrow {
  display: inline-block;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--accent);
  margin: 0 0 .625rem;
  text-transform: none;
}

.section-intro {
  font-size: 1.0625rem;
  color: var(--muted);
  max-width: 44ch;
  margin: 0 0 2rem;
}

/* ============================================================
   Header — frosted glass nav, Apple-style
   ============================================================ */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--divider);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 48px;
  padding: 0 1.5rem;
  display: flex; align-items: center; gap: 1.5rem;
}
.brand {
  color: var(--text);
  font-weight: 500;
  font-size: .875rem;
  letter-spacing: -.01em;
  text-decoration: none;
  margin-right: auto;
}
.brand:hover { color: var(--text); text-decoration: none; }

.nav ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; gap: 1.75rem;
  font-size: .75rem;
}
.nav ul a {
  color: var(--text);
  text-decoration: none;
  opacity: .8;
  transition: opacity .2s var(--ease);
  letter-spacing: -.005em;
}
.nav ul a:hover {
  color: var(--text);
  opacity: 1;
  text-decoration: none;
}

@media (max-width: 640px) {
  .header-inner { gap: .75rem; padding: 0 1rem; }
  .nav ul { gap: .875rem; font-size: .7rem; }
  .brand { font-size: .8125rem; }
}
@media (max-width: 480px) {
  .header-inner { gap: .5rem; padding: 0 .875rem; }
  .nav ul { gap: .625rem; font-size: .65rem; }
  .brand { display: none; }
}

/* ============================================================
   Dark mode switch — refined for Apple aesthetic
   ============================================================ */

.dm-toggle {
  background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer;
  display: inline-flex; align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.dm-track {
  width: 36px; height: 20px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.dm-thumb {
  position: absolute;
  top: 1px; left: 1px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: transform .25s var(--ease), background-color .25s var(--ease);
}
[data-mode="dark"] .dm-track {
  background: var(--accent);
  border-color: var(--accent);
}
[data-mode="dark"] .dm-thumb { transform: translateX(16px); }
.dm-icon { display: none; }
[data-mode="light"] .dm-sun { display: block; }
[data-mode="dark"]  .dm-moon { display: block; }
.dm-accent { display: none; }
.dm-toggle:hover .dm-track { border-color: var(--muted); }
[data-mode="dark"] .dm-toggle:hover .dm-track { border-color: var(--accent-hov); }
.dm-toggle:focus-visible { outline: none; }
.dm-toggle:focus-visible .dm-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
   Main layout
   ============================================================ */

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.5rem 6rem;
}

section { padding: 5rem 0 0; }
section:first-of-type { padding-top: 4rem; }

.section-head { margin-bottom: 2.5rem; }
.section-head h2 { color: var(--accent); }

@media (max-width: 640px) {
  main { padding: 0 1.25rem 4rem; }
  section { padding-top: 4rem; }
  section:first-of-type { padding-top: 3rem; }
  .section-head { margin-bottom: 2rem; }
}

/* ============================================================
   Hero — centered, Apple leadership-page style
   ============================================================ */

.hero {
  text-align: center;
  padding: 1.5rem 0 1rem;
}

.avatar-wrap {
  display: inline-block;
  margin: 0 auto 1.75rem;
  position: relative;
}
.avatar {
  width: 168px; height: 168px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow:
    0 0 0 1px var(--avatar-ring),
    0 10px 36px rgba(0,0,0,.12);
}

.hero h1 {
  margin-bottom: .5rem;
}
.hero .role-line {
  font-size: 1.125rem;
  color: var(--muted);
  margin: 0 0 2rem;
  letter-spacing: -.01em;
}
.hero .role-line .at {
  color: var(--subtle);
  margin: 0 .35em;
}

.hero-bio {
  max-width: var(--maxw-prose);
  margin: 0 auto;
  font-size: 1.0625rem;
  line-height: 1.52;
  color: var(--text);
}
.hero-bio p { margin-bottom: 1rem; }
.hero-bio em {
  font-style: normal;
  color: var(--muted);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 1px;
}

.socials {
  list-style: none; padding: 0; margin: 2.5rem 0 0;
  display: flex; justify-content: center;
  gap: .5rem; flex-wrap: wrap;
}
.socials a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid transparent;
  transition: color .2s var(--ease), background-color .2s var(--ease), transform .2s var(--ease);
}
.socials a:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  transform: translateY(-2px);
  text-decoration: none;
}

@media (max-width: 640px) {
  .hero { padding-top: .5rem; }
  .avatar { width: 132px; height: 132px; }
  .hero .role-line { font-size: 1rem; margin-bottom: 1.5rem; }
}

/* ============================================================
   News — clean dated list
   ============================================================ */

.news {
  list-style: none; padding: 0; margin: 0;
}
.news li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem;
  padding: 1.125rem 0;
  border-top: 1px solid var(--divider);
  align-items: baseline;
}
.news li:first-child { border-top: none; padding-top: 0; }
.news li:last-child { padding-bottom: 0; }
.news time {
  color: var(--muted);
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -.01em;
}
.news li > span {
  font-size: 1rem;
  line-height: 1.5;
}
.news em {
  font-style: normal;
  color: var(--text);
  font-weight: 500;
}

@media (max-width: 560px) {
  .news li { grid-template-columns: 1fr; gap: .25rem; }
}

/* ============================================================
   Publications — Apple-style cards
   ============================================================ */

.year-group + .year-group { margin-top: 2rem; }
.year-group h3 {
  margin-bottom: 1.25rem;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--subtle);
}

.pubs {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1rem;
}
.pubs li {
  padding: 1.5rem 1.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1.5rem;
  align-items: start;
}
.pubs li:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.pub-thumb {
  width: 120px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  object-fit: cover;
  display: block;
  border: 1px solid var(--divider);
}
.pub-thumb-placeholder {
  background: linear-gradient(135deg, var(--surface-2), var(--divider));
}
.pub-body { min-width: 0; }
.pubs .title {
  margin: 0 0 .375rem;
  font-size: 1.1875rem;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.3;
  color: var(--text);
}
.pubs .authors {
  margin: 0 0 .25rem;
  font-size: .9375rem;
  color: var(--muted);
}
.pubs .venue {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .875rem;
  letter-spacing: -.005em;
}
.pubs .venue .meta { font-style: normal; opacity: .7; }
.pubs .links {
  margin: 0;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.pubs .links a {
  font-size: .9375rem;
  color: var(--accent);
  font-weight: 400;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .25rem;
}
.pubs .links a::after {
  content: "›";
  display: inline-block;
  font-weight: 500;
  transition: transform .2s var(--ease);
}
.pubs .links a:hover {
  color: var(--accent-hov);
  text-decoration: none;
}
.pubs .links a:hover::after {
  transform: translateX(3px);
}

@media (max-width: 560px) {
  .pubs li {
    padding: 1.25rem 1.25rem;
    grid-template-columns: 80px 1fr;
    gap: 1rem;
  }
  .pubs .title { font-size: 1.0625rem; }
  .pub-thumb { width: 80px; }
}

/* ============================================================
   Teaching
   ============================================================ */

.teaching {
  list-style: none; padding: 0; margin: 0;
}
.teaching li {
  display: grid;
  grid-template-columns: 8rem 1fr auto;
  gap: 1.5rem;
  align-items: start;
  padding: 1.125rem 0;
  border-top: 1px solid var(--divider);
}
.teaching li:first-child { border-top: none; padding-top: 0; }
.teaching li:last-child { padding-bottom: 0; }
.teaching .term {
  color: var(--muted);
  font-size: .9375rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -.01em;
}
.teaching .course-block {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}
.teaching .course {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -.01em;
}
.teaching .topics {
  margin: 0;
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--muted);
}
.teaching .role-tag {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  padding: .25rem .75rem;
  background: var(--surface);
  border-radius: var(--radius-pill);
  letter-spacing: -.005em;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .teaching li { grid-template-columns: 1fr; gap: .25rem; }
  .teaching .role-tag { justify-self: start; margin-top: .375rem; }
}

/* ============================================================
   Experience timeline
   ============================================================ */

.timeline {
  list-style: none; padding: 0; margin: 0;
}
.timeline li {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.25rem;
  padding: 0 0 2rem;
  align-items: start;
}
.timeline li:last-child { padding-bottom: 0; }
.exp-logo {
  width: 64px; height: 64px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  padding: 6px;
  border: 1px solid var(--divider);
}
.timeline .what {
  margin: 0 0 .125rem;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -.015em;
}
.timeline .where {
  margin: 0;
  color: var(--muted);
  font-size: .9375rem;
}
.timeline .when {
  margin: .125rem 0 0;
  color: var(--subtle);
  font-size: .8125rem;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -.005em;
}
.timeline .note {
  margin: .5rem 0 0;
  font-size: .9375rem;
  color: var(--muted);
  line-height: 1.55;
  max-width: 52ch;
}

@media (max-width: 560px) {
  .timeline li {
    grid-template-columns: 48px 1fr;
    gap: 1rem;
  }
  .exp-logo { width: 48px; height: 48px; padding: 4px; }
}

/* ============================================================
   Footer
   ============================================================ */

footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2rem 1.5rem 2.5rem;
  color: var(--subtle);
  font-size: .75rem;
  letter-spacing: -.005em;
  border-top: 1px solid var(--divider);
}
footer p { margin: 0; }

/* ============================================================
   BibTeX dialog
   ============================================================ */

#bib-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow);
  max-width: min(640px, calc(100vw - 2rem));
  width: 100%;
}
#bib-dialog::backdrop {
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.bib-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--divider);
}
.bib-dialog-head h3 {
  margin: 0;
  color: var(--text);
  text-transform: none;
  letter-spacing: -.01em;
  font-size: 1rem;
}
.bib-close {
  background: none; border: 0; padding: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.25rem; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.bib-close:hover { background: var(--surface); color: var(--text); }
.bib-content {
  margin: 0;
  padding: 1.25rem;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  max-height: 60vh;
}
.bib-content code {
  font-family: inherit;
}
.bib-dialog-foot {
  display: flex; justify-content: flex-end;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--divider);
}
.bib-copy {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: .5rem 1rem;
  border-radius: var(--radius-pill);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .15s var(--ease);
}
.bib-copy:hover { background: var(--accent-hov); }
.bib-copy.copied { background: var(--muted); }

/* ============================================================
   Print
   ============================================================ */

@media print {
  .site-header, .skip, footer, .socials { display: none; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
  .pubs li { background: #fff; box-shadow: none; border: 1px solid #ddd; }
  section { page-break-inside: avoid; }
}
