/* ---------- Design tokens ---------- */
:root {
  --bg: #0b0d12;
  --bg-elevated: #12151c;
  --bg-elevated-2: #171b24;
  --border: #242833;
  --text: #e8eaf0;
  --text-dim: #9aa1b2;
  --text-faint: #6b7182;
  --accent: #7dd3fc;
  --accent-2: #a78bfa;
  --gold: #f5c451;
  --focus: #7dd3fc;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --wrap: 960px;
  --radius: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7fb;
    --bg-elevated: #ffffff;
    --bg-elevated-2: #f0f1f6;
    --border: #e2e4ec;
    --text: #171923;
    --text-dim: #565c6d;
    --text-faint: #8790a3;
    --accent: #0284c7;
    --accent-2: #7c3aed;
    --gold: #a5720a;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes blobDrift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(3%, -4%) scale(1.06); }
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes dash {
  to { stroke-dashoffset: 0; }
}

/* Scroll-reveal: visible by default (no-JS / no-IntersectionObserver fallback).
   Only html.js-reveal (set synchronously in <head>, see index.html) hides
   elements up front so JS can animate them in via .is-visible. */
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 0.84, 0.44, 1),
    transform 0.7s cubic-bezier(0.16, 0.84, 0.44, 1);
}
.js-reveal .reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

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

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #0b0d12;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.scroll-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.1s linear;
}

.scroll-ball {
  position: absolute;
  left: 0%;
  bottom: -8px;
  width: 15px;
  height: 15px;
  transform: translateX(-50%);
  transition: left 0.1s linear;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}
.scroll-ball svg { display: block; width: 100%; height: 100%; }

.nav {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: padding 0.25s ease;
}

.site-header.scrolled .nav { padding: 8px 24px; }
.site-header.scrolled .nav-brand { transform: scale(0.92); }

.nav-brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  display: inline-block;
  transition: transform 0.25s ease, border-color 0.2s ease;
}
.nav-brand:hover { text-decoration: none; border-color: var(--accent); }

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

.nav-links a {
  position: relative;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--text); }

.nav-cta {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px !important;
  color: var(--text) !important;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.nav-cta:hover { border-color: var(--accent); transform: translateY(-1px); }
.nav-cta::after { display: none; }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 18px;
  margin: 0 auto;
  background: var(--text);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 110px 0 90px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(600px 300px at 15% 20%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(500px 280px at 85% 10%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%);
  pointer-events: none;
  animation: blobDrift 16s ease-in-out infinite;
  will-change: transform;
}

.hero-inner { position: relative; }

.hero-inner > * {
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 0.84, 0.44, 1) forwards;
}
.eyebrow { animation-delay: 0.05s; }
.hero h1 { animation-delay: 0.15s; }
.hero-tagline { animation-delay: 0.28s; }
.hero-actions { animation-delay: 0.42s; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  margin: 0 0 18px;
}

.hero h1 {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  line-height: 1.05;
  margin: 0 0 22px;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--text) 40%, var(--accent) 60%, var(--accent-2) 80%, var(--text) 100%);
  background-size: 250% auto;
  background-position: 0% center;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 0.84, 0.44, 1) forwards 0.15s,
    gradientPan 9s linear infinite 1s;
}

@keyframes gradientPan {
  to { background-position: -250% center; }
}

.hero-tagline {
  max-width: 640px;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-dim);
  margin: 0 0 36px;
}

.hl {
  color: var(--text);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn:active { transform: translateY(0); }

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 40%, color-mix(in srgb, var(--text) 15%, transparent) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}
.btn:hover::before { transform: translateX(120%); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d12;
}
.btn-primary:hover { opacity: 0.92; }

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 26px;
  height: 26px;
  transform: translateX(-50%);
  opacity: 0.7;
  transition: opacity 0.2s ease;
  animation: ballBounce 1.8s ease-in-out infinite;
}
.scroll-cue:hover { opacity: 1; }
.scroll-cue svg { display: block; width: 100%; height: 100%; }

@keyframes ballBounce {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  50% { transform: translateX(-50%) translateY(10px) rotate(70deg); }
}

/* ---------- Sections ---------- */
.section {
  padding: 72px 0;
  border-top: 1px solid var(--border);
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 1.6rem;
  margin: 0 0 36px;
  letter-spacing: -0.01em;
}

.section-title .num {
  display: inline-block;
  transition: transform 0.3s ease;
}
.section.is-visible .section-title .num {
  animation: floatY 3s ease-in-out infinite;
}

.num {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
}

.about-text {
  max-width: 720px;
  font-size: 1.05rem;
  color: var(--text-dim);
}

/* ---------- Timeline (experience) ---------- */
.timeline-wrap { position: relative; }

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.timeline-fill {
  position: absolute;
  left: -1px;
  top: 0;
  width: 1px;
  height: 0%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transition: height 0.1s linear;
}

.timeline-item {
  position: relative;
  padding: 0 0 40px 32px;
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-marker {
  position: absolute;
  left: -5px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
}
.js-reveal .timeline-marker {
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s;
}
.js-reveal .timeline-item.is-visible .timeline-marker { transform: scale(1); }

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
}

.timeline-head h3 {
  margin: 0;
  font-size: 1.12rem;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.timeline-org {
  margin: 4px 0 12px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.timeline-content ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-dim);
}
.timeline-content li { margin-bottom: 6px; }

/* ---------- Projects ---------- */
.grid-projects {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -20px color-mix(in srgb, var(--accent) 45%, transparent);
}

.card:hover .badge-gold {
  animation: floatY 1.6s ease-in-out infinite;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.card-head h3 { margin: 0; font-size: 1.08rem; }

.badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge-gold {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  margin: 0 0 14px;
}

.card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-dim);
  font-size: 0.93rem;
}
.card li { margin-bottom: 6px; }
.card li:last-child { margin-bottom: 0; }

/* ---------- Skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 28px 40px;
}

.skill-group h3 {
  font-size: 0.95rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease, background-color 0.2s ease,
    opacity 0.4s ease;
}
.chip:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
  transform: translateY(-2px);
}

/* Chips pop in one-by-one once their skill-group has scrolled into view. */
.js-reveal .skill-group .chip { opacity: 0; transform: scale(0.85); }
.js-reveal .skill-group.is-visible .chip {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.2s ease, background-color 0.2s ease;
}
.js-reveal .skill-group.is-visible .chip:hover { transform: translateY(-2px); }
/* stagger by position within the group */
.chip:nth-child(1) { transition-delay: 0.02s; }
.chip:nth-child(2) { transition-delay: 0.06s; }
.chip:nth-child(3) { transition-delay: 0.1s; }
.chip:nth-child(4) { transition-delay: 0.14s; }
.chip:nth-child(5) { transition-delay: 0.18s; }
.chip:nth-child(6) { transition-delay: 0.22s; }
.chip:nth-child(7) { transition-delay: 0.26s; }
.chip:nth-child(8) { transition-delay: 0.3s; }
.chip:nth-child(9) { transition-delay: 0.34s; }
.chip:nth-child(10) { transition-delay: 0.38s; }

/* ---------- Education ---------- */
.edu-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.edu-orgs {
  margin: 0;
  color: var(--text-faint);
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 64px 0 32px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: space-between;
  padding-bottom: 40px;
}

.footer-inner h2 {
  margin: 0 0 10px;
  font-size: 1.8rem;
}

.footer-inner > div:first-child p {
  max-width: 420px;
  color: var(--text-dim);
  margin: 0;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
}

.footer-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.82rem;
  margin: 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 20px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 10px 0;
  }

  .hero { padding: 80px 0 60px; }
  .section { padding: 56px 0; }
}
