/* ---------- Design tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif-display: Georgia, "Times New Roman", serif;

  --bg: #f7f8fb;
  --bg-alt: #eef0f7;
  --surface: #ffffff;
  --border: #e1e4ee;
  --text: #1c2130;
  --text-muted: #565f75;
  --accent: #4f46e5;
  --accent-strong: #3f37c9;
  --accent-contrast: #ffffff;
  --shadow: 0 1px 2px rgba(23, 26, 43, 0.04), 0 8px 24px rgba(23, 26, 43, 0.06);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --max-width: 920px;
  --header-height: 80px;
}

:root[data-theme="dark"] {
  --bg: #0f1220;
  --bg-alt: #141830;
  --surface: #171b30;
  --border: #2a2f4a;
  --text: #e8eaf5;
  --text-muted: #a4aac5;
  --accent: #818cf8;
  --accent-strong: #a5b4fc;
  --accent-contrast: #0f1220;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px rgba(0, 0, 0, 0.35);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

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

/* Inline text links (professor names, course pages, media links) — a
   subtle underline instead of the harsh browser-default blue+underline. */
.text-link {
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
.text-link:hover { border-color: var(--accent); }

h1, h2, h3 { line-height: 1.2; font-weight: 700; }

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}

.brand-icon {
  width: 22px;
  height: 22px;
  filter: var(--brand-icon-filter, none);
}

:root[data-theme="dark"] .brand-icon { filter: invert(1); }

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--text);
  border-color: var(--accent);
}

/* Separates same-page sections from links that navigate to another page. */
.nav-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  align-self: center;
}

.nav-page-link::after {
  content: "↗";
  display: inline-block;
  margin-left: 0.3em;
  font-size: 0.8em;
  opacity: 0.55;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.icon { width: 18px; height: 18px; }

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

.nav-toggle { display: none; }

/* ---------- Hero ---------- */
.hero {
  padding: 4rem 1.25rem 3rem;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
  scroll-margin-top: var(--header-height);
}

.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.hero-photo {
  width: 180px;
  height: 180px;
  border-radius: 999px;
  object-fit: cover;
  box-shadow: var(--shadow);
  border: 4px solid var(--surface);
  flex-shrink: 0;
}

.hero-text h1 {
  margin: 0 0 0.35rem;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
}

.hero-tagline {
  margin: 0 0 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.hero-intro {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  max-width: 55ch;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* ---------- Sections ---------- */
.section { padding: 3.5rem 1.25rem; scroll-margin-top: var(--header-height); }
.section-alt { background: var(--bg-alt); }

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section h2 {
  font-size: 1.6rem;
  margin: 0 0 1.25rem;
  letter-spacing: -0.01em;
}

.section h3 {
  font-size: 1.05rem;
  margin: 1.75rem 0 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-hint {
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1.25rem;
}

.prose p { margin: 0 0 1rem; }
.prose ul { margin: 0 0 1rem; padding-left: 1.25rem; }
.prose li { margin-bottom: 0.4rem; }

/* ---------- Accordion (education) ---------- */
.accordion { display: flex; flex-direction: column; gap: 0.75rem; }

.accordion details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  box-shadow: var(--shadow);
}

.accordion summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.accordion summary::-webkit-details-marker { display: none; }

.accordion summary .meta {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.accordion summary .chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.accordion details[open] summary .chevron { transform: rotate(90deg); }

.accordion ul {
  margin: 0.9rem 0 0.1rem;
  padding-left: 1.1rem;
}

.accordion li { margin-bottom: 0.4rem; color: var(--text-muted); }

.edu-subheading {
  margin: 1rem 0 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.accordion h5.edu-subheading:first-of-type { margin-top: 0.9rem; }

.edu-item-place {
  font-size: 0.85em;
  color: var(--text-muted);
}

/* ---------- Cards (teaching) ---------- */
.card-list { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.card .role { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.card h4 { margin: 0.3rem 0 0.2rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }

.note-card {
  margin-top: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Project cards (full-width, media on the side) ---------- */
.project-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.project-card-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
}

.project-card-row.no-media { grid-template-columns: 1fr; }

.project-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.project-info h4 { margin-bottom: 0.4rem; }
.project-info p { margin-bottom: 1rem; color: var(--text-muted); }

.project-media {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  align-self: center; /* fixed 16:10 box, never stretched by long text */
}

.project-media-img-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
}

.project-media-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
}

/* Phone screenshots are much taller than wide — cropping them into the
   16:10 desktop-site box would cut off most of the screen. Use a taller
   box and letterbox instead of cropping once we know it's portrait. */
.project-media.portrait .project-media-img {
  aspect-ratio: auto;
  width: auto;
  height: 340px;
  object-fit: contain;
}

/* Portrait shots (phones, PDF pages): the media column shrinks to the
   image's own width so no space is lost to letterboxing. */
.project-card-row.portrait-row { grid-template-columns: 1fr auto; }


.project-media-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  opacity: 0.85;
}

.project-media-arrow:hover { opacity: 1; border-color: var(--accent); }
.project-media-prev { left: 0.6rem; }
.project-media-next { right: 0.6rem; }

.project-media-dots {
  position: absolute;
  bottom: 0.6rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.35rem;
}

.project-media-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.project-media-dot.active { background: var(--accent); }

@media (max-width: 720px) {
  .project-card-row {
    grid-template-columns: 1fr;
  }
  .project-media { order: -1; }
  .project-card-row.portrait-row { grid-template-columns: 1fr; }
  .project-card-row.portrait-row .project-media { justify-self: center; }
}

/* ---------- Project screenshot lightbox ---------- */
.project-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
}

.project-lightbox.open { display: flex; }

.project-lightbox-img {
  max-width: min(90vw, 1100px);
  max-height: 85vh;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.project-lightbox-close,
.project-lightbox-nav {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-lightbox-close:hover,
.project-lightbox-nav:hover { background: rgba(255, 255, 255, 0.2); }

.project-lightbox-close {
  top: 1.2rem;
  right: 1.2rem;
  width: 40px;
  height: 40px;
  font-size: 1.6rem;
}

.project-lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 2rem;
}

.project-lightbox-prev { left: 1.2rem; }
.project-lightbox-next { right: 1.2rem; }

.project-lightbox-count {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
}

body.no-scroll { overflow: hidden; }

.project-group { margin-bottom: 2rem; }
.project-group:last-child { margin-bottom: 0; }

.project-category {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.project-type,
.project-status {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.project-type {
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.project-status {
  color: var(--accent);
  border: 1px solid var(--accent);
}

.project-status-outdated {
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
}

.project-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.project-source {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.project-source:hover { color: var(--accent); }

/* ---------- Lists (publications, resources) ---------- */
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }

.link-list a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.link-list a:hover { border-color: var(--accent); color: var(--accent); }

.link-list.plain li {
  color: var(--text-muted);
  padding: 0.15rem 0;
}
.link-list.plain strong { color: var(--text); }

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip-list a {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}
.chip-list a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- CV ---------- */
.cv-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.cv-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}

.cv-item a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cv-item a:hover { background: var(--accent-strong); transform: translateY(-1px); }

.cv-item h4 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.cv-item p { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.92rem; }

/* ---------- Contact ---------- */
.contact-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.contact-grid a {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.contact-grid a:hover { border-color: var(--accent); transform: translateY(-2px); }

.contact-grid .icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--accent);
}

.contact-grid .contact-text { min-width: 0; }
.contact-grid .contact-label { display: block; font-weight: 700; font-size: 0.85rem; }
.contact-grid .contact-value {
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.footer-note {
  font-size: 0.8rem;
  margin: 0 0 0.75rem;
}
.footer-note:empty { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero-inner { flex-direction: column; text-align: center; }
  .hero-actions { justify-content: center; }

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

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.5rem 1.25rem 1rem;
    gap: 0.25rem;
    display: none;
  }

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

  .site-nav a { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }

  .nav-sep { width: 100%; height: 1px; margin: 0.25rem 0; }
}

/* ---------- Extra Things I Did (standalone page) ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
.back-link:hover { color: var(--accent); }
.back-link .icon { width: 16px; height: 16px; }

.page-hero {
  padding: 3rem 1.25rem 2rem;
  text-align: center;
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
}
.page-hero h1 { font-size: 2rem; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.page-hero p { color: var(--text-muted); max-width: 60ch; margin: 0 auto; }
.page-hero .page-hero-cta { margin-top: 1.1rem; }

.et-group { margin-bottom: 0.5rem; }

.et-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.et-list li { color: var(--text-muted); }
.et-list .et-note { display: block; font-size: 0.88rem; margin-top: 0.15rem; }
.et-list .et-note a { font-weight: 600; }

.et-card-list { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 1.25rem; }

.et-card { padding: 0; overflow: hidden; }

.et-card-media {
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
}
.et-card-media img,
.et-card-media video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-alt);
}

.et-card-photo-pending {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
}
.et-card-body { padding: 1rem 1.1rem; }
.et-card-body h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.et-card-body p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.et-card-body .et-note { display: block; margin-top: 0.5rem; font-size: 0.85rem; font-weight: 600; }

.et-sublist-card { padding: 1.1rem 1.25rem; }
.et-sublist-card h4 { margin: 0 0 0.6rem; font-size: 1rem; }
.et-sublist-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.et-sublist-card li { color: var(--text-muted); font-size: 0.92rem; }
.et-sublist-card .et-empty-note { color: var(--text-muted); font-size: 0.88rem; font-style: italic; }

/* ---------- Course detail page ---------- */
.course-section { margin-bottom: 1.75rem; }
.course-section:last-child { margin-bottom: 0; }
