/* Base colors come from CSS custom properties injected via site.zon.
   Fallbacks are provided in case the inline <style> block is missing. */
:root {
  --title-color: #1e3a8a;
  --accent-color: #2563eb;
  --text-color: #1f2937;
  --muted-color: #6b7280;
  --background-color: #ffffff;
  --surface-color: #f3f4f6;
  --menu-bg: #111827;
  --menu-fg: #f9fafb;
  --font-family: system-ui, sans-serif;
  --max-width: 62rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-family);
  color: var(--text-color);
  background: var(--background-color);
  line-height: 1.65;
  font-size: 1.125rem;
}

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

code {
  background: var(--surface-color);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
}

/* Header + cascade menu ---------------------------------------------------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--menu-bg);
  color: var(--menu-fg);
}

.brand {
  font-weight: 700;
  color: var(--menu-fg);
  font-size: 1.1rem;
}
.brand:hover { text-decoration: none; opacity: 0.85; }

.menu > ul {
  list-style: none;
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.menu li { position: relative; }

.menu a {
  display: block;
  padding: 0.5rem 0.85rem;
  color: var(--menu-fg);
  border-radius: 0.35rem;
}
.menu a:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }

/* Cascade / dropdown submenu */
.menu li > ul {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  position: absolute;
  top: 100%;
  /* Anchor to the right edge of the parent item: the menu sits at the right
     edge of the screen, so a left-anchored dropdown (even while invisible)
     extends past the viewport and causes page-wide horizontal scrolling. */
  right: 0;
  left: auto;
  min-width: 12rem;
  background: var(--menu-bg);
  border-radius: 0.35rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
  z-index: 20;
}

.menu li:hover > ul,
.menu li:focus-within > ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.menu .has-children > a::after {
  content: " \25be"; /* ▾ */
  font-size: 0.75em;
  opacity: 0.8;
}

/* Content ------------------------------------------------------------------ */
.content {
  max-width: var(--max-width);
  margin: 3rem auto;
  padding: 0 2rem;
}

.page-title { color: var(--title-color); margin-bottom: 0.25rem; font-size: 2rem; }
.role { color: var(--muted-color); font-weight: 600; margin-top: 0; }
.tagline { color: var(--muted-color); }

.hero { margin-bottom: 2rem; }

/* Papers */
.papers { list-style: none; padding: 0; }
.paper-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--surface-color);
}
.paper-link { font-weight: 600; font-size: 1.05rem; }
.paper-meta { display: block; color: var(--muted-color); font-size: 0.9rem; }
.paper-venue { display: block; color: var(--muted-color); font-size: 0.9rem; font-style: italic; }
.paper-links { display: block; color: var(--muted-color); font-size: 0.85rem; margin: 0.15rem 0 0; }
.paper-links a { overflow-wrap: anywhere; }

.paper .authors { color: var(--muted-color); margin-bottom: 0.15rem; }
.paper .venue { color: var(--muted-color); font-size: 0.95rem; margin: 0 0 0.4rem; }
.paper .doi { font-size: 0.95rem; margin-top: 0; }
.paper .abstract { background: var(--surface-color); padding: 1rem 1.25rem; border-radius: 0.5rem; }
.paper .actions { margin-top: 1.5rem; }
.paper h2 { color: var(--title-color); font-size: 1.35rem; margin-top: 2rem; }
.paper .muted { color: var(--muted-color); font-size: 0.9rem; }

/* Summary sections */
.summary h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.summary ul { padding-left: 1.2rem; }
.summary li { margin: 0.3rem 0; }

/* Data / results tables */
.datatable { border-collapse: collapse; width: 100%; font-size: 0.92rem; margin: 0.5rem 0; }
.datatable caption { caption-side: bottom; color: var(--muted-color); font-size: 0.85rem; padding-top: 0.5rem; text-align: left; }
.datatable th, .datatable td { border-bottom: 1px solid var(--surface-color); padding: 0.4rem 0.6rem; text-align: left; }
.datatable thead th { color: var(--title-color); border-bottom: 2px solid var(--surface-color); }
.datatable.results td { text-align: right; font-variant-numeric: tabular-nums; }
.datatable.results td:first-child, .datatable.results th:first-child { text-align: left; }
.datatable .best { color: #238636; font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* CV -------------------------------------------------------------------- */
html { scroll-behavior: smooth; }

/* Two-column CV layout: sticky section index + content */
.cv-layout {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 2.75rem;
  align-items: start;
  /* Use more of the page and sit closer to the left */
  max-width: 76rem;
  margin-left: 2rem;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 0.5rem;
}

.cv-nav {
  position: sticky;
  top: 1.5rem;
  align-self: start;
}
.cv-nav nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--surface-color);
}
.cv-nav li { margin: 0; }
.cv-nav a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.75rem;
  margin-left: -2px; /* overlap the ul border */
  border-left: 2px solid transparent;
  color: var(--muted-color);
  font-size: 0.82rem;
  line-height: 1.25;
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.cv-nav a:hover { color: var(--text-color); text-decoration: none; }
.cv-nav a.active {
  color: var(--accent-color);
  border-left-color: var(--accent-color);
  font-weight: 600;
  transform: translateX(2px);
}

/* Anchored sections clear the top of the viewport nicely on jump */
.cv-section { scroll-margin-top: 1.5rem; }
.page-title { scroll-margin-top: 1.5rem; }
/* First section sits tight under the page title */
.cv-section:first-of-type h2 { margin-top: 1rem; }

/* Collapse to single column on narrower screens */
@media (max-width: 52rem) {
  .cv-layout { grid-template-columns: 1fr; gap: 1rem; }
  .cv-nav { position: static; top: auto; }
  .cv-nav nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    border-left: 0;
  }
  .cv-nav a {
    padding: 0.25rem 0.6rem;
    margin-left: 0;
    border-left: 0;
    border: 1px solid var(--surface-color);
    border-radius: 1rem;
    font-size: 0.82rem;
  }
  .cv-nav a.active {
    transform: none;
    border-color: var(--accent-color);
    background: var(--surface-color);
  }
}

.cv h2 {
  color: var(--title-color);
  font-size: 1.25rem;
  margin-top: 2.25rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0;
  border-bottom: 0;
}

/* Headerless alignment table: rows only, no borders, just tidy columns. */
.cv-table { font-size: 1rem; width: auto; }
.cv-table td {
  padding: 0.3rem 1.5rem 0.3rem 0;
  border: 0;
  vertical-align: top;
}
/* First column reads like a label: year / degree */
.cv-table td:first-child { font-weight: 600; white-space: nowrap; }

/* Responsive: stack row cells on narrow screens */
@media (max-width: 34rem) {
  .cv-table, .cv-table tbody, .cv-table tr, .cv-table td { display: block; width: 100%; }
  .cv-table tr { padding: 0.4rem 0; border-bottom: 1px solid var(--surface-color); }
  .cv-table td { padding: 0.1rem 0; white-space: normal; }
  .cv-table td:first-child { color: var(--title-color); }
}

/* Education list -------------------------------------------------------- */
.edu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--surface-color);
}

.edu-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--surface-color);
}
.edu-item:last-child { border-bottom: 0; }

/* Left column: degree label + optional grade, stacked */
.edu-left {
  flex: 0 0 6.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

/* Right column: place + optional title, stacked; grows to fill the row */
.edu-right {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.edu-degree {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-color);
  line-height: 1.3;
}

.edu-place { font-weight: 600; color: var(--text-color); }

.edu-title { color: var(--muted-color); font-size: 0.95rem; }

/* Grade: compact badge below the degree label, aligned with the title line */
.edu-grade {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-color);
  background: var(--surface-color);
  padding: 0.05rem 0.45rem;
  border-radius: 0.35rem;
}

.edu-date {
  flex: 0 0 auto;
  color: var(--muted-color);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 34rem) {
  .edu-left { flex-basis: 5rem; }
}

/* Entry list (conferences, certifications, achievements) ----------------- */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--surface-color);
}

.entry {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--surface-color);
}
.entry:last-child { border-bottom: 0; }

/* Title row: title on the left, date pinned to the right */
.entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.entry-title { font-weight: 700; color: var(--text-color); }

/* Inline detail after the "|" separator in the image */
.entry-detail { font-weight: 400; color: var(--muted-color); }
.entry-detail::before {
  content: "|";
  margin: 0 0.5rem;
  color: var(--surface-color);
  font-weight: 400;
}

.entry-date {
  flex: 0 0 auto;
  color: var(--muted-color);
  font-size: 0.85rem;
  font-style: italic;
  white-space: nowrap;
}

/* Subtitle line under the title (e.g. "Workshop at University of ...") */
.entry-sub {
  margin: 0.1rem 0 0;
  color: var(--muted-color);
  font-size: 0.95rem;
}

/* Bulleted description points */
.entry-points {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  color: var(--text-color);
  font-size: 0.95rem;
}
.entry-points li { margin: 0.15rem 0; }

@media (max-width: 34rem) {
  .entry-head { flex-direction: column; gap: 0.15rem; }
}

/* Figures */
.figure { margin: 1rem 0; }
.figure img {
  width: 100%;
  height: auto;
  border: 1px solid var(--surface-color);
  border-radius: 0.5rem;
  background: #fff;
}
.figure figcaption { color: var(--muted-color); font-size: 0.88rem; margin-top: 0.5rem; }

/* Tensor-network / TikZ diagrams: natural size, no frame, centered.
   Give each <img> an explicit width attribute at a uniform scale so
   different diagrams stay visually consistent with each other. */
.figure.diagram { text-align: center; }
.figure.diagram img,
.diagram-row img { max-width: 100%; height: auto; border: none; border-radius: 0; background: transparent; }
.diagram-row { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: center; align-items: flex-end; margin: 0.75rem 0; }
.diagram-row figure { margin: 0; text-align: center; min-width: 0; }
.diagram-row figcaption { color: var(--muted-color); font-size: 0.85rem; margin-top: 0.4rem; }
.figure.diagram img.pfig { max-width: 640px; }

/* Centered display equations, rendered with KaTeX */
.equation {
  margin: 1.1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0;
}
.equation .katex-display { margin: 0; }
.paper .katex { font-size: 1.05em; }

/* Terminal-style code block with a copy button (used for cite.bib) */
.codeblock {
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #1f2937;
  background: #0d1117;
  color: #e6edf3;
  font-size: 0.9rem;
}

.codeblock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: #161b22;
  border-bottom: 1px solid #21262d;
}

.codeblock-title {
  color: #8b949e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.copy-btn {
  border: 1px solid #30363d;
  background: #21262d;
  color: #e6edf3;
  padding: 0.2rem 0.7rem;
  border-radius: 0.35rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.12s ease;
}
.copy-btn:hover { background: #30363d; }
.copy-btn.copied { background: #238636; border-color: #238636; }

.codeblock-body {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
.codeblock-body code {
  background: none;
  padding: 0;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

/* Contact / social links --------------------------------------------------- */
.contact-links {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--surface-color);
  border-radius: 0.5rem;
  color: var(--text-color);
  background: var(--background-color);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.contact-link:hover {
  text-decoration: none;
  color: var(--accent-color);
  border-color: var(--accent-color);
  background: var(--surface-color);
}

.contact-icon {
  display: inline-flex;
  align-items: center;
  color: var(--muted-color);
  transition: color 0.15s ease;
}
.contact-link:hover .contact-icon { color: var(--accent-color); }
.contact-icon svg { display: block; }

.contact-text { display: inline-flex; flex-direction: column; line-height: 1.25; }
.contact-name { font-weight: 600; }
.contact-handle {
  font-weight: 400;
  color: var(--muted-color);
  font-size: 0.82rem;
}

/* CV contact box: compact Contact panel, floated top-right beside the title */
.contact-box {
  float: right;
  margin: 0 0 1rem 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface-color);
  border-radius: 0.5rem;
  background: var(--surface-color);
  font-size: 0.92rem;
  max-width: 20rem;
}
.contact-box-title {
  margin: 0 0 0.5rem;
  font-weight: 700;
  color: var(--title-color);
}
.contact-box dl { margin: 0; }
.contact-box .contact-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}
.contact-box .contact-row + .contact-row { margin-top: 0.35rem; }
.contact-box dt { font-weight: 600; color: var(--muted-color); }
.contact-box dd { margin: 0; }
.contact-box-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}
.contact-sep { color: var(--muted-color); }

@media (max-width: 34rem) {
  .contact-box { float: none; max-width: none; margin-left: 0; }
}

/* Footer ------------------------------------------------------------------- */
.site-footer {
  max-width: var(--max-width);
  margin: 3rem auto 2rem;
  padding: 1.25rem;
  color: var(--muted-color);
  border-top: 1px solid var(--surface-color);
  font-size: 0.9rem;
}

/* Compact variant of the social links used in the footer */
.footer-links { margin-top: 0.75rem; gap: 0.5rem; }
.footer-links .contact-link {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
  background: transparent;
}
