/* ============================================================
   Academic Personal Homepage — Haodong Lei
   ============================================================ */

/* ---------- CSS Variables (Light Theme) ---------- */
:root {
  --color-bg:            #edf0f2;
  --color-bg-alt:        #e3e7ea;
  --color-surface:       #f4f5f6;
  --color-border:        #cdd4da;
  --color-text:          #3a4450;
  --color-text-secondary:#5f6f7a;
  --color-text-muted:    #7b8b8a;
  --color-primary:       #6B7D8A;
  --color-primary-hover: #5a6b77;
  --color-primary-light: #dce3e8;
  --color-accent:        #9B8EA4;
  --color-card-shadow:   0 1px 3px rgba(100,110,120,0.08);
  --color-card-hover:    0 4px 12px rgba(100,110,120,0.12);
  --color-tag-bg:        #e6ede8;
  --color-tag-text:      #4a6658;
  --radius-sm:           6px;
  --radius-md:           10px;
  --radius-lg:           16px;
  --font-sans:           'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:           'JetBrains Mono', 'Fira Code', monospace;
  --transition:          0.2s ease;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
  --color-bg:            #1c2128;
  --color-bg-alt:        #222830;
  --color-surface:       #272d36;
  --color-border:        #363e48;
  --color-text:          #d3dbe3;
  --color-text-secondary:#94a3b0;
  --color-text-muted:    #6c7a88;
  --color-primary:       #8DA399;
  --color-primary-hover: #9bb5aa;
  --color-primary-light: #28322e;
  --color-card-shadow:   0 1px 3px rgba(0,0,0,0.2);
  --color-card-hover:    0 4px 16px rgba(0,0,0,0.3);
  --color-tag-bg:        #2a3532;
  --color-tag-text:      #8DA399;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background var(--transition), color var(--transition);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* All headings use pixel font */
h1, h2, h3, h4, h5, h6 {
  font-family: 'VT323', monospace;
}

/* ---------- Container ---------- */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---------- Top Navigation ---------- */
.top-nav {
  display: flex;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem 0;
  max-width: 860px;
  margin: 0 auto;
}
.top-nav a {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.top-nav a:hover,
.top-nav a.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  text-decoration: none;
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-text-secondary);
  box-shadow: var(--color-card-shadow);
  transition: all var(--transition);
}
.theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--color-card-hover);
}
.sun-icon, .moon-icon { transition: opacity var(--transition); }
[data-theme="light"] .moon-icon { display: none; }
[data-theme="dark"]  .sun-icon  { display: none; }

/* ---------- Hero Section ---------- */
.hero {
  padding: 3.5rem 0 2.5rem;
}
.hero-content {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}
.hero-avatar {
  flex-shrink: 0;
}
.hero-avatar img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-border);
  box-shadow: var(--color-card-shadow);
}
.hero-text {
  flex: 1;
  min-width: 0;
}
.hero-name {
  font-family: 'VT323', monospace;
  font-size: 2rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
  color: var(--color-text);
  text-shadow: 3px 3px 0 var(--color-primary-light);
  image-rendering: pixelated;
}
.hero-name-cn {
  font-family: 'ZCOOL KuaiLe', 'Noto Sans SC', var(--font-sans);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--color-text);
  margin-left: 0.75rem;
  text-shadow: 2px 2px 0 var(--color-primary-light);
}
.hero-bio {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}
.hero-affiliation,
.hero-location {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.2rem;
}
.affil-icon, .loc-icon { margin-right: 0.3rem; }

/* ---------- CV Buttons ---------- */
.cv-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

/* ---------- Social Links ---------- */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-family: 'VT323', monospace;
  font-size: 1rem;
  font-weight: 400;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.social-link:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  text-decoration: none;
}
.social-wechat {
  cursor: default;
}
.social-clawhub {
  color: #c27a7a;
  border: 1px solid #c27a7a;
  background: rgba(194, 122, 122, 0.08);
}
.social-clawhub:hover {
  color: #a86565;
  background: rgba(194, 122, 122, 0.18);
  border-color: #a86565;
}

/* ---------- Buttons (pixel style) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 3px solid var(--color-text);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-text);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  color: #ffffff;
  text-decoration: none;
}
.btn-outline {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-text);
}
.btn-outline:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
  text-decoration: none;
}
.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-width: 2px;
}

/* ---------- Sections ---------- */
.section {
  padding: 3rem 0;
  border-top: 1px solid var(--color-border);
}
.section-alt {
  background: var(--color-bg-alt);
}
.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--color-text);
}
.section-icon { font-size: 1.3rem; }
.section-body {
  font-size: 0.98rem;
  color: var(--color-text-secondary);
  line-height: 1.8;
}
.section-body p { margin-bottom: 0.75rem; }
.section-body p:last-child { margin-bottom: 0; }

/* ---------- Timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.timeline-item {
  display: flex;
  gap: 1.15rem;
  align-items: flex-start;
}
.timeline-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #ffffff;
}
.timeline-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.timeline-content {
  flex: 1;
  min-width: 0;
}
.timeline-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.timeline-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.timeline-title a {
  color: var(--color-text);
}
.timeline-title a:hover {
  color: var(--color-primary);
}
.timeline-role-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.1rem 0.55rem;
  border-radius: 99px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-left: 0.5rem;
  vertical-align: middle;
}
.timeline-desc {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.15rem;
}
.timeline-supervisor {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* ---------- Publications ---------- */
.pub-section {
  margin-bottom: 1.5rem;
}
.pub-section-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--color-primary);
  display: inline-block;
}
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---------- Publication Card ---------- */
.pub-card {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--color-card-shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.pub-card:hover {
  box-shadow: var(--color-card-hover);
  transform: translateY(-1px);
}
.pub-thumb {
  flex-shrink: 0;
  width: 180px;
}
.pub-thumb img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  object-fit: cover;
  aspect-ratio: 16/9;
}
.pub-body {
  flex: 1;
  min-width: 0;
}
.pub-title {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--color-text);
  line-height: 1.5;
}
.pub-authors {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.35rem;
  line-height: 1.5;
}
.pub-authors em {
  font-style: normal;
  font-weight: 600;
  color: var(--color-text);
}
.pub-venue {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.pub-venue-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.1rem 0.55rem;
  border-radius: 99px;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
}
.pub-year-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.1rem 0.55rem;
  border-radius: 99px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-right: 0.4rem;
}
.pub-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- Footer ---------- */
.footer {
  padding: 2rem 0;
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
}
.footer-text {
  margin-bottom: 0.25rem;
}
.footer-credit a {
  color: var(--color-text-secondary);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .hero-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .hero-avatar img {
    width: 120px;
    height: 120px;
  }
  .hero-name {
    font-size: 1.55rem;
  }
  .hero-name-cn {
    display: block;
    margin-left: 0;
    margin-top: 0.2rem;
  }
  .social-links {
    justify-content: center;
  }
  .cv-buttons {
    justify-content: center;
  }
  .pub-card {
    flex-direction: column;
  }
  .pub-thumb {
    width: 100%;
    max-width: 320px;
  }
  .timeline-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .section-title {
    font-size: 1.2rem;
  }
  .container {
    padding: 0 1rem;
  }
}

@media (max-width: 480px) {
  .hero-name {
    font-size: 1.35rem;
  }
  .hero {
    padding: 2.5rem 0 1.5rem;
  }
  .section {
    padding: 2rem 0;
  }
  .btn {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
  }
}

/* ============================================================
   Pixel Pet — AI Companion
   ============================================================ */
.pixel-pet {
  position: fixed;
  bottom: 10px;
  left: 10px;
  right: auto;
  z-index: 999;
  cursor: pointer;
  transition: transform 0.3s ease;
  image-rendering: pixelated;
}
.pixel-pet:hover {
  transform: scale(1.08);
}
.pixel-pet.active {
  transform: scale(1.12);
}
.pet-video-wrapper {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: 14px;
  overflow: hidden;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.pet-video {
  display: block;
  max-width: 140px;
  max-height: 140px;
  width: auto;
  height: auto;
  clip-path: inset(0 round 12px);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  pointer-events: none;
}

/* ---- Wait bubble (wind-magic NPC speech) ---- */
.pet-bubble {
  position: fixed;
  bottom: 158px;
  left: 10px;
  right: auto;
  z-index: 997;
  max-width: 210px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-family: 'VT323', 'ZCOOL KuaiLe', monospace;
  font-size: 1rem;
  line-height: 1.3;
  color: var(--color-text);
  background: var(--color-primary-light);
  border: 3px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.15);
  image-rendering: pixelated;
  opacity: 0;
  transform: translateY(6px) scale(0.92);
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.12s steps(2), transform 0.12s steps(2);
}
.pet-bubble.show {
  visibility: visible;
  animation: petBubbleBlink 3.5s steps(1) forwards;
}
/* Pixel tail pointing down toward the pet */
.pet-bubble::after {
  content: '';
  position: absolute;
  left: 22px;
  bottom: -10px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--color-border);
}
.pet-bubble-wind {
  display: inline-block;
  animation: petWindSpin 2s linear infinite;
}
.pet-bubble-text { white-space: normal; }

/* NPC blink: pop in, hold, flicker, fade out */
@keyframes petBubbleBlink {
  0%   { opacity: 0; transform: translateY(6px) scale(0.92); }
  8%   { opacity: 1; transform: translateY(0) scale(1); }
  12%  { opacity: 0.5; }
  16%  { opacity: 1; }
  85%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-4px) scale(0.96); visibility: hidden; }
}
@keyframes petWindSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---- Chat panel ---- */
.pet-chat {
  position: fixed;
  bottom: 170px;
  left: 10px;
  z-index: 998;
  width: 280px;
  background: var(--color-surface);
  border: 3px solid var(--color-text);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.pet-chat.open {
  display: flex;
}
.pet-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  font-family: 'VT323', 'ZCOOL KuaiLe', monospace;
  font-size: 1rem;
  background: var(--color-primary-light);
  border-bottom: 2px solid var(--color-border);
}
.pet-chat-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  line-height: 1;
}
.pet-chat-close:hover {
  color: var(--color-accent);
}
.pet-chat-body {
  flex: 1;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--color-bg-alt);
}
.pet-chat-msg {
  font-family: 'VT323', 'ZCOOL KuaiLe', monospace;
  font-size: 0.95rem;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  max-width: 90%;
  word-break: break-word;
  line-height: 1.5;
}
.pet-msg-bot {
  align-self: flex-start;
  background: var(--color-primary-light);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.pet-msg-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
}
.pet-chat-input {
  display: flex;
  border-top: 2px solid var(--color-border);
  padding: 0.4rem;
  gap: 0.3rem;
}
.pet-input {
  flex: 1;
  font-family: 'VT323', 'ZCOOL KuaiLe', monospace;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
}
.pet-input:focus {
  border-color: var(--color-primary);
}
.pet-send-btn {
  font-family: 'VT323', 'ZCOOL KuaiLe', monospace;
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.pet-send-btn:hover {
  background: var(--color-primary-hover);
}
.pet-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   Hobby Page — Pixel RPG Adventure Style
   ============================================================ */

/* ---- color palette (Morandi blue-gray) ---- */
.life-page {
  --color-bg:            #fef7ed;
  --color-bg-alt:        #fdf0dc;
  --color-surface:       #fff8f0;
  --color-border:        #e8cfa0;
  --color-text:          #5c3d2e;
  --color-text-secondary:#8b5e3c;
  --color-text-muted:    #b8946e;
  --color-primary:       #d4852c;
  --color-primary-hover: #b8701f;
  --color-primary-light: #fce8cc;
  --color-accent:        #c0604d;
  --color-tag-bg:        #fef0d5;
  --color-tag-text:      #8b5e3c;
  --color-card-shadow:   0 1px 3px rgba(180,140,100,0.15);
  --color-card-hover:    0 4px 12px rgba(180,140,100,0.25);

  --trophy-bg:           #fef7ed;
  --trophy-border:       #d4a04a;
  font-family: 'VT323', monospace;
  image-rendering: pixelated;
}
.life-page[data-theme="dark"] {
  --color-bg:            #1a1a2e;
  --color-bg-alt:        #1f1f35;
  --color-surface:       #272744;
  --color-border:        #3d3d5c;
  --color-text:          #e8d5b7;
  --color-text-secondary:#b8a9c9;
  --color-text-muted:    #7a6e8a;
  --color-primary:       #f0c060;
  --color-primary-hover: #ffd780;
  --color-primary-light: #3a2a10;
  --color-accent:        #c98bdb;
  --color-tag-bg:        #2a2030;
  --color-tag-text:      #d4a0e8;
  --color-card-shadow:   0 1px 3px rgba(0,0,0,0.3);
  --color-card-hover:    0 4px 16px rgba(0,0,0,0.4);

  --trophy-bg:           #2a2030;
  --trophy-border:       #c98bdb;
}

/* ---- hero ---- */
.life-page .hero-name {
  font-family: 'VT323', monospace;
  font-size: 2.5rem;
  color: var(--color-primary);
  text-shadow: 2px 2px 0 var(--color-primary-light);
}
.life-page .hero-bio {
  font-family: 'VT323', monospace;
  font-size: 1.15rem;
  color: var(--color-text-secondary);
}
.life-page .section-title {
  font-family: 'VT323', monospace;
  font-size: 1.6rem;
}
.life-page .pixel-section {
  border-top: 3px dashed var(--color-border);
}

/* ---- trophy hint ---- */
.pixel-hint {
  font-family: 'VT323', monospace;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: -0.8rem;
  margin-bottom: 1.5rem;
}

/* ---- trophy grid ---- */
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1.5rem;
}

/* ---- trophy card ---- */
.trophy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.25rem 0.75rem;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  border-radius: 0;
  box-shadow: 4px 4px 0 var(--color-border);
  cursor: default;
  animation: trophy-float 3s ease-in-out infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.trophy-card:nth-child(2) { animation-delay: 0.5s; }
.trophy-card:nth-child(3) { animation-delay: 1.0s; }
.trophy-card:nth-child(4) { animation-delay: 1.5s; }
.trophy-card:nth-child(5) { animation-delay: 2.0s; }

.trophy-card:hover {
  animation: trophy-bounce 0.3s ease;
  transform: translateY(-6px);
  box-shadow: 4px 10px 0 var(--color-primary);
  border-color: var(--color-primary);
}

/* ---- trophy icon ---- */
.trophy-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 0.75rem;
}
.trophy-icon svg {
  display: block;
}

/* ---- trophy text ---- */
.trophy-name {
  font-family: 'VT323', monospace;
  font-size: 1.1rem;
  color: var(--color-text);
  margin-bottom: 0.3rem;
}
.trophy-desc {
  font-family: 'VT323', monospace;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ---- float animation ---- */
@keyframes trophy-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes trophy-bounce {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-10px) scale(1.06); }
  70%  { transform: translateY(-3px) scale(0.98); }
  100% { transform: translateY(-6px) scale(1); }
}
