/* ============================================================
   CHAU MING TSUN — Personal Academic Website
   Clean Light Theme Design System (inspired by Wowchemy Academic)
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Colors — Light Theme */
  --bg-primary: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f9fbfd;
  --bg-sidebar: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-hover: #cbd5e1;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-heading: #0f172a;

  --accent: #2563eb;
  --accent-dim: rgba(37, 99, 235, 0.08);
  --accent-hover: #1d4ed8;
  --accent-secondary: #7c3aed;
  --accent-secondary-dim: rgba(124, 58, 237, 0.08);

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-nav: 0 1px 3px rgba(0, 0, 0, 0.08);

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;

  /* Spacing */
  --sidebar-width: 480px;
  --nav-height: 58px;
  --section-gap: 72px;
  --container-padding: 40px;

  /* Transitions */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 20px);
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  line-height: 1.3;
  font-weight: 600;
}

ul {
  list-style: none;
}

::selection {
  background: var(--accent-dim);
  color: var(--text-heading);
}

/* --- Top Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--container-padding);
}

.navbar__brand {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-heading);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.navbar__brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.navbar__links {
  display: flex;
  gap: 4px;
}

.navbar__link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.navbar__link:hover {
  color: var(--text-heading);
  background: var(--bg-secondary);
  text-decoration: none;
}

.navbar__link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Hamburger */
.navbar__hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 8px;
  border: none;
  background: none;
  z-index: 1001;
}

.navbar__hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.navbar__hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.navbar__hamburger.open span:nth-child(2) {
  opacity: 0;
}

.navbar__hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Page Layout --- */
.page-wrapper {
  display: flex;
  margin-top: var(--nav-height);
  min-height: calc(100vh - var(--nav-height));
}

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: var(--nav-height);
  width: var(--sidebar-width);
  height: calc(100vh - var(--nav-height));
  flex-shrink: 0;
  padding: 28px 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

/* Avatar */
.avatar {
  width: 175px;
  height: 175px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

.avatar__initials {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 2px;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar__name {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 3px;
}

.sidebar__position {
  font-size: 1rem;
  color: var(--text-heading);
  margin-top: 16px;
  margin-bottom: 2px;
  font-weight: 400;
}

.sidebar__workplace {
  font-size: 0.92rem;
  color: var(--text-heading);
  margin-bottom: 16px;
  font-weight: 400;
  line-height: 1.4;
}

.sidebar__title {
  font-size: 1rem;
  color: var(--text-heading);
  margin-bottom: 0px;
  font-weight: 400;
}

.sidebar__institution {
  font-size: 1rem;
  color: var(--text-heading);
  margin-bottom: 16px;
  font-weight: 400;
}

.sidebar__institution a {
  color: var(--text-heading);
}

/* Social Icons */
.social-icons {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.social-icons a {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  transition: all var(--transition-medium);
  text-decoration: none;
}

.social-icons a:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
  text-decoration: none;
}

/* Sidebar sections */
.sidebar__divider {
  width: 60%;
  height: 1px;
  background: var(--border-subtle);
  margin: 2px 0 12px;
}

.sidebar__section-title {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.sidebar__interests {
  text-align: left;
  width: 100%;
  margin-bottom: 12px;
}

.sidebar__interests li {
  padding: 2px 0;
  font-size: 0.98rem;
  color: var(--text-secondary);
  position: relative;
  padding-left: 16px;
}

.sidebar__interests li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}

.sidebar__education {
  text-align: left;
  width: 100%;
}

.sidebar__edu-item {
  padding: 4px 0;
  border-left: 2px solid var(--border-subtle);
  padding-left: 12px;
  margin-bottom: 4px;
}

.sidebar__edu-degree {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.sidebar__edu-school {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  padding: var(--container-padding);
  padding-top: 48px;
  padding-right: 150px;
}

/* --- Sections --- */
.section {
  margin-bottom: var(--section-gap);
}

.section__header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.section__icon {
  display: none;
}

.section__title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section__subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* --- About Section --- */
.about__text {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text-secondary);
}

.about__text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.about__cv-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-medium);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.about__cv-link:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  text-decoration: none;
  color: #ffffff;
  transform: translateY(-1px);
}

/* --- Timeline Cards (Experience) --- */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent-secondary), var(--border-subtle));
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-card);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -30px;
  top: 30px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg-primary);
  border: 2px solid var(--accent);
}

.timeline-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
  transform: translateX(4px);
}

.timeline-item__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.timeline-item__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.timeline-item__role {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.timeline-item__date {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.timeline-item__details {
  margin-top: 10px;
}

.timeline-item__details li {
  padding: 3px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
  line-height: 1.6;
}

.timeline-item__details li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}

/* --- Research Cards --- */
.research-group {
  margin-bottom: 32px;
}

.research-group__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
}

.research-card {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-card);
}

.research-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.research-card__text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.research-card__text strong {
  color: var(--text-primary);
}

.research-card__meta {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.research-card__tag {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 500;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.research-card__tag--purple {
  background: var(--accent-secondary-dim);
  color: var(--accent-secondary);
  border-color: rgba(124, 58, 237, 0.15);
}

/* --- Awards Grid --- */
.awards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.award-card {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-medium);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow-card);
}

.award-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.award-card__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.award-card__name {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.5;
}

.award-card__year {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Skills Section --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.skill-category {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-card);
}

.skill-category:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
}

.skill-category__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-category__items li {
  padding: 5px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
  line-height: 1.6;
}

.skill-category__items li::before {
  content: '✦';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.6rem;
  top: 8px;
}

/* --- Conferences / Extras --- */
.conference-list li {
  padding: 10px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding-left: 20px;
  position: relative;
  line-height: 1.6;
}

.conference-list li:last-child {
  border-bottom: none;
}

.conference-list li::before {
  content: '📍';
  position: absolute;
  left: 0;
  font-size: 0.7rem;
}

/* --- Projects Grid --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.project-card {
  display: block;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-medium);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
  text-decoration: none;
}

.project-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.project-card__icon {
  font-size: 1.4rem;
  color: var(--text-secondary);
}

.project-card:hover .project-card__icon {
  color: var(--accent);
}

.project-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
}

.project-card__desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 14px;
}

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

.project-card__tag {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-weight: 500;
  border: 1px solid var(--border-subtle);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 32px var(--container-padding);
  border-top: 1px solid var(--border-subtle);
  margin-top: 40px;
}

.footer__text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Scroll Animations --- */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.stagger-children>*:nth-child(1) {
  transition-delay: 0ms;
}

.stagger-children>*:nth-child(2) {
  transition-delay: 60ms;
}

.stagger-children>*:nth-child(3) {
  transition-delay: 120ms;
}

.stagger-children>*:nth-child(4) {
  transition-delay: 180ms;
}

.stagger-children>*:nth-child(5) {
  transition-delay: 240ms;
}

.stagger-children>*:nth-child(6) {
  transition-delay: 300ms;
}

.stagger-children>*:nth-child(7) {
  transition-delay: 360ms;
}

.stagger-children>*:nth-child(8) {
  transition-delay: 420ms;
}

/* --- Responsive Design --- */
@media (max-width: 900px) {
  :root {
    --sidebar-width: 100%;
    --container-padding: 24px;
    --section-gap: 56px;
  }

  .navbar__links {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-medium);
    box-shadow: var(--shadow-nav);
  }

  .navbar__links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .navbar__hamburger {
    display: flex;
  }

  .page-wrapper {
    flex-direction: column;
  }

  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    height: auto;
    padding: 36px 24px 28px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .avatar {
    width: 120px;
    height: 120px;
  }

  .avatar__initials {
    font-size: 2.2rem;
  }

  .main-content {
    padding: 24px;
    padding-top: 32px;
  }

  .timeline {
    padding-left: 20px;
  }

  .timeline-item__header {
    flex-direction: column;
  }

  .awards-grid {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  :root {
    --container-padding: 16px;
  }

  .section__title {
    font-size: 1.4rem;
  }

  .sidebar__name {
    font-size: 1.3rem;
  }
}