:root {
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #59636e;
  --card: #f6f8fa;
  --border: #d1d9e0;
  --accent: #a51417; /* WashU red */
}

[data-theme="dark"] {
  --bg: #0d1117;
  --text: #e6edf3;
  --muted: #9198a1;
  --card: #161b22;
  --border: #30363d;
  --accent: #ff6b6b;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

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

/* Nav */
.nav {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.logo { font-weight: 700; color: var(--text); }
.nav nav { display: flex; gap: 20px; align-items: center; }
.nav nav a { color: var(--muted); }
#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
}

/* Sections */
main { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
section { padding: 64px 0; scroll-margin-top: 60px; }
h2 { font-size: 1.6rem; margin-top: 0; }

.hero { padding: 120px 0 80px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 0 12px; }
.lead { font-size: 1.2rem; color: var(--muted); margin: 0 0 28px; }

.buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:hover { text-decoration: none; opacity: 0.85; }

/* Row lists (education, experience, projects) */
.row-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--border); }
.row-list > li { border-bottom: 1px solid var(--border); }
.row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 20px 12px;
  color: var(--text);
  transition: background 0.15s;
}
.row h3 { margin: 0 0 4px; font-size: 1.1rem; }
.row .org { font-weight: 400; color: var(--muted); }
.row p { margin: 0 0 10px; color: var(--muted); }
.row p:last-child, .row .tags { margin: 0; }
.row .details { margin: 0 0 10px; padding-left: 20px; color: var(--muted); }
.row .details:last-child { margin-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-thumb {
  width: 168px;
  flex-shrink: 0;
  order: 3; /* far right, after the date */
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.row-meta {
  order: -1; /* date column on the far left */
  width: 150px;
  flex-shrink: 0;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.arrow { display: inline-block; margin-left: 6px; transition: transform 0.15s; }

/* Clickable rows */
.row.link:hover { background: var(--card); text-decoration: none; }
.row.link:hover h3 { color: var(--accent); }
.row.link:hover .arrow { transform: translateX(4px); color: var(--accent); }

/* Project detail page */
.back { display: inline-block; margin: 40px 0 0; color: var(--muted); }
.project-page header { padding: 24px 0 8px; }
.project-page h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 0 0 8px; }
.project-page .meta { color: var(--muted); margin: 0 0 16px; }
.project-page img { width: 100%; border-radius: 10px; border: 1px solid var(--border); margin: 16px 0; }
.project-page section { padding: 24px 0; }
.project-page h2 { font-size: 1.3rem; }
.project-page h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.project-page figure { margin: 20px 0; }
.project-page figure img { margin: 0; }
.project-page video { width: 100%; display: block; border-radius: 10px; border: 1px solid var(--border); background: #000; }
.project-page figcaption { margin-top: 6px; font-size: 0.9rem; color: var(--muted); }

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.gallery figure { margin: 0; }
.gallery img { aspect-ratio: 4 / 3; object-fit: cover; }
/* Portrait photos and phone videos: cap the width so they don't get too tall */
.gallery.portrait { grid-template-columns: repeat(auto-fit, minmax(200px, 320px)); justify-content: center; margin: 20px 0; }
.gallery.portrait img { aspect-ratio: 3 / 4; }
.project-page .media-narrow { max-width: 720px; margin: 20px auto; }
.project-page .media-portrait { max-width: 360px; margin: 20px auto; }
.project-page .hero-img { aspect-ratio: 16 / 9; object-fit: cover; }

/* Comparison tables */
.project-page table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.project-page th, .project-page td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.project-page th { font-weight: 600; }
.project-page td:first-child { color: var(--muted); }

/* Numbered flow diagram */
.pipeline { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px; counter-reset: step; }
.pipeline li {
  flex: 1 1 140px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  counter-increment: step;
}
.pipeline li::before { content: counter(step); display: block; font-size: 0.75rem; color: var(--accent); font-weight: 700; }
.pipeline strong { display: block; }
.pipeline span { font-size: 0.85rem; color: var(--muted); }

.tags { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li {
  font-size: 0.8rem;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }

footer {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 520px) {
  .nav { padding: 12px 16px; }
  .nav nav { gap: 12px; }
  main { padding: 0 16px; }
  .row { flex-direction: column; gap: 8px; padding: 16px 8px; }
  .row-thumb { width: 100%; order: -2; }
  .row-meta { width: auto; }
}
