/* ============================================
   An Thai Le — Academic Personal Website
   Pure CSS/JS, zero dependencies
   ============================================ */

/* ── CSS Variables ── */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-text: #292524;
  --color-text-secondary: #78716c;
  --color-text-muted: #a8a29e;
  --color-border: #e7e5e4;
  --color-primary: #0f766e;
  --color-primary-light: #14b8a6;
  --color-primary-dark: #115e59;
  --color-accent: #d97706;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;

  --max-width: 960px;
  --nav-height: 64px;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-bg: #0c0a09;
  --color-surface: #1c1917;
  --color-text: #f5f5f4;
  --color-text-secondary: #a8a29e;
  --color-text-muted: #78716c;
  --color-border: #292524;
  --color-primary: #14b8a6;
  --color-primary-light: #2dd4bf;
  --color-primary-dark: #0d9488;
  --color-accent: #fbbf24;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 16px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.65;
  font-size: 16px;
  transition: background var(--transition), color var(--transition);
}

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

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

[data-theme="dark"] a:hover {
  color: var(--color-primary-light);
}

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

::selection {
  background: var(--color-primary);
  color: #fff;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; margin-bottom: 1.25rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; }
h4 { font-size: 1rem; margin-bottom: 0.5rem; }

p {
  margin-bottom: 1rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
}

/* ── Layout ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 3.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.section:last-of-type {
  border-bottom: none;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  color: var(--color-text);
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
  margin-left: 0.5rem;
}

/* ── Navigation ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 249, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
  transition: background var(--transition);
}

[data-theme="dark"] .navbar {
  background: rgba(12, 10, 9, 0.85);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  letter-spacing: -0.03em;
}

.nav-brand:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all var(--transition);
}

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

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Mobile Menu */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: 4px;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

/* ── Hero ── */
.hero {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--color-border);
}

.hero-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3rem;
  align-items: start;
}

.hero-avatar {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  user-select: none;
  object-fit: cover;
  border: 3px solid var(--color-surface);
}

.hero-content {
  padding-top: 0.5rem;
}

.hero-name {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .hero-name {
  background: linear-gradient(135deg, var(--color-text) 0%, var(--color-primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-title {
  font-size: 1.15rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 1.25rem;
  font-family: var(--font-sans);
}

.hero-bio {
  max-width: 640px;
  margin-bottom: 1.5rem;
  color: var(--color-text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.hero-link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.hero-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ── News ── */
.news-list {
  list-style: none;
}

.news-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}

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

.news-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 500;
  padding-top: 0.15rem;
}

.news-text {
  font-size: 0.95rem;
  color: var(--color-text);
  font-family: var(--font-sans);
  line-height: 1.6;
}

.news-text strong {
  color: var(--color-primary);
  font-weight: 600;
}

/* ── Research ── */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

.research-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  transition: all var(--transition);
}

.research-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ── Service Grid (2-column) ── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

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

.research-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.research-card-icon svg {
  width: 20px;
  height: 20px;
  color: #fff;
}

.research-card h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.research-card p {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  line-height: 1.6;
  margin-bottom: 0;
}

/* ── Publications ── */
.pub-thumb {
  width: 200px;
  height: 130px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

.pub-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.pub-body {
  min-width: 0;
}

.pub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.pub-filter-btn {
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.pub-filter-btn:hover,
.pub-filter-btn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

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

.pub-item {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.25rem;
  align-items: start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  transition: all var(--transition);
}

.pub-item:hover {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-sm);
}

.pub-item.pub-featured {
  border-left: 4px solid var(--color-accent);
  background: linear-gradient(90deg, rgba(217, 119, 6, 0.04) 0%, var(--color-surface) 60px);
}

[data-theme="dark"] .pub-item.pub-featured {
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.06) 0%, var(--color-surface) 60px);
}

.pub-item.pub-featured:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.12);
}

.pub-featured-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--color-accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
  line-height: 1.4;
}

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

.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.pub-title a {
  color: var(--color-text);
  text-decoration: none;
}

.pub-title a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.6rem;
  font-family: var(--font-sans);
}

.pub-authors .me {
  color: var(--color-text);
  font-weight: 600;
}

.pub-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.pub-venue {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.venue-tier-1 { background: #fef3c7; color: #92400e; }
.venue-tier-2 { background: #dcfce7; color: #166534; }
.venue-tier-3 { background: #dbeafe; color: #1e40af; }
.venue-journal { background: #f3e8ff; color: #6b21a8; }
.venue-prep { background: #f1f5f9; color: #475569; }

[data-theme="dark"] .venue-tier-1 { background: #451a03; color: #fcd34d; }
[data-theme="dark"] .venue-tier-2 { background: #052e16; color: #86efac; }
[data-theme="dark"] .venue-tier-3 { background: #172554; color: #93c5fd; }
[data-theme="dark"] .venue-journal { background: #3b0764; color: #d8b4fe; }
[data-theme="dark"] .venue-prep { background: #1e293b; color: #94a3b8; }

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.pub-links a {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  transition: all var(--transition);
}

.pub-links a:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-surface);
}

.pub-links svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Timeline (Experience) ── */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--color-border);
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  padding-bottom: 2rem;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -1.5rem;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
}

.timeline-content h4 {
  font-size: 1rem;
  margin-bottom: 0.15rem;
}

.timeline-org {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-weight: 500;
  margin-bottom: 0.15rem;
  font-family: var(--font-sans);
}

.timeline-time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  line-height: 1.6;
  margin-bottom: 0;
}

.timeline-desc ul {
  list-style: disc;
  padding-left: 1.25rem;
}

.timeline-desc li {
  margin-bottom: 0.25rem;
}

/* ── Teaching ── */
.teach-list {
  list-style: none;
}

.teach-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--color-border);
  gap: 1rem;
}

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

.teach-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.teach-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ── People ── */
.people-category-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.people-category-title:first-of-type {
  margin-top: 0;
}

.people-past-title {
  color: var(--color-text-muted);
  font-weight: 500;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.people-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.people-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.people-card.people-past {
  opacity: 0.82;
}

.people-card.people-past:hover {
  opacity: 1;
}

.people-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.people-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.15);
}

.people-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.people-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.people-links {
  display: flex;
  gap: 0.5rem;
}

.people-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  transition: all var(--transition);
}

.people-links a:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
  background: var(--color-surface);
}

.people-links svg {
  width: 13px;
  height: 13px;
}

.collab-affiliation {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-weight: 400;
  line-height: 1.3;
}

/* ── Footer ── */
.footer {
  padding: 2.5rem 0;
  text-align: center;
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-family: var(--font-sans);
}

/* ── Scroll Reveal ── */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root {
    --nav-height: 56px;
  }

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

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

  .hero-avatar {
    width: 120px;
    height: 120px;
    font-size: 3rem;
    margin: 0 auto;
  }

  .hero-name {
    font-size: 2rem;
  }

  .hero-bio {
    margin-left: auto;
    margin-right: auto;
  }

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

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 1rem;
  }

  .nav-links.open {
    display: flex;
  }

  .mobile-menu-btn {
    display: block;
  }

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

  .section {
    padding: 2.5rem 0;
  }

  .news-item {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .pub-item {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .pub-thumb {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pub-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }

  .pub-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .pub-links {
    margin-left: 0;
  }

  .timeline {
    padding-left: 1.25rem;
  }

  .timeline-dot {
    left: -1.25rem;
    width: 10px;
    height: 10px;
  }

  .pub-item.pub-featured {
    background: var(--color-surface);
  }

  [data-theme="dark"] .pub-item.pub-featured {
    background: var(--color-surface);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .hero-name {
    font-size: 1.65rem;
  }

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

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

/* ── Print ── */
@media print {
  .navbar,
  .theme-toggle,
  .mobile-menu-btn,
  .hero-links,
  .pub-links,
  .pub-filters,
  .footer {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .section {
    padding: 1rem 0;
    border-bottom: 1px solid #ddd;
  }

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

  .pub-item {
    border: 1px solid #ddd;
    break-inside: avoid;
  }
}
