/* === Custom Properties === */
:root {
  --bg: #f0f1f3;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5d6370;
  --border: #e0e0e0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --link-hover-bg: #f3f4f6;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --badge-bg: #dbeafe;
  --badge-text: #1e40af;
  --pdf-bg: #fef2f2;
  --pdf-text: #dc2626;
  --pdf-hover: #fecaca;
}

html[data-theme="dark"] {
  --bg: #111827;
  --surface: #1f2937;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #374151;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --link-hover-bg: #374151;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --badge-bg: #1e3a5f;
  --badge-text: #93c5fd;
  --pdf-bg: #3b1818;
  --pdf-text: #fca5a5;
  --pdf-hover: #5c2020;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

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

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

/* === Layout === */
#container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

/* === Header / Nav === */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
  transition: background-color 0.2s;
}

nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--link-hover-bg);
}

/* === Theme Toggle === */
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

#theme-toggle:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.icon-dark { display: none; }
html[data-theme="dark"] .icon-light { display: none; }
html[data-theme="dark"] .icon-dark { display: inline; }

/* === Sections === */
.section {
  margin-bottom: 48px;
}

h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.section-note {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* === Hero / About === */
.hero {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 20px;
}

.avatar {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  flex-shrink: 0;
}

.hero-text h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2px;
}

.location {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.about-body p {
  margin-bottom: 16px;
  font-size: 0.95rem;
}

.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  display: inline-block;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  transition: background-color 0.15s, border-color 0.15s;
  cursor: pointer;
}

.btn:hover {
  background: var(--link-hover-bg);
  border-color: var(--text-muted);
  color: var(--text);
}

/* === Timeline (Experience & Education) === */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

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

.timeline-date {
  flex-shrink: 0;
  width: 120px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}

.timeline-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.timeline-content .org {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.timeline-content p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.timeline-content a {
  font-size: 0.88rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--badge-bg);
  color: var(--badge-text);
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* === Publications === */
.pub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 20px;
}

.pub-filter {
  background: none;
  border: 1px solid var(--border);
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.15s;
  font-family: inherit;
}

.pub-filter:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.pub-filter.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pub-list {
  list-style: none;
  counter-reset: pub-counter 28;
}

.pub-item {
  display: flex;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
}

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

.pub-item.hidden {
  display: none;
}

.pub-year {
  flex-shrink: 0;
  width: 48px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding-top: 2px;
}

.pub-details {
  flex: 1;
  min-width: 0;
}

.pub-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 2px;
  line-height: 1.4;
}

.pub-authors {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

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

.pub-pdf {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  background: var(--pdf-bg);
  color: var(--pdf-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background-color 0.15s;
}

.pub-pdf:hover {
  background: var(--pdf-hover);
  color: var(--pdf-text);
}

/* === Certifications === */
.cert-list {
  display: flex;
  flex-direction: column;
}

.cert-item {
  display: flex;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.cert-date {
  flex-shrink: 0;
  width: 120px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}

.cert-name {
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.cert-id {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* === Footer === */
footer {
  text-align: center;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* === Email tooltip === */
.email-revealed {
  position: relative;
}

.email-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  box-shadow: var(--shadow), 0 4px 12px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--text);
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.email-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === Responsive === */
@media (max-width: 700px) {
  #container {
    padding: 0 14px 32px;
  }

  header {
    margin-bottom: 20px;
  }

  nav {
    gap: 2px;
  }

  .nav-link {
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .avatar {
    width: 100px;
    height: 100px;
  }

  .hero-text h1 {
    font-size: 1.5rem;
  }

  .timeline-item {
    flex-direction: column;
    gap: 4px;
  }

  .timeline-date {
    width: auto;
  }

  .cert-item {
    flex-direction: column;
    gap: 4px;
  }

  .cert-date {
    width: auto;
  }

  .pub-item {
    flex-direction: column;
    gap: 4px;
  }

  .pub-year {
    width: auto;
  }

  .section {
    margin-bottom: 36px;
  }
}

@media (max-width: 480px) {
  .hero-text h1 {
    font-size: 1.3rem;
  }

  .links-row {
    gap: 6px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .nav-link {
    font-size: 0.72rem;
    padding: 5px 6px;
  }
}

/* === System dark mode fallback === */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: #111827;
    --surface: #1f2937;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #374151;
    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --link-hover-bg: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --badge-bg: #1e3a5f;
    --badge-text: #93c5fd;
    --pdf-bg: #3b1818;
    --pdf-text: #fca5a5;
    --pdf-hover: #5c2020;
  }

  html:not([data-theme]) .icon-light { display: none; }
  html:not([data-theme]) .icon-dark { display: inline; }
}

/* === Print === */
@media print {
  header, #theme-toggle, .pub-filters, .links-row {
    display: none;
  }

  body {
    font-size: 11pt;
    color: #000;
    background: #fff;
  }

  .section {
    page-break-inside: avoid;
  }

  a {
    color: #000;
    text-decoration: underline;
  }
}
