/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fb;
  --surface: #ffffff;
  --border: #e4e8ef;
  --border-strong: #cfd6e1;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #e8f0fe;
  --accent-text: #1e40af;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, .05), 0 16px 40px -16px rgba(37, 99, 235, .25);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --container: 1120px;
  --header-h: 68px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --bg-alt: #0f172a;
  --surface: #111a2e;
  --border: #1f2a40;
  --border-strong: #2c3a55;
  --text: #e5e9f0;
  --text-2: #a3adbf;
  --text-3: #7c889c;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: #15213d;
  --accent-text: #93c5fd;
  --success: #4ade80;
  --success-soft: #122b1c;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 40px -16px rgba(96, 165, 250, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 700; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.container { width: min(var(--container), calc(100% - 48px)); margin-inline: auto; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0; }
.muted { color: var(--text-3); }
.accent { color: var(--accent); }
.eyebrow { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); font-weight: 500; margin-bottom: 12px; }
.small-heading { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); font-weight: 500; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; background: var(--accent); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; color: #fff; }

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
  border: 1px solid transparent;
  transition: background-color .2s, transform .15s, box-shadow .2s, color .2s;
}
.button:hover { background: var(--accent-strong); color: #fff; transform: translateY(-1px); box-shadow: 0 8px 20px -10px var(--accent); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .6; cursor: wait; transform: none; box-shadow: none; }
.button-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.button-ghost:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); box-shadow: none; }
.button-small { padding: 8px 16px; font-size: 14px; }
.icon-button {
  width: 40px; height: 40px; border-radius: 999px; display: inline-grid; place-items: center;
  color: var(--text-2); border: 1px solid transparent; transition: background-color .2s, color .2s, border-color .2s;
}
.icon-button:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--border); }
.text-link { font-weight: 600; color: var(--accent-text); display: inline-flex; align-items: center; gap: 6px; }
.text-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.site-header.is-scrolled { border-bottom-color: var(--border); box-shadow: 0 4px 20px -16px rgba(15, 23, 42, .3); }
.nav { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: 0; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { display: block; padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-2); transition: background-color .2s, color .2s; }
.nav-links a:hover { color: var(--text); background: var(--accent-soft); }
.nav-links a.is-active { color: var(--accent-text); background: var(--accent-soft); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.25fr .9fr; gap: 56px; align-items: center;
  padding: 88px 0 72px; min-height: min(calc(100vh - var(--header-h)), 720px);
}
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 13px; font-weight: 500; border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--success); position: relative; flex-shrink: 0; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--success); opacity: .6; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.5); opacity: 0; } }
h1 { font-size: clamp(40px, 5.4vw, 64px); font-weight: 800; letter-spacing: -0.035em; margin: 22px 0 12px; line-height: 1.05; }
.hero-role { font-size: 18px; font-weight: 500; color: var(--text-2); }
.hero-lede { font-size: 17px; color: var(--text-2); max-width: 560px; margin-top: 18px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.social-row { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 28px; }
.social-row a { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--text-2); }
.social-row a:hover { color: var(--accent); }

.hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; gap: 20px; position: relative; overflow: hidden;
}
.hero-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--accent), #7c3aed); }
.hero-card-head, .hero-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--text-3); }
.hero-card-foot { border-top: 1px solid var(--border); padding-top: 16px; }
.status { display: inline-flex; align-items: center; gap: 8px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.stats > div { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stats dt { font-size: 12px; color: var(--text-3); font-weight: 500; }
.stats dd { margin: 4px 0 0; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.stats dd.is-updated { animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.9); color: var(--accent); } 100% { transform: scale(1); } }
.hero-highlights { display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--text-2); }
.hero-highlights li { display: flex; gap: 10px; align-items: flex-start; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex-shrink: 0; }

/* ---------- Sections ---------- */
.section { padding: 96px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { max-width: 680px; margin-bottom: 44px; }
h2 { font-size: clamp(30px, 3.6vw, 42px); letter-spacing: -0.03em; }
.section-intro { color: var(--text-2); font-size: 17px; margin-top: 14px; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }

/* ---------- Timeline ---------- */
.timeline { position: relative; display: flex; flex-direction: column; gap: 8px; }
.timeline::before { content: ""; position: absolute; left: 171px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { display: grid; grid-template-columns: 150px 1fr; gap: 44px; position: relative; padding: 18px 0; }
.tl-item::before {
  content: ""; position: absolute; left: 166px; top: 27px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent); box-shadow: 0 0 0 4px var(--bg); z-index: 1;
}
.tl-date { font-family: var(--mono); font-size: 13px; color: var(--text-3); padding-top: 4px; text-align: right; white-space: nowrap; }
.tl-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.tl-body:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); }
.tl-body h3 { font-size: 18px; margin-bottom: 8px; }
.tl-body p { color: var(--text-2); font-size: 15px; }
.tl-body em { font-style: italic; color: var(--text); }
.tl-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tl-links a { font-size: 13px; font-weight: 500; color: var(--accent-text); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; transition: background-color .2s, color .2s; }
.tl-links a:hover { background: var(--accent); color: #fff; }

/* ---------- Projects ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.chip { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 14px; font-weight: 500; color: var(--text-2); background: var(--surface); transition: background-color .2s, color .2s, border-color .2s; }
.chip:hover { border-color: var(--accent); color: var(--accent-text); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
:root[data-theme="dark"] .chip.is-active { background: var(--accent); color: #0b1220; border-color: var(--accent); }

.project-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; transition: transform .2s, box-shadow .2s, border-color .2s, opacity .3s;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.project-card.featured { grid-column: 1 / -1; background: linear-gradient(135deg, var(--surface), var(--accent-soft)); }
.project-card.is-hidden { display: none; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-3); }
.tag-label { font-size: 12px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; letter-spacing: .01em; }
.project-card h3 { font-size: 22px; }
.project-card.featured h3 { font-size: 28px; }
.project-card > p { color: var(--text-2); font-size: 15px; }
.project-card.featured > p { max-width: 720px; }
.outcomes { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); padding-left: 18px; }
.outcomes li { position: relative; }
.outcomes li::before { content: ""; position: absolute; left: -18px; top: 9px; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.outcomes strong { color: var(--text); font-weight: 700; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; }
.stack li { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--bg-alt); border: 1px solid var(--border); padding: 4px 9px; border-radius: 6px; }
.card-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: auto; padding-top: 6px; }
.card-links a { font-size: 14px; font-weight: 600; color: var(--accent-text); display: inline-flex; align-items: center; gap: 6px; }
.card-links a::after { content: "↗"; font-size: 12px; opacity: .7; }
.card-links a:hover { color: var(--accent); }
.empty-state { color: var(--text-3); padding: 32px 0; text-align: center; }

.more-work { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--border); }
.more-work h3 { font-size: 16px; margin-bottom: 16px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-family: var(--mono); }
.more-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 32px; margin-bottom: 24px; }
.more-list li { display: flex; flex-direction: column; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.more-list a { font-weight: 600; font-size: 15px; }
.more-list span { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ---------- Open source ---------- */
.pr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.pr-card {
  display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s, border-color .2s; color: inherit;
}
.pr-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--accent); color: inherit; }
.pr-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-3); }
.pr-card h3 { font-size: 17px; }
.pr-card p { font-size: 14px; color: var(--text-2); flex: 1; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.badge-merged { background: var(--success-soft); color: var(--success); }
.badge-merged::before { content: "✓ "; }
.oss-foot { margin-top: 28px; }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skill-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.skill-group h3 { font-size: 15px; margin-bottom: 14px; color: var(--text); }
.skill-group .stack li { font-size: 13px; padding: 6px 11px; background: var(--bg); }

/* ---------- Credentials ---------- */
.cred-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.cred-list li a { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "issuer date" "name date"; gap: 2px 16px; align-items: center; padding: 16px 4px; border-bottom: 1px solid var(--border); transition: background-color .2s, padding .2s; border-radius: 6px; }
.cred-list li a:hover { background: var(--accent-soft); padding-inline: 12px; color: inherit; }
.cred-issuer { grid-area: issuer; font-size: 12px; color: var(--text-3); font-weight: 500; }
.cred-name { grid-area: name; font-weight: 600; font-size: 15px; }
.cred-list .mono { grid-area: date; }
.education-card { margin-top: 48px; display: flex; justify-content: space-between; align-items: center; gap: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; box-shadow: var(--shadow); }
.education-card .eyebrow { margin-bottom: 6px; }
.education-card h3 { font-size: 20px; margin-bottom: 4px; }
.education-card p:not(.eyebrow) { color: var(--text-2); font-size: 15px; }
.edu-meta { display: flex; flex-direction: column; gap: 6px; text-align: right; font-size: 13px; color: var(--text-3); max-width: 320px; }
.edu-meta strong { font-size: 24px; color: var(--text); letter-spacing: -0.02em; }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: start; }
.contact-email-row { display: flex; align-items: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.contact-email { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; border-bottom: 2px solid var(--accent); padding-bottom: 2px; }
.contact-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg); font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field textarea { resize: vertical; min-height: 120px; }
.field.is-invalid input, .field.is-invalid textarea { border-color: var(--danger); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { font-size: 14px; min-height: 20px; color: var(--text-2); }
.form-status.is-success { color: var(--success); font-weight: 500; }
.form-status.is-error { color: var(--danger); }

/* ---------- Footer ---------- */
.site-footer { padding: 28px 0; border-top: 1px solid var(--border); }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.footer-row a { font-weight: 500; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .hero { grid-template-columns: 1fr; gap: 40px; min-height: 0; padding-top: 64px; }
  .hero-card { max-width: 560px; }
  .pr-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .nav-links {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 20px 18px; box-shadow: 0 16px 32px -16px rgba(15, 23, 42, .3);
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 12px 14px; font-size: 15px; }
  .menu-toggle { display: inline-grid; }
  .nav-cta { display: none; }
  .project-grid, .skills-grid, .more-list, .cred-grid, .contact-grid { grid-template-columns: 1fr; }
  .cred-grid { gap: 36px; }
  .contact-grid { gap: 40px; }
  .education-card { flex-direction: column; align-items: flex-start; }
  .edu-meta { text-align: left; }
}
@media (max-width: 700px) {
  .container { width: calc(100% - 32px); }
  .section { padding: 64px 0; }
  .hero { padding: 48px 0 56px; }
  .hero-lede { font-size: 16px; }
  .timeline::before { left: 7px; }
  .tl-item { grid-template-columns: 1fr; gap: 8px; padding-left: 30px; }
  .tl-item::before { left: 2px; top: 24px; }
  .tl-date { text-align: left; }
  .tl-body { padding: 18px; }
  .project-card { padding: 20px; }
  .project-card.featured h3 { font-size: 24px; }
  .contact-form { padding: 20px; }
  .footer-row { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .pulse::after { animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
@media print {
  .site-header, .hero-actions, .filters, .contact-form, .site-footer a, .skip-link { display: none !important; }
  .reveal { opacity: 1; transform: none; }
  .section { padding: 24px 0; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; color: #666; }
}
