/* ---------- Design tokens ---------- */
:root {
  --ink-900: #14171c;
  --ink-700: #383f4a;
  --ink-500: #5c6572;
  --ink-300: #9aa3af;
  --ink-100: #e6e9ed;
  --paper: #fcfcfb;
  --paper-alt: rgba(255, 255, 255, 0.5);
  --accent: #2a5bd7;
  --accent-2: #7c3aed;
  --accent-3: #06b6d4;
  --accent-ink: #14265c;
  --gradient-1: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  --gradient-2: linear-gradient(135deg, var(--accent-3) 0%, var(--accent) 50%, var(--accent-2) 100%);
  --code: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --max: 1080px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.04), 0 8px 24px rgba(20, 23, 28, 0.05);
  --shadow-glow: 0 12px 40px rgba(42, 91, 215, 0.16), 0 4px 14px rgba(124, 58, 237, 0.1);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { 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;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink-900);
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(42, 91, 215, 0.13), transparent 60%),
    radial-gradient(950px 680px at 95% 8%, rgba(124, 58, 237, 0.12), transparent 55%),
    radial-gradient(850px 850px at 50% 38%, rgba(6, 182, 212, 0.08), transparent 60%),
    radial-gradient(900px 700px at 8% 68%, rgba(124, 58, 237, 0.1), transparent 55%),
    radial-gradient(1000px 700px at 100% 95%, rgba(42, 91, 215, 0.11), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  opacity: 0;
}
body.page-ready {
  opacity: 1;
  transition: opacity 0.6s var(--ease);
}

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

h1, h2, h3, h4 {
  font-family: var(--sans);
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; }
a { color: inherit; }

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

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 251, 250, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ink-100);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink-900);
}
.brand span {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-nav a {
  text-decoration: none;
  color: var(--ink-700);
  font-size: 0.92rem;
  font-weight: 500;
}
.site-nav a:hover { color: var(--ink-900); }
.site-nav a.active {
  color: var(--accent);
  position: relative;
}
.site-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -21px;
  height: 2px;
  background: var(--gradient-1);
}
.site-nav a.nav-cta.active::after { display: none; }

.nav-cta {
  background: var(--gradient-1);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 999px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.nav-cta:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--ink-900);
  border-radius: 2px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 100px 0 72px;
  border-bottom: 1px solid var(--ink-100);
  overflow: hidden;
}

.hero-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: float-blob 16s ease-in-out infinite;
}
.blob-a {
  width: 420px; height: 420px;
  background: var(--accent);
  top: -160px; right: 8%;
  animation-delay: 0s;
}
.blob-b {
  width: 320px; height: 320px;
  background: var(--accent-2);
  bottom: -140px; right: 28%;
  animation-delay: -5s;
}
.blob-c {
  width: 260px; height: 260px;
  background: var(--accent-3);
  top: 20%; left: -120px;
  animation-delay: -10s;
}

@keyframes float-blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -24px) scale(1.08); }
  66% { transform: translate(-20px, 18px) scale(0.96); }
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  font-family: var(--code);
  font-size: 0.82rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
  font-weight: 600;
}

.hero-name {
  font-size: clamp(1.9rem, 4vw, 2.85rem);
  max-width: 20ch;
  margin-bottom: 22px;
  min-height: 1.2em;
}

.typewriter {
  display: inline;
}

.caret {
  display: inline-block;
  width: 3px;
  height: 0.85em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: -0.1em;
  animation: caret-blink 0.9s step-end infinite;
}
.caret.caret-done { animation: caret-blink 0.9s step-end infinite; }
.caret.caret-hide { display: none; }

@keyframes caret-blink {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.hero-lede {
  font-size: 1.15rem;
  color: var(--ink-500);
  max-width: 58ch;
  margin-bottom: 32px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

/* Staged hero reveal: JS toggles .stage-in on each .hero-stage in sequence */
.hero-stage {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.hero-stage.stage-in {
  opacity: 1;
  transform: none;
}

.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--ink-900);
  color: #fff;
}
.btn-primary:hover {
  background: var(--gradient-1);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  border-color: var(--ink-100);
  color: var(--ink-900);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.hero-meta {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-size: 0.86rem;
  color: var(--ink-500);
}
.hero-meta li { position: relative; }

.hero-photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.photo-ring {
  position: absolute;
  inset: -14px;
  border-radius: 32% 68% 65% 35% / 45% 35% 65% 55%;
  background: var(--gradient-2);
  opacity: 0.55;
  filter: blur(2px);
  animation: ring-morph 12s ease-in-out infinite;
  z-index: 0;
}

@keyframes ring-morph {
  0%, 100% { border-radius: 32% 68% 65% 35% / 45% 35% 65% 55%; }
  50% { border-radius: 62% 38% 40% 60% / 55% 60% 40% 45%; }
}

.photo-frame {
  position: relative;
  z-index: 1;
  width: min(320px, 100%);
  aspect-ratio: 4 / 5;
  border-radius: 28% 72% 68% 32% / 42% 38% 62% 58%;
  overflow: hidden;
  border: 4px solid var(--paper);
  box-shadow: var(--shadow-glow);
  transition: border-radius 0.6s var(--ease), transform 0.4s var(--ease);
}

.photo-frame:hover {
  border-radius: 40% 60% 50% 50% / 40% 40% 60% 60%;
  transform: translateY(-4px);
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 26px;
  height: 42px;
  border: 2px solid var(--ink-300);
  border-radius: 999px;
  z-index: 1;
  opacity: 0.7;
}
.scroll-cue span {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 4px;
  height: 8px;
  background: var(--accent);
  border-radius: 999px;
  transform: translateX(-50%);
  animation: cue-scroll 1.8s ease-in-out infinite;
}
@keyframes cue-scroll {
  0% { opacity: 1; top: 7px; }
  70% { opacity: 0; top: 22px; }
  100% { opacity: 0; top: 22px; }
}

/* ---------- Sections ---------- */
.section {
  padding: 84px 0;
}
.section-alt {
  background: linear-gradient(180deg, rgba(42, 91, 215, 0.05), rgba(124, 58, 237, 0.045) 55%, rgba(6, 182, 212, 0.04));
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(20, 23, 28, 0.04);
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 1.7rem;
  margin-bottom: 40px;
}
.section-title.small {
  font-size: 1.25rem;
  margin-bottom: 20px;
}

.section-num {
  font-family: var(--code);
  font-size: 0.85rem;
  border: 1px solid var(--ink-100);
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--paper);
  background-image: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  will-change: opacity, transform;
}
.reveal-up { transform: translateY(32px); }
.reveal-left { transform: translateX(-48px); }
.reveal-right { transform: translateX(48px); }
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

.section-intro {
  color: var(--ink-500);
  max-width: 62ch;
  margin-top: -20px;
  margin-bottom: 32px;
}

/* ---------- About ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
  align-items: start;
}

.about-copy {
  font-size: 1.05rem;
  color: var(--ink-700);
}

.skills-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}
.skills-list li {
  font-family: var(--code);
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--ink-700);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.skills-list li:hover {
  transform: translateY(-2px);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: var(--shadow-glow);
  background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--gradient-1) border-box;
  border: 1px solid transparent;
}

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--ink-100);
}

.timeline-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 32px;
  padding: 0 0 48px 32px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gradient-1);
  border: 3px solid var(--paper-alt);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.timeline-item:hover::before {
  transform: scale(1.3);
  box-shadow: 0 0 0 5px rgba(42, 91, 215, 0.14);
}
.timeline-item:last-child { padding-bottom: 0; }

.timeline-when {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timeline-date {
  font-family: var(--code);
  font-size: 0.85rem;
  color: var(--ink-900);
  font-weight: 600;
}
.timeline-loc {
  font-size: 0.82rem;
  color: var(--ink-500);
}

.timeline-body h3 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}
.timeline-org {
  font-weight: 400;
  color: var(--ink-500);
}

.timeline-body ul {
  margin: 0;
  padding-left: 20px;
  color: var(--ink-700);
}
.timeline-body li { margin-bottom: 6px; }

/* ---------- Work cards ---------- */
.work-group { margin-bottom: 56px; }
.work-group:last-child { margin-bottom: 0; }

.work-group-title {
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.work-group-desc {
  color: var(--ink-500);
  font-size: 0.92rem;
  max-width: 60ch;
  margin-bottom: 22px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 2px rgba(20, 23, 28, 0.03);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--gradient-1);
  opacity: 0;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: opacity 0.25s var(--ease);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
  border-color: transparent;
}
.card:hover::before { opacity: 1; }

.card-tag {
  font-family: var(--code);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
}

.card h4 {
  font-size: 1rem;
  color: var(--ink-900);
}

.card p {
  font-size: 0.88rem;
  color: var(--ink-500);
  margin: 0;
  flex-grow: 1;
}

.card-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-900);
  margin-top: 4px;
}

.section-alt .card { background: rgba(255, 255, 255, 0.78); }

/* ---------- More grid (open source / education / toolkit) ---------- */
.more-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 48px;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--ink-700);
  font-size: 0.95rem;
}
.plain-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--ink-100);
}
.plain-list li:last-child { border-bottom: none; }

.edu-degree { font-weight: 600; color: var(--ink-900); margin-bottom: 4px; }
.edu-school { color: var(--ink-700); margin-bottom: 4px; }
.edu-meta { font-size: 0.85rem; color: var(--ink-500); font-family: var(--code); }

.toolkit p {
  font-size: 0.88rem;
  color: var(--ink-700);
  margin-bottom: 12px;
}
.toolkit strong { color: var(--ink-900); }

/* ---------- Contact ---------- */
.contact-section {
  position: relative;
  background: radial-gradient(circle at 15% 20%, #1c2440 0%, var(--ink-900) 45%), var(--ink-900);
  color: var(--paper);
  overflow: hidden;
}
.contact-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-2);
  opacity: 0.08;
  pointer-events: none;
}
.contact-section .wrap { position: relative; z-index: 1; }
.contact-section .section-num {
  background: var(--ink-700);
  background-image: none;
  border-color: var(--ink-500);
  -webkit-text-fill-color: #fff;
  color: #fff;
}
.contact-inner { text-align: left; }
.contact-lede {
  color: var(--ink-300);
  max-width: 55ch;
  font-size: 1.05rem;
  margin-bottom: 32px;
}
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}
.icon-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 84px;
  text-decoration: none;
  color: var(--ink-300);
}
.icon-link-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}
.icon-link-badge svg { width: 22px; height: 22px; }
.icon-link-label {
  font-size: 0.78rem;
  font-weight: 600;
  transition: color 0.25s var(--ease);
}
.icon-link:hover .icon-link-badge,
.icon-link:focus-visible .icon-link-badge {
  background: var(--gradient-1);
  border-color: transparent;
  transform: translateY(-4px) scale(1.06);
  box-shadow: var(--shadow-glow);
}
.icon-link:hover .icon-link-label,
.icon-link:focus-visible .icon-link-label { color: #fff; }

/* ---------- Footer ---------- */
.site-footer {
  padding: 28px 0;
  text-align: center;
  color: var(--ink-500);
  font-size: 0.82rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .more-grid { grid-template-columns: 1fr; gap: 36px; }
  .card-grid, .card-grid-3 { grid-template-columns: 1fr 1fr; }
  .timeline-item { grid-template-columns: 1fr; gap: 10px; }
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-photo { order: -1; margin-bottom: 8px; }
  .photo-frame { width: min(240px, 70vw); }
  .hero-actions, .hero-meta { justify-content: center; }
  .hero-name { max-width: none; margin-left: auto; margin-right: auto; }
  .hero-lede { margin-left: auto; margin-right: auto; }
}

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--ink-100);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 24px 20px;
    display: none;
  }
  .site-nav.open {
    display: flex;
    z-index: 60;
    box-shadow: var(--shadow);
  }
  .site-nav a {
    width: 100%;
    padding: 12px 0;
    border-bottom: 1px solid var(--ink-100);
  }
  .nav-cta {
    margin-top: 10px;
    text-align: center;
    border-radius: 8px;
  }
  .hero { padding: 64px 0 48px; }
  .section { padding: 56px 0; }
  .card-grid, .card-grid-3 { grid-template-columns: 1fr; }
  body { background-attachment: scroll; }
  .hero-blob { opacity: 0.22; }
  .blob-a { width: 260px; height: 260px; }
  .blob-b { width: 200px; height: 200px; }
  .blob-c { width: 160px; height: 160px; }
  .scroll-cue { display: none; }
}
