/* =================================================================
   Theme C — Modern engineering (overrides styles.css)
   ================================================================= */

:root {
  --bg:          #f8fafc;
  --bg-elev:     #ffffff;
  --bg-sunk:     #f1f5f9;
  --fg:          #1e293b;
  --fg-strong:   #0f172a;
  --fg-muted:    #64748b;
  --fg-faint:    #94a3b8;
  --accent:      #1d4ed8;
  --accent-2:    #0ea5e9;
  --accent-soft: #bfdbfe;
  --rule:        #e2e8f0;
  --rule-strong: #cbd5e1;
  --highlight:   #dbeafe;
  --danger:      #dc2626;
  --success:     #16a34a;
  --radius:      14px;
  --shadow:      0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lift: 0 2px 4px rgba(15,23,42,.05), 0 18px 40px rgba(29,78,216,.14);

  --font-display: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif:   "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg:          #0b1220;
  --bg-elev:     #111a2e;
  --bg-sunk:     #0a1020;
  --fg:          #cbd5e1;
  --fg-strong:   #f8fafc;
  --fg-muted:    #94a3b8;
  --fg-faint:    #64748b;
  --accent:      #60a5fa;
  --accent-2:    #22d3ee;
  --accent-soft: #1e3a8a;
  --rule:        #1e293b;
  --rule-strong: #334155;
  --highlight:   #172554;
  --shadow:      0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lift: 0 2px 4px rgba(0,0,0,.3), 0 18px 40px rgba(96,165,250,.18);
}

body {
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "cv11", "ss01";
}
h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.025em; }
h1 { font-size: clamp(38px, 5vw, 60px); line-height: 1.05; letter-spacing: -0.035em; }
h2 { font-size: clamp(26px, 3vw, 36px); }
h3 { font-size: clamp(18px, 1.8vw, 21px); }

/* ---------- scroll progress ---------- */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 100; pointer-events: none;
}

/* ---------- nav ---------- */
.nav { border-bottom-color: transparent; transition: box-shadow .3s ease, border-color .3s ease; }
.nav.scrolled { border-bottom-color: var(--rule); box-shadow: 0 4px 20px rgba(15,23,42,.06); }
.nav-inner { transition: padding .3s ease; }
.nav.scrolled .nav-inner { padding-top: 12px; padding-bottom: 12px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.brand .deg {
  font-family: var(--font-mono); font-size: 10px; color: var(--accent);
  background: var(--highlight); padding: 2px 6px; border-radius: 99px; margin-left: 8px;
}
.nav-links { font-family: var(--font-display); font-size: 14px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.nav-links a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; border-radius: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s ease;
}
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.theme-toggle { border-color: var(--rule-strong); transition: transform .4s ease, background-color .2s, border-color .2s; }
.theme-toggle:hover { transform: rotate(25deg); }

/* ---------- labels ---------- */
.eyebrow, .hero-meta, .section-head .label, .stat-label, .timeline-date,
.pub-venue, .project-card .meta, .project-card .role, .result-count, .contact-row .label,
.footer .footer-col h5, .footer-bottom, .aside-card .label, .research-card .num, .hero-affil dt {
  letter-spacing: 0.06em;
}
.section-head .label {
  border-top: 0; padding: 6px 12px; border-radius: 99px; justify-self: start;
  background: var(--highlight); color: var(--accent); font-weight: 600; text-transform: none; font-size: 12px;
}
.hero-meta .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--highlight); }

/* ---------- hero ---------- */
.hero { position: relative; isolation: isolate; align-items: center; }
.hero::before, .hero::after, .page-header::before {
  content: ''; position: absolute; z-index: -1; border-radius: 50%; filter: blur(60px); opacity: .55;
  animation: drift 18s ease-in-out infinite alternate;
}
.hero::before { width: 460px; height: 460px; top: -80px; left: -120px; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }
.hero::after  { width: 380px; height: 380px; bottom: -60px; right: 10%; background: radial-gradient(circle, color-mix(in oklch, var(--accent-2) 35%, transparent), transparent 70%); animation-duration: 22s; animation-direction: alternate-reverse; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(40px, 30px) scale(1.08); }
  100% { transform: translate(-30px, 50px) scale(.95); }
}
.hero h1 .role-rotator {
  display: inline-block; color: var(--fg-muted); font-weight: 500;
  border-right: 2px solid var(--accent); padding-right: 4px; white-space: nowrap;
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { border-color: transparent; } }
.hero-tagline { font-size: 18px; color: var(--fg-muted); }
.hero-affil { border-top-color: var(--rule); }

.hero > div:first-child > * { opacity: 0; transform: translateY(18px); animation: rise .8s cubic-bezier(.2,.7,.2,1) forwards; }
.hero > div:first-child > *:nth-child(1) { animation-delay: .05s; }
.hero > div:first-child > *:nth-child(2) { animation-delay: .15s; }
.hero > div:first-child > *:nth-child(3) { animation-delay: .25s; }
.hero > div:first-child > *:nth-child(4) { animation-delay: .35s; }
.hero > div:first-child > *:nth-child(5) { animation-delay: .45s; }
.hero-portrait { opacity: 0; animation: pop 1s .3s cubic-bezier(.2,.7,.2,1) forwards; perspective: 900px; }
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: scale(.94) translateY(20px); } to { opacity: 1; transform: none; } }

.portrait-frame {
  border-radius: 22px; border: 0; box-shadow: var(--shadow-lift);
  transition: transform .25s ease-out; transform-style: preserve-3d; will-change: transform;
}
.portrait-frame::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.28), transparent 45%);
  mix-blend-mode: soft-light;
}
.hero-portrait::before {
  content: ''; position: absolute; inset: 14px -14px -14px 14px; border-radius: 22px; z-index: -1;
  border: 2px solid var(--accent); opacity: .35;
}
.portrait-caption { font-family: var(--font-mono); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none;
  border-radius: 10px; border: 1px solid var(--rule-strong); color: var(--fg-strong); padding: 12px 20px;
  position: relative; overflow: hidden;
}
.btn:hover { background: var(--bg-elev); color: var(--fg-strong); border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in oklch, var(--accent) 85%, black); color: #fff; box-shadow: var(--shadow-lift); }
.btn.primary::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-20deg); animation: shine 4.5s ease-in-out infinite;
}
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }

/* ---------- stats ---------- */
.stats { border-color: var(--rule); }
.stat { border-left-color: var(--rule); }
.stat-num {
  font-family: var(--font-display); font-weight: 750; font-size: 52px; letter-spacing: -0.04em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { text-transform: none; font-family: var(--font-display); font-size: 13px; font-weight: 500; }

/* ---------- cards (shared) ---------- */
.aside-card, .research-card, .project-card {
  border-radius: var(--radius); border: 1px solid var(--rule); background: var(--bg-elev);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s ease, border-color .35s ease;
}
.research-card:hover, .project-card:hover, .aside-card:hover {
  transform: translateY(-6px); box-shadow: var(--shadow-lift);
  border-color: color-mix(in oklch, var(--accent) 45%, var(--rule)); background: var(--bg-elev);
}
.research-card::before, .project-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in oklch, var(--accent) 12%, transparent), transparent 60%);
}
.research-card:hover::before, .project-card:hover::before { opacity: 1; }
.research-card::after, .project-card::after {
  content: ''; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0); transform-origin: left; transition: transform .45s ease;
}
.research-card:hover::after, .project-card:hover::after { transform: scaleX(1); }

.research-grid { gap: 20px; border: 0; }
.research-card { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.research-card .num {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  background: var(--highlight); color: var(--accent); font-weight: 700;
}
.research-card h3 { font-family: var(--font-display); font-weight: 650; }
.research-card li::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); top: 15px; }

.project-grid { gap: 20px; background: none; border: 0; }
.project-card h3 { font-family: var(--font-display); font-weight: 650; }
.project-card .meta { text-transform: none; font-size: 12px; }
.project-card .client { color: var(--accent); }
.project-card .status {
  padding: 3px 10px; border-radius: 99px; background: var(--bg-sunk); color: var(--fg-muted); font-weight: 600;
}
.project-card .status::before { background: var(--success); box-shadow: 0 0 0 0 var(--success); animation: ping 2.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--success) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 7px transparent; } }
.project-card .role { text-transform: none; font-family: var(--font-display); font-weight: 600; font-size: 13px; border-top: 1px solid var(--rule); }
.project-card .role a { color: var(--accent); text-decoration: none; }
.project-card .role a:hover { text-decoration: underline; }

/* ---------- timeline ---------- */
.timeline-list { border-left: 2px solid var(--rule); position: relative; }
.timeline-list::before {
  content: ''; position: absolute; left: -2px; top: 0; width: 2px; height: var(--tl, 0%);
  background: linear-gradient(var(--accent), var(--accent-2)); transition: height .15s linear;
}
.timeline-item { border-top-color: var(--rule); transition: background-color .3s ease; border-radius: 0 12px 12px 0; }
.timeline-item:hover { background: var(--bg-elev); }
.timeline-item::before { left: -7px; width: 12px; height: 12px; border: 2px solid var(--accent); background: var(--bg); }
.timeline-item.current::before { background: var(--accent); animation: pulse 2.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 55%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }
.timeline-content .where { font-style: normal; color: var(--accent); font-weight: 500; }

/* ---------- publications ---------- */
.pub-card { border-radius: 12px; padding: 24px 20px; transition: background-color .3s ease, transform .3s ease; }
.pub-card:hover { background: var(--bg-elev); transform: translateX(6px); box-shadow: inset 3px 0 0 var(--accent); }
.pub-body h4 { font-family: var(--font-display); font-weight: 650; }
.pub-authors .me { font-style: normal; color: var(--accent); font-weight: 700; }
.pub-venue { text-transform: none; font-size: 12px; }
.tag { border-radius: 99px; text-transform: none; letter-spacing: 0; font-family: var(--font-display); font-weight: 600; font-size: 11px; padding: 3px 10px; }
.tag.journal { color: #1d4ed8; background: #dbeafe; border-color: transparent; }
.tag.conference { color: #0f766e; background: #ccfbf1; border-color: transparent; }
.tag.patent { color: #7c3aed; background: #ede9fe; border-color: transparent; }
[data-theme="dark"] .tag.journal { color: #93c5fd; background: #172554; }
[data-theme="dark"] .tag.conference { color: #5eead4; background: #042f2e; }
[data-theme="dark"] .tag.patent { color: #c4b5fd; background: #2e1065; }
.doi-badge { border-radius: 8px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.doi-badge:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pub-abstract { border-left-color: var(--accent-soft); }
.search-input, .chip { border-radius: 10px; font-family: var(--font-display); }
.chip { text-transform: none; letter-spacing: 0; font-weight: 600; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- page header (inner pages) ---------- */
.page-header { position: relative; isolation: isolate; overflow: hidden; }
.page-header::before { width: 520px; height: 520px; top: -260px; right: -120px; background: radial-gradient(circle, var(--accent-soft), transparent 70%); }
.page-header h1 { background: linear-gradient(120deg, var(--fg-strong) 30%, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- contact ---------- */
.contact-row .value { font-family: var(--font-display); }
.contact-form input, .contact-form select, .contact-form textarea {
  border-radius: 10px !important; font-family: var(--font-display) !important;
  transition: border-color .2s ease, box-shadow .2s ease !important;
}
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus {
  border-color: var(--accent) !important; box-shadow: 0 0 0 4px var(--highlight) !important; outline: none;
}

/* ---------- footer ---------- */
.footer { background: var(--bg-elev); }
.footer .brand-block .brand { font-size: 24px; }

/* ---------- reveal with stagger ---------- */
.fade-in { transform: translateY(28px); transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1); }
.stagger > * { opacity: 0; transform: translateY(24px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.visible .stagger > *, .stagger.visible > * { opacity: 1; transform: none; }
.visible .stagger > *:nth-child(2), .stagger.visible > *:nth-child(2) { transition-delay: .08s; }
.visible .stagger > *:nth-child(3), .stagger.visible > *:nth-child(3) { transition-delay: .16s; }
.visible .stagger > *:nth-child(4), .stagger.visible > *:nth-child(4) { transition-delay: .24s; }
.visible .stagger > *:nth-child(5), .stagger.visible > *:nth-child(5) { transition-delay: .32s; }
.visible .stagger > *:nth-child(6), .stagger.visible > *:nth-child(6) { transition-delay: .40s; }
.visible .stagger > *:nth-child(n+7), .stagger.visible > *:nth-child(n+7) { transition-delay: .48s; }

::selection { background: var(--accent); color: #fff; }

/* ---------- accessibility: respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fade-in, .stagger > *, .hero > div:first-child > *, .hero-portrait { opacity: 1 !important; transform: none !important; }
}

@media (max-width: 960px) {
  .hero::before, .hero::after { opacity: .35; }
  .hero-portrait::before { display: none; }
}
