/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --bg-card: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1d1d1f;
  --text-dim: #6e6e73;
  --text-faint: #86868b;
  --accent: #0071e3;
  --accent-2: #0058ad;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --radius: 20px;
  --max-width: 1100px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-alt: #1c1c1e;
    --bg-card: #1c1c1e;
    --border: rgba(255, 255, 255, 0.12);
    --text: #f5f5f7;
    --text-dim: #a1a1a6;
    --text-faint: #6e6e73;
    --accent: #0a84ff;
    --accent-2: #409cff;
    --accent-soft: rgba(10, 132, 255, 0.16);
  }
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease;
}

h1, h2, h3 { line-height: 1.08; margin: 0; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; color: var(--text-dim); }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

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

/* ---------- Interactive constellation background ---------- */
/* Sits between the body background and the content; decorative only. */
.bg-canvas {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
main, .site-footer { position: relative; z-index: 1; }

.skip-link {
  position: absolute; left: -999px; top: auto;
  background: var(--accent); color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 200;
}
.skip-link:focus { left: 16px; top: 16px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(0, 0, 0, 0.72); }
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.nav-brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.nav-brand .dot { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a { font-size: 0.82rem; color: var(--text); font-weight: 400; transition: opacity 0.15s ease; opacity: 0.9; }
.nav-links a:hover { opacity: 1; color: var(--accent); }
.nav-cta {
  color: var(--accent) !important;
  padding: 6px 14px; border-radius: 980px; background: var(--accent-soft);
}
.nav-cta:hover { background: var(--accent-soft); opacity: 1; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; background: none; border: none; cursor: pointer;
}
.nav-toggle span { width: 100%; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }

/* ---------- Hero ---------- */
.hero { padding: 88px 24px 96px; text-align: center; }

.hero-avatar {
  width: 168px; height: 168px; margin: 0 auto 32px;
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 0 0 1px var(--border), 0 20px 40px rgba(0, 0, 0, 0.12);
}
.hero-avatar img {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover;
}

.eyebrow {
  display: inline-block; color: var(--text-faint); font-weight: 600; font-size: 0.78rem;
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 14px;
}
.hero h1 {
  font-size: clamp(2.75rem, 7vw, 5.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}
.hero-lede {
  max-width: 600px; margin: 20px auto 0; font-size: 1.25rem; font-weight: 400;
  color: var(--text-dim); letter-spacing: -0.01em;
}
.hero-actions { display: flex; gap: 24px; justify-content: center; align-items: center; margin-top: 36px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; padding: 12px 24px; border-radius: 980px;
  font-weight: 400; font-size: 1.02rem; transition: transform 0.3s var(--ease), background 0.2s ease, opacity 0.2s ease;
  border: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { color: var(--accent); padding: 12px 4px; }
.btn-ghost::after { content: '\203A'; margin-left: 4px; font-weight: 600; }
.btn-ghost:hover { opacity: 0.7; }

.hero-stats {
  display: flex; justify-content: center; gap: 56px; margin-top: 80px; flex-wrap: wrap;
  padding-top: 40px; border-top: 1px solid var(--border);
}
.hero-stats li { display: flex; flex-direction: column; align-items: center; }
.hero-stats strong { font-size: 2rem; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.hero-stats span { font-size: 0.82rem; color: var(--text-faint); margin-top: 6px; }

/* ---------- Sections ---------- */
.section { padding: 100px 24px; }
.section-title {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem); margin-bottom: 24px; letter-spacing: -0.025em;
}
.lede { font-size: 1.08rem; max-width: 680px; }

/* ---------- About ---------- */
.about-grid { display: flex; gap: 56px; align-items: flex-start; }
.about-grid .lede { flex: 1; font-size: 1.15rem; color: var(--text-dim); }
.about-photo {
  flex-shrink: 0; width: 240px; margin: 0;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 16px 32px rgba(0, 0, 0, 0.08);
}
.about-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Timeline ---------- */
.timeline { margin-top: 44px; }
.timeline-item {
  padding: 32px 0;
  border-top: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: 1px solid var(--border); }
.timeline-marker { display: none; }
.timeline-content { padding: 0; }
.timeline-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 24px;
  margin-bottom: 6px;
}
.timeline-head h3 { font-size: 1.2rem; letter-spacing: -0.015em; }
.timeline-date { font-size: 0.85rem; color: var(--text-faint); font-weight: 400; white-space: nowrap; }
.timeline-org { color: var(--accent); font-weight: 500; font-size: 0.92rem; margin-bottom: 12px; }
.timeline-content p:not(.timeline-org) { max-width: 680px; }
.timeline-content p + p { margin-top: 10px; }

/* ---------- Featured project (deep-dive black section) ---------- */
.section-feature {
  --bg-card: #1c1c1e;
  --border: rgba(255, 255, 255, 0.12);
  --text: #f5f5f7;
  --text-dim: #a1a1a6;
  --text-faint: #6e6e73;
  --accent: #2997ff;
  padding: 110px 0;
  background: #000;
  color: var(--text);
}
.section-feature .eyebrow { color: var(--accent); }
.section-feature .section-title { color: var(--text); }
.section-feature .lede { color: var(--text-dim); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 48px 0 64px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat-card {
  background: var(--bg-card);
  padding: 28px 20px; text-align: center;
}
.stat-card strong { display: block; font-size: 1.9rem; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.stat-card span { display: block; margin-top: 8px; font-size: 0.8rem; color: var(--text-faint); }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.feature-card {
  background: var(--bg-card);
  padding: 30px 28px; transition: background 0.25s ease;
}
.feature-card:hover { background: #232325; }
.feature-card h3 { font-size: 1.05rem; margin-bottom: 10px; color: var(--text); letter-spacing: -0.01em; }
.feature-card p { font-size: 0.92rem; color: var(--text-dim); }

/* Let the constellation run through the full-bleed sections. In dark mode the
   page behind the case-study band is already black, so dropping its fill costs
   nothing visually; in light mode the band stays solid by design. */
@media (prefers-color-scheme: dark) {
  .section-feature { background: transparent; }
}

/* ---------- Skills ---------- */
.skills-group { margin-bottom: 36px; }
.skills-group h3 { font-size: 0.8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 16px; font-weight: 600; }
.chip-list { display: flex; flex-wrap: wrap; gap: 10px; }
.chip-list li {
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 980px;
  padding: 8px 16px; font-size: 0.86rem; color: var(--text-dim); font-weight: 400;
}

/* ---------- Education ---------- */
.edu-list { display: flex; flex-direction: column; gap: 0; margin-top: 36px; }
.edu-list li {
  display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px;
  padding: 20px 0; border-top: 1px solid var(--border);
}
.edu-list li:last-child { border-bottom: 1px solid var(--border); }
.edu-list strong { font-size: 1rem; color: var(--text); font-weight: 500; }
.edu-list span { font-size: 0.85rem; color: var(--text-faint); }

/* ---------- Contact ---------- */
.section-contact { text-align: center; background: rgba(245, 245, 247, 0.72); }
/* Must follow the rule above: same specificity, so order decides the winner. */
@media (prefers-color-scheme: dark) {
  .section-contact { background: rgba(28, 28, 30, 0.72); }
}
.section-contact .lede { margin: 0 auto; font-size: 1.15rem; }
.contact-links { display: flex; justify-content: center; gap: 32px; margin-top: 36px; flex-wrap: wrap; }
.contact-links a {
  font-weight: 400; font-size: 1.05rem; color: var(--accent);
  transition: opacity 0.15s ease;
}
.contact-links a:hover { opacity: 0.7; }

/* ---------- Fun photo ---------- */
.section-fun { padding-top: 0; text-align: center; }
.fun-photo {
  margin: 0 auto; max-width: 340px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 14px 20px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 20px 40px rgba(0, 0, 0, 0.08);
}
.fun-photo img { display: block; width: 100%; border-radius: calc(var(--radius) - 8px); }
.fun-photo figcaption { margin-top: 14px; font-size: 0.85rem; color: var(--text-faint); }

/* ---------- Footer ---------- */
.site-footer { padding: 40px 24px; text-align: center; color: var(--text-faint); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* Staggered cascades for grouped reveals */
.hero-stats li:nth-child(1), .stat-row .reveal:nth-child(1), .feature-grid .reveal:nth-child(1) { transition-delay: 0ms; }
.hero-stats li:nth-child(2), .stat-row .reveal:nth-child(2), .feature-grid .reveal:nth-child(2) { transition-delay: 90ms; }
.hero-stats li:nth-child(3), .stat-row .reveal:nth-child(3), .feature-grid .reveal:nth-child(3) { transition-delay: 180ms; }
.stat-row .reveal:nth-child(4), .feature-grid .reveal:nth-child(4) { transition-delay: 270ms; }
.feature-grid .reveal:nth-child(5) { transition-delay: 360ms; }
.feature-grid .reveal:nth-child(6) { transition-delay: 450ms; }
.feature-grid .reveal:nth-child(7) { transition-delay: 540ms; }
.feature-grid .reveal:nth-child(8) { transition-delay: 630ms; }
.feature-grid .reveal:nth-child(9) { transition-delay: 720ms; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 52px; left: 0; right: 0; flex-direction: column; align-items: flex-start;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 20px 24px; gap: 20px; transform: translateY(-8px); opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .nav-links.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-cta { align-self: flex-start; }

  .hero { padding: 72px 20px 72px; }
  .hero-avatar { width: 132px; height: 132px; }
  .hero-stats { gap: 36px; }

  .about-grid { flex-direction: column-reverse; gap: 28px; }
  .about-photo { width: 100%; max-width: 280px; }

  .feature-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }

  .timeline-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .edu-list li { flex-direction: column; align-items: flex-start; gap: 4px; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .hero-actions { flex-direction: column; width: 100%; }
  .hero-actions .btn-primary { justify-content: center; width: 100%; }
}
