/* ---------- Color tokens (light is the default) ---------- */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f3f4f3;
  --text: #1a1d21;
  --muted: #555c68;
  --border: #e2e4e7;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --on-accent: #ffffff;
  --accent-soft: #e6f3f1;
  --warn-soft: #fdf3e2;
  --warn-text: #8a4b00;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);

  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark tokens: follow the OS setting unless the visitor picked light... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #151920;
    --surface-2: #1b2029;
    --text: #e6e8ec;
    --muted: #a0a8b6;
    --border: #272d37;
    --accent: #5fd4c4;
    --accent-strong: #8ae3d7;
    --on-accent: #06201d;
    --accent-soft: #10302d;
    --warn-soft: #33260f;
    --warn-text: #f3c77a;
    --shadow: none;
    color-scheme: dark;
  }
}
/* ...or when they explicitly picked dark with the toggle. */
:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #151920;
  --surface-2: #1b2029;
  --text: #e6e8ec;
  --muted: #a0a8b6;
  --border: #272d37;
  --accent: #5fd4c4;
  --accent-strong: #8ae3d7;
  --on-accent: #06201d;
  --accent-soft: #10302d;
  --warn-soft: #33260f;
  --warn-text: #f3c77a;
  --shadow: none;
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
img { max-width: 100%; height: auto; display: block; }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 760px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 8px 14px; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; color: var(--on-accent); }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand {
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.02em;
  color: var(--text); text-decoration: none; margin-right: auto;
}
.nav-links { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.nav-links a {
  display: block; padding: 6px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 0.95rem; font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }

.menu-toggle, .theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.menu-toggle:hover, .theme-toggle:hover { background: var(--surface-2); }
.menu-toggle { display: none; }

/* Show the moon in light mode, the sun in dark mode. */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

@media (max-width: 760px) {
  .menu-toggle { display: inline-flex; }
  nav { order: 3; }
  .theme-toggle { order: 2; }
  .nav-links {
    display: none;
    position: absolute; left: 0; right: 0; top: 60px;
    flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 8px; font-size: 1rem; }
}

/* ---------- Hero ---------- */
.hero { padding: 96px 0 72px; }
.eyebrow {
  color: var(--accent); font-weight: 600; font-size: 0.9rem;
  letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 12px;
}
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.75rem); font-weight: 800; letter-spacing: -0.025em; }
.tagline {
  font-size: clamp(1.15rem, 2.2vw, 1.4rem); color: var(--muted);
  max-width: 44ch; margin: 18px 0 28px; line-height: 1.5;
}

.social { list-style: none; padding: 0; margin: 0 0 28px; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.social a {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.social a:hover { color: var(--accent); }

.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px;
  font-weight: 600; font-size: 0.98rem; text-decoration: none;
  border: 1px solid transparent; transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); color: var(--on-accent); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; border-top: 1px solid var(--border); }
.section h2 { font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 750; margin-bottom: 24px; }
.section-intro { color: var(--muted); margin-top: -12px; margin-bottom: 28px; }
.subhead { font-size: 1.05rem; margin: 32px 0 12px; }

/* About: education */
.education { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.education li {
  padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.edu-meta { color: var(--muted); font-size: 0.95rem; }

/* ---------- Research ---------- */
.research-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.research-card + .research-card { margin-top: 20px; }
.research-card h3 { font-size: 1.3rem; margin-bottom: 14px; }
.research-card.featured { border-left: 4px solid var(--accent); }
.badge {
  display: inline-block; margin-bottom: 12px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn-text);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
}
.tldr {
  font-weight: 700; font-size: 1.08rem; line-height: 1.5;
  padding: 14px 16px; border-radius: 10px; background: var(--accent-soft);
  margin-bottom: 24px;
}
.research-steps { margin: 0; display: grid; gap: 20px; }
.research-steps > div { display: grid; grid-template-columns: 170px 1fr; gap: 16px; }
.research-steps dt {
  font-weight: 700; font-size: 0.85rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); padding-top: 3px;
}
.research-steps dd { margin: 0; }
.research-steps ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
@media (max-width: 640px) {
  .research-steps > div { grid-template-columns: 1fr; gap: 4px; }
  .research-card { padding: 20px; }
}

/* ---------- Projects ---------- */
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 760px) { .project-grid { grid-template-columns: 1fr; } }

.project-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.shot, .shot-img { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; }
.shot {
  display: flex; align-items: center; justify-content: center;
  background:
    repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--border) 45%, transparent) 12px 13px),
    var(--surface-2);
  border-bottom: 2px dashed var(--border);
}
.shot span {
  font-family: var(--mono); font-size: 0.8rem; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--muted);
  padding: 4px 10px; border-radius: 6px;
}
.shot-img { border-bottom: 1px solid var(--border); }
.hide-placeholders .shot { display: none; }
.project-body { padding: 22px; display: flex; flex-direction: column; flex: 1; }
.kind {
  color: var(--accent); font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 6px;
}
.project-body h3 { font-size: 1.2rem; margin-bottom: 10px; }
.project-body > p:not(.kind) { color: var(--text); font-size: 0.98rem; }
.repo-link { margin-top: 16px; font-weight: 600; text-decoration: none; align-self: flex-start; }
.repo-link:hover { text-decoration: underline; }

.tags { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-size: 0.8rem; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.project-body .tags { margin-top: auto; padding-top: 16px; }

/* ---------- Experience ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  position: relative; padding: 0 0 36px 28px;
  border-left: 2px solid var(--border);
}
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: -7px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.role-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
.role-head h3 { font-size: 1.15rem; }
.dates { color: var(--muted); font-size: 0.92rem; margin: 0; font-variant-numeric: tabular-nums; }
.org { color: var(--muted); margin: 4px 0 10px; font-size: 0.97rem; }
.timeline ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

/* ---------- Skills ---------- */
.skills { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; }
.skills dt { font-weight: 700; margin-bottom: 2px; }
.skills dd { margin: 0; }
.skills .tags { margin-top: 8px; }
@media (max-width: 640px) { .skills { grid-template-columns: 1fr; } }

/* ---------- Contact / footer ---------- */
.contact-email { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 700; margin: 12px 0 16px; }
.contact-email a { text-decoration: none; }
.contact-email a:hover { text-decoration: underline; }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero { padding: 64px 0 56px; }
  .section { padding: 56px 0; }
}
