:root {
  --bg: #0b0e14;
  --fg: #e6e6eb;
  --muted: #9aa0b4;
  --accent: #7aa2f7;
  --accent-bright: #a8c8ff;
  --card-border: rgba(122, 162, 247, 0.15);
  --glow: rgba(122, 162, 247, 0.4);
}

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

body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Subtle grid overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(122, 162, 247, 0.015) 2px, rgba(122, 162, 247, 0.015) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(122, 162, 247, 0.015) 2px, rgba(122, 162, 247, 0.015) 4px);
  background-size: 80px 80px;
  z-index: -1;
  pointer-events: none;
}

/* Particles background */
#particles-js {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 15% 20%, rgba(40, 60, 120, 0.35), transparent 50%),
    radial-gradient(circle at 85% 70%, rgba(122, 162, 247, 0.1), transparent 45%),
    var(--bg);
}

#particles-js::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(122, 162, 247, 0.03) 50%, transparent 100%);
  animation: shimmer 15s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ── Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInLeft {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes cardFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes glowPulse {
  0%, 100% {
    text-shadow: 0 0 20px var(--glow), 0 0 40px var(--glow);
  }
  50% {
    text-shadow: 0 0 30px var(--glow), 0 0 60px var(--glow);
  }
}

@keyframes underlineGrow {
  to { width: 100%; }
}

@keyframes rotateGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* ── Navbar ── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(31, 37, 64, 0.5);
}

.navbar-brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.navbar-brand span {
  color: var(--accent);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.navbar-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--fg);
}

/* ── Typography ── */
h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 0.5rem;
  position: relative;
  display: inline-block;
}

h1 span {
  color: var(--accent);
  position: relative;
  display: inline-block;
  animation: glowPulse 3s ease-in-out infinite;
}

/* Animated underline that grows under the name */
h1::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  box-shadow: 0 0 10px var(--glow);
  animation: underlineGrow 1.5s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

p.lead {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 720px;
  margin-top: 1.5rem;
  line-height: 1.75;
}

/* ── Page header ── */
.page-header {
  padding: 8rem 1.5rem 4rem;
  max-width: 1100px;
  margin: auto;
  opacity: 0;
  animation: fadeInUp 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.page-header.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4rem;
}

/* ── Avatar with rotating glow blob ── */
.avatar-wrapper {
  position: relative;
  flex-shrink: 0;
  opacity: 0;
  animation: fadeInRight 1s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

.avatar-wrapper::before {
  content: '';
  position: absolute;
  inset: -8px;
  background: conic-gradient(
    from 0deg,
    var(--accent),
    var(--accent-bright),
    transparent,
    var(--accent)
  );
  border-radius: 50%;
  animation: rotateGlow 8s linear infinite;
  z-index: -1;
  filter: blur(4px);
}

.avatar-link {
  display: block;
  position: relative;
  text-decoration: none;
  cursor: pointer;
}

.avatar {
  display: block;
  width: 256px;
  height: 256px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 0 60px rgba(122, 162, 247, 0.1);
  border: 4px solid var(--bg);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  filter: grayscale(10%);
}

.avatar-link:hover .avatar {
  transform: scale(1.05);
  filter: grayscale(0%);
}

/* Avatar column: text + picture stacked */
.avatar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

/* Curved "Resume" text sitting above the avatar */
.resume-arc {
  width: 320px;
  height: 65px;
  pointer-events: none;
  overflow: visible;
  margin-bottom: -4px;
}

.resume-arc-text {
  font-family: Inter, system-ui, sans-serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  fill: var(--accent-bright);
  opacity: 0;
  transition: opacity 0.8s ease;
}

.avatar-col:hover .resume-arc-text {
  opacity: 1;
}

/* ── Buttons ── */
.actions {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid #2a2f45;
  background: #0f1424;
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn:hover {
  border-color: var(--accent);
  background: rgba(122, 162, 247, 0.05);
  transform: translateY(-2px);
}

/* ── Cards ── */
section {
  max-width: 1100px;
  margin: auto;
  padding: 0 1.5rem 4rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.card {
  background: linear-gradient(180deg, #121826, #0e1320);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 2rem;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px);
}

/* Staggered card entrance animations */
.card:nth-child(1) { animation: cardFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards; }
.card:nth-child(2) { animation: cardFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards; }
.card:nth-child(3) { animation: cardFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards; }
.card:nth-child(4) { animation: cardFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.65s forwards; }
.card:nth-child(5) { animation: cardFadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.8s forwards; }

.card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow:
    0 0 15px rgba(122, 162, 247, 0.2),
    0 0 30px rgba(122, 162, 247, 0.08);
}

.card h3 {
  margin: 0 0 0.75rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.card .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.card .tag {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  background: rgba(122, 162, 247, 0.1);
  color: var(--accent);
  font-weight: 500;
}

.card-link {
  display: inline-block;
  margin-top: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.card-link:hover {
  color: var(--accent-bright);
  text-decoration: underline;
}

/* ── Nav cards (index page) ── */
.nav-cards {
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 720px;
}

.nav-card {
  display: block;
  text-decoration: none;
  background: linear-gradient(180deg, #121826, #0e1320);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 2.25rem;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0;
  transform: translateX(-20px);
}

.nav-card:nth-child(1) {
  animation: slideInLeft 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.8s forwards;
}

.nav-card:nth-child(2) {
  animation: slideInLeft 0.8s cubic-bezier(0.22, 1, 0.36, 1) 1s forwards;
}

.nav-card:hover {
  transform: translateX(8px) translateY(-4px);
  border-color: var(--accent);
  box-shadow:
    0 20px 60px rgba(122, 162, 247, 0.15),
    0 0 40px rgba(122, 162, 247, 0.08);
}

.nav-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-card h3::before {
  content: '\2192';
  font-size: 1.25rem;
  color: var(--accent);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  display: inline-block;
}

.nav-card:hover h3::before {
  transform: translateX(6px);
}

.nav-card p {
  margin: 0;
  color: var(--muted);
}

/* ── Contact menu ── */
.contact {
  position: relative;
  display: inline-block;
  margin-top: 2rem;
}

.contact-btn {
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border: none;
  color: var(--bg);
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 4px 20px rgba(122, 162, 247, 0.3);
}

.contact-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(122, 162, 247, 0.4);
}

.contact-menu {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.5rem);
  transform: translateY(-50%) scale(0.95);
  background: #121826;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  min-width: 280px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 10;
  backdrop-filter: blur(10px);
}

.contact-menu.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(-50%) scale(1);
}

.contact-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.4rem 0;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(122, 162, 247, 0.08);
  font-size: 0.85rem;
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-row span:first-child {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  white-space: nowrap;
}

.contact-menu a {
  color: var(--fg);
  text-decoration: none;
  word-break: break-word;
  font-size: 0.85rem;
  transition: color 0.2s ease;
}

.contact-menu a:hover {
  color: var(--accent-bright);
}

/* ── Paper page ── */
.paper-content {
  max-width: 800px;
  margin: auto;
  padding: 0 1.5rem 4rem;
}

.paper-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  color: var(--fg);
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.5rem;
}

.paper-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--fg);
}

.paper-content p {
  color: var(--muted);
  line-height: 1.85;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.paper-content ul,
.paper-content ol {
  color: var(--muted);
  line-height: 1.85;
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.paper-content li {
  margin-bottom: 0.4rem;
}

.paper-content strong {
  color: var(--fg);
}

.paper-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.paper-meta span {
  display: block;
  margin: 0.25rem 0;
}

.paper-abstract {
  background: linear-gradient(180deg, #121826, #0e1320);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.paper-abstract p {
  margin-bottom: 0;
  font-style: italic;
}

.paper-abstract .label {
  font-weight: 700;
  color: var(--accent);
  font-style: normal;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  display: block;
}

/* ── Resume page ── */
.resume-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.download-btn {
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.download-btn svg {
  flex-shrink: 0;
}

.resume-section {
  margin-bottom: 3rem;
}

.resume-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.resume-entry {
  margin-bottom: 1.75rem;
}

.resume-entry:last-child {
  margin-bottom: 0;
}

.resume-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.resume-entry-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.resume-date {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.resume-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.resume-detail {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.6;
}

.resume-list {
  list-style: none;
  padding-left: 0;
  margin-top: 0.5rem;
}

.resume-list li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.resume-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

.resume-skills {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.resume-skill-group {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.resume-skill-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  min-width: 160px;
}

.resume-awards .resume-entry {
  margin-bottom: 0.75rem;
}

/* ── Footer ── */
footer {
  text-align: center;
  padding: 3rem 1.5rem 4rem;
  color: var(--muted);
  font-size: 0.9rem;
  opacity: 0;
  animation: fadeIn 1s ease 1.2s forwards;
}

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

/* ── Responsive ── */
@media (max-width: 768px) {
  .navbar {
    padding: 0.75rem 1rem;
  }

  .navbar-links {
    gap: 1rem;
  }

  .page-header.hero {
    flex-direction: column-reverse;
    text-align: center;
    gap: 2rem;
  }

  .page-header {
    text-align: center;
  }

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

  .resume-arc {
    width: 200px;
    height: 45px;
  }

  .contact-menu {
    top: calc(100% + 0.75rem);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
  }

  .contact-menu.active {
    transform: translateX(-50%) scale(1);
  }

  .actions {
    justify-content: center;
  }

  h1 {
    font-size: 2.5rem;
  }

  .nav-cards {
    max-width: 100%;
  }

  .grid.two-col {
    grid-template-columns: 1fr;
  }

  .resume-header {
    flex-direction: column;
    align-items: center;
  }

  .resume-skill-label {
    min-width: 100%;
  }
}
