/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg: #0a0b0f;
  --bg-elevated: #101218;
  --bg-card: #12141b;
  --bg-card-hover: #161923;
  --border: #1f232c;
  --border-hover: #2b303c;
  --text: #eef0f3;
  --text-dim: #9aa1ad;
  --text-faint: #5c6270;
  --accent: #4da3ff;
  --accent-soft: rgba(77, 163, 255, 0.12);
  --accent-2: #9673f2;
  --accent-2-soft: rgba(150, 115, 242, 0.14);
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --accent-warm: #ffb454;
  --accent-warm-soft: rgba(255, 180, 84, 0.12);
  --success: #6ee7b7;
  --danger: #ff8a8a;

  --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --max-w: 1120px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-glow: 0 0 0 1px var(--border), 0 12px 40px -12px rgba(0, 0, 0, 0.6);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fbfbfd;
  --border: #e4e7ec;
  --border-hover: #d3d8e0;
  --text: #14161a;
  --text-dim: #565d6b;
  --text-faint: #8b93a1;
  --accent: #1f6fe0;
  --accent-soft: rgba(31, 111, 224, 0.08);
  --accent-2: #7c3aed;
  --accent-2-soft: rgba(124, 58, 237, 0.08);
  --accent-warm: #b3690a;
  --accent-warm-soft: rgba(179, 105, 10, 0.1);
  --shadow-glow: 0 0 0 1px var(--border), 0 12px 40px -16px rgba(20, 22, 26, 0.15);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f7f9;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fbfbfd;
    --border: #e4e7ec;
    --border-hover: #d3d8e0;
    --text: #14161a;
    --text-dim: #565d6b;
    --text-faint: #8b93a1;
    --accent: #1f6fe0;
    --accent-soft: rgba(31, 111, 224, 0.08);
    --accent-2: #7c3aed;
    --accent-2-soft: rgba(124, 58, 237, 0.08);
    --accent-warm: #b3690a;
    --accent-warm-soft: rgba(179, 105, 10, 0.1);
    --shadow-glow: 0 0 0 1px var(--border), 0 12px 40px -16px rgba(20, 22, 26, 0.15);
    color-scheme: light;
  }
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
::selection { background: var(--accent-soft); color: var(--accent); }

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

@media (min-width: 1440px) {
  :root { --max-w: 1280px; }
  .container { padding: 0 40px; }
}
@media (min-width: 1800px) {
  :root { --max-w: 1440px; }
  .container { padding: 0 56px; }
}

.mono { font-family: var(--font-mono); }

.grad-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.section {
  padding: 96px 0;
  border-bottom: 1px solid var(--border);
}
.section:last-of-type { border-bottom: none; }

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 14px;
}
.section-tag::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--accent-gradient);
}

.section-head {
  max-width: 640px;
  margin-bottom: 56px;
}
.section-head h2 {
  font-size: clamp(28px, 3.4vw, 38px);
  margin-bottom: 14px;
}
.section-head p {
  color: var(--text-dim);
  font-size: 16.5px;
}

/* ============================================================
   Header / Nav
   ============================================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.25s ease, background-color 0.25s ease;
}
.site-header.is-scrolled {
  border-bottom-color: var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.nav-logo {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo .dot {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-links a {
  font-size: 14.5px;
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); }
.nav-links a.active { color: var(--accent); }

.nav-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); background: var(--bg-card); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }

.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
}
.nav-toggle svg { width: 18px; height: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-card); transform: translateY(-1px); }
.btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #06101f;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-sm { padding: 7px 13px; font-size: 13.5px; }
.btn svg { width: 15px; height: 15px; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: 168px 0 96px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -20% -10%;
  background:
    radial-gradient(560px circle at 82% 8%, var(--accent-soft) 0%, transparent 60%),
    radial-gradient(480px circle at 8% 55%, var(--accent-2-soft) 0%, transparent 65%);
  pointer-events: none;
  animation: heroMesh 16s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes heroMesh {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.05); }
}
.hero-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}
.hero .container {
  position: relative;
  z-index: 1;
}
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.12;
}
@media (prefers-reduced-motion: reduce) {
  .hero::before { animation: none; }
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 100px;
  margin-bottom: 28px;
}
.hero-eyebrow .pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(110, 231, 183, 0); }
  100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}
.hero h1 {
  font-size: clamp(36px, 5.6vw, 64px);
  line-height: 1.08;
  max-width: 900px;
  margin-bottom: 24px;
}
.hero h1 .highlight {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-lede {
  font-size: clamp(16px, 1.6vw, 19px);
  color: var(--text-dim);
  max-width: 620px;
  margin-bottom: 36px;
}
.hero-lede strong { color: var(--text); font-weight: 600; }
.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 56px;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta svg { width: 14px; height: 14px; opacity: 0.8; }

/* ============================================================
   Stack strip
   ============================================================ */
.stack {
  padding: 56px 0;
  border-bottom: 1px solid var(--border);
}
.stack-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
.stack-group h4 {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.stack-group.is-primary h4 { color: var(--accent); }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.stack-group.is-primary .pill {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--text);
  background: var(--accent-soft);
}

/* ============================================================
   Projects
   ============================================================ */
.project-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
  margin-bottom: 28px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.project-card:hover { border-color: var(--border-hover); }
.project-card:nth-child(even) { direction: rtl; }
.project-card:nth-child(even) > * { direction: ltr; }

.project-card.is-flagship {
  border-color: color-mix(in srgb, var(--accent-2) 35%, var(--border));
}
.project-card.is-flagship::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: var(--radius-lg);
  background: var(--accent-gradient);
  opacity: 0.5;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

.project-card::after,
.earlier-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), var(--accent-2-soft), transparent 60%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 1;
}
.project-card:hover::after,
.earlier-card:hover::after { opacity: 1; }
.earlier-card { position: relative; overflow: hidden; }
.earlier-card > * { position: relative; z-index: 2; }

.project-visual {
  position: relative;
  z-index: 2;
  min-width: 0;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  border-right: 1px solid var(--border);
  min-height: 280px;
}
.project-card:nth-child(even) .project-visual { border-right: none; border-left: 1px solid var(--border); }
.project-visual svg { width: 100%; height: auto; }

.project-body {
  position: relative;
  z-index: 2;
  min-width: 0;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
}
.project-links {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.project-index {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}
.project-body h3 {
  font-size: 22px;
  margin-bottom: 10px;
}
.project-summary {
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 20px;
}
.project-highlights {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}
.project-highlights li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}
.project-highlights li::before {
  content: "";
  flex-shrink: 0;
  width: 5px; height: 5px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.project-highlights b { color: var(--accent-warm); font-weight: 600; }
.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
}

/* Earlier work - compact list */
.earlier-work-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  margin: 64px 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.earlier-work-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.earlier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.earlier-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--bg-card);
  transition: border-color 0.2s ease;
}
.earlier-card:hover { border-color: var(--border-hover); }
.earlier-card .period {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.earlier-card h4 {
  font-size: 15.5px;
  margin-bottom: 8px;
}
.earlier-card p {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.earlier-card .pill-row { gap: 6px; }
.earlier-card .pill { font-size: 11px; padding: 4px 8px; }

/* ============================================================
   Experience
   ============================================================ */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
}
.timeline-item:first-child { border-top: none; }
.timeline-when {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  padding-top: 3px;
}
.timeline-when .current {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--success);
  background: rgba(110, 231, 183, 0.1);
  border: 1px solid rgba(110, 231, 183, 0.25);
  padding: 3px 8px;
  border-radius: 100px;
}
.timeline-body h3 {
  font-size: 19px;
  margin-bottom: 4px;
}
.timeline-body .role {
  font-size: 14px;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-bottom: 16px;
  display: block;
}
.timeline-body ul { display: flex; flex-direction: column; gap: 10px; }
.timeline-body li {
  display: flex;
  gap: 10px;
  font-size: 14.5px;
  color: var(--text-dim);
  line-height: 1.6;
}
.timeline-body li::before {
  content: "";
  flex-shrink: 0;
  width: 5px; height: 5px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}
.timeline-body li b { color: var(--text); font-weight: 600; }

/* ============================================================
   About
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 64px;
  align-items: start;
}
.about-copy p {
  color: var(--text-dim);
  font-size: 16px;
  margin-bottom: 18px;
}
.about-copy strong { color: var(--text); }
.about-copy .lede { font-size: 18px; color: var(--text); margin-bottom: 22px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  background: var(--bg-card);
  padding: 24px 20px;
}
.stat .num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}
.stat .label {
  font-size: 12.5px;
  color: var(--text-dim);
}

.edu-card {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  background: var(--bg-card);
}
.edu-card .school { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.edu-card .degree { font-size: 13.5px; color: var(--text-dim); margin-bottom: 4px; }
.edu-card .when { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); }

/* ============================================================
   Contact
   ============================================================ */
.contact-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.contact-link {
  background: var(--bg-card);
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: background-color 0.2s ease;
}
.contact-link:hover { background: var(--bg-card-hover); }
.contact-link .icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.contact-link .icon svg { width: 18px; height: 18px; }
.contact-link .label {
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.contact-link .value {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}
.contact-link .arrow { margin-top: auto; color: var(--text-faint); transition: transform 0.2s ease, color 0.2s ease; }
.contact-link:hover .arrow { transform: translateX(4px); color: var(--accent); }
.contact-link .arrow svg { width: 16px; height: 16px; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  padding: 32px 0;
}
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.footer-row p {
  font-size: 13px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}
.footer-links { display: flex; gap: 18px; }
.footer-links a {
  color: var(--text-faint);
  transition: color 0.2s ease;
}
.footer-links a:hover { color: var(--accent); }
.footer-links svg { width: 18px; height: 18px; }

/* ============================================================
   Reveal animation
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .project-card, .project-card:nth-child(even) { grid-template-columns: minmax(0, 1fr); direction: ltr; }
  .project-visual { border-right: none !important; border-left: none !important; border-bottom: 1px solid var(--border); min-height: 220px; }
  .contact-panel { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 1fr; gap: 10px; }
  .hero { padding-top: 140px; }
}

@media (max-width: 860px) {
  .nav-links.is-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 68px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px;
    gap: 4px;
  }
  .nav-links.is-open a { padding: 12px 14px; }
}

@media (max-width: 600px) {
  .section { padding: 64px 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .project-body { padding: 28px 24px; }
}
