/* ===========================================================
   Tom Ngo — Personal Website
   Clean, minimal academic style inspired by andrewng.org
   =========================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --text: #1a1d23;
  --text-muted: #5b6470;
  --text-faint: #8a929c;
  --accent: #1a56db;
  --accent-hover: var(--accent-hover);
  --accent-soft: #e8effc;
  --border: #e6e8ec;
  --surface: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.85);
  --max-width: 820px;
  --radius: 12px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-serif: "Newsreader", Georgia, Cambria, "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04),
    0 8px 24px rgba(16, 24, 40, 0.06);
}

html {
  color-scheme: light;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-soft: #171a21;
  --text: #e7e9ee;
  --text-muted: #a6adba;
  --text-faint: #707783;
  --accent: #6699ff;
  --accent-hover: #8fb4ff;
  --accent-soft: #1a2742;
  --border: #272b34;
  --surface: #171a21;
  --header-bg: rgba(15, 17, 21, 0.82);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ----------  Reset / base  ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

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

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

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

p {
  margin: 0 0 1.1em;
}

/* Keep small UI elements in a clean sans for contrast with the serif */
.nav-links a,
.eyebrow,
.tag,
.chip,
.btn,
.pub-year,
.meta,
.date,
.social-row a,
.footer-copy {
  font-family: var(--font-sans);
}

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

/* ----------  Header / nav  ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-right: auto;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 4px 0;
  position: relative;
}

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

.nav-links a[aria-current="page"] {
  color: var(--text);
}

.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

.nav-toggle svg {
  display: block;
}

/* theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
  margin-left: 8px;
  color: var(--text-muted);
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.theme-toggle svg {
  width: 19px;
  height: 19px;
  display: block;
}

.theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ----------  Layout helpers  ---------- */
main {
  padding: 0 0 72px;
}

.section {
  padding-top: 56px;
}

.section-title {
  font-size: 1.5rem;
  margin: 0 0 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px;
}

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

/* ----------  Hero (About)  ---------- */
.hero {
  text-align: center;
  padding: 64px 0 8px;
}

.hero-photo {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  margin: 0 auto 24px;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
  background: var(--bg-soft);
}

.hero h1 {
  font-size: 2.4rem;
  margin: 0 0 8px;
}

.hero-tagline {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto 22px;
}

.hero-tagline strong {
  color: var(--text);
  font-weight: 600;
}

/* social / link row */
.social-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.social-row a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--surface);
  transition: all 0.15s ease;
}

.social-row a:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}

.social-row svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ----------  Prose blocks  ---------- */
.lead {
  font-size: 1.08rem;
}

.cards {
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  background: var(--surface);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: #d6dae1;
}

.card h3 {
  font-size: 1.12rem;
  margin: 0 0 4px;
}

.card .meta {
  color: var(--text-faint);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

.card ul {
  margin: 0;
  padding-left: 18px;
}

.card ul li {
  margin-bottom: 6px;
  color: var(--text-muted);
}

/* tag pills */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
}

.tag {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 3px 9px;
}

/* "View on GitHub" link on project cards */
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 16px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
}

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

.card-link svg {
  width: 16px;
  height: 16px;
}

/* Award badge */
.award {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: #92600a;
  background: #fdf3d3;
  border: 1px solid #f3dca0;
  border-radius: 999px;
  padding: 5px 12px;
  margin: 2px 0 14px;
}

.award svg {
  width: 15px;
  height: 15px;
}

[data-theme="dark"] .award {
  color: #f5cf72;
  background: #2c2410;
  border-color: #4a3c16;
}

/* ----------  Research interests grid  ---------- */
.interest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 4px 0 8px;
}

.interest {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--bg-soft);
}

.interest h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

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

/* ----------  Publications  ---------- */
.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 18px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.pub:last-child {
  border-bottom: 0;
}

.pub-year {
  font-weight: 700;
  color: var(--text-faint);
  font-size: 0.95rem;
  padding-top: 1px;
}

.pub-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 4px;
}

.pub-authors {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 3px;
}

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

.pub-venue {
  color: var(--text-faint);
  font-size: 0.9rem;
  font-style: italic;
  margin: 0;
}

/* ----------  CV page  ---------- */
.cv-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: baseline;
  margin-bottom: 4px;
}

.cv-item h3 {
  font-size: 1.05rem;
  margin: 0;
}

.cv-item .date {
  color: var(--text-faint);
  font-size: 0.88rem;
  white-space: nowrap;
}

.cv-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 8px;
}

.cv-block {
  margin-bottom: 30px;
}

.cv-block ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.cv-block ul li {
  margin-bottom: 6px;
  color: var(--text-muted);
}

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

.chip {
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 5px 11px;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* ----------  Footer  ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 0;
  margin-top: 24px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-social {
  display: flex;
  gap: 14px;
}

.footer-social a {
  color: var(--text-faint);
  display: inline-flex;
}

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

.footer-social svg {
  width: 20px;
  height: 20px;
}

.footer-copy {
  color: var(--text-faint);
  font-size: 0.88rem;
}

/* ----------  Scroll reveal  ---------- */
.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}

.reveal-ready .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Staggered entrance for the hero on load */
.hero .container > .reveal:nth-child(1) {
  transition-delay: 0.04s;
}
.hero .container > .reveal:nth-child(2) {
  transition-delay: 0.12s;
}
.hero .container > .reveal:nth-child(3) {
  transition-delay: 0.2s;
}
.hero .container > .reveal:nth-child(4) {
  transition-delay: 0.28s;
}

@media (prefers-reduced-motion: reduce) {
  .reveal-ready .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ----------  Responsive  ---------- */
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav-links {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 24px 16px;
    box-shadow: var(--shadow);
    display: none;
  }

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

  .nav-links a {
    width: 100%;
    padding: 11px 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .nav-links a:last-child {
    border-bottom: 0;
  }

  .nav-links a[aria-current="page"]::after {
    display: none;
  }

  .hero {
    padding: 40px 0 8px;
  }

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

  .pub {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .pub-year {
    padding-top: 0;
  }

  .cv-item {
    grid-template-columns: 1fr;
  }
}
