/* ==========================================================================
   Nan Feng — Personal Academic & Engineering Portfolio
   Simplistic, fast, accessible editorial stylesheet with refined motion
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --text: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #1e3a5f;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --tag-bg: #f1f5f9;
  --tag-text: #334155;
  --badge-journal-bg: #ecfdf5;
  --badge-journal-text: #065f46;
  --badge-review-bg: #eff6ff;
  --badge-review-text: #1e40af;
  --badge-preprint-bg: #fefce8;
  --badge-preprint-text: #854d0e;
  --badge-thesis-bg: #f5f3ff;
  --badge-thesis-text: #5b21b6;
  --figure-canvas: #ffffff;
  --mesh-dot: rgba(30, 58, 95, 0.14);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.22);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --max-width: 960px;
  --header-height: 64px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-subtle: #111827;
  --bg-elevated: #131c2e;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #93c5fd;
  --accent-hover: #bfdbfe;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(147, 197, 253, 0.28);
  --border: #1e293b;
  --border-strong: #334155;
  --tag-bg: #1e293b;
  --tag-text: #cbd5e1;
  --badge-journal-bg: rgba(16, 185, 129, 0.15);
  --badge-journal-text: #6ee7b7;
  --badge-review-bg: rgba(59, 130, 246, 0.18);
  --badge-review-text: #93c5fd;
  --badge-preprint-bg: rgba(245, 158, 11, 0.16);
  --badge-preprint-text: #fcd34d;
  --badge-thesis-bg: rgba(139, 92, 246, 0.18);
  --badge-thesis-text: #c4b5fd;
  --figure-canvas: #f8fafc;
  --mesh-dot: rgba(147, 197, 253, 0.16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.38);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 20px);
  -webkit-text-size-adjust: 100%;
}

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

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

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

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Accessibility helpers */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 12px;
  color: #ffffff;
}

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

/* ==========================================================================
   Subtle Motion & Keyframes
   ========================================================================== */

@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes mesh-drift {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(-10px, 8px, 0);
  }
}

@keyframes hero-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hero-stagger {
  animation: hero-enter 0.5s var(--ease-out) both;
}

.hero-stagger-2 {
  animation: hero-enter 0.55s var(--ease-out) 0.08s both;
}

.hero-stagger-3 {
  animation: hero-enter 0.55s var(--ease-out) 0.14s both;
}

/* Scroll Reveal (progressive enhancement: visible unless JS enables it) */
.js-reveal-ready [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.48s var(--ease-out), transform 0.48s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.js-reveal-ready [data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.scroll-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
  opacity: 0.85;
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #1e3a5f;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  display: inline-block;
  padding: 6px 11px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: var(--bg-subtle);
}

.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.menu-toggle {
  display: none;
}

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

/* ==========================================================================
   Hero Section
   ========================================================================== */

.hero {
  position: relative;
  overflow: hidden;
  padding: 56px 0 44px;
  border-bottom: 1px solid var(--border);
}

.hero-mesh-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle, var(--mesh-dot) 1.25px, transparent 1.25px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 65% 80% at 86% 24%, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 65% 80% at 86% 24%, #000 0%, rgba(0, 0, 0, 0.35) 55%, transparent 100%);
  animation: mesh-drift 16s ease-in-out infinite;
}

.hero > .container {
  position: relative;
  z-index: 1;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 188px;
  gap: 44px;
  align-items: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--accent);
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 0.42em;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  animation: pulse-ring 2.8s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
}

.hero-subtitle {
  margin: 0 0 18px;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-wrap: balance;
}

.hero-lead {
  margin: 0 0 24px;
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 64ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s var(--ease-out);
}

.btn:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn-primary {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: #ffffff;
}

.btn-primary:hover {
  background: #152b47;
  border-color: #152b47;
  color: #ffffff;
}

[data-theme="dark"] .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

[data-theme="dark"] .btn-primary:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #ffffff;
}

.hero-portrait-wrap {
  justify-self: end;
}

.hero-portrait {
  width: 184px;
  height: 184px;
  object-fit: cover;
  object-position: center 15%;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: #f8fafc;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease-out), border-color 0.2s ease;
}

.hero-portrait:hover {
  transform: scale(1.02);
  border-color: var(--border-strong);
}

[data-theme="dark"] .hero-portrait {
  border-color: var(--border-strong);
  filter: brightness(0.94) contrast(1.03);
}

/* Key Facts Strip */
.facts-strip {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.fact-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fact-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.fact-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.fact-sub {
  font-size: 0.83rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Sections
   ========================================================================== */

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

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

.section-subtle {
  background: var(--bg-subtle);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 26px;
}

.section-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}

.section-desc {
  margin: 6px 0 0;
  font-size: 0.96rem;
  color: var(--text-muted);
  max-width: 70ch;
}

/* ==========================================================================
   About
   ========================================================================== */

.about-content {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 36px;
  align-items: start;
}

.about-prose p {
  margin: 0 0 15px;
  color: var(--text-secondary);
}

.about-prose p:last-child {
  margin-bottom: 0;
}

.about-prose a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.about-prose a:hover {
  text-decoration-color: var(--accent-hover);
}

.focus-card {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.focus-card h3 {
  margin: 0 0 12px;
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.focus-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.focus-list li {
  position: relative;
  padding-left: 16px;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.focus-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ==========================================================================
   Unified Research & Publications (with embedded representative figures)
   ========================================================================== */

.pub-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  padding: 6px 13px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.filter-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.filter-btn.active {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: #ffffff;
}

[data-theme="dark"] .filter-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.pub-count {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.pub-item {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 18px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  transition: border-color 0.2s ease, box-shadow 0.24s var(--ease-out);
}

.pub-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

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

.pub-year {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 2px;
}

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

.pub-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 7px;
}

.pub-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pub-badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.badge-journal {
  background: var(--badge-journal-bg);
  color: var(--badge-journal-text);
}

.badge-review {
  background: var(--badge-review-bg);
  color: var(--badge-review-text);
}

.badge-preprint {
  background: var(--badge-preprint-bg);
  color: var(--badge-preprint-text);
}

.badge-thesis {
  background: var(--badge-thesis-bg);
  color: var(--badge-thesis-text);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--badge-journal-text);
  background: var(--badge-journal-bg);
  border: 1px solid color-mix(in srgb, var(--badge-journal-text) 24%, transparent);
  border-radius: 999px;
  white-space: nowrap;
}

.live-badge.is-paused {
  color: var(--text-muted);
  background: var(--tag-bg);
  border-color: var(--border);
}

.live-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-ring 2.2s infinite;
}

.live-badge.is-paused .live-badge-dot {
  background: var(--text-muted);
  animation: none;
}

.pub-title {
  margin: 0 0 6px;
  font-size: 1.07rem;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text);
}

.pub-authors {
  margin: 0 0 4px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

.pub-venue {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.pub-venue em {
  color: var(--text-secondary);
}

.pub-summary {
  margin: 0 0 13px;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 76ch;
}

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

.pill-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.pill-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* Embedded Publication Figures & Interactive Switcher */
.pub-media {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.media-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.media-tab {
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.media-tab:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.media-tab.active {
  background: #1e3a5f;
  border-color: #1e3a5f;
  color: #ffffff;
}

[data-theme="dark"] .media-tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.pub-media-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pub-figure-wrap {
  margin: 0;
}

.research-figure-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--figure-canvas);
  cursor: zoom-in;
  position: relative;
  text-align: left;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.2s var(--ease-out);
}

.research-figure-btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.research-figure-btn img {
  max-width: 100%;
  max-height: 290px;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: transform 0.3s var(--ease-out);
}

.pub-media-grid .research-figure-btn {
  height: 224px;
  padding: 12px;
}

.pub-media-grid .research-figure-btn img {
  max-height: 100%;
}

.research-figure-btn:hover img {
  transform: scale(1.015);
}

.zoom-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #334155;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.research-figure-btn:hover .zoom-hint,
.research-figure-btn:focus-visible .zoom-hint {
  opacity: 1;
}

.pub-figure-caption {
  margin: 8px 2px 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ==========================================================================
   Open-Source Software
   ========================================================================== */

.subsection-label {
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.subsection-label.spaced {
  margin-top: 28px;
}

.repo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.repo-card {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  transition: border-color 0.18s ease, box-shadow 0.22s var(--ease-out), transform 0.22s var(--ease-out);
}

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

.repo-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.repo-arrow {
  color: var(--text-muted);
  transition: color 0.16s ease, transform 0.16s ease;
}

.repo-card:hover .repo-arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.repo-name {
  margin: 0 0 8px;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.repo-name a {
  color: var(--text);
}

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

.lang-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.repo-desc {
  margin: 0 0 14px;
  font-size: 0.89rem;
  color: var(--text-secondary);
  flex: 1;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.74rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--tag-bg);
  color: var(--tag-text);
}

/* ==========================================================================
   Experience, Education & Skills
   ========================================================================== */

.timeline-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 36px;
  align-items: start;
}

.timeline {
  position: relative;
  padding-left: 20px;
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-period {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.timeline-role {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.timeline-org {
  margin: 2px 0 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.timeline-bullets {
  margin: 0;
  padding-left: 18px;
  font-size: 0.89rem;
  color: var(--text-secondary);
}

.timeline-bullets li {
  margin-bottom: 5px;
}

.timeline-bullets li:last-child {
  margin-bottom: 0;
}

.edu-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.edu-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}

.edu-card h4 {
  margin: 0 0 3px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.edu-meta {
  margin: 0 0 4px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.edu-note {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.skills-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-elevated);
}

.skill-group {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
}

.skill-group:last-child {
  border-bottom: none;
}

.skill-cat {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.skill-items {
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ==========================================================================
   Honors, Talks & Academic Service
   ========================================================================== */

.recognition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.info-panel {
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.info-panel h3 {
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.compact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.compact-list li {
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.compact-list strong {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.compact-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Contact & Footer
   ========================================================================== */

.contact-card {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 28px;
  padding: 28px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  align-items: center;
}

.contact-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.contact-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.contact-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.88rem;
}

.contact-email {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.contact-location {
  color: var(--text-secondary);
}

.copy-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
}

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

.site-footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  font-size: 0.84rem;
  color: var(--text-muted);
}

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

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

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

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

/* ==========================================================================
   Modals (BibTeX & Image Lightbox)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 22px 24px;
  animation: modal-in 0.2s var(--ease-out) both;
}

.modal-dialog.lightbox-dialog {
  max-width: 980px;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.bibtex-code {
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lightbox-img-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.lightbox-img-wrap img {
  margin: 0 auto;
  max-height: 70vh;
  object-fit: contain;
}

.lightbox-caption {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Reduced Motion Preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js-reveal-ready [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 840px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }
  .hero-portrait-wrap {
    order: -1;
    justify-self: start;
  }
  .hero-portrait {
    width: 124px;
    height: 124px;
  }
  .facts-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .about-content,
  .pub-media-grid,
  .repo-grid,
  .timeline-grid,
  .recognition-grid,
  .contact-card {
    grid-template-columns: 1fr;
  }
  .pub-media-grid .research-figure-btn {
    height: auto;
    min-height: 160px;
  }
}

@media (max-width: 720px) {
  .menu-toggle {
    display: inline-flex;
  }
  .nav-links {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px 20px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: none;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-links a {
    padding: 10px 12px;
  }
  .hero {
    padding: 36px 0 32px;
  }
  .section {
    padding: 40px 0;
  }
  .pub-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 18px 18px;
  }
  .research-figure-btn {
    padding: 10px;
  }
  .contact-card {
    padding: 22px 20px;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .site-header,
  .hero-mesh-bg,
  .hero-actions,
  .pub-controls,
  .media-switcher,
  .card-links,
  .copy-btn,
  .zoom-hint,
  .live-badge,
  .site-footer {
    display: none !important;
  }
  .js-reveal-ready [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  body {
    color: #000000;
    background: #ffffff;
    font-size: 11pt;
  }
  .section {
    padding: 18px 0;
    break-inside: avoid;
  }
  .repo-card,
  .pub-item {
    break-inside: avoid;
    box-shadow: none;
  }
}
