/* ============================================================
   Dr. Henry So — Personal Website
   Design: modern, fresh, gradient-accented academic portfolio
   ============================================================ */

:root {
  --bg: #f7f8fc;
  --bg-tint: #eef1fb;
  --surface: #ffffff;
  --text: #10132a;
  --text-soft: #4a4f6a;
  --text-mute: #7b8098;
  --border: rgba(16, 19, 42, 0.08);
  --brand: #5b53ff;
  --brand-2: #00c2c7;
  --accent: #ff7a59;
  --grad: linear-gradient(120deg, #5b53ff 0%, #7b5cff 40%, #00c2c7 100%);
  --shadow-sm: 0 4px 16px rgba(16, 19, 42, 0.06);
  --shadow-md: 0 14px 40px rgba(16, 19, 42, 0.10);
  --shadow-lg: 0 30px 70px rgba(91, 83, 255, 0.18);
  --radius: 18px;
  --radius-lg: 28px;
  --maxw: 1160px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0a0c1b;
  --bg-tint: #10132a;
  --surface: #14172e;
  --text: #eef0ff;
  --text-soft: #b6bad5;
  --text-mute: #7c82a3;
  --border: rgba(255, 255, 255, 0.09);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 14px 40px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

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

h1, h2, h3, .nav__name { font-family: "Sora", sans-serif; line-height: 1.15; }

a { color: inherit; text-decoration: none; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s;
}
.btn--primary { background: var(--grad); color: #fff; box-shadow: var(--shadow-md); }
.btn--primary:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.btn--ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn--ghost:hover { transform: translateY(-3px); border-color: var(--brand); color: var(--brand); }

/* ---------- Navigation ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  transition: background 0.3s, box-shadow 0.3s, backdrop-filter 0.3s;
}
.nav.scrolled {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border);
}
.nav__inner { display: flex; align-items: center; justify-content: space-between; height: 74px; }
.nav__brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.nav__logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--grad);
  color: #fff; font-family: "Sora"; font-weight: 800; font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.nav__name { font-size: 1.02rem; }
.nav__links { display: flex; gap: 30px; }
.nav__links a {
  font-size: 0.95rem; font-weight: 500; color: var(--text-soft);
  position: relative; padding: 4px 0;
}
.nav__links a::after {
  content: ""; position: absolute; left: 0; bottom: -2px;
  width: 0; height: 2px; background: var(--grad); border-radius: 2px;
  transition: width 0.3s var(--ease);
}
.nav__links a:hover { color: var(--text); }
.nav__links a:hover::after { width: 100%; }
.nav__actions { display: flex; align-items: center; gap: 12px; }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 1.1rem; color: var(--text);
  display: grid; place-items: center;
  transition: transform 0.3s var(--ease), box-shadow 0.25s;
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.08); box-shadow: var(--shadow-sm); }
.nav__burger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 6px; }
.nav__burger span { width: 24px; height: 2.5px; background: var(--text); border-radius: 2px; transition: 0.3s; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  padding: 120px 0 80px;
}
.hero__bg { position: absolute; inset: 0; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; animation: float 16s ease-in-out infinite; }
.orb--1 { width: 460px; height: 460px; background: #5b53ff; top: -120px; left: -80px; }
.orb--2 { width: 380px; height: 380px; background: #00c2c7; bottom: -100px; right: -60px; animation-delay: -5s; }
.orb--3 { width: 300px; height: 300px; background: #ff7a59; top: 40%; right: 25%; opacity: 0.35; animation-delay: -9s; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -40px) scale(1.08); }
}
.hero__inner { position: relative; z-index: 1; max-width: 860px; }
.hero__eyebrow {
  display: inline-block;
  font-weight: 600; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand);
  padding: 8px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  margin-bottom: 24px;
}
.hero__title { font-size: clamp(2.8rem, 7vw, 5rem); font-weight: 800; letter-spacing: -0.02em; }
.hero__title-sub {
  display: block; margin-top: 14px;
  font-size: clamp(1.1rem, 2.4vw, 1.6rem); font-weight: 600;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lead { margin-top: 26px; font-size: 1.18rem; color: var(--text-soft); max-width: 640px; }
.hero__cta { margin-top: 36px; display: flex; gap: 16px; flex-wrap: wrap; }
.hero__stats { margin-top: 60px; display: flex; gap: 48px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; }
.stat__num { font-family: "Sora"; font-size: 2.6rem; font-weight: 800; line-height: 1; display: inline; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat__plus { font-family: "Sora"; font-size: 2rem; font-weight: 800; color: var(--brand); }
.stat__label { margin-top: 8px; font-size: 0.9rem; color: var(--text-mute); max-width: 150px; }
.hero__scroll { position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); z-index: 1; }
.mouse {
  display: block; width: 26px; height: 42px; border: 2px solid var(--text-mute); border-radius: 14px; position: relative;
}
.mouse::before {
  content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 8px; background: var(--brand); border-radius: 3px;
  animation: scroll-dot 1.6s ease-in-out infinite;
}
@keyframes scroll-dot { 0% { opacity: 0; top: 8px; } 40% { opacity: 1; } 100% { opacity: 0; top: 22px; } }

/* ---------- Sections ---------- */
.section { padding: 110px 0; }
.section--tint { background: var(--bg-tint); }
.section__head { max-width: 680px; margin-bottom: 56px; }
.section__kicker { font-weight: 600; font-size: 0.82rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand); }
.section__title { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 800; letter-spacing: -0.02em; margin-top: 12px; }
.section__intro { margin-top: 16px; font-size: 1.1rem; color: var(--text-soft); }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 48px; align-items: start; }
.about__text p { color: var(--text-soft); font-size: 1.08rem; margin-bottom: 20px; }
.about__text strong { color: var(--text); }
.about__card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-md);
  position: sticky; top: 100px;
}
.about__card h3 { font-size: 1.15rem; margin-bottom: 18px; }
.chip-list { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.chip-list li {
  font-size: 0.85rem; font-weight: 500; padding: 8px 14px; border-radius: 999px;
  background: var(--bg-tint); color: var(--text-soft); border: 1px solid var(--border);
}
.about__institution { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.about__institution-label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); }
.about__institution-name { display: block; margin-top: 6px; font-weight: 600; font-family: "Sora"; }

/* ---------- Cards grid ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.3s;
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--grad); opacity: 0; transition: opacity 0.35s; z-index: -1;
}
.card:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); border-color: transparent; }
.card__icon {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.7rem; background: var(--bg-tint); margin-bottom: 20px;
  transition: transform 0.35s var(--ease);
}
.card:hover .card__icon { transform: scale(1.1) rotate(-6deg); }
.card h3 { font-size: 1.2rem; margin-bottom: 10px; }
.card p { color: var(--text-soft); font-size: 0.98rem; }

/* ---------- Roles ---------- */
.roles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.role {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 32px; position: relative; transition: transform 0.35s var(--ease), box-shadow 0.35s;
  border-left: 4px solid transparent; background-clip: padding-box;
}
.role::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad); border-radius: 4px 0 0 4px;
  transform: scaleY(0); transform-origin: top; transition: transform 0.4s var(--ease);
}
.role:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); }
.role:hover::after { transform: scaleY(1); }
.role__tag {
  display: inline-block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 14px;
}
.role h3 { font-size: 1.25rem; margin-bottom: 10px; }
.role p { color: var(--text-soft); font-size: 0.98rem; }

/* ---------- Timeline ---------- */
.timeline { position: relative; max-width: 760px; margin: 0 auto; padding-left: 32px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--brand), var(--brand-2)); border-radius: 2px;
}
.tl-item { position: relative; padding-bottom: 40px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -32px; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 15%, transparent);
}
.tl-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 26px; box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.tl-content:hover { transform: translateX(6px); box-shadow: var(--shadow-md); }
.tl-badge {
  display: inline-block; font-size: 0.76rem; font-weight: 600; color: var(--brand-2);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px;
}
.tl-content h3 { font-size: 1.15rem; margin-bottom: 4px; }
.tl-content p { color: var(--text-soft); font-size: 0.96rem; }

/* ---------- Credentials ---------- */
.creds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.cred {
  text-align: center; padding: 40px 28px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.35s var(--ease), box-shadow 0.35s;
}
.cred:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); }
.cred__abbr {
  display: inline-grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 18px;
  border-radius: 20px; font-family: "Sora"; font-weight: 800; font-size: 1.2rem; color: #fff;
  background: var(--grad); box-shadow: var(--shadow-md);
}
.cred h3 { font-size: 1.1rem; margin-bottom: 8px; }
.cred p { color: var(--text-soft); font-size: 0.94rem; }

/* ---------- Research & Achievements ---------- */
.research-stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 44px;
}
.rstat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 18px; text-align: center; box-shadow: var(--shadow-sm);
}
.rstat__num {
  display: block; font-family: "Sora"; font-weight: 800; font-size: 2rem; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rstat__label { display: block; margin-top: 8px; font-size: 0.82rem; color: var(--text-mute); }

.research__tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.rtab {
  font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--border);
  transition: all 0.25s var(--ease);
}
.rtab:hover { color: var(--brand); border-color: var(--brand); }
.rtab.is-active { color: #fff; background: var(--grad); border-color: transparent; box-shadow: var(--shadow-sm); }

.research__search { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
#researchSearch {
  flex: 1; min-width: 220px; font-family: inherit; font-size: 0.95rem;
  padding: 12px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: border-color 0.25s, box-shadow 0.25s;
}
#researchSearch:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.research__count { font-size: 0.85rem; color: var(--text-mute); white-space: nowrap; }

.research__body { min-height: 120px; }
.hidden { display: none !important; }

/* Publication list */
.pub-list { list-style: none; counter-reset: pub; display: grid; gap: 12px; }
.pub-item {
  counter-increment: pub; position: relative; padding: 18px 20px 18px 56px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.96rem; color: var(--text-soft); line-height: 1.6;
  transition: transform 0.25s var(--ease), box-shadow 0.25s, border-color 0.25s;
}
.pub-item::before {
  content: counter(pub); position: absolute; left: 16px; top: 16px;
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-family: "Sora"; font-weight: 700; font-size: 0.8rem; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, transparent);
}
.pub-item:hover { transform: translateX(4px); box-shadow: var(--shadow-sm); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.pub-item em { color: var(--text); font-style: italic; }
.pub-item strong { color: var(--brand); }

/* Grants */
.grant-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grant-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.grant-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.grant-card__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.grant-card__role {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent);
  padding: 5px 10px; border-radius: 999px;
}
.grant-card__amount { font-family: "Sora"; font-weight: 700; font-size: 0.95rem; color: var(--brand-2); white-space: nowrap; }
.grant-card h4 { font-size: 1.02rem; line-height: 1.4; margin-bottom: 10px; }
.grant-card__meta { font-size: 0.85rem; color: var(--text-mute); }
.grant-card__meta span { color: var(--text-soft); font-weight: 600; }

/* Awards */
.award-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.award-card {
  display: flex; gap: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px; transition: transform 0.3s var(--ease), box-shadow 0.3s;
}
.award-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.award-card__year {
  flex: 0 0 auto; align-self: flex-start; font-family: "Sora"; font-weight: 800; font-size: 0.9rem;
  color: #fff; background: var(--grad); padding: 8px 12px; border-radius: 10px; box-shadow: var(--shadow-sm);
}
.award-card__main h4 { font-size: 1.02rem; line-height: 1.4; margin-bottom: 6px; }
.award-card__level { display: inline-block; font-size: 0.82rem; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.award-card__org { font-size: 0.85rem; color: var(--text-mute); }

/* Teaching */
.teach-group { margin-bottom: 30px; }
.teach-group:last-child { margin-bottom: 0; }
.teach-group h4 {
  font-size: 1.05rem; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--border);
  color: var(--brand);
}
.teach-list { list-style: none; display: grid; gap: 8px; }
.teach-item {
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; font-size: 0.92rem; color: var(--text-soft);
  transition: border-color 0.25s;
}
.teach-item:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }

/* ---------- Contact ---------- */
.section--contact { position: relative; overflow: hidden; }
.contact { text-align: center; max-width: 720px; margin: 0 auto; position: relative; z-index: 1; }
.contact__title { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; letter-spacing: -0.02em; margin: 14px 0 18px; }
.contact__lead { color: var(--text-soft); font-size: 1.15rem; margin-bottom: 34px; }
.contact__actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* ---------- Footer ---------- */
.footer { padding: 34px 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; justify-content: space-between; align-items: center; color: var(--text-mute); font-size: 0.9rem; }

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .about { grid-template-columns: 1fr; }
  .about__card { position: static; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .creds { grid-template-columns: 1fr; }
  .research-stats { grid-template-columns: repeat(3, 1fr); }
  .grant-grid, .award-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .nav__links {
    position: fixed; inset: 74px 0 auto 0;
    flex-direction: column; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 24px 24px; box-shadow: var(--shadow-md);
    transform: translateY(-140%); transition: transform 0.4s var(--ease);
  }
  .nav__links.open { transform: translateY(0); }
  .nav__links a { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .nav__burger { display: flex; }
  .nav__burger.active span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .nav__burger.active span:nth-child(2) { opacity: 0; }
  .nav__burger.active span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
  .cards, .roles { grid-template-columns: 1fr; }
  .research-stats { grid-template-columns: repeat(2, 1fr); }
  .hero__stats { gap: 30px; }
  .footer__inner { flex-direction: column; gap: 8px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
