/* ============ base ============ */
:root {
  --bg: #fafaf8;
  --bg-card: #ffffff;
  --bg-elev: #f1f3f6;
  --text: #374151;
  --heading: #111827;
  --muted: #6b7280;
  --accent: #1d5fbf;
  --accent-dim: rgba(29, 95, 191, 0.08);
  --accent-contrast: #ffffff;
  --border: #e3e6ea;
  --hover-border: rgba(29, 95, 191, 0.35);
  --nav-bg: rgba(250, 250, 248, 0.9);
  --shadow: rgba(17, 24, 39, 0.10);
  --particle: 29, 95, 191;
  --mono: "JetBrains Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417; --bg-card: #1a1d22; --bg-elev: #22262d; --text: #c8ccd2; --heading: #f2f3f5;
    --muted: #8b929c; --accent: #7cb7ff; --accent-dim: rgba(124, 183, 255, 0.12); --accent-contrast: #0b1a2e;
    --border: #2a2f37; --hover-border: rgba(124, 183, 255, 0.45); --nav-bg: rgba(18, 20, 23, 0.88);
    --shadow: rgba(0, 0, 0, 0.45); --particle: 124, 183, 255; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #121417; --bg-card: #1a1d22; --bg-elev: #22262d; --text: #c8ccd2; --heading: #f2f3f5;
    --muted: #8b929c; --accent: #7cb7ff; --accent-dim: rgba(124, 183, 255, 0.12); --accent-contrast: #0b1a2e;
    --border: #2a2f37; --hover-border: rgba(124, 183, 255, 0.45); --nav-bg: rgba(18, 20, 23, 0.88);
    --shadow: rgba(0, 0, 0, 0.45); --particle: 124, 183, 255; color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  transition: background 0.25s, color 0.25s;
}
.accent { color: var(--accent); }
.muted { color: var(--muted); font-size: 0.85rem; }
a { color: var(--accent); text-decoration: none; }

#particles {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}

/* ============ nav ============ */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 3rem;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  transition: transform 0.3s, box-shadow 0.3s;
}
#navbar.hidden { transform: translateY(-100%); }
#navbar.scrolled { box-shadow: 0 1px 0 var(--border), 0 6px 20px var(--shadow); }
.logo { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; color: var(--heading); }
#nav-links { display: flex; gap: 2rem; list-style: none; margin-left: auto; margin-right: 1.6rem; }
#nav-links a {
  color: var(--text); font-size: 0.9rem; font-weight: 500;
  transition: color 0.2s;
}
#nav-links a:hover, #nav-links a.active { color: var(--accent); }
#nav-toggle { display: none; background: none; border: none; color: var(--heading); font-size: 1.5rem; cursor: pointer; }

/* ============ hero + about (first view) ============ */
.hero {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 6rem 2rem 4.5rem;
  position: relative; z-index: 1;
}
.hero-grid {
  width: 100%; max-width: 1160px;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 3.5rem; align-items: center;
}
.hero-hello { font-family: var(--mono); color: var(--accent); margin-bottom: 0.5rem; }
.hero-name {
  font-size: clamp(2.4rem, 5.2vw, 4rem);
  font-weight: 800; color: var(--heading); line-height: 1.1;
}
.hero-tagline {
  font-size: clamp(1.25rem, 3vw, 1.9rem);
  color: var(--muted); font-weight: 700; margin: 0.5rem 0 1.2rem;
}
.hero-tagline .hl { color: var(--heading); }
.cursor { animation: blink 1s step-end infinite; color: var(--accent); font-weight: 400; }
@keyframes blink { 50% { opacity: 0; } }
.hero-sub { max-width: 520px; margin-bottom: 2rem; }
.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-links { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin-top: 1.8rem; font-family: var(--mono); font-size: 0.8rem; }
.hero-links a { color: var(--muted); transition: color 0.2s; }
.hero-links a:hover { color: var(--accent); }

.btn {
  display: inline-block; padding: 0.8rem 1.8rem; border-radius: 8px;
  font-weight: 600; font-size: 0.95rem; transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: 0 4px 14px var(--accent-dim); }
.btn-primary:hover { box-shadow: 0 6px 18px var(--hover-border); }
.btn-ghost { border: 1.5px solid var(--accent); color: var(--accent); }
.btn-ghost:hover { background: var(--accent-dim); }

.avatar-ring {
  width: 260px; height: 260px; border-radius: 50%; padding: 6px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--border));
}
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; border: 5px solid var(--bg); }
.avatar-ring.small { width: 104px; height: 104px; padding: 3px; }
.avatar-ring.small img { border-width: 3px; }

.about-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.7rem 1.8rem; display: flex; flex-direction: column; gap: 1.05rem;
  box-shadow: 0 18px 44px var(--shadow);
}
.about-card > p { font-size: 0.94rem; }
.about-head { display: flex; align-items: center; gap: 1.2rem; }
.about-label { font-family: var(--mono); font-size: 0.8rem; color: var(--heading); margin-bottom: 0.2rem; }
.about-role { color: var(--heading); font-weight: 700; line-height: 1.35; }
.about-meta { color: var(--muted); font-size: 0.85rem; }
.highlights { list-style: none; display: grid; gap: 0.45rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.highlights li { display: grid; grid-template-columns: 7.2rem 1fr; gap: 0.8rem; align-items: baseline; font-size: 0.88rem; }
.highlights b { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.tool-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tool-chips li { font-family: var(--mono); font-size: 0.7rem; padding: 0.2rem 0.65rem; border-radius: 999px; background: var(--accent-dim); color: var(--accent); }

.scroll-hint {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  width: 26px; height: 44px; border: 2px solid var(--muted); border-radius: 14px;
}
.scroll-hint span {
  position: absolute; top: 8px; left: 50%; width: 4px; height: 8px;
  background: var(--accent); border-radius: 2px; transform: translateX(-50%);
  animation: scrollhint 1.8s ease-in-out infinite;
}
@keyframes scrollhint { 0% { opacity: 1; top: 8px; } 70% { opacity: 0; top: 24px; } 100% { opacity: 0; } }

/* ============ sections ============ */
.section { max-width: 1080px; margin: 0 auto; padding: 6rem 2rem; position: relative; z-index: 1; }
.section-title {
  font-size: clamp(1.6rem, 4vw, 2.1rem); color: var(--heading);
  margin-bottom: 3rem; display: flex; align-items: center; gap: 0.8rem;
}
.section-num { font-family: var(--mono); color: var(--accent); font-size: 0.75em; font-weight: 400; }
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--border); margin-left: 1rem;
}

/* reveal-on-scroll */
.js .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.visible { opacity: 1; transform: none; }

/* ============ projects ============ */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.6rem; }
.card {
  background: var(--bg-card); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px var(--shadow); border-color: var(--hover-border); }
.card-media { aspect-ratio: 16/9; background: var(--bg-elev); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.card:hover .card-media img { transform: scale(1.03); }
.card-media.fig-light { background: #fff; }
.card-media.fig-light img { object-fit: contain; }

/* ============ featured research ============ */
.section-lead { max-width: 760px; margin: -1rem 0 2.2rem; font-size: 1.02rem; }
.feature-list { display: flex; flex-direction: column; gap: 2rem; margin-bottom: 3.5rem; }
.feature {
  display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr); align-items: stretch;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.feature:hover { border-color: var(--hover-border); box-shadow: 0 12px 30px var(--shadow); }
.feature:nth-child(even) .feature-media { order: 2; }
.feature-media { display: flex; align-items: center; justify-content: center; background: #fff; padding: 0.8rem; min-height: 280px; }
.feature-media img { width: 100%; max-height: 360px; object-fit: contain; }
.feature-media.video { background: #0f1115; padding: 0; }
.feature-media video { display: block; height: 100%; max-height: 420px; width: auto; max-width: 100%; }
.feature-body { padding: 1.8rem; display: flex; flex-direction: column; gap: 0.7rem; justify-content: center; }
.feature-body h3 { color: var(--heading); font-size: 1.3rem; }
.feature-kicker { font-family: var(--mono); font-size: 0.76rem; color: var(--accent); }
.feature-body .tags { margin-top: 0.3rem; }
.feature-body .card-links { display: flex; gap: 1.2rem; }
.feature.wide { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.feature-media.yt { background: transparent; align-items: center; min-height: 0; padding: 1.2rem; }
.yt-play, .yt iframe { border-radius: 10px; overflow: hidden; }
.yt-play, .yt iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.yt-play { position: relative; padding: 0; background: none; cursor: pointer; }
.yt-play img { width: 100%; height: 100%; max-height: none; object-fit: cover; display: block; }
.yt-icon {
  position: absolute; left: 14px; top: 14px; width: 60px; height: 42px;
  background: rgba(15, 17, 21, 0.78); border: 1px solid rgba(255, 255, 255, 0.5); border-radius: 12px; transition: background 0.2s;
}
.yt-icon::after {
  content: ""; position: absolute; left: 50%; top: 50%; transform: translate(-35%, -50%);
  border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff;
}
.yt-play:hover .yt-icon, .yt-play:focus-visible .yt-icon { background: var(--accent); }
.chapters { list-style: none; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chapters button {
  font-family: var(--mono); font-size: 0.72rem; color: var(--text); background: transparent;
  border: 1px solid var(--border); border-radius: 999px; padding: 0.28rem 0.7rem; cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.chapters button:hover, .chapters button.active { border-color: var(--accent); color: var(--accent); }
.chapters .mine button { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.credit { font-size: 0.78rem; color: var(--muted); }
.subsection-title { color: var(--heading); font-size: 1.1rem; margin-bottom: 1.4rem; }
.media-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 3rem; background: radial-gradient(circle at 30% 30%, var(--bg-card), var(--bg-elev));
}
.card-body { padding: 1.3rem; display: flex; flex-direction: column; gap: 0.6rem; flex: 1; }
.card-body h3 { color: var(--heading); font-size: 1.05rem; }
.card-body p { font-size: 0.9rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; margin-top: auto; }
.tags li {
  font-family: var(--mono); font-size: 0.72rem; color: var(--accent);
  background: var(--accent-dim); padding: 0.2rem 0.6rem; border-radius: 999px;
}
.card-links { font-size: 0.85rem; font-weight: 600; }

/* ============ publications ============ */
.pub-list { display: flex; flex-direction: column; gap: 1.6rem; }
.pub {
  display: grid; grid-template-columns: 220px 1fr; gap: 1.5rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; transition: border-color 0.25s, transform 0.25s;
}
.pub:hover { border-color: var(--hover-border); box-shadow: 0 10px 26px var(--shadow); }
.pub-media { min-height: 130px; }
.pub-media .media-placeholder { font-size: 2.2rem; }
.pub-media img { width: 100%; height: 100%; object-fit: cover; }
.pub-body { padding: 1.2rem 1.2rem 1.2rem 0; }
.pub-body h3 { color: var(--heading); font-size: 1.02rem; margin-bottom: 0.3rem; }
.pub-meta { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); margin-bottom: 0.5rem; }
.pub-authors { font-size: 0.82rem; margin-bottom: 0.3rem; opacity: 0.85; }
.pub-media.fig { display: flex; align-items: center; justify-content: center; background: #fff; padding: 0.5rem; cursor: zoom-in; }
.pub-media.fig img { width: 100%; height: 100%; max-height: 240px; object-fit: contain; }

/* ============ cv timeline ============ */
.cv-actions { margin-bottom: 3rem; }
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--border));
}
.tl-item { position: relative; padding-bottom: 2.4rem; }
.tl-dot {
  position: absolute; left: -2rem; top: 6px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
.tl-content h3 { color: var(--heading); font-size: 1.05rem; }
.tl-meta { font-family: var(--mono); font-size: 0.8rem; color: var(--accent); margin: 0.2rem 0 0.4rem; }

/* ============ contact / footer ============ */
.contact { text-align: center; }
.contact .section-title { justify-content: center; }
.contact .section-title::after { display: none; }
.contact p { max-width: 560px; margin: 0 auto 2rem; }
.socials { margin-top: 2.5rem; display: flex; gap: 2rem; justify-content: center; font-family: var(--mono); font-size: 0.9rem; }
footer { text-align: center; padding: 2rem; font-size: 0.8rem; color: var(--muted); position: relative; z-index: 1; }

/* ============ theme toggle ============ */
.nav-right { display: flex; align-items: center; gap: 1.6rem; }
#theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card);
  color: var(--heading); cursor: pointer; display: grid; place-items: center; transition: border-color 0.2s;
}
#theme-toggle:hover { border-color: var(--accent); }
#theme-toggle svg { width: 18px; height: 18px; }
#theme-toggle .sun { display: none; }
.is-dark #theme-toggle .sun { display: block; }
.is-dark #theme-toggle .moon { display: none; }

/* ============ news + citations ============ */
.news { margin-bottom: 2.6rem; }
.news-list { list-style: none; display: grid; gap: 0.55rem; border-left: 2px solid var(--border); padding-left: 1.2rem; }
.news-list li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; font-size: 0.93rem; }
.news-list time { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); padding-top: 0.15rem; }
.bib { margin-top: 0.6rem; font-size: 0.85rem; }
.bib summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.bib pre {
  position: relative; margin-top: 0.5rem; padding: 0.9rem 1rem; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 8px; font-family: var(--mono); font-size: 0.72rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.copy-bib {
  position: absolute; top: 0.5rem; right: 0.5rem; font-family: var(--mono); font-size: 0.7rem; padding: 0.2rem 0.6rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text); cursor: pointer;
}
.copy-bib:hover { border-color: var(--accent); color: var(--accent); }

/* ============ awards ============ */
.awards-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.award {
  display: grid; grid-template-columns: 2.6rem 1fr; gap: 0.95rem; align-items: start;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.15rem 1.2rem;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s;
}
.award:hover { transform: translateY(-3px); box-shadow: 0 12px 30px var(--shadow); border-color: var(--hover-border); }
.award-icon {
  width: 2.6rem; height: 2.6rem; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent);
}
.award-icon svg { width: 1.35rem; height: 1.35rem; }
.award-kind {
  display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline;
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); flex-wrap: wrap;
}
.award-year { color: var(--accent); font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.award h3 { color: var(--heading); font-size: 1rem; line-height: 1.35; margin: 0.25rem 0 0.2rem; }
.award-issuer { font-size: 0.85rem; color: var(--muted); }
.award-detail { font-size: 0.86rem; margin-top: 0.45rem; line-height: 1.55; }
.award-body { min-width: 0; }
.award:not(.featured) { grid-template-columns: 1fr; gap: 0.75rem; align-content: start; }
.award:not(.featured) .award-icon { width: 2.2rem; height: 2.2rem; }
.award:not(.featured) .award-icon svg { width: 1.15rem; height: 1.15rem; }
.award.featured { grid-column: span 2; border-color: var(--hover-border); background: linear-gradient(135deg, var(--accent-dim), transparent 60%), var(--bg-card); }
.award.featured h3 { font-size: 1.12rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .cursor, .scroll-hint span { animation: none; }
}

/* ============ responsive ============ */
@media (max-width: 1020px) and (min-width: 861px) {
  .awards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .hero { padding: 6.5rem 1.2rem 4.5rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2.2rem; }
  .about-card { padding: 1.3rem; }
  .avatar-ring.small { width: 84px; height: 84px; }
  .highlights li { grid-template-columns: 1fr; gap: 0; }
  .pub { grid-template-columns: 1fr; }
  .feature { grid-template-columns: 1fr; }
  .feature.wide { grid-template-columns: 1fr; }
  .feature.wide .feature-media { order: 0; }
  .feature-media.yt { padding: 0.8rem 0.8rem 0; }
  .feature:nth-child(even) .feature-media { order: 0; }
  .feature-media { min-height: 200px; }
  .feature-body { padding: 1.2rem; }
  .pub-body { padding: 0 1.2rem 1.2rem; }
  #nav-toggle { display: block; }
  .nav-right { gap: 0.9rem; }
  .news-list li { grid-template-columns: 1fr; gap: 0; }
  .awards-grid { grid-template-columns: 1fr; }
  .award.featured { grid-column: auto; }
  #nav-links {
    position: absolute; top: 100%; right: 0; left: 0; margin: 0;
    flex-direction: column; align-items: center; gap: 1.2rem; padding: 1.5rem 0;
    background: var(--bg); border-bottom: 1px solid var(--border); display: none;
  }
  #nav-links.open { display: flex; }
}
