/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --bg-base:        #0d1117;
  --bg-surface:     #161b22;
  --bg-hover:       #1c2128;
  --border:         #21262d;

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #6e7681;

  --accent:         #4f8ef7;
  --accent-dim:     #2d5aa8;

  --font-heading: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;

  --sidebar-width: 260px;
  --radius:        6px;

  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  2rem;
  --space-xl:  4rem;
}

/* ============================================================
   Light mode overrides
   ============================================================ */
html.light {
  --bg-base:        #ffffff;
  --bg-surface:     #f6f8fa;
  --bg-hover:       #eaeef2;
  --border:         #d0d7de;
  --text-primary:   #1f2328;
  --text-secondary: #57606a;
  --text-muted:     #848d97;
  --accent:         #0969da;
  --accent-dim:     #0550ae;
}

/* ============================================================
   Theme toggle button
   ============================================================ */
#theme-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
  padding: 0;
}

#theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.icon-moon { display: none; }
html.light .icon-sun  { display: none; }
html.light .icon-moon { display: block; }

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
}

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

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
}

/* ============================================================
   Layout
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
  max-width: 1100px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  position: relative;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: var(--bg-base);
}

/* Profile block */
.sidebar-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.sidebar-photo {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  filter: grayscale(15%);
  display: block;
}

.sidebar-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-family: var(--font-heading);
}

.sidebar-title {
  font-size: 0.82rem;
  color: var(--accent);
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.4;
}

.sidebar-affiliations {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.1rem;
}

.sidebar-affiliations span {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Divider */
.sidebar-divider {
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

/* Nav */
.sidebar-nav ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-nav a {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  border-left: 2px solid var(--accent);
  padding-left: calc(0.75rem - 2px);
}

/* External icon links */
.sidebar-links {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  align-items: center;
}

.sidebar-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: border-color 0.2s, background 0.2s;
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar-icon-link:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  text-decoration: none;
}

.sidebar-icon-link img {
  width: 27px;
  height: 27px;
  object-fit: contain;
  display: block;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.sidebar-icon-link:hover img {
  opacity: 1;
}

/* Footer at bottom of sidebar */
.sidebar-spacer {
  flex: 1;
}

.sidebar-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   Content area
   ============================================================ */
.content {
  flex: 1;
  min-width: 0;
  padding: 3rem 3.5rem;
  display: flex;
  flex-direction: column;
  gap: 3rem;
}

/* ============================================================
   Sections
   ============================================================ */
.section {
  padding: 0;
}

.section-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.subsection-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
  font-weight: 600;
}

/* ============================================================
   About
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.about-text p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.about-text p:last-of-type {
  margin-bottom: 0;
}

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

.about-text a {
  color: var(--accent);
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: var(--space-md);
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
}

#coauthor-graph {
  width: 100%;
  height: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ============================================================
   Projects
   ============================================================ */
.project-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.project-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

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

.project-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px;
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.project-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.project-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ============================================================
   Affiliations
   ============================================================ */
.affil-grid {
  display: grid;
  gap: 0.75rem;
}

.affil-grid--primary {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 0.75rem;
}

.affil-grid--secondary {
  grid-template-columns: repeat(5, 1fr);
}

.affil-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.affil-box img {
  max-width: 100%;
  max-height: 48px;
  width: auto;
  object-fit: contain;
  display: block;
}

.affil-grid--secondary .affil-box {
  height: 64px;
  padding: 0.5rem;
}

.affil-grid--secondary .affil-box img {
  max-height: 38px;
}

.affil-box--dim img {
  opacity: 0.45;
}

@media (max-width: 768px) {
  .affil-grid--primary  { grid-template-columns: repeat(2, 1fr); }
  .affil-grid--secondary { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   Publications
   ============================================================ */
.pub-group {
  margin-bottom: var(--space-xl);
}

.pub-group:last-child {
  margin-bottom: 0;
}

.pub-group-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
  padding-left: var(--space-sm);
  border-left: 3px solid var(--accent-dim);
}

.pub-year-group {
  margin-bottom: var(--space-lg);
}

.pub-year-group:last-child {
  margin-bottom: 0;
}

.pub-year-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-heading);
  margin-bottom: 0.6rem;
}

.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pub-item {
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

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

.pub-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  font-size: 0.92rem;
}

.pub-main {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
}

.pub-title {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.4;
}

.pub-authors {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.pub-venue {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.pub-me {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 2px;
}

.pub-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  flex-shrink: 0;
  text-align: right;
}

.pub-year {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.pub-note {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--accent-dim);
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
  text-align: center;
}

/* ============================================================
   CV
   ============================================================ */
.btn {
  display: inline-block;
  padding: 0.55rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
  margin-bottom: var(--space-xl);
}

.btn--primary {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--text-primary);
}

.btn--primary:hover {
  background: var(--accent);
  text-decoration: none;
}

.cv-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.cv-block-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
  padding-left: var(--space-sm);
  border-left: 3px solid var(--accent-dim);
}

.cv-list { list-style: none; }

.cv-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

.cv-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  padding-top: 2px;
  white-space: nowrap;
}

.cv-details {
  color: var(--text-secondary);
  line-height: 1.5;
}

.cv-details strong {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================================
   Contact
   ============================================================ */
.contact-inner {
  max-width: 560px;
}

.contact-lead {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contact-list li {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s;
}

.contact-list li:hover { border-color: var(--accent-dim); }

.contact-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 110px;
  font-weight: 500;
}

/* ============================================================
   Responsive — mobile: sidebar becomes top bar
   ============================================================ */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1.5rem;
    gap: 1.25rem;
  }

  .sidebar-profile {
    flex-direction: row;
    text-align: left;
    align-items: center;
    gap: 1rem;
  }

  .sidebar-photo {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
  }

  .sidebar-affiliations {
    margin-top: 0.25rem;
  }

  .sidebar-nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .sidebar-nav a {
    padding: 0.35rem 0.75rem;
  }

  .sidebar-links {
    flex-direction: row;
  }

  .sidebar-spacer { display: none; }

  .sidebar-footer { display: none; }

  .content {
    padding: 2rem 1.5rem;
    gap: 2rem;
  }

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

@media (max-width: 480px) {
  .cv-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .sidebar {
    padding: 1.25rem;
  }

  .content {
    padding: 1.5rem 1rem;
  }
}
