:root {
  --bg: #fbfbfa;
  --bg-alt: #f2f1ee;
  --surface: #ffffff;
  --border: #e6e4de;
  --text: #16181c;
  --text-dim: #5b5f66;
  --text-faint: #8b8f97;
  --accent: #2563eb;
  --accent-dim: #dbe6fd;
  --accent-2: #0d9488;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20,20,20,.04), 0 8px 24px -12px rgba(20,20,20,.10);
  --max-w: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --bg-alt: #111318;
    --surface: #14171c;
    --border: #262a31;
    --text: #eef0f3;
    --text-dim: #a7acb5;
    --text-faint: #6d727b;
    --accent: #5b8cff;
    --accent-dim: #16213d;
    --accent-2: #2dd4bf;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -14px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ============ SURFACE FX: noise + cursor glow ============ */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.1s steps(4) infinite;
}
@media (prefers-color-scheme: dark) { .noise-overlay { opacity: 0.06; mix-blend-mode: soft-light; } }
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 2%); }
  50% { transform: translate(2%, -1%); }
  75% { transform: translate(-1%, -2%); }
}

.cursor-glow {
  position: fixed;
  top: 0; left: 0;
  width: 480px; height: 480px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
  transform: translate(calc(var(--mx, 50vw) - 50%), calc(var(--my, 30vh) - 50%));
  transition: opacity .3s ease;
  opacity: 0;
  will-change: transform;
}
.cursor-glow.active { opacity: 1; }
@media (max-width: 720px), (hover: none) { .cursor-glow { display: none; } }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

img, svg { max-width: 100%; display: block; }

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

/* ============ NAV ============ */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.nav-logo .dot { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  list-style: none;
}

.nav-links a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: color .15s ease;
}
.nav-links a:hover { color: var(--text); }

.nav-cta {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg) !important;
}
.nav-cta:hover { opacity: 0.85; }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-toggle span {
  width: 22px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}

/* ============ HERO ============ */
.hero {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 140px 24px 80px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-dim), transparent 70%);
}

.particle-net {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 380px;
  z-index: 0;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}
@media (max-width: 720px) {
  .particle-net { height: 280px; }
}
.particle-net canvas {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}
@media (prefers-reduced-motion: reduce) {
  .particle-net { display: none; }
  .noise-overlay { animation: none; }
}

.hero-inner { max-width: 760px; position: relative; z-index: 2; }

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.hero-name {
  font-size: clamp(3.2rem, 9vw, 6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 18px;
  background: linear-gradient(100deg, var(--text) 30%, var(--accent) 45%, var(--accent-2) 55%, var(--text) 70%);
  background-size: 250% auto;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: shimmer 7s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 0% 50%; }
  100% { background-position: 250% 50%; }
}
@media (prefers-reduced-motion: reduce) { .hero-name { animation: none; } }

.hero-role {
  font-size: clamp(1.05rem, 2.4vw, 1.5rem);
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.hero-role .sep { color: var(--text-faint); margin: 0 4px; }

.hero-sub {
  font-size: 1.08rem;
  color: var(--text-dim);
  max-width: 620px;
  margin: 0 auto 36px;
}
.hero-sub strong { color: var(--text); }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  border: 1px solid transparent;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
}
.btn-primary:hover { opacity: 0.88; }

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-ghost {
  color: var(--text-dim);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); }

.hero-links {
  display: flex;
  justify-content: center;
  gap: 22px;
}
.hero-links a {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-faint);
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.hero-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ============ HERO TERMINAL ============ */
.terminal {
  margin-top: 44px;
  width: 100%;
  max-width: 620px;
  text-align: left;
  background: #0d1117;
  border: 1px solid #262c36;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.45);
}
@media (prefers-color-scheme: light) {
  .terminal { box-shadow: 0 20px 50px -18px rgba(20,20,20,0.22); }
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  background: #161b22;
  border-bottom: 1px solid #262c36;
}
.terminal-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.dot-red { background: #ff5f56; }
.dot-yellow { background: #ffbd2e; }
.dot-green { background: #27c93f; }
.terminal-title {
  margin-left: 10px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: #7d8590;
}

.terminal-body {
  margin: 0;
  padding: 18px 20px 22px;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
  color: #c9d1d9;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 190px;
  max-height: 240px;
  overflow-y: auto;
}
.terminal-body .t-prompt { color: #58a6ff; }
.terminal-body .t-ok { color: #3fb950; }
.terminal-body .t-dim { color: #7d8590; }
.terminal-body .t-url { color: #a5d6ff; }

.terminal-cursor {
  color: #58a6ff;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .terminal-cursor { animation: none; } }

@media (max-width: 720px) {
  .terminal { max-width: 100%; }
  .terminal-body { font-size: 0.76rem; max-height: 200px; }
}

.hero-scroll-cue {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
}
.hero-scroll-cue span {
  display: block;
  width: 4px; height: 8px;
  background: var(--text-faint);
  border-radius: 2px;
  margin: 6px auto 0;
  animation: scrollcue 1.8s ease-in-out infinite;
}
@keyframes scrollcue {
  0% { transform: translateY(0); opacity: 1; }
  70% { transform: translateY(12px); opacity: 0; }
  100% { opacity: 0; }
}

/* ============ IMPACT STRIP ============ */
.impact-strip {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.impact-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 44px 24px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
}
.impact-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  padding: 0 8px;
}
.impact-number {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.impact-label {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ============ SECTIONS (shared) ============ */
.section { padding: 100px 24px; }
.section-alt { background: var(--bg-alt); }
.section-inner { max-width: var(--max-w); margin: 0 auto; }

.section-eyebrow {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.section-title {
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  max-width: 720px;
  margin-bottom: 56px;
}

/* ============ ENGINEERING PRINCIPLES ============ */
.principles-section { padding-bottom: 88px; }

.principles-lede {
  font-size: 1.02rem;
  font-style: italic;
  color: var(--text-dim);
  max-width: 720px;
  padding-left: 20px;
  border-left: 3px solid var(--accent-2);
  margin-bottom: 48px;
}

.principles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
}

.principle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
}

.principle-mark {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-2);
  background: var(--accent-dim);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.principle-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 10px; }
.principle-card p { font-size: 0.88rem; color: var(--text-dim); }

/* ============ EXPERIENCE / TIMELINE ============ */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.job {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.job-featured {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  position: relative;
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.job-role { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.job-company {
  font-size: 0.95rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}

.job-tag {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.job-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  font-size: 0.85rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.job-date { font-family: var(--mono); font-weight: 600; color: var(--text-dim); }

.job-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.job-bullets li {
  position: relative;
  padding-left: 20px;
  font-size: 0.96rem;
  color: var(--text-dim);
}
.job-bullets li::before {
  content: "";
  position: absolute;
  left: 0; top: 9px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.job-bullets strong { color: var(--text); font-weight: 700; }

.job-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.job-skills span {
  font-family: var(--mono);
  font-size: 0.74rem;
  padding: 5px 11px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
}

.job-award {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-2);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.award-badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 14%, transparent);
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.job-links {
  display: flex;
  gap: 20px;
  margin-top: 14px;
}
.job-links a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}
.job-links a:hover { text-decoration: underline; }

/* ============ PROJECTS ============ */
.pillar-group { margin-bottom: 56px; }
.pillar-group:last-child { margin-bottom: 0; }
.pillar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 22px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 22px;
}

.project-card {
  --rx: 0deg;
  --ry: 0deg;
  --ty: 0px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  display: flex;
  flex-direction: column;
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--ty));
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.project-card:hover {
  --ty: -3px;
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
@media (hover: none) { .project-card { transform: none !important; } }

.project-card-flagship {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-dim), var(--surface) 60%);
}

.project-prod-signals {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.project-prod-signals span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-prod-signals span::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  flex-shrink: 0;
}

.project-stats {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.project-stats div { display: flex; flex-direction: column; gap: 2px; }
.project-stats strong {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}
.project-stats span { font-size: 0.7rem; color: var(--text-faint); }

.project-card h4 { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; }
.project-card p { font-size: 0.9rem; color: var(--text-dim); margin-bottom: 18px; flex-grow: 1; }

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}
.project-tags span {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 4px 10px;
  background: var(--bg-alt);
  border-radius: 999px;
  color: var(--text-dim);
}

.project-link { font-size: 0.87rem; font-weight: 700; color: var(--accent); }
.project-link:hover { text-decoration: underline; }

/* ============ RESEARCH ============ */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}
.research-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  border-radius: var(--radius);
  padding: 26px;
}
.research-kicker {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.research-card h3 { font-size: 1.02rem; font-weight: 700; margin-bottom: 10px; line-height: 1.35; }
.research-card p { font-size: 0.88rem; color: var(--text-dim); }
.research-card .project-link { display: inline-block; margin-top: 10px; }

/* ============ SKILLS ============ */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
}
.skill-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.skill-group h4 {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}
.skill-group p { font-size: 0.9rem; color: var(--text-dim); line-height: 1.7; }

/* ============ EDUCATION ============ */
.edu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 22px;
}
.edu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.edu-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.edu-head h3 { font-size: 1.1rem; font-weight: 700; }
.edu-date { font-family: var(--mono); font-size: 0.8rem; color: var(--text-faint); }
.edu-degree { font-size: 0.94rem; font-weight: 600; color: var(--accent); margin-bottom: 10px; }
.edu-detail { font-size: 0.88rem; color: var(--text-dim); }

/* ============ CONTACT ============ */
.contact-section { text-align: center; }
.contact-inner { display: flex; flex-direction: column; align-items: center; }
.contact-sub { font-size: 1rem; color: var(--text-dim); margin-bottom: 32px; margin-top: -30px; }
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-bottom: 32px;
}
.contact-links {
  display: flex;
  gap: 24px;
}
.contact-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
}
.contact-links a:hover { color: var(--accent); }

/* ============ FOOTER ============ */
.site-footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-faint);
}
.paw { opacity: 0.7; }

/* ============ RESPONSIVE ============ */
@media (max-width: 860px) {
  .impact-inner { grid-template-columns: repeat(2, 1fr); }
  .impact-item:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: 66px; left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px 24px;
    transform: translateY(-130%);
    transition: transform .25s ease;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 0; width: 100%; }
  .nav-cta { display: inline-block; margin-top: 8px; }

  .impact-inner { grid-template-columns: 1fr 1fr; padding: 32px 24px; }
  .job-head { flex-direction: column; }
  .job-meta { align-items: flex-start; }
  .section { padding: 72px 20px; }
}

/* ============ SCROLL-DRIVEN REVEAL (progressive enhancement) ============ */
/* Guarded by @supports: browsers without scroll-timeline support simply
   never apply this rule, so content stays at its normal, fully-visible
   default in every rule above. Nothing is ever hidden by default. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .job, .research-card, .skill-group, .edu-card, .principle-card {
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 30%;
    }
    /* project-card already has a JS-driven tilt transform — reveal via opacity only, no transform conflict */
    .project-card {
      animation: reveal-fade linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 30%;
    }
    @keyframes reveal-fade {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    @keyframes reveal-up {
      from { opacity: 0; transform: translateY(28px); }
      to { opacity: 1; transform: translateY(0); }
    }
  }
}
