/* ---------- Theme ---------- */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --border: #e3ded2;
  --text: #1c2420;
  --muted: #5a6560;
  --accent: #2f6443;
  --accent-soft: #e3eee6;
  --purple: #5550b0;
  --purple-soft: #e8e8f8;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 8px 24px rgba(20, 30, 25, .06);
  --radius: 14px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1211;
    --surface: #151b19;
    --surface-2: #1b2320;
    --border: #26302c;
    --text: #e3e8e5;
    --muted: #9aa7a1;
    --accent: #84c49a;
    --accent-soft: #1d2d24;
    --purple: #aaa8f0;
    --purple-soft: #21213a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1211;
  --surface: #151b19;
  --surface-2: #1b2320;
  --border: #26302c;
  --text: #e3e8e5;
  --muted: #9aa7a1;
  --accent: #84c49a;
  --accent-soft: #1d2d24;
  --purple: #aaa8f0;
  --purple-soft: #21213a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

body.purple { --accent: var(--purple); --accent-soft: var(--purple-soft); }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(2.4rem, 6vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); margin-bottom: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; display: block; }
strong { font-weight: 600; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.section { padding-block: 4rem; }
.section + .section { padding-top: 0; }

.eyebrow {
  font-family: var(--sans); font-size: .78rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
  margin-bottom: .75rem;
}
.muted { color: var(--muted); }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .65rem 1.2rem; border-radius: 999px;
  font-weight: 500; font-size: .95rem; text-decoration: none;
  background: var(--accent); color: var(--bg);
  border: 1px solid var(--accent);
  transition: transform .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); opacity: .92; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .4rem .9rem; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; }

.chip {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; list-style: none; }
.tags li {
  font-size: .85rem; padding: .25rem .7rem; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.nav { display: flex; align-items: center; gap: .25rem; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500;
  padding: .4rem .75rem; border-radius: 8px;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.header-actions { display: flex; align-items: center; gap: .25rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}

/* ---------- Page header (inner pages) ---------- */
.page-head { padding-block: 4rem 2.5rem; }
.page-head p:not(.eyebrow) { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin-top: 1rem; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 4rem; align-items: center; padding-block: 4.5rem 3.5rem; }
.hero h1 { margin-bottom: 1.25rem; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 560px; }
.hero .btn-row { margin-top: 1.75rem; }
.portrait { position: relative; }
.portrait img {
  border-radius: 22px; aspect-ratio: 4 / 5; object-fit: cover; width: 100%;
  box-shadow: var(--shadow);
}
.portrait::before {
  content: ''; position: absolute; inset: 18px -18px -18px 18px; z-index: -1;
  border-radius: 22px; background: var(--accent-soft); border: 1px solid var(--border);
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat b { display: block; font-family: var(--serif); font-size: 1.6rem; color: var(--accent); font-weight: 600; line-height: 1.2; }
.stat span { font-size: .9rem; color: var(--muted); }

.explore { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.explore a {
  display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; transition: border-color .2s, transform .2s;
}
.explore a:hover { border-color: var(--accent); transform: translateY(-2px); }
.explore h3 { margin-bottom: .35rem; display: flex; justify-content: space-between; }
.explore h3::after { content: '→'; color: var(--accent); font-family: var(--sans); }
.explore p { color: var(--muted); margin: 0; font-size: .95rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}

/* Publications */
.pubs { display: grid; gap: 1.5rem; }
.pub { display: grid; grid-template-columns: 260px 1fr; }
.pub-img { background: #fff; display: grid; place-items: center; padding: 1rem; border-right: 1px solid var(--border); }
.pub-img img { max-height: 230px; object-fit: contain; }
.pub-body { padding: 1.5rem 1.75rem; }
.pub-body .chip { margin-bottom: .75rem; }
.pub-body h3 { margin-bottom: .4rem; }
.pub-meta { font-size: .9rem; color: var(--muted); margin-bottom: .9rem; }
.pub-body ul { padding-left: 1.1rem; margin: 0 0 1.1rem; color: var(--muted); }
.pub-body li { margin-bottom: .35rem; }

/* Experience timeline */
.timeline { position: relative; list-style: none; margin: 0; padding: 0; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline > li { position: relative; padding-left: 2.5rem; margin-bottom: 2rem; }
.timeline > li::before {
  content: ''; position: absolute; left: 0; top: 1.75rem; width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.job { padding: 1.5rem 1.75rem; }
.job-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.job-role { color: var(--accent); font-weight: 600; }
.job-date { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.job ul { padding-left: 1.1rem; margin: .9rem 0 0; color: var(--muted); }
.job li { margin-bottom: .4rem; }
.job-img { margin-top: 1rem; border-radius: 10px; border: 1px solid var(--border); max-width: 420px; }

/* Projects */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.project { display: flex; flex-direction: column; }
.project-img { background: #fff; aspect-ratio: 16 / 10; border-bottom: 1px solid var(--border); overflow: hidden; }
.project-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.project-img.text {
  display: grid; place-items: center; background: var(--accent-soft);
  font-family: ui-monospace, 'SF Mono', Menlo, monospace; color: var(--accent); font-size: 1.05rem;
}
.project-body { padding: 1.4rem 1.5rem 1.5rem; display: flex; flex-direction: column; flex: 1; }
.project-body h3 { margin-bottom: .25rem; }
.project-body .pub-meta { margin-bottom: .75rem; }
.project-body p { color: var(--muted); font-size: .95rem; }
.project-body .tags { margin: auto 0 1rem; padding-top: .5rem; }
.project-body .btn { align-self: flex-start; }

/* About */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.edu { padding: 1.5rem; }
.edu h3 { margin-bottom: .2rem; }
.edu .pub-meta { margin-bottom: .6rem; }
.edu p { margin: 0; font-size: .95rem; color: var(--muted); }
.honors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.honor { padding: 1.5rem; }
.honor b { font-family: var(--serif); font-size: 2rem; color: var(--accent); display: block; line-height: 1.1; font-weight: 600; }
.honor h3 { font-size: 1.05rem; margin: .5rem 0 .3rem; }
.honor p { margin: 0; font-size: .9rem; color: var(--muted); }
.skills { display: grid; gap: 1.25rem; }
.skill-row { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; align-items: start; }
.skill-row h3 { font-family: var(--sans); font-size: .95rem; font-weight: 600; padding-top: .25rem; }

details {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: .75rem;
}
summary {
  cursor: pointer; list-style: none; padding: 1rem 1.25rem; font-weight: 600;
  display: flex; justify-content: space-between; gap: 1rem;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; color: var(--accent); font-size: 1.3rem; line-height: 1; transition: transform .2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { margin: 0; padding: 0 1.25rem 1.1rem; color: var(--muted); }

/* Contact */
.contact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.contact {
  display: flex; gap: 1rem; align-items: center; padding: 1.4rem;
  text-decoration: none; color: var(--text); transition: border-color .2s, transform .2s;
  overflow-wrap: anywhere;
}
.contact:hover { border-color: var(--accent); transform: translateY(-2px); }
.contact svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.contact small { display: block; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; margin-top: 3rem; font-size: .9rem; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 1.25rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .honors { grid-template-columns: 1fr; }
  .pub { grid-template-columns: 1fr; }
  .pub-img { border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 2.5rem; padding-block: 2.5rem 2rem; }
  .portrait { order: -1; max-width: 300px; margin-right: 18px; }
  .explore, .projects, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .skill-row { grid-template-columns: 1fr; gap: .5rem; }
  .page-head { padding-block: 2.5rem 1.5rem; }
  .section { padding-block: 2.5rem; }

  .menu-btn { display: grid; }
  .nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: .5rem 1.25rem 1rem;
  }
  .nav a { padding: .7rem .75rem; }
  .nav.open { display: flex; }
}
