/* ============================================================
   1. RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  padding-left: 1.5rem;
}

/* ============================================================
   2. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  --color-header-bg: #1a1a2e;
  --color-header-text: #ffffff;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-bg: #ffffff;
  --color-bg-alt: #f4f5f7;
  --color-text: #212529;
  --color-text-muted: #6c757d;
  --color-border: #dee2e6;
  --sidebar-width: 280px;
  --content-max-width: 1200px;
  --header-height: 56px;
}

/* ============================================================
   3. LAYOUT
   ============================================================ */
.site-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.site-body {
  display: flex;
  flex: 1;
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
  padding: 2rem 1rem;
  gap: 2rem;
  align-items: flex-start;
}

/* ============================================================
   4. HEADER
   ============================================================ */
.site-header {
  background: var(--color-header-bg);
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.site-header__inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  color: var(--color-header-text);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.site-title:hover {
  color: #ccd6f6;
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: #ccd6f6;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.site-nav a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.site-nav a.is-current {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* ============================================================
   5. SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
  align-self: flex-start;
}

.author-profile {
  background: var(--color-bg-alt);
  border-radius: 6px;
  padding: 1.5rem 1.25rem;
  text-align: center;
  border: 1px solid var(--color-border);
}

.author-avatar {
  margin-bottom: 1rem;
}

.author-avatar img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto;
  border: 3px solid var(--color-border);
}

.author-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.author-bio {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.social-links {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
}

.social-links li {
  border-top: 1px solid var(--color-border);
}

.social-links li:first-child {
  border-top: none;
}

.social-links a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.25rem;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.15s;
}

.social-links a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.social-links i {
  width: 1.1rem;
  text-align: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

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

/* ============================================================
   6. MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--color-accent);
}

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

.main-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 3rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.main-content h2:first-child {
  margin-top: 0;
}

.main-content ul {
  margin-bottom: 1rem;
}

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

/* spacer used in about.md */
.spacer {
  margin-top: 4rem;
}

/* ============================================================
   7. PUBLICATION CARDS (homepage selected publications)
   ============================================================ */
.pub-card {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

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

.pub-card__image {
  width: 280px;
  flex-shrink: 0;
}

.pub-card__image img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.pub-card__body {
  flex: 1;
  min-width: 0;
  text-align: justify;
}

.pub-card__body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

.pub-card__body h3 a {
  color: var(--color-text);
}

.pub-card__body h3 a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.pub-card__body p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* ============================================================
   8. ARCHIVE ITEMS (publications, talks, teaching pages)
   ============================================================ */
.archive-item {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--color-border);
}

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

.archive-item h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.archive-item h3 a {
  color: var(--color-text);
}

.archive-item h3 a:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.archive-item .meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.archive-item .excerpt {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.archive-item .links {
  font-size: 0.85rem;
}

.archive-item .links a {
  color: var(--color-accent);
  margin-right: 0.75rem;
}

.archive-category-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

.archive-category-heading + hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin-bottom: 1.25rem;
}

.scholar-link {
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* ============================================================
   8b. PROJECT CARDS (misc page)
   ============================================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.35rem;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.project-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--color-accent);
}

.project-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.project-card p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1.1rem;
  flex: 1;
}

.project-card .project-link {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-accent);
  padding: 0.45rem 0.9rem;
  border-radius: 5px;
  transition: background 0.15s;
}

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

/* ============================================================
   9. CV SECTIONS
   ============================================================ */
.cv-section {
  margin-bottom: 2.5rem;
}

.cv-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--color-border);
}

.cv-entry {
  margin-bottom: 1.1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--color-accent);
  line-height: 1.6;
  font-size: 0.95rem;
}

.cv-entry > strong {
  display: block;
  font-weight: 600;
  color: var(--color-text);
}

.cv-entry .cv-meta {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.cv-section ul {
  margin: 0;
}

.cv-section > ul {
  padding-left: 1.25rem;
}

/* ============================================================
   10. FOOTER
   ============================================================ */
.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: auto;
}

.site-footer a {
  color: var(--color-text-muted);
}

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

/* ============================================================
   11. RESPONSIVE (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  .site-body {
    flex-direction: column;
    padding: 1.25rem 1rem;
    gap: 1.5rem;
  }

  .sidebar {
    width: 100%;
    position: static;
  }

  .author-profile {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem;
    text-align: left;
  }

  .author-avatar {
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .author-avatar img {
    width: 100px;
    height: 100px;
  }

  .author-info {
    flex: 1;
    min-width: 0;
  }

  .social-links {
    width: 100%;
  }

  .pub-card {
    flex-direction: column;
  }

  .pub-card__image {
    width: 100%;
    max-width: 320px;
  }

  .page-title {
    font-size: 1.4rem;
  }

  .site-header {
    height: auto;
    position: static;
  }

  .site-header__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
  }

  .site-nav {
    gap: 0.2rem;
  }

  .site-nav a {
    padding: 0.3rem 0.55rem;
  }

  .sidebar {
    top: 1rem;
  }
}
