/* ===========================
   Yuchen (Ethan) Yuan
   Personal Academic Homepage
   Warm & Approachable Theme
   =========================== */

/* --- CSS Variables --- */
:root {
  --color-bg: #f8f9fb;
  --color-bg-alt: #eef1f5;
  --color-surface: #ffffff;
  --color-text: #2e3440;
  --color-text-light: #6b7280;
  --color-heading: #1e2533;
  --color-accent: #4a6d8c;
  --color-accent-hover: #3a5a76;
  --color-accent-light: #e3ecf3;
  --color-sage: #5a8a7a;
  --color-sage-light: #e4f0ec;
  --color-border: #dce1e8;
  --color-link: #4a6d8c;

  --font-heading: 'Crimson Pro', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --max-width: 820px;
  --nav-height: 64px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(30, 37, 51, 0.06);
  --shadow-md: 0 4px 12px rgba(30, 37, 51, 0.08);
  --transition: 0.2s ease;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --color-bg: #2b3040;
  --color-bg-alt: #323848;
  --color-surface: #3a4155;
  --color-text: #d8dce4;
  --color-text-light: #a0a8b8;
  --color-heading: #eaeff5;
  --color-accent: #7ab0de;
  --color-accent-hover: #94c2ea;
  --color-accent-light: #343f55;
  --color-sage: #85ccb0;
  --color-sage-light: #2e4a40;
  --color-border: #454e62;
  --color-link: #7ab0de;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.22);
}

[data-theme="dark"] .site-nav {
  background: rgba(43, 48, 64, 0.92);
}

[data-theme="dark"] .post-content pre {
  background: #1e2430;
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--color-accent-hover);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* --- Navigation --- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 249, 251, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
}

.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-logo {
  text-decoration: none;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-heading);
  letter-spacing: -0.01em;
}

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

.nav-links a {
  display: block;
  padding: 0.4rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 450;
  color: var(--color-text-light);
  border-radius: 6px;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* Dropdown */
.nav-dropdown {
  position: relative;
}

.caret {
  font-size: 0.65em;
  margin-left: 2px;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  list-style: none;
  padding: 0.35rem 0;
  z-index: 200;
}

.dropdown-menu li a {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-radius: 0;
}

.nav-dropdown:hover .dropdown-menu {
  display: block;
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* --- Main Content --- */
.site-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  min-height: calc(100vh - var(--nav-height) - 120px);
}

/* --- Home Page --- */
.home-hero {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

.hero-photo {
  flex-shrink: 0;
}

.hero-photo img,
.hero-photo .photo-placeholder {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--color-bg-alt);
  box-shadow: var(--shadow-sm);
}

.photo-placeholder {
  background: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  font-size: 0.8rem;
}

.hero-text h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--color-heading);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.hero-text .affiliation {
  font-size: 1.05rem;
  color: var(--color-text-light);
  margin-bottom: 1rem;
}

.hero-text .intro {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--color-text);
}

.hero-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  transition: all var(--transition);
}

.hero-links a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}

/* --- Sections --- */
.home-section {
  margin-bottom: 2.5rem;
}

.home-section h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--color-accent-light);
}

/* --- News/Updates --- */
.news-list {
  list-style: none;
}

.news-list li {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  gap: 1rem;
  align-items: baseline;
}

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

.news-date {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--color-text-light);
  font-family: var(--font-mono);
  min-width: 90px;
}

.news-text {
  font-size: 0.92rem;
}

/* --- Post Lists --- */
.post-list {
  list-style: none;
}

.post-list-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--color-border);
}

.post-list-item:last-child {
  border-bottom: none;
}

.post-list-item h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.post-list-item h3 a {
  color: var(--color-heading);
}

.post-list-item h3 a:hover {
  color: var(--color-accent);
}

.post-list-meta {
  font-size: 0.82rem;
  color: var(--color-text-light);
  margin-bottom: 0.4rem;
}

.post-list-excerpt {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.6;
}

/* --- Page --- */
.page-header {
  margin-bottom: 2rem;
}

.page-header h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-heading);
}

.page-subtitle {
  font-size: 1.05rem;
  color: var(--color-text-light);
  margin-top: 0.4rem;
}

.page-content {
  font-size: 0.95rem;
}

.page-content h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 2rem 0 0.8rem;
}

.page-content h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 1.5rem 0 0.6rem;
}

.page-content p {
  margin-bottom: 1rem;
}

.page-content ul, .page-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}

.page-content li {
  margin-bottom: 0.3rem;
}

/* --- Post --- */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-heading);
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.post-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-research {
  background: var(--color-sage-light);
  color: var(--color-sage);
}

.tag-thoughts {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.post-content {
  font-size: 0.95rem;
}

.post-content p {
  margin-bottom: 1.2rem;
}

.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: 0.5rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--color-text-light);
  font-style: italic;
}

.post-content pre {
  background: #1e2533;
  color: #dce1e8;
  padding: 1.2rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--color-bg-alt);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.back-link {
  font-size: 0.9rem;
  color: var(--color-text-light);
}

.back-link:hover {
  color: var(--color-accent);
}

/* --- Publications --- */
.pub-list {
  list-style: none;
}

.pub-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--color-border);
}

.pub-item:last-child {
  border-bottom: none;
}

.pub-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 0.3rem;
}

.pub-authors {
  font-size: 0.88rem;
  color: var(--color-text-light);
  margin-bottom: 0.2rem;
}

.pub-authors strong {
  color: var(--color-text);
}

.pub-venue {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-style: italic;
  margin-bottom: 0.4rem;
}

.pub-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pub-links a {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  transition: all var(--transition);
}

.pub-links a:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

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

.project-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all var(--transition);
}

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

.project-card h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.project-card h3 a {
  color: var(--color-heading);
}

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

.project-card p {
  font-size: 0.88rem;
  color: var(--color-text-light);
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.project-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.project-tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--color-bg-alt);
  color: var(--color-text-light);
}

/* --- CV Timeline --- */
.cv-section {
  margin-bottom: 2rem;
}

.cv-entry {
  display: flex;
  gap: 1.5rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}

.cv-entry:last-child {
  border-bottom: none;
}

.cv-year {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-family: var(--font-mono);
  min-width: 100px;
  padding-top: 0.1rem;
}

.cv-details h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 0.2rem;
}

.cv-details p {
  font-size: 0.9rem;
  color: var(--color-text-light);
}

/* --- Footer --- */
.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-info p {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.footer-affiliation {
  font-size: 0.8rem !important;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--color-text-light);
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--color-accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
  }

  .nav-links.open {
    display: flex;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: 1rem;
    display: none;
  }

  .nav-dropdown.open .dropdown-menu {
    display: block;
  }

  .home-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .hero-photo img,
  .hero-photo .photo-placeholder {
    width: 120px;
    height: 120px;
  }

  .hero-links {
    justify-content: center;
  }

  .news-list li {
    flex-direction: column;
    gap: 0.2rem;
  }

  .cv-entry {
    flex-direction: column;
    gap: 0.3rem;
  }

  .footer-container {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

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

/* --- Dark Mode Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-light);
  transition: all var(--transition);
  padding: 0;
  margin-left: 0.5rem;
}

.theme-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-light);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  width: 16px;
  height: 16px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

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

/* --- Giscus Comments --- */
.comments-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.comments-section h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 1rem;
}

/* --- Scroll Hint & Home About Reveal --- */
.scroll-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.5rem 0 0.5rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.scroll-hint:hover {
  opacity: 0.85;
}

.scroll-hint-text {
  font-size: 0.82rem;
  color: var(--color-text-light);
  letter-spacing: 0.03em;
}

.scroll-hint svg {
  color: var(--color-text-light);
  animation: bounce-down 1.8s ease-in-out infinite;
}

@keyframes bounce-down {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.home-about {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.6s ease 0.15s;
}

.home-about.revealed {
  max-height: 2000px;
  opacity: 1;
}

.home-about-inner {
  padding: 2rem 0 1rem;
}

.home-about-inner h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--color-accent-light);
}

.home-about-inner h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-heading);
  margin: 1.5rem 0 0.6rem;
}

.home-about-inner p {
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 1rem;
}

.home-about-inner ul {
  margin: 0.5rem 0 1rem 1.5rem;
}

.home-about-inner li {
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.scroll-hint.hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* --- Utilities --- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
