/* ==========================================================================
   RG-MAP Project Page Stylesheet
   Academic, clean, publication-grade design harmonized with paper figures.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --navy: #0f2942;
  --brand: #1d4ed8;
  --brand-hover: #1e40af;
  --brand-soft: #eff6ff;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --emerald: #059669;
  --emerald-soft: #ecfdf5;
  --rose: #dc2626;
  --rose-soft: #fef2f2;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px rgba(15, 23, 42, 0.12);

  --container-max: 1120px;
  --font-sans: "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

/* ---------- Sticky Navigation Bar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--navy);
  letter-spacing: -0.02em;
  text-decoration: none !important;
}

.nav-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--navy), var(--brand));
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--brand);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.lang-btn.active {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.lang-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* ---------- Hero Section ---------- */
.hero {
  position: relative;
  padding: 64px 0 44px;
  background:
    radial-gradient(circle at 12% 10%, rgba(29, 78, 216, 0.06), transparent 42%),
    radial-gradient(circle at 88% 15%, rgba(5, 150, 105, 0.05), transparent 38%),
    linear-gradient(180deg, #ffffff 0%, var(--bg-subtle) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-content {
  text-align: center;
  max-width: 960px;
  margin: 0 auto;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 20px;
  border: 1px solid rgba(29, 78, 216, 0.15);
}

.hero-title {
  margin: 0 0 22px;
  font-size: clamp(1.85rem, 3.6vw, 2.8rem);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--navy);
}

.hero-title .accent {
  background: linear-gradient(120deg, var(--navy) 0%, var(--brand) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-bottom: 14px;
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--text-primary);
}

.author-item sup {
  color: var(--brand);
  font-weight: 700;
  margin-left: 2px;
  font-size: 0.72em;
}

.affiliations {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.affiliations sup {
  color: var(--brand);
  font-weight: 700;
  margin-right: 3px;
}

.correspondence-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.hero-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.16s ease;
  text-decoration: none !important;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--navy);
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.btn-accent {
  background: var(--brand-soft);
  border-color: rgba(29, 78, 216, 0.25);
  color: var(--brand);
}

.btn-accent:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* ---------- Headline KPI Metrics ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  text-align: left;
}

.metric-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
  line-height: 1.15;
  margin-bottom: 4px;
}

.metric-value.emerald { color: var(--emerald); }
.metric-value.brand { color: var(--brand); }
.metric-value.amber { color: var(--amber); }

.metric-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.metric-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---------- Sections ---------- */
.section {
  padding: 64px 0;
}

.section-alt {
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-header {
  max-width: 780px;
  margin: 0 auto 36px;
  text-align: center;
}

.section-tag {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 8px;
}

.section-title {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.section-desc {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.98rem;
}

/* ---------- Video Containers ---------- */
.video-stage {
  background: #0b1220;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(15, 23, 42, 0.14);
}

.video-stage video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  object-fit: contain;
}

.video-caption-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 0.88rem;
}

.video-caption-bar strong {
  color: #ffffff;
}

.video-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-size: 0.76rem;
  font-weight: 600;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.demo-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.demo-card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b1220;
  object-fit: contain;
}

.demo-card-body {
  padding: 18px 20px;
}

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

.demo-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}

.demo-pill.emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
}

.demo-duration {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.demo-card-body h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  color: var(--navy);
}

.demo-card-body p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---------- Abstract & Highlights ---------- */
.abstract-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 28px;
}

.abstract-box p {
  margin: 0;
  font-size: 1.01rem;
  line-height: 1.8;
  color: var(--text-secondary);
  text-align: justify;
}

.highlights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.highlight-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.highlight-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.highlight-num.m1 { background: #e0f2fe; color: #0369a1; }
.highlight-num.m2 { background: #ffedd5; color: #c2410c; }
.highlight-num.m3 { background: #dcfce7; color: #15803d; }
.highlight-num.m4 { background: #eff6ff; color: #1d4ed8; }

.highlight-card h3 {
  margin: 0 0 8px;
  font-size: 1.04rem;
  color: var(--navy);
}

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

/* ---------- Figure Frames & Zoom ---------- */
.figure-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.figure-img-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: zoom-in;
  background: #ffffff;
}

.figure-img-wrap img {
  width: 100%;
  height: auto;
  transition: transform 0.25s ease;
}

.figure-img-wrap:hover img {
  transform: scale(1.008);
}

.zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.76);
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}

.figure-img-wrap:hover .zoom-hint {
  opacity: 1;
}

.figure-caption {
  margin: 14px 4px 2px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.figure-caption strong {
  color: var(--navy);
}

/* ---------- Interactive Tabs (Method & Results) ---------- */
.tabs-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 26px;
}

.tab-btn {
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.tab-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.22s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.method-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.method-detail-grid.single-col {
  grid-template-columns: 1fr;
}

.method-detail-text h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
  color: var(--navy);
}

.method-detail-text p {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.formula-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--navy);
  overflow-x: auto;
  margin: 12px 0;
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.91rem;
}

.bullet-list li {
  margin-bottom: 6px;
}

/* ---------- Tables ---------- */
.table-wrap {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  text-align: right;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--navy);
}

.data-table thead th {
  background: var(--bg-subtle);
  color: var(--navy);
  font-weight: 700;
  font-size: 0.82rem;
  border-bottom: 2px solid var(--border-strong);
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table tbody tr.row-highlight {
  background: #eff6ff;
  font-weight: 700;
}

.data-table tbody tr.row-highlight td {
  color: var(--navy);
}

.badge-good {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--emerald-soft);
  color: var(--emerald);
  font-weight: 700;
  font-size: 0.78rem;
}

.badge-warn {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--rose-soft);
  color: var(--rose);
  font-weight: 700;
  font-size: 0.78rem;
}

.two-col-figs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.two-col-figs .figure-card {
  margin-bottom: 0;
}

.summary-callout {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 24px;
  align-items: center;
}

/* ---------- Open-Source Software Card ---------- */
.software-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: stretch;
}

.software-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 26px 28px;
  box-shadow: var(--shadow-sm);
}

.software-card h3 {
  margin: 0 0 12px;
  font-size: 1.15rem;
  color: var(--navy);
}

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.chip {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.code-block {
  position: relative;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.65;
  overflow-x: auto;
  margin: 0;
}

.code-block .comment {
  color: #94a3b8;
}

/* ---------- BibTeX & Footer ---------- */
.bibtex-wrap {
  position: relative;
  max-width: 860px;
  margin: 0 auto;
}

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

.funding-box {
  max-width: 860px;
  margin: 24px auto 0;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 10px;
}

/* ---------- Image Lightbox Modal ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(6px);
}

.lightbox.open {
  display: flex;
}

.lightbox-inner {
  position: relative;
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-inner img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

.lightbox-caption {
  max-width: 820px;
  color: #e2e8f0;
  font-size: 0.88rem;
  text-align: center;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.7);
  color: #ffffff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background: #ffffff;
  color: var(--navy);
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .demo-grid,
  .highlights-grid,
  .method-detail-grid,
  .two-col-figs,
  .summary-callout,
  .software-grid {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
  }
}

@media (max-width: 560px) {
  .hero {
    padding: 44px 0 32px;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .abstract-box {
    padding: 22px 20px;
  }
  .section {
    padding: 44px 0;
  }
}
