/* ==========================================================================
   Zexuan Li — Personal Website
   ========================================================================== */

/* --- CSS Variables / Theming --- */
:root {
  /* Light theme (default) */
  --bg: #edeaf2;
  --bg-gradient: none;
  --text: #1a1a2e;
  --text-secondary: #555568;
  --text-muted: #8888a0;
  --accent: #7b68ee;
  --accent-hover: #6350d8;
  --link: #7b8ccc;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
  --card-hover-shadow: 0 8px 40px rgba(0, 0, 0, 0.1);
  --nav-bg: rgba(240, 240, 245, 0.85);
  --overlay-mint: rgba(180, 240, 220, 0.45);
  --overlay-lavender: rgba(200, 190, 255, 0.4);
  --footer-bg: #1a1a2e;
  --footer-text: #e0e0f0;
  --pub-venue-bg: #eee8ff;
  --pub-venue-text: #5b4daa;
  --tag-bg: rgba(0, 0, 0, 0.04);
  --divider: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --bg: #0e0e1a;
  --bg-gradient: linear-gradient(160deg, #0e0e1a 0%, #14102a 40%, #0e0e1a 100%);
  --text: #e8e8f0;
  --text-secondary: #a0a0b8;
  --text-muted: #6868a0;
  --accent: #9b8aff;
  --accent-hover: #b0a0ff;
  --link: #9ba8dd;
  --card-bg: #1a1a2e;
  --card-border: rgba(255, 255, 255, 0.06);
  --card-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
  --card-hover-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(14, 14, 26, 0.9);
  --overlay-mint: rgba(100, 200, 180, 0.35);
  --overlay-lavender: rgba(140, 120, 220, 0.35);
  --footer-bg: #08081a;
  --footer-text: #c0c0d8;
  --pub-venue-bg: #2a2050;
  --pub-venue-text: #b8a8ff;
  --tag-bg: rgba(255, 255, 255, 0.06);
  --divider: rgba(255, 255, 255, 0.08);
}

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

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

body {
  font-family:
    "DM Sans",
    -apple-system,
    sans-serif;
  background: var(--bg) url("assets/images/bg.png") no-repeat center top / cover;
  color: var(--text);
  line-height: 1.65;
  transition:
    background-color 0.4s ease,
    color 0.3s ease;
  min-height: 100vh;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--accent);
}

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

strong {
  font-weight: 600;
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 3rem;
  background: var(--nav-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
  transition: background 0.3s;
}

.nav__logo {
  font-family: "DM Mono", monospace;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.logo-l {
  color: #81ebc4;
}
.logo-zx {
  color: var(--accent);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav__link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.nav__link:hover {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    border-color 0.2s;
}
.theme-toggle:hover {
  background: var(--tag-bg);
  border-color: var(--accent);
}

[data-theme="light"] .icon-moon {
  display: none;
}
[data-theme="dark"] .icon-sun {
  display: none;
}

/* --- Hero Section --- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 8rem 3rem 4rem;
}

.hero__content {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.hero__greeting {
  font-family: "DM Mono", monospace;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 400;
  margin-bottom: 1.5rem;
  color: var(--text);
  opacity: 0;
  animation: fadeUp 0.8s ease forwards;
}

.hero__image-container {
  position: relative;
  margin-bottom: 2rem;
  opacity: 0;
  animation: fadeUp 0.8s ease 0.15s forwards;
}

.hero__image-frame {
  position: relative;
  width: 100%;
  max-width: 520px;
}

.hero__image {
  width: 100%;
  height: auto;
}

.hero__name {
  font-family: "DM Mono", monospace;
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-bottom: 1.2rem;
  color: var(--text);
  opacity: 0;
  animation: fadeUp 0.8s ease 0.3s forwards;
}

.hero__bio {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
  max-width: 540px;
  opacity: 0;
  animation: fadeUp 0.8s ease 0.45s forwards;
}

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

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

/* --- Section --- */
.section {
  max-width: 960px;
  margin: 0 auto;
  padding: 5rem 3rem;
}

.section__title {
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--divider);
}

/* --- Publications --- */
.publications {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.pub {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.pub__venue {
  flex-shrink: 0;
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--pub-venue-bg);
  color: var(--pub-venue-text);
  margin-top: 2px;
  white-space: nowrap;
}

.pub__body {
  flex: 1;
}

.pub__title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.pub__authors {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.pub__desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.7rem;
}

.pub__links {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pub__link {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  padding: 3px 10px;
  border: 1px solid var(--divider);
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.pub__link:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tag-bg);
}

/* --- Project Cards --- */
.project-card--featured {
  display: flex;
  gap: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition:
    box-shadow 0.3s,
    transform 0.3s;
  text-decoration: none;
  color: inherit;
  margin-bottom: 2rem;
}
.project-card--featured:hover {
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-3px);
  color: inherit;
}

.project-card--featured .project-card__image {
  flex: 0 0 45%;
  overflow: hidden;
}
.project-card--featured .project-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}
.project-card--featured:hover .project-card__image img {
  transform: scale(1.03);
}

.project-card--featured .project-card__info {
  padding: 2rem 2rem 2rem 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.project-card__name {
  font-family: "DM Mono", monospace;
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.project-card__tags {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 0.8rem;
}

.project-card__desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.project-card__desc strong {
  color: var(--text);
}

.project-card__cta {
  font-family: "DM Mono", monospace;
  font-size: 0.82rem;
  color: var(--accent);
  transition: letter-spacing 0.2s;
}
.project-card--featured:hover .project-card__cta {
  letter-spacing: 0.04em;
}

/* Compact project cards */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.project-card--compact {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition:
    box-shadow 0.3s,
    transform 0.3s;
}
.project-card--compact:hover {
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-2px);
}

.project-card--compact .project-card__image {
  height: 180px;
  overflow: hidden;
}
.project-card--compact .project-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}
.project-card--compact:hover .project-card__image img {
  transform: scale(1.03);
}

.project-card--compact .project-card__info {
  padding: 1.2rem;
}

.project-card--compact .project-card__name {
  font-size: 1.15rem;
  margin-bottom: 0.25rem;
}

.project-card--compact .project-card__desc {
  font-size: 0.85rem;
  line-height: 1.55;
  margin-bottom: 0;
}

/* --- Footer --- */
.footer {
  padding: 2rem 3rem;
  margin-top: 2rem;
}

.footer__content {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
}

.footer__title {
  font-family: "DM Mono", monospace;
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 0.8rem;
  color: var(--text);
}

.footer__links {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.footer__link {
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.footer__link:hover {
  color: var(--accent);
}

/* --- Interactive Effects --- */

/* Mouse-following gradient glow on hero */
.hero {
  position: relative;
  overflow: hidden;
}

.hero__glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
  background: radial-gradient(600px circle at var(--glow-x, 50%) var(--glow-y, 50%), rgba(129, 235, 196, 0.15), rgba(123, 104, 238, 0.1) 40%, transparent 70%);
  will-change: opacity;
}

.hero:hover .hero__glow {
  opacity: 1;
}

/* Magnetic nav links */
.nav__link {
  transition: color 0.2s, transform 0.15s ease-out;
  display: inline-block;
}

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

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

/* Typewriter effect */
.typewriter {
  display: inline-block;
  border-right: 2px solid var(--text);
  animation: blink 0.7s step-end infinite;
}

.typewriter.done {
  border-right-color: transparent;
  animation: none;
}

@keyframes blink {
  50% { border-right-color: transparent; }
}

/* --- Animations --- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav {
    padding: 0.8rem 1.5rem;
  }
  .nav__links {
    gap: 1.2rem;
  }
  .nav__link {
    font-size: 0.82rem;
  }

  .hero {
    padding: 7rem 1.5rem 3rem;
    min-height: auto;
  }

  .hero__name {
    font-size: 2.2rem;
    letter-spacing: 0.04em;
  }

  .section {
    padding: 3rem 1.5rem;
  }

  .project-card--featured {
    flex-direction: column;
  }
  .project-card--featured .project-card__info {
    padding: 1.5rem;
  }

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

  .pub {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer {
    padding: 3rem 1.5rem;
  }
  .footer__links {
    flex-direction: column;
    gap: 0.8rem;
  }
}
