/* ==========================================================================
   Neural Motion Generator (NMG) — Academic Project Page Stylesheet
   Palette aligned with NMG paper figures:
     Studio Surface : #F5F7F9 / #FFFFFF
     Primary Ink    : #27313B
     Secondary Ink  : #4D5964 / #536372
     Muted Ink      : #728397
     Steel Blue     : #35638C (soft #E8F0F6)
     Sage Green     : #376854 (soft #E7F1EC)
     Warm Ochre     : #A87442 / #6C5746 (soft #F1ECE5)
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f5f7f9;
  --bg-card: #ffffff;
  --ink: #27313b;
  --ink-2: #4d5964;
  --ink-3: #6c7a89;
  --border: #dce2e8;
  --border-strong: #c7d1db;

  --blue: #35638c;
  --blue-soft: #e8f0f6;
  --teal: #3b7a7c;
  --sage: #376854;
  --sage-soft: #e7f1ec;
  --ochre: #a87442;
  --ochre-dark: #6c5746;
  --ochre-soft: #f1ece5;
  --crimson: #b84444;
  --crimson-soft: #f9ebeb;

  --serif: "Newsreader", "STIX Two Text", "Liberation Serif", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(39, 49, 59, 0.05);
  --shadow-md: 0 8px 24px rgba(39, 49, 59, 0.08);
  --shadow-lg: 0 20px 56px rgba(24, 32, 42, 0.24);
  --max-text: 820px;
  --max-page: 1120px;
  --max-wide: 1380px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.65;
}

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

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

/* ---------- Top Navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(220, 226, 232, 0.85);
}

.topbar-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.16rem 0.5rem;
  border-radius: 5px;
  background: var(--ink);
  color: #fff;
  font-family: var(--serif);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.brand-venue {
  font-size: 0.8rem;
  color: var(--ink-3);
  font-weight: 500;
  border-left: 1px solid var(--border);
  padding-left: 0.65rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.35rem;
  font-size: 0.88rem;
  font-weight: 500;
}
.nav-links a {
  color: var(--ink-2);
  transition: color 0.15s ease;
}
.nav-links a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Containers & Sections ---------- */
.container {
  max-width: var(--max-page);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-wide {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-text {
  max-width: var(--max-text);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section {
  padding: 4rem 0;
}
.section-subtle {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-header {
  text-align: center;
  max-width: 740px;
  margin: 0 auto 2.2rem;
}
.section-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue);
  margin-bottom: 0.45rem;
}
.section-title {
  margin: 0 0 0.6rem;
  font-family: var(--serif);
  font-size: clamp(1.65rem, 2.6vw, 2.1rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.section-desc {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.96rem;
}

/* ---------- Hero Header ---------- */
.hero-header {
  padding: 1.7rem 0 1.15rem;
  text-align: center;
}

.paper-title {
  margin: 0 auto 0.45rem;
  max-width: 960px;
  font-family: var(--serif);
  font-size: clamp(2.05rem, 3.6vw, 2.85rem);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.paper-subtitle {
  margin: 0 auto 0.9rem;
  max-width: 820px;
  font-family: var(--serif);
  font-size: clamp(1.1rem, 1.75vw, 1.32rem);
  font-weight: 400;
  line-height: 1.35;
  color: var(--ink-2);
}

.authors-block {
  margin-bottom: 0.95rem;
  font-size: 0.96rem;
  color: var(--ink);
}
.author-item {
  display: inline-block;
  margin: 0 0.45rem;
  font-weight: 500;
}
.affiliations-line {
  margin-top: 0.25rem;
  font-size: 0.88rem;
  color: var(--ink-3);
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.54rem 1.05rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover {
  border-color: var(--ink);
  background: var(--bg-subtle);
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn-primary:hover {
  background: #1b242c;
  border-color: #1b242c;
  color: #fff;
}
.btn.is-disabled {
  opacity: 0.62;
  cursor: default;
  pointer-events: none;
}
.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ---------- Hero 4x4 Video Wall ---------- */
.wall-section {
  padding: 0.6rem 0 2.8rem;
}

.wall-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill {
  padding: 0.36rem 0.78rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.81rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.34rem 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.79rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ctrl-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.ctrl-btn.active {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
}

.video-wall {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.video-wall.is-filtered {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wall-row-heading {
  grid-column: 1 / -1;
  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0.5rem 0.1rem 0.05rem;
  border-bottom: 1px solid #edf1f5;
  margin-top: 0.2rem;
}
.wall-row-heading:first-child {
  margin-top: 0;
  padding-top: 0.1rem;
}
.wall-row-heading.is-hidden {
  display: none;
}

.video-tile {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f2f4f6;
  border: 1px solid #e3e8ee;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.video-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.video-tile.is-hidden {
  display: none;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-label {
  position: absolute;
  top: 7px;
  left: 10px;
  right: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.tile-title {
  font-family: var(--serif);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  text-shadow: 0 1px 6px rgba(246, 248, 250, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-k {
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(232, 240, 246, 0.85);
  color: var(--blue);
  flex-shrink: 0;
}
.tile-k.is-sage {
  background: rgba(231, 241, 236, 0.88);
  color: var(--sage);
}
.tile-k.is-ochre {
  background: rgba(241, 236, 229, 0.9);
  color: var(--ochre-dark);
}
.tile-k.is-crimson {
  background: rgba(249, 235, 235, 0.9);
  color: var(--crimson);
}

.tile-footer {
  position: absolute;
  bottom: 7px;
  left: 9px;
  right: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.video-tile:hover .tile-footer,
.video-wall.is-filtered .tile-footer {
  opacity: 1;
}

.tile-metric {
  font-family: var(--mono);
  font-size: 0.71rem;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid rgba(220, 226, 232, 0.85);
}

.tile-zoom {
  font-size: 0.71rem;
  font-weight: 600;
  color: #fff;
  background: rgba(39, 49, 59, 0.78);
  padding: 2px 7px;
  border-radius: 5px;
}

.wall-legend {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  font-size: 0.83rem;
  color: var(--ink-2);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.legend-grad {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #35638c 0%, #3b7a7c 35%, #376854 70%, #a87442 100%);
}
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.legend-cube {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: rgba(194, 161, 122, 0.65);
  border: 1px solid #7a6147;
}
.legend-note {
  width: 100%;
  text-align: center;
  margin: 0.45rem auto 0;
  max-width: 940px;
  font-size: 0.82rem;
  color: var(--ink-3);
}

/* ---------- Headline Metrics Strip ---------- */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 2.6rem;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.metric-value {
  font-family: var(--serif);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.35rem;
}
.metric-value .accent-blue { color: var(--blue); }
.metric-value .accent-sage { color: var(--sage); }
.metric-value .accent-ochre { color: var(--ochre-dark); }
.metric-value .sub-vs {
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-3);
}
.metric-label {
  font-size: 0.82rem;
  line-height: 1.42;
  color: var(--ink-2);
}

/* ---------- Abstract ---------- */
.abstract-text {
  font-size: 1.01rem;
  line-height: 1.75;
  color: var(--ink);
  text-align: justify;
  margin: 0;
}
.abstract-text p {
  margin: 0 0 0.9rem;
}
.abstract-text p:last-child {
  margin-bottom: 0;
}

/* ---------- Method Overview ---------- */
.figure-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.8rem;
  cursor: zoom-in;
  transition: border-color 0.16s ease;
}
.figure-frame:hover {
  border-color: var(--border-strong);
}
.figure-frame img {
  width: 100%;
  height: auto;
  margin: 0 auto;
}
.figure-caption {
  margin: 0.9rem 0 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-2);
}

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

.pillar-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.3rem;
}
.pillar-num {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  margin-bottom: 0.55rem;
}
.pillar-num.blue { background: var(--blue-soft); color: var(--blue); }
.pillar-num.sage { background: var(--sage-soft); color: var(--sage); }
.pillar-num.ochre { background: var(--ochre-soft); color: var(--ochre-dark); }

.pillar-card h3 {
  margin: 0 0 0.45rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
}
.pillar-card p {
  margin: 0;
  font-size: 0.89rem;
  line-height: 1.58;
  color: var(--ink-2);
}

/* ---------- Quantitative Results Tabs ---------- */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.8rem;
}
.tab-btn {
  padding: 0.5rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}
.tab-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.card-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-box h3 {
  margin: 0 0 0.35rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--ink);
}
.card-sub {
  margin: 0 0 0.95rem;
  font-size: 0.84rem;
  color: var(--ink-3);
}

.table-wrap {
  overflow-x: auto;
}
table.academic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
table.academic-table th,
table.academic-table td {
  padding: 0.48rem 0.55rem;
  text-align: right;
  border-bottom: 1px solid #eef2f5;
  white-space: nowrap;
}
table.academic-table th:first-child,
table.academic-table td:first-child,
table.academic-table th.left,
table.academic-table td.left {
  text-align: left;
}
table.academic-table thead tr:first-child th {
  border-top: 2px solid var(--ink);
}
table.academic-table thead tr:last-child th {
  border-bottom: 1.5px solid var(--ink);
  color: var(--ink);
  font-weight: 600;
}
table.academic-table tbody tr.group-sep td {
  border-top: 1.5px solid var(--border-strong);
}
table.academic-table tbody tr.row-nmg {
  background: rgba(53, 99, 140, 0.055);
}
table.academic-table tbody tr.row-mean {
  border-top: 1.5px solid var(--border-strong);
  font-weight: 600;
  background: var(--bg-subtle);
}
table.academic-table tbody tr:last-child td {
  border-bottom: 2px solid var(--ink);
}
.best {
  font-weight: 700;
  color: var(--ink);
}
.gain-badge {
  display: inline-block;
  margin-left: 4px;
  font-family: var(--mono);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sage-soft);
  color: var(--sage);
}

.result-img {
  display: block;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid #eef2f5;
  cursor: zoom-in;
}

.takeaway-list {
  margin: 0.9rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.87rem;
  color: var(--ink-2);
}
.takeaway-list li {
  margin-bottom: 0.42rem;
}

/* ---------- Scope & Limitations Callout ---------- */
.scope-card {
  margin-top: 2rem;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--ochre);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
}
.scope-card h3 {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.scope-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-2);
}
.scope-grid strong {
  color: var(--ink);
}
@media (max-width: 720px) {
  .scope-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- BibTeX ---------- */
.bibtex-box {
  position: relative;
  background: #fbfcfd;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.3rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink);
  overflow-x: auto;
}
.bibtex-box pre {
  margin: 0;
  font-family: inherit;
}
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0.32rem 0.72rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.copy-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.copy-btn.copied {
  background: var(--sage-soft);
  border-color: var(--sage);
  color: var(--sage);
}

/* ---------- Footer ---------- */
.footer {
  padding: 2.2rem 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* ---------- Lightbox Modal ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 27, 34, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.lightbox.open {
  display: flex;
}
.lightbox-card {
  width: min(980px, 95vw);
  max-height: 92vh;
  background: #fff;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.lightbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.lightbox-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
}
.lightbox-close {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink-2);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.lightbox-media {
  background: #f3f5f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  max-height: 70vh;
}
.lightbox-media video,
.lightbox-media img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}
.lightbox-body {
  padding: 0.9rem 1.2rem 1.05rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.lightbox-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--blue);
  background: var(--blue-soft);
  padding: 3px 9px;
  border-radius: 5px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .video-wall {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
  }
  .pillars-grid {
    grid-template-columns: 1fr;
  }
  .video-wall,
  .video-wall.is-filtered {
    grid-template-columns: 1fr;
  }
  .metrics-strip {
    grid-template-columns: 1fr;
  }
  .wall-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
