/* CSS Variables for theming */
:root {
  /* Light mode colors - Navy & Teal theme */
  --color-primary: #1a2332;
  --color-secondary: #14b8a6;
  --color-bg: #fafafa;
  --color-text: #2d3748;
  --color-border: #e2e8f0;
  --color-muted: #718096;
  --color-accent-bg: #ffffff;
  --color-code-bg: #f5f5f5;
  --color-hover-bg: #e6f7f5;
  --shadow-color: rgba(0, 0, 0, 0.1);
}

/* Dark mode colors */
[data-theme="dark"] {
  --color-primary: #60a5fa;
  --color-secondary: #2dd4bf;
  --color-bg: #0f172a;
  --color-text: #e2e8f0;
  --color-border: #334155;
  --color-muted: #94a3b8;
  --color-accent-bg: #1e293b;
  --color-code-bg: #1e293b;
  --color-hover-bg: #1e293b;
  --shadow-color: rgba(0, 0, 0, 0.3);
}

/* System preference support */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #60a5fa;
    --color-secondary: #2dd4bf;
    --color-bg: #0f172a;
    --color-text: #e2e8f0;
    --color-border: #334155;
    --color-muted: #94a3b8;
    --color-accent-bg: #1e293b;
    --color-code-bg: #1e293b;
    --color-hover-bg: #1e293b;
    --shadow-color: rgba(0, 0, 0, 0.3);
  }
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Typography */
body {
  font-family: Georgia, 'Times New Roman', Times, serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--color-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

p, ul, ol {
  margin-bottom: 1rem;
}

ul, ol {
  margin-left: 2rem;
}

/* Links */
a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  border-bottom: 1px solid transparent;
}

a:hover {
  border-bottom-color: var(--color-secondary);
}

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

.site-header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

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

.site-title:hover {
  border-bottom: none;
}

.nav-menu {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  margin: 0;
}

.nav-menu a {
  text-decoration: none;
  font-weight: 500;
}

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
  position: relative;
}

.theme-toggle:hover {
  background: var(--color-hover-bg);
  border-color: var(--color-secondary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: var(--color-text);
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: absolute;
}

/* Show moon icon in dark mode (represents current state) */
[data-theme="dark"] .sun-icon {
  opacity: 0;
  transform: rotate(180deg);
}

[data-theme="dark"] .moon-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Show sun icon in light mode (represents current state) */
[data-theme="light"] .moon-icon {
  opacity: 0;
  transform: rotate(-180deg);
}

[data-theme="light"] .sun-icon {
  opacity: 1;
  transform: rotate(0deg);
}

/* Default state (before JS loads) - show moon for dark default */
:root:not([data-theme]) .moon-icon {
  opacity: 0;
}

:root:not([data-theme]) .sun-icon {
  opacity: 1;
}

/* Social Links */
.social-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  transition: all 0.3s ease;
}

.social-icon:hover {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
}

.social-icon:hover svg {
  fill: white;
}

.social-icon svg {
  width: 18px;
  height: 18px;
  fill: var(--color-text);
  transition: fill 0.3s ease;
}

/* Footer */
.site-footer {
  border-top: 2px solid var(--color-border);
  padding-top: 2rem;
  margin-top: 3rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

/* Buttons */
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 2px solid var(--color-primary);
  text-decoration: none;
  color: var(--color-primary);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  transition: all 0.3s ease;
  font-weight: 500;
}

.button:hover {
  background: var(--color-primary);
  color: var(--color-bg);
  border-bottom: 2px solid var(--color-primary);
}

/* Profile Section (Homepage) */
.profile-section {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 3rem;
  padding: 2rem;
  background: var(--color-accent-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow-color);
}

.profile-image {
  flex-shrink: 0;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 3px solid var(--color-secondary);
  object-fit: cover;
  box-shadow: 0 4px 12px var(--shadow-color);
}

.profile-content {
  flex: 1;
}

.profile-content h1 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.profile-content .affiliation {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

/* News Section */
.news-section {
  margin-bottom: 3rem;
  padding: 1.5rem;
  background: var(--color-accent-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.news-section h2 {
  margin-top: 0;
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--color-primary);
}

.news-list {
  list-style: none;
  margin: 0;
}

.news-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

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

.news-date {
  flex-shrink: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 80px;
}

.news-text {
  flex: 1;
  line-height: 1.5;
}

/* Main content sections */
section {
  margin-bottom: 3rem;
}

.intro {
  margin-bottom: 3rem;
}

/* Navigation list */
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0;
}

/* Blog listing */
.post-list {
  border-top: 1px solid var(--color-border);
}

.post-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.2s ease;
}

.post-item:hover {
  background: var(--color-hover-bg);
  padding-left: 1rem;
  padding-right: 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
}

.post-item h2,
.post-item h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
}

.post-item .meta {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.post-item .summary {
  margin: 0;
  color: var(--color-text);
}

/* Single post meta */
article header .meta {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.tags {
  display: inline;
  margin-left: 1rem;
}

.tag {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  margin-left: 0.5rem;
  color: var(--color-secondary);
  border-radius: 3px;
}

/* Post navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin: 3rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.page-number {
  font-size: 0.9rem;
  color: var(--color-muted);
}

/* Newsletter form */
.newsletter {
  border: 2px solid var(--color-border);
  padding: 1.5rem;
  margin: 3rem 0;
  background: var(--color-accent-bg);
  border-radius: 8px;
}

.newsletter h3 {
  margin-top: 0;
  color: var(--color-primary);
}

.newsletter-form {
  margin-top: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 0.5rem;
  border: 2px solid var(--color-border);
  font-family: inherit;
  font-size: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 4px;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-secondary);
  background: var(--color-accent-bg);
}

.form-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* Publications */
.publication-item {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--color-accent-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.publication-item .pub-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-primary);
}

.publication-item .pub-authors {
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.publication-item .pub-venue {
  color: var(--color-muted);
  font-style: italic;
  margin-bottom: 0.75rem;
}

.publication-abstract {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-text);
  line-height: 1.6;
  display: none;
}

.publication-abstract.show {
  display: block;
}

.abstract-toggle {
  background: none;
  border: 1px solid var(--color-secondary);
  color: var(--color-secondary);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  font-family: inherit;
}

.abstract-toggle:hover {
  background: var(--color-secondary);
  color: white;
}

/* Footnotes */
.footnotes {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.9rem;
}

.footnotes ol {
  margin-left: 1.5rem;
}

.footnote-ref {
  text-decoration: none;
  font-weight: bold;
  color: var(--color-secondary);
}

sup {
  line-height: 0;
}

/* Footnote popup (for hover functionality) */
.footnote-popup {
  position: absolute;
  display: none;
  background: var(--color-accent-bg);
  border: 2px solid var(--color-border);
  padding: 0.75rem;
  max-width: 300px;
  font-size: 0.9rem;
  z-index: 1000;
  box-shadow: 4px 4px 12px var(--shadow-color);
  border-radius: 6px;
}

.footnote-popup.active {
  display: block;
}

/* Citation popup */
.citation-popup {
  position: absolute;
  display: none;
  background: var(--color-accent-bg);
  border: 2px solid var(--color-border);
  padding: 0.75rem;
  max-width: 400px;
  font-size: 0.9rem;
  z-index: 1000;
  box-shadow: 4px 4px 12px var(--shadow-color);
  border-radius: 6px;
}

.citation-popup.active {
  display: block;
}

/* Code blocks */
pre {
  background: var(--color-code-bg);
  border: 1px solid var(--color-border);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  border-radius: 6px;
}

code {
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  font-size: 0.9em;
  background: var(--color-code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

pre code {
  background: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--color-secondary);
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--color-muted);
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

th, td {
  border: 1px solid var(--color-border);
  padding: 0.5rem;
  text-align: left;
}

th {
  background: var(--color-code-bg);
  font-weight: 600;
  color: var(--color-primary);
}

/* Responsive */
@media (max-width: 600px) {
  body {
    font-size: 16px;
    padding: 1rem 0.5rem;
  }

  .site-header nav {
    flex-direction: column;
    gap: 1rem;
  }

  .nav-menu {
    gap: 1rem;
  }

  .profile-section {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.5rem;
  }

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

  .news-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .news-date {
    min-width: auto;
  }

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

  .pagination {
    flex-direction: column;
    gap: 1rem;
  }

  .main-nav ul {
    flex-direction: column;
  }

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

  .research-item-title {
    font-size: 1rem;
  }

  .research-item-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
}

/* Research Page Styles */
.research-page {
  max-width: 900px;
}

.research-section {
  margin-bottom: 4rem;
}

.research-section h2 {
  color: var(--color-primary);
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-border);
}

.research-interests {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: 3rem;
}

.research-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.research-item {
  padding: 1.25rem;
  background: var(--color-accent-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.research-item.collapsible .research-item-header.clickable {
  cursor: pointer;
  user-select: none;
}

.research-item:hover {
  box-shadow: 0 2px 8px var(--shadow-color);
  border-color: var(--color-secondary);
}

.research-item-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.research-item-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.research-item-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
  line-height: 1.4;
}

.research-item-title a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s ease;
  border-bottom: none;
}

.research-item-title a:hover {
  color: var(--color-secondary);
}

.research-item-title a::after {
  content: " ↗";
  font-size: 0.85em;
  color: var(--color-secondary);
  opacity: 0.7;
}

.expand-icon {
  font-size: 1.5rem;
  color: var(--color-secondary);
  font-weight: 300;
  line-height: 1;
  min-width: 1.5rem;
  text-align: center;
  transition: transform 0.2s ease;
}

.research-item-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.research-item-date {
  font-size: 0.9rem;
  color: var(--color-muted);
  font-weight: 500;
  text-transform: capitalize;
}

.research-item-venue {
  font-size: 0.9rem;
  color: var(--color-muted);
  font-style: italic;
}

.research-item-abstract {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
  margin-top: 0.75rem;
}

.research-item-abstract.collapsed {
  display: none;
}

.research-item-abstract.expanded {
  display: block;
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
