/* ============================
   CSS Custom Properties
   ============================ */

:root {
  /* Dark theme (default) — PaperMod / Lil'Log gray */
  --bg-primary: #1d1e20;
  --bg-secondary: #2e2e33;
  --bg-tertiary: #414144;
  --text-primary: #dadadb;
  --text-secondary: #9b9c9d;
  --text-muted: #6c6d6f;
  --accent: #82aaff;
  --accent-hover: #a3c0ff;
  --accent-secondary: #c3e88d;
  --border: #333333;
  --code-bg: #37383e;
  --card-bg: #2e2e33;
  --shadow: rgba(0, 0, 0, 0.4);
  --header-bg: rgba(29, 30, 32, 0.85);

  /* Sizing */
  --sidebar-width: 220px;
  --header-height: 60px;
  --content-max-width: 860px;
  --radius: 8px;
  --radius-sm: 4px;
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eaecf3;
  --text-primary: #1a1b2e;
  --text-secondary: #4a4d6e;
  --text-muted: #8b8fb0;
  --accent: #3b6dd6;
  --accent-hover: #2f5bc4;
  --accent-secondary: #2e7d32;
  --border: #d4d6e4;
  --code-bg: #f0f2f8;
  --card-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.06);
  --header-bg: rgba(245, 245, 247, 0.85);
}

/* ============================
   Reset
   ============================ */

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

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.7;
  transition: background-color 0.3s ease, color 0.3s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

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

/* ============================
   Header
   ============================ */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.site-logo:hover {
  color: var(--accent);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================
   Theme Toggle
   ============================ */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

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

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

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

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

/* ============================
   Social Links
   ============================ */

.social-links {
  display: flex;
  gap: 0.35rem;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.social-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-tertiary);
}

.social-links a svg {
  width: 18px;
  height: 18px;
}

/* ============================
   Layout
   ============================ */

.site-layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ============================
   Sidebar
   ============================ */

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  padding: 1.5rem 0.75rem;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================
   Main Content
   ============================ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem 3rem;
  max-width: calc(var(--content-max-width) + var(--sidebar-width) + 6rem);
}

/* ============================
   Hero: About + News
   ============================ */

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}

.about-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.profile-image {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
}

.about-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.about-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.about-text p {
  margin-bottom: 0.75rem;
}

.about-text strong {
  color: var(--text-primary);
}

/* ============================
   News Section
   ============================ */

.news-section h2,
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.news-item {
  display: block;
  padding: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.news-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-1px);
}

.news-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.news-body {
  padding: 0.75rem 0.9rem;
}

.news-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.news-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.2rem;
}

.news-item:hover .news-title {
  color: var(--accent);
}

.news-content {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
  line-height: 1.5;
}

.news-source {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.news-source svg {
  width: 12px;
  height: 12px;
}

/* ============================
   Post List
   ============================ */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  display: block;
  padding: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
  text-decoration: none;
}

.post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px var(--shadow);
  transform: translateY(-1px);
}

.post-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.post-card:hover .post-title {
  color: var(--accent);
}

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

.post-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.post-meta svg {
  width: 14px;
  height: 14px;
}

.post-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.post-tags {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: 600;
}

/* ============================
   Blog Post Page
   ============================ */

.post-content {
  max-width: var(--content-max-width);
}

.post-header {
  margin-bottom: 2.5rem;
}

.post-header .post-title {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 1rem;
}

.post-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.post-body h1 { font-size: 1.75rem; margin: 2.5rem 0 1rem; font-weight: 700; }
.post-body h2 { font-size: 1.45rem; margin: 2rem 0 0.75rem; font-weight: 600; }
.post-body h3 { font-size: 1.2rem; margin: 1.75rem 0 0.5rem; font-weight: 600; }
.post-body h4 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; font-weight: 600; }

.post-body p {
  margin-bottom: 1.1rem;
}

.post-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.post-body code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
  font-size: 0.85em;
}

.post-body :not(pre) > code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.post-body ul, .post-body ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body img {
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.post-body th, .post-body td {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-body th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============================
   Publications Page
   ============================ */

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

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.publications-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.publication-item {
  padding: 1.2rem 1.4rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease;
}

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

.publication-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.4;
}

.publication-title a {
  color: inherit;
}

.publication-authors {
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.publication-venue {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.2rem;
}

.publication-meta {
  display: flex;
  gap: 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.no-publications {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}

.no-publications p {
  margin-bottom: 0.5rem;
}

.no-publications code {
  background: var(--code-bg);
  padding: 0.2em 0.5em;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

/* ============================
   CV Page
   ============================ */

.cv-container {
  max-width: var(--content-max-width);
}

.cv-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

.cv-btn-primary {
  background: var(--accent);
  color: #fff;
}

.cv-btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.cv-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.cv-btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cv-embed {
  width: 100%;
  height: calc(100vh - 280px);
  min-height: 500px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
}

/* ============================
   Footer
   ============================ */

.site-footer {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ============================
   Mobile Menu Toggle
   ============================ */

.mobile-menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================
   Responsive
   ============================ */

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

  .main-content {
    padding: 2rem;
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .sidebar {
    display: none;
    position: fixed;
    z-index: 99;
    width: 100%;
    height: auto;
    max-height: calc(100vh - var(--header-height));
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    box-shadow: 0 8px 24px var(--shadow);
  }

  .sidebar.open {
    display: flex;
  }

  .main-content,
  .site-footer {
    margin-left: 0;
    padding: 1.5rem 1.25rem;
  }

  .header-inner {
    padding: 0 1rem;
  }

  .post-header .post-title {
    font-size: 1.5rem;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .profile-image {
    width: 80px;
    height: 80px;
  }

  .about-name {
    font-size: 1.25rem;
  }

  .cv-embed {
    height: 60vh;
    min-height: 400px;
  }
}

/* ============================
   Utilities
   ============================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
