/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --border: #30363d;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

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

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

/* ===== MAIN LAYOUT ===== */
section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 5rem 2rem;
  position: relative;
}

/* Reserve initial space on desktop to avoid first-load large layout shifts */
.gitgraph-page {
  min-height: 3200px;
}

/* ===== GIT GRAPH SECTION ===== */
.gitgraph-container {
  overflow-x: auto;
}

#gitGraph {
  display: block;
  margin: 0;
}

/* ===== DETAIL PANELS ===== */
.gitgraph-detail {
  position: absolute;
  padding: 1rem 1.5rem;
  text-align: left;
  right: 5rem;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
  margin-bottom: 20px;
}

.gitgraph-detail h3,
.gitgraph-detail h4,
.gitgraph-detail strong {
  color: var(--text-primary);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.gitgraph-detail p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.gitgraph-detail ul {
  padding-left: 1.2rem;
  margin-bottom: 0.5rem;
}

.gitgraph-detail li {
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.gitgraph-detail cite {
  color: var(--text-muted);
  font-style: normal;
}

.gitgraph-detail a {
  color: var(--accent);
}

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

/* ===== PUBLICATIONS ===== */
.pub-category {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.pub-list {
  list-style: none;
  padding-left: 0;
}

.pub-list li {
  padding: 0.4rem 0;
  border-left: 2px solid var(--border);
  padding-left: 0.8rem;
  margin-bottom: 0.4rem;
  transition: border-color 0.15s;
}

.pub-list li:hover {
  border-left-color: var(--accent);
}

.pub-list li strong {
  color: var(--text-primary);
  font-weight: 500;
}

.pub-list li cite small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

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

.pub-list li a {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--accent);
  margin-left: 0.3rem;
}

.pub-list li a:hover {
  background: var(--border);
}

/* Reusable badge-style link (same look as publication links) */
a.link-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--accent);
  margin-left: 0.3rem;
}

a.link-badge:hover {
  background: var(--border);
}

/* ===== PUB BOX (embedded in detail panels) ===== */
.pub-box {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}

.pub-box h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.pub-box-scroll {
  max-height: 300px;
  overflow-y: auto;
}

.pub-box .pub-list li {
  font-size: 0.78rem;
  padding: 0.3rem 0;
  padding-left: 0.6rem;
  margin-bottom: 0.3rem;
}

/* Type badge before each publication */
.pub-type-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--green);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0px 4px;
  margin-right: 0.3rem;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ===== EXPANDED PANELS (project/academic pages — full content on desktop) ===== */
.expanded-panels .gitgraph-detail {
  max-height: none;
  overflow-y: visible;
}

/* ===== MINI NAV (horizontal link bar in presentation panel) ===== */
.mini-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

.mini-nav a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--accent);
  transition: all 0.15s;
  text-decoration: none;
}

.mini-nav a:hover {
  background: var(--border);
  color: var(--accent-hover);
}

.mini-nav-sep {
  color: var(--text-muted);
  font-size: 0.75rem;
  user-select: none;
}

/* ===== REPO CARDS (GitHub repository embeds) ===== */
.repo-box {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}

.repo-box h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.repo-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.repo-card {
  display: block;
  flex: 1 1 220px;
  max-width: 320px;
  min-height: 90px;
  padding: 0.6rem 0.8rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.repo-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.repo-card-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.repo-icon {
  fill: var(--text-muted);
  flex-shrink: 0;
}

.repo-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repo-desc {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin: 0 0 0.3rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.repo-desc[data-loading] {
  color: var(--text-muted);
  font-style: italic;
}

.repo-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.lang-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 2px;
  vertical-align: middle;
}

.repo-stars {
  color: var(--yellow);
}

/* ===== TOOLTIP ===== */
.gitgraph-tooltip {
  position: absolute;
  margin-top: -15px;
  margin-left: 25px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  font-family: var(--font-mono);
  line-height: 1.4;
  box-shadow: var(--shadow);
}

.gitgraph-tooltip:after {
  position: absolute;
  top: 10px;
  left: -18px;
  width: 0;
  height: 0;
  border-width: 10px;
  border-style: solid;
  border-color: transparent;
  border-right-color: var(--bg-tertiary);
  content: "";
}

/* ===== CODE ===== */
code, pre {
  font-family: var(--font-mono);
}

code {
  padding: 2px 6px;
  font-size: 0.85em;
  color: var(--accent);
  background: var(--bg-tertiary);
  border-radius: 4px;
}

pre {
  display: block;
  padding: 12px 16px;
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

/* ===== IMAGES ===== */
.logoimage {
  display: none;
}

/* ===== TYPOGRAPHY ===== */
h1 {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0.5em 0;
  color: var(--text-primary);
}

h4 {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== CV HEADER ===== */
.cv-header {
  text-align: center;
  padding: 0.3rem 0 0.8rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.cv-header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

.cv-subtitle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ===== SOCIAL LINKS ===== */
.social-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.6rem;
}

.social-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.social-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.social-links a svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.social-links a img {
  width: 16px;
  height: 16px;
  border-radius: 2px;
}

/* ===== CV FOOTER / SITE FOOTER ===== */
.cv-footer,
.site-footer {
  text-align: right;
  padding: 1rem 0 0.5rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.site-footer {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

/* ===== HAMBURGER MENU ===== */
.hamburger-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  width: 40px;
  height: 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
  transition: all 0.3s;
  opacity: 0.6;
}

.hamburger-btn:hover {
  opacity: 1;
  border-color: var(--accent);
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.3s;
}

.hamburger-btn.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}

.hamburger-btn.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

.nav-menu {
  position: fixed;
  top: 0;
  right: -250px;
  width: 250px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: 999;
  display: flex;
  flex-direction: column;
  padding: 5rem 2rem 2rem;
  gap: 0.3rem;
  transition: right 0.3s ease;
  box-shadow: -4px 0 15px rgba(0,0,0,0.3);
}

.nav-menu.open {
  right: 0;
}

.nav-menu a {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  transition: all 0.15s;
  text-decoration: none;
}

.nav-menu a:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.nav-menu a.active {
  color: var(--accent);
  background: var(--bg-tertiary);
  border-left: 2px solid var(--accent);
}

.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.nav-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Hide Jekyll's default header */
header { display: none; }

/* ===== PAGE HEADER (sub-pages) ===== */
.page-header {
  position: relative;
  text-align: center;
  padding: 0.3rem 0 0.8rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
}

.page-brand-muted {
  display: block;
  position: absolute;
  left: 50%;
  top: 0.2rem;
  transform: translateX(-50%);
  width: max-content;
  color: var(--text-muted);
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  margin: 0;
}

.page-subtitle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ===== LIGHT THEME ===== */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eaeef2;
    --text-primary: #1f2328;
    --text-secondary: #59636e;
    --text-muted: #818b98;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --border: #d1d9e0;
    --green: #1a7f37;
    --yellow: #9a6700;
    --red: #d1242f;
    --purple: #8250df;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  }
}

/* ===== RESPONSIVE ===== */

/* — Tablet large (≤1200px): reduce side padding — */
@media screen and (max-width: 1200px) {
  section {
    padding: 0.5rem 2rem 2rem;
  }

  .gitgraph-detail {
    right: 2rem;
  }
}

/* — Tablet small / iPad (≤1024px): tighter padding — */
@media screen and (max-width: 1024px) {
  section {
    padding: 0.5rem 1rem 2rem;
  }

  .gitgraph-detail {
    right: 1rem;
  }
}

/* — Mobile (≤768px): git graph left, panels right — */
@media screen and (max-width: 768px) {
  .gitgraph-page {
    min-height: 0;
  }

  section {
    padding: 0.5rem 0.5rem 1rem;
  }

  /* Panels stretch from git-graph edge (left set by JS) to right edge */
  .gitgraph-detail {
    right: 0.5rem !important;
    max-height: min(46vh, 360px) !important;
    overflow-y: auto;
    font-size: 0.78rem;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0;
  }

  .expanded-panels .gitgraph-detail {
    max-height: min(46vh, 340px) !important;
    overflow-y: auto !important;
  }

  .repo-cards {
    flex-direction: column;
    gap: 0.4rem;
  }

  .repo-card {
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
  }



  .cv-header h1 {
    font-size: 1.4rem;
  }

  .cv-subtitle {
    font-size: 0.75rem;
  }

  .social-links {
    gap: 0.5rem;
  }

  .social-links a {
    width: 28px;
    height: 28px;
  }

  .social-links a svg {
    width: 14px;
    height: 14px;
  }

  .cv-footer,
  .site-footer {
    text-align: center;
  }
}

/* — Very small screens (≤400px): even more compact — */
@media screen and (max-width: 400px) {
  section {
    padding: 0.3rem 0.25rem 0.8rem;
  }

  .gitgraph-detail {
    font-size: 0.72rem;
    padding: 0.4rem 0.5rem;
    right: 0.25rem !important;
    max-height: min(42vh, 300px) !important;
  }

  .gitgraph-detail::before {
    font-size: 0.68rem;
  }

  .cv-header h1 {
    font-size: 1.2rem;
  }

  .cv-subtitle {
    font-size: 0.68rem;
  }

  .social-links a {
    width: 24px;
    height: 24px;
  }

  .social-links a svg {
    width: 12px;
    height: 12px;
  }
}
