/* ============================================================
   UtK Project Page — Nerfies-inspired academic style
   Bilingual-aware: body.lang-en / body.lang-zh toggles .en / .zh
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f7fb;
  --fg: #1a1a1f;
  --fg-muted: #5a6070;
  --border: #e5e7ef;
  --brand: #e97eba;
  --brand-dark: #b1539a;
  --accent: #4f9ff8;
  --highlight: #e63946;
  --code-bg: #0f172a;
  --code-fg: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --max-w: 1120px;
  --max-w-narrow: 820px;
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

body.dark {
  --bg: #0b0d12;
  --bg-alt: #12151c;
  --fg: #e6e8ee;
  --fg-muted: #9aa1b2;
  --border: #232938;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --code-bg: #070910;
}

/* ---------- Bilingual visibility ---------- */
body.lang-en .zh,
body.lang-zh .en { display: none !important; }

/* ---------- Reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}
body.lang-zh { font-family: 'Noto Sans SC', 'Inter', sans-serif; letter-spacing: 0.01em; }

img, svg { max-width: 100%; display: block; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(233, 126, 186, 0.1); padding: 0.1em 0.35em; border-radius: 4px; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h2 {
  font-size: clamp(1.6rem, 2.6vw, 2rem);
  font-weight: 700;
  margin: 0 0 1rem;
  position: relative;
  padding-bottom: 0.6rem;
}
h2::after {
  content: ""; position: absolute; left: 0; bottom: 0;
  width: 48px; height: 3px; background: var(--brand); border-radius: 2px;
}
h3 { font-size: 1.2rem; font-weight: 600; margin: 1.6rem 0 0.8rem; }

p { margin: 0 0 1em; }

/* ---------- Layout ---------- */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: var(--max-w-narrow); }
.section { padding: 72px 0; }
.section-alt { background: var(--bg-alt); }
.section-lead { font-size: 1.05rem; color: var(--fg-muted); max-width: 820px; margin-bottom: 2rem; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
body.dark .navbar { background: rgba(11, 13, 18, 0.85); }

.nav-inner {
  max-width: var(--max-w); margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; object-fit: contain; }
.nav-links { display: flex; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.nav-links a { color: var(--fg-muted); font-size: 0.92rem; font-weight: 500; }
.nav-links a:hover { color: var(--fg); text-decoration: none; }
.nav-actions { display: flex; gap: 8px; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--fg);
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s ease;
}
.btn-ghost:hover { background: var(--bg-alt); border-color: var(--brand); }

@media (max-width: 720px) {
  .nav-links { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 72px 24px 56px;
  text-align: center;
  background:
    radial-gradient(ellipse at top, rgba(233, 126, 186, 0.12), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(79, 159, 248, 0.08), transparent 60%);
  border-bottom: 1px solid var(--border);
}
.hero-inner { max-width: 960px; margin: 0 auto; }
.venue-badge {
  display: inline-block;
  padding: 4px 12px;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.03em;
  margin-bottom: 18px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #1a1a1f 0%, #4a4a5a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body.dark .hero-title {
  background: linear-gradient(90deg, #fff 0%, #b0b4c2 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--fg-muted);
  max-width: 760px;
  margin: 0 auto 24px;
}
.authors { margin: 18px 0 6px; font-size: 1.02rem; }
.authors a { color: var(--fg); font-weight: 500; }
.authors a:hover { color: var(--brand-dark); }
.authors sup { color: var(--fg-muted); font-weight: 400; }
.affiliations { color: var(--fg-muted); font-size: 0.92rem; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }

.hero-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 24px 0 32px;
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); text-decoration: none; border-color: var(--brand); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff !important;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.05); }

.affiliation-logos {
  display: flex; gap: 36px; justify-content: center; align-items: center;
  flex-wrap: wrap;
  opacity: 0.85;
  margin-top: 16px;
}
.affiliation-logos img {
  height: 42px; width: auto; object-fit: contain;
  filter: grayscale(20%);
  transition: filter 0.2s ease;
}
.affiliation-logos img:hover { filter: grayscale(0%); }
body.dark .affiliation-logos img { filter: brightness(1.5) grayscale(20%); }

/* ---------- TL;DR card ---------- */
.tldr-section { padding-top: 48px; padding-bottom: 24px; }
.tldr-card {
  max-width: 920px; margin: 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.tldr-card::before {
  content: ""; position: absolute; left: 0; top: 0; width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}
.tldr-label {
  display: inline-block;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--brand-dark); background: rgba(233, 126, 186, 0.12);
  padding: 3px 10px; border-radius: 6px;
  margin-bottom: 10px;
}
.tldr-text { font-size: 1.05rem; margin: 0; line-height: 1.75; }

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-top: 28px;
}
.kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-value {
  font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1;
}
.kpi-value span { font-size: 1.3rem; font-weight: 600; }
.kpi-label { font-size: 0.85rem; color: var(--fg-muted); margin-top: 8px; }

/* ---------- Two column ---------- */
.two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 40px; align-items: center;
}
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.figure {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.figure-compact {
  max-width: 620px;
  margin: 0 auto 24px;
}
.figure-compact img { margin: 0 auto; }
.fig-caption {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--fg-muted);
  text-align: center;
  font-style: italic;
}

/* SVG text helpers */
.svg-title { font-family: var(--font-sans); font-size: 12px; fill: currentColor; font-weight: 600; }
.svg-axis { font-family: var(--font-sans); font-size: 10px; fill: var(--fg-muted); }
.svg-caption { font-family: var(--font-sans); font-size: 10px; fill: var(--brand-dark); font-weight: 600; }
.svg-row-title { font-family: var(--font-sans); font-size: 13px; font-weight: 700; fill: currentColor; }
.svg-sublabel { font-family: var(--font-sans); font-size: 11px; font-weight: 600; fill: var(--fg-muted); }
.svg-chunk { font-family: var(--font-sans); font-size: 13px; font-weight: 600; }
.svg-chunk-sm { font-family: var(--font-sans); font-size: 11px; font-weight: 600; }
.svg-note { font-family: var(--font-sans); font-size: 11px; fill: var(--fg-muted); }
.svg-knot { font-family: var(--font-sans); font-size: 18px; fill: var(--highlight); font-weight: 700; }
.svg-legend { font-family: var(--font-sans); font-size: 11px; fill: var(--fg-muted); }

/* ---------- Method section ---------- */
.method-figure {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
  overflow-x: auto;
  color: var(--fg);
}
.method-figure svg { min-width: 760px; }

.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.method-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.method-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.method-card h3 { margin-top: 0; }
.method-step {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(233, 126, 186, 0.3);
}

.callout {
  background: linear-gradient(135deg, rgba(233, 126, 186, 0.08), rgba(79, 159, 248, 0.06));
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  font-size: 1rem;
  line-height: 1.75;
}

/* ---------- Results table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: var(--bg); }
.results-table th, .results-table td { padding: 10px 14px; text-align: center; border-bottom: 1px solid var(--border); }
.results-table th { background: var(--bg-alt); font-weight: 600; color: var(--fg); }
.results-table td:first-child, .results-table th:first-child { text-align: left; }
.results-table tbody tr:hover { background: var(--bg-alt); }
.results-table tr.row-ours { background: rgba(233, 126, 186, 0.08); }
.results-table tr.row-ours:hover { background: rgba(233, 126, 186, 0.14); }

/* ---------- Analysis grid ---------- */
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.analysis-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.analysis-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.analysis-card h3 { margin-top: 8px; }
.analysis-card p { margin: 0; color: var(--fg-muted); font-size: 0.95rem; }
.analysis-card .badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 10px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-weight: 700; font-size: 0.95rem;
  font-family: var(--font-mono);
}

/* ---------- Resources (download cards) ---------- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  max-width: 820px;
}
.resource-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
}
.resource-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}
.resource-icon {
  flex: 0 0 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(233, 126, 186, 0.15), rgba(79, 159, 248, 0.12));
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
body.dark .resource-icon { color: var(--brand); }
.resource-body { flex: 1; min-width: 0; }
.resource-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.resource-desc { color: var(--fg-muted); font-size: 0.88rem; }
.resource-arrow {
  flex: 0 0 auto;
  color: var(--fg-muted);
  transition: transform 0.18s ease, color 0.18s ease;
}
.resource-card:hover .resource-arrow {
  transform: translateX(4px);
  color: var(--brand-dark);
}

/* ---------- Models ---------- */
.model-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px; margin: 20px 0 28px;
}
.model-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--fg);
  transition: all 0.2s ease;
}
.model-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}
.model-name { font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; color: var(--brand-dark); margin-bottom: 4px; }
body.dark .model-name { color: var(--brand); }
.model-desc { font-size: 0.88rem; color: var(--fg-muted); }

.code-title { margin-top: 28px; }

/* ---------- Code block ---------- */
.code-block {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 18px 20px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
  margin: 0;
}
.code-block code { background: transparent; color: inherit; padding: 0; }

/* ---------- BibTeX ---------- */
.bibtex-wrap { position: relative; }
.btn-copy {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  padding: 6px 12px; font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.1);
  color: var(--code-fg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-copy:hover { background: rgba(255, 255, 255, 0.2); }
.btn-copy.copied { background: #10b981; color: #fff; border-color: transparent; }

/* ---------- Reveal-on-scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- Footer ---------- */
.footer {
  padding: 36px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.88rem;
}
.footer-links a { color: var(--fg-muted); }
.footer-links a:hover { color: var(--brand-dark); }
