/* ==========================================================================
   Minimalist Portfolio & Academic Theme
   Ultra-fast, responsive, zero-framework CSS with Light/Dark Mode
   ========================================================================== */

:root,
:root[data-theme="light"] {
  --bg-color: #fafafa;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --card-border-hover: #cbd5e1;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-light: #e0f2fe;
  --award-bg: #fef2f2;
  --award-text: #dc2626;
  --award-border: #fecaca;
  --tag-bg: #f3f4f6;
  --tag-text: #374151;
  --code-bg: #f3f4f6;
  --nav-border: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] {
  --bg-color: #0b0f19;
  --card-bg: #111827;
  --card-border: #1f2937;
  --card-border-hover: #374151;
  --text-primary: #f9fafb;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-light: rgba(56, 189, 248, 0.12);
  --award-bg: rgba(239, 68, 68, 0.12);
  --award-text: #f87171;
  --award-border: rgba(239, 68, 68, 0.25);
  --tag-bg: #1f2937;
  --tag-text: #9ca3af;
  --code-bg: #1f2937;
  --nav-border: #1f2937;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-color);
  line-height: 1.65;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Typography & Links */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.25;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  scroll-margin-top: 70px;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.5rem; margin-top: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--card-border); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p {
  margin-top: 0;
  margin-bottom: 1.2em;
  color: var(--text-secondary);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

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

hr {
  border: 0;
  height: 1px;
  background-color: var(--card-border);
  margin: 2.5em 0;
}

ul, ol {
  color: var(--text-secondary);
  padding-left: 1.5em;
  margin-bottom: 1.2em;
}

li {
  margin-bottom: 0.4em;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background-color: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

pre {
  background-color: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

/* Math typesetting */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}

/* Mermaid Diagram */
.mermaid {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  margin: 1.5em 0;
  padding: 12px;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

/* Header & Navigation */
.site-header {
  border-bottom: 1px solid var(--nav-border);
  background-color: var(--bg-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background-color: rgba(250, 250, 250, 0.85);
}

:root[data-theme="dark"] .site-header {
  background-color: rgba(11, 15, 25, 0.85);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav-link {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

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

/* Theme Toggle Button */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 9px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s ease;
}

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

.theme-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

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

/* Main Content Area */
.site-main {
  padding-top: 28px;
  padding-bottom: 48px;
  min-height: calc(100vh - 180px);
}

/* Hero Section */
.hero-section {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-top: 12px;
  margin-bottom: 32px;
}

/* Featured Video Showcase */
.video-showcase {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px 0 28px 0;
}

.featured-video {
  max-width: 340px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-md);
  display: block;
}

@media (max-width: 640px) {
  .hero-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

.hero-avatar {
  width: 110px;
  height: 110px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--card-border);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.hero-info {
  flex-grow: 1;
}

.hero-name {
  font-size: 1.85rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text-primary);
}

.hero-tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0 0 14px 0;
  line-height: 1.4;
}

/* Social & Contact Pill Links */
.contact-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.pill-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

.pill-link svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  flex-shrink: 0;
}

/* Portfolio Projects Grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 22px;
  margin: 20px 0;
}

@media (max-width: 500px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
}

.project-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.project-thumbnail {
  width: 100%;
  height: 175px;
  object-fit: cover;
  background-color: var(--code-bg);
  border-bottom: 1px solid var(--card-border);
}

.project-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.project-title a {
  color: var(--text-primary);
  text-decoration: none;
}

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

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tag-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  background-color: var(--tag-bg);
  color: var(--tag-text);
}

.project-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 14px 0;
  flex-grow: 1;
}

.project-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
}

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

/* Publications Items */
.publication-item {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.publication-item:hover {
  border-color: var(--card-border-hover);
}

.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px 0;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

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

.pub-venue {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 8px;
}

.pub-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.badge-award {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--award-bg);
  color: var(--award-text);
  border: 1px solid var(--award-border);
}

.badge-btn {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 4px;
  background-color: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.badge-btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--card-border);
  padding: 32px 0 40px 0;
  background-color: var(--bg-color);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  text-align: center;
}

.footer-copyright {
  font-size: 0.85rem;
}

/* Single Content Pages (Articles / Project Details) */
.article-header {
  margin-bottom: 24px;
}

.article-title {
  margin-top: 0;
  font-size: 2rem;
}

.article-meta {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-top: 6px;
}

.article-content {
  font-size: 1rem;
  line-height: 1.7;
}

.article-content img {
  border-radius: 6px;
  margin: 1.5em auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 20px;
}
