:root {
  --bg: #000;
  --surface: #0a0a0a;
  --border: rgba(255, 255, 255, 0.07);
  --text: #fff;
  --text-dim: rgba(255, 255, 255, 0.5);
  --text-faint: rgba(255, 255, 255, 0.25);
  --maxw: 1100px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="light"] {
  --bg: #f2f1ef;
  --surface: #e9e8e6;
  --border: rgba(0, 0, 0, 0.08);
  --text: #111;
  --text-dim: rgba(0, 0, 0, 0.55);
  --text-faint: rgba(0, 0, 0, 0.25);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  cursor: none;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

body.loading { overflow: hidden; }

h1, h2, h3 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

a { color: inherit; text-decoration: none; cursor: none; }
button { cursor: none; }
section { scroll-margin-top: 90px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ---------- Loading screen ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.8s var(--ease-out);
}

.loader.done { transform: translateY(-100%); }

.loader-text {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  display: flex;
}

.loader-text span {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.loader-text span.show {
  opacity: 1;
  transform: translateY(0);
}

.loader-cursor {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 300;
  animation: blink 0.7s step-end infinite;
  color: var(--text-dim);
}

/* ---------- Grain ---------- */
.grain {
  position: fixed; inset: -50%; width: 200%; height: 200%;
  z-index: 1; pointer-events: none; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.5s steps(1) infinite;
}

html[data-theme="light"] .grain { opacity: 0.025; }

@keyframes grain-shift {
  0% { transform: translate(0,0); }
  25% { transform: translate(-5%,-5%); }
  50% { transform: translate(5%,0); }
  75% { transform: translate(-2%,5%); }
  100% { transform: translate(0,0); }
}

/* ---------- Custom cursor ---------- */
.cursor-dot {
  position: fixed; top: 0; left: 0; border-radius: 50%;
  pointer-events: none; z-index: 9999; mix-blend-mode: difference;
  width: 6px; height: 6px; background: #fff; transform: translate(-50%,-50%);
}

/* ---------- Nav (colin.cv style) ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 40px;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  transition: color 0.3s var(--ease);
}

.brand:hover { color: var(--text); }

.nav-right {
  display: flex; align-items: center; gap: 32px;
}

.nav-links { display: flex; gap: 28px; }

.nav-links a {
  font-size: 0.82rem;
  color: var(--text-faint);
  transition: color 0.3s var(--ease);
}

.nav-links a:hover,
.nav-links a.active { color: var(--text); }

.theme-toggle {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent;
  color: var(--text-faint); transition: color 0.3s var(--ease);
}

.theme-toggle:hover { color: var(--text); }

.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.menu-btn {
  display: none; flex-direction: column; gap: 7px;
  background: none; border: none; padding: 8px;
}

.menu-btn span {
  width: 22px; height: 1px; background: var(--text);
  transition: 0.4s var(--ease); transform-origin: center;
}

.menu-btn.open span:first-child { transform: translateY(4px) rotate(45deg); }
.menu-btn.open span:last-child { transform: translateY(-4px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 140px 40px 100px;
  max-width: var(--maxw); margin: 0 auto;
  position: relative; z-index: 2;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
}

.hero-label {
  font-size: 0.85rem; color: var(--text-dim);
  letter-spacing: 0.08em; margin-bottom: 24px; overflow: hidden;
}

.hero-name {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  margin-bottom: 24px;
  overflow: hidden;
}

.particle-wrap {
  position: relative; width: 100%;
  height: clamp(340px, 55vh, 560px);
}

.particle-wrap canvas { display: block; width: 100%; height: 100%; }

.hero-sub {
  max-width: 520px; color: var(--text-dim);
  font-size: 1rem; line-height: 1.75; margin-bottom: 44px;
}

.hero-cta { display: flex; gap: 16px; flex-wrap: wrap; }

.btn-fill, .btn-line {
  position: relative; display: inline-flex; align-items: center;
  padding: 14px 32px; font-size: 0.82rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; overflow: hidden;
  transition: color 0.4s var(--ease);
}

.btn-fill { background: var(--text); color: var(--bg); }

.btn-fill::before {
  content: ""; position: absolute; inset: 0;
  background: var(--bg); transform: translateY(101%);
  transition: transform 0.45s var(--ease-out);
}

.btn-fill:hover { color: var(--text); }
.btn-fill:hover::before { transform: translateY(0); }

.btn-line {
  border: 1px solid var(--border);
  color: var(--text); background: transparent;
}

.btn-line::before {
  content: ""; position: absolute; inset: 0;
  background: var(--text); transform: translateY(101%);
  transition: transform 0.45s var(--ease-out);
}

.btn-line:hover { color: var(--bg); }
.btn-line:hover::before { transform: translateY(0); }

.btn-text { position: relative; z-index: 1; }

.hero-meta {
  position: absolute; bottom: 48px; left: 40px; right: 40px;
  display: flex; justify-content: space-between; align-items: flex-end;
}

.hero-scroll {
  display: flex; align-items: center; gap: 14px;
  font-size: 0.7rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.15em;
}

.scroll-line {
  width: 50px; height: 1px; background: var(--text-faint);
  position: relative; overflow: hidden;
}

.scroll-line::after {
  content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  background: var(--text); animation: scroll-pulse 2s var(--ease) infinite;
}

@keyframes scroll-pulse {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

.hero-role { font-family: "Space Grotesk", sans-serif; font-size: 0.82rem; color: var(--text-dim); }

.cursor-blink { color: var(--text); animation: blink 1s step-end infinite; }

@keyframes blink { 50% { opacity: 0; } }

/* ---------- Split text ---------- */
.split-text .char {
  display: inline-block; transform: translateY(110%);
  transition: transform 0.6s var(--ease-out);
}
.split-text .char.space { width: 0.3em; }
.split-text.visible .char { transform: translateY(0); }
.split-text .word { display: inline-block; overflow: hidden; vertical-align: top; }

/* ---------- Marquee ---------- */
.marquee {
  position: relative; z-index: 2;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 20px 0; overflow: hidden; white-space: nowrap;
}

.marquee-track {
  display: inline-flex; animation: scroll-left 25s linear infinite;
  will-change: transform;
}

.marquee-track span {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem; font-weight: 500;
  letter-spacing: 0.16em; color: var(--text-faint); padding: 0 16px;
}

.marquee-track .sep { padding: 0 8px; opacity: 0.3; }

@keyframes scroll-left {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee:hover .marquee-track { animation-play-state: paused; }

/* ---------- Sections ---------- */
.section {
  position: relative; z-index: 2;
  max-width: var(--maxw); margin: 0 auto; padding: 120px 40px;
}

.section-head {
  display: flex; align-items: baseline; gap: 18px;
  margin-bottom: 64px; padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.section-num {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem; color: var(--text-dim);
  font-weight: 600; letter-spacing: 0.1em;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; overflow: hidden;
}

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

.about-text p { color: var(--text-dim); font-size: 0.95rem; line-height: 1.85; margin-bottom: 20px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }

.stat-num, .stat-num-text {
  display: block; font-family: "Space Grotesk", sans-serif;
  font-size: 2.4rem; font-weight: 700; color: var(--text); line-height: 1;
}

.stat-label {
  display: block; margin-top: 10px; font-size: 0.72rem;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em;
}

/* ---------- Experience ---------- */
.exp-list { display: grid; gap: 0; }

.exp-item {
  display: grid; grid-template-columns: 220px 1fr;
  gap: 48px; padding: 40px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: padding-left 0.5s var(--ease-out);
}

.exp-item:first-child { border-top: 1px solid var(--border); }

[data-hover-line] { position: relative; }

[data-hover-line]::before {
  content: ""; position: absolute; left: 0; top: 0;
  width: 2px; height: 0; background: var(--text);
  transition: height 0.5s var(--ease-out);
}

[data-hover-line]:hover::before { height: 100%; }
.exp-item:hover { padding-left: 20px; }

.exp-meta { display: flex; flex-direction: column; gap: 4px; }
.exp-date { font-size: 0.78rem; color: var(--text-faint); letter-spacing: 0.04em; }
.exp-org { font-size: 0.82rem; color: var(--text-dim); }
.exp-body h3 { font-size: 1.05rem; margin-bottom: 14px; }
.exp-body p { color: var(--text-dim); font-size: 0.9rem; line-height: 1.75; margin-bottom: 18px; }

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

.tags span {
  font-size: 0.68rem; padding: 5px 14px;
  border: 1px solid var(--border); color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.exp-item:hover .tags span { color: var(--text-dim); border-color: rgba(255,255,255,0.15); }
html[data-theme="light"] .exp-item:hover .tags span { border-color: rgba(0,0,0,0.15); }

/* ---------- Research ---------- */
.research-grid { display: grid; grid-template-columns: repeat(2, 1fr); }

.research-item {
  padding: 36px 32px; border: 1px solid var(--border); margin: -0.5px;
  transition: background 0.5s var(--ease); position: relative; overflow: hidden;
}

.research-item::after {
  content: ""; position: absolute; bottom: 0; left: 0;
  width: 0; height: 1px; background: var(--text);
  transition: width 0.6s var(--ease-out);
}

.research-item:hover { background: var(--surface); }
.research-item:hover::after { width: 100%; }

.research-date { font-size: 0.72rem; color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; }
.research-item h3 { font-size: 0.95rem; margin: 12px 0 10px; }
.research-item p { color: var(--text-dim); font-size: 0.85rem; line-height: 1.65; }

/* ---------- Awards ---------- */
.awards-list { display: grid; gap: 0; }

.award-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--border);
  transition: padding-left 0.5s var(--ease-out);
}

.award-row:first-child { border-top: 1px solid var(--border); }
.award-row:hover { padding-left: 20px; }
.award-title { font-size: 0.92rem; font-weight: 500; }
.award-detail { font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; }

/* ---------- Publications ---------- */
.pub-list { display: grid; gap: 0; }

.pub-row {
  padding: 32px 0; border-bottom: 1px solid var(--border);
  transition: padding-left 0.5s var(--ease-out);
}

.pub-row:first-child { border-top: 1px solid var(--border); }
.pub-row:hover { padding-left: 20px; }
.pub-row h3 { font-size: 0.95rem; margin-bottom: 8px; line-height: 1.5; }
.pub-venue { display: block; font-size: 0.82rem; color: var(--text-faint); }

.pub-link {
  display: inline-block; margin-top: 12px; font-size: 0.78rem;
  color: var(--text-dim); letter-spacing: 0.04em; text-transform: uppercase;
  position: relative;
}

.pub-link::after {
  content: ""; position: absolute; left: 0; bottom: -2px;
  width: 0; height: 1px; background: var(--text);
  transition: width 0.4s var(--ease-out);
}

.pub-link:hover { color: var(--text); }
.pub-link:hover::after { width: 100%; }

/* ---------- Education ---------- */
.edu-list { display: grid; gap: 0; }

.edu-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; padding: 28px 0; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; transition: padding-left 0.5s var(--ease-out);
}

.edu-row:first-child { border-top: 1px solid var(--border); }
.edu-row:hover { padding-left: 20px; }
.edu-row h3 { font-size: 0.95rem; }
.edu-row p { color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.edu-right { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.edu-right span:last-child { font-size: 0.75rem; color: var(--text-faint); }
.dim { color: var(--text-faint); font-weight: 400; }
.highlight { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 1.1rem; }

/* ---------- Contact ---------- */
.contact-section { max-width: var(--maxw); margin: 0 auto; padding: 140px 40px; position: relative; z-index: 2; }
.contact-body { max-width: 640px; }
.contact-body .section-num { display: block; margin-bottom: 24px; }
.contact-headline { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; overflow: hidden; }
.contact-headline + .contact-headline { margin-top: 4px; }
.contact-body > p { color: var(--text-dim); margin: 24px 0 40px; line-height: 1.75; }
.contact-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.footer { position: relative; z-index: 2; border-top: 1px solid var(--border); padding: 40px; }

.footer-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 16px;
}

.footer-left { display: flex; gap: 16px; font-size: 0.78rem; color: var(--text-dim); }
.footer-links { display: flex; gap: 28px; }

.footer-links a {
  font-size: 0.75rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
  transition: color 0.3s var(--ease);
}

.footer-links a:hover { color: var(--text); }

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0; transform: translateY(30px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal.visible { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  body, a, button { cursor: auto; }
  .cursor-dot, .cursor-ring { display: none; }
  .nav { padding: 18px 24px; }
  .section { padding: 80px 24px; }
  .hero { padding: 130px 24px 80px; }
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .hero-portrait { order: -1; }
  .hero-portrait img { max-height: 260px; }
  .hero-meta { left: 24px; right: 24px; bottom: 28px; }
  .about-grid { grid-template-columns: 1fr; gap: 48px; }
  .exp-item { grid-template-columns: 1fr; gap: 10px; }
  .research-grid { grid-template-columns: 1fr; }
  .particle-wrap { height: clamp(120px, 20vh, 220px); }

  .nav-links {
    position: fixed; inset: 0; background: var(--bg);
    flex-direction: column; justify-content: center; align-items: center;
    gap: 32px; opacity: 0; pointer-events: none;
    transition: opacity 0.4s var(--ease); z-index: 40;
  }

  .nav-links.open { opacity: 1; pointer-events: auto; }
  .nav-links a { font-size: 1.4rem; }
  .menu-btn { display: flex; }
  .footer { padding: 30px 24px; }
  .contact-section { padding: 80px 24px; }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 24px; }
  .award-row { flex-direction: column; gap: 4px; }
  .edu-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .edu-right { text-align: left; }
  .hero-meta { flex-direction: column; gap: 16px; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .marquee-track { animation: none; }
  .grain { animation: none; }
  .split-text .char { transform: none; }
  .loader { display: none; }
}
