/* ================================================================
   DESIGN TOKENS
================================================================ */
:root {
  --bg:          #ffffff;
  --bg-alt:      #f5f7fc;
  --bg-dark:     #0d1117;

  --text:        #111827;
  --text-muted:  #6b7280;
  --text-light:  #f9fafb;

  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-tint:  #dbeafe;
  --ours:         #059669;

  --border:      #e5e7eb;
  --radius:      12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.07), 0 4px 12px rgba(0,0,0,0.05);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; border-radius: var(--radius); }

sup { font-size: 0.65em; line-height: 0; position: relative; top: -0.4em; }

/* ================================================================
   LAYOUT
================================================================ */
.container      { max-width: 960px;  margin: 0 auto; padding: 0 1.5rem; }
.container.narrow { max-width: 720px; margin: 0 auto; padding: 0 1.5rem; }

/* ================================================================
   HERO
================================================================ */
.hero {
  padding: 5.5rem 0 4.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.venue-badge {
  display: inline-block;
  padding: 0.3rem 0.9rem;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.75rem;
}

.paper-title {
  font-size: clamp(1.65rem, 3.8vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.025em;
  max-width: 800px;
  margin: 0 auto 1.75rem;
  color: var(--text);
}

.title-accent { color: var(--accent); }

.authors {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 1.5rem;
  row-gap: 0.25rem;
  font-size: 1.0rem;
  font-weight: 500;
  margin-bottom: 0.6rem;
}

.author { color: var(--text); text-decoration: none; }
.author:hover { color: var(--accent); }

.affiliations {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 1.5rem;
  row-gap: 0.2rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 2.75rem;
}

/* Buttons */
.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
  font-family: var(--font);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline:hover {
  background: var(--accent-tint);
  transform: translateY(-1px);
}

.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* ================================================================
   TEASER
================================================================ */
.teaser {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
}

.teaser-figure { margin-bottom: 1.75rem; }

.tldr-card {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.25rem 1.75rem;
  background: var(--bg-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.tldr-tag {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
}

.tldr {
  font-size: 0.975rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
}
.tldr em { color: var(--accent); font-style: normal; font-weight: 600; }

/* ================================================================
   SECTIONS
================================================================ */
.section       { padding: 5rem 0; }
.section.alt   { background: var(--bg-alt); }
.section.dark  { background: var(--bg-dark); }

.section-heading {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.section-heading.light { color: var(--text-light); }

.section-lead {
  font-size: 0.975rem;
  color: var(--text-muted);
  max-width: 660px;
  margin-bottom: 2.75rem;
  line-height: 1.65;
}

/* Abstract — collapsed with fade + expand */
.abstract-wrap {
  position: relative;
  max-height: 14rem;
  overflow: hidden;
  transition: max-height 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.abstract-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3.5rem;
  background: linear-gradient(to bottom, transparent, var(--bg-alt));
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.abstract-body p {
  font-size: 0.975rem;
  color: #374151;
  line-height: 1.75;
  margin-bottom: 1.1rem;
}
.abstract-body p:last-child { margin-bottom: 0; }

/* Toggle button: ── Read more ── */
.abstract-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.85rem 0 0;
  font-family: var(--font);
  transition: color 0.15s;
}
.abstract-toggle::before,
.abstract-toggle::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  transition: background 0.15s;
}
.abstract-toggle:hover { color: var(--accent); }
.abstract-toggle:hover::before,
.abstract-toggle:hover::after { background: var(--accent-tint); }

/* ================================================================
   METHOD
================================================================ */
.full-figure { margin-bottom: 2.5rem; }
.full-figure img { width: 100%; border-radius: 0; }

.method-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.method-card {
  padding: 1.4rem 1.5rem;
  border-top: 2px solid var(--mc-color, var(--accent));
  background: var(--mc-bg, var(--bg-alt));
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Colors sampled directly from method-figure.pdf */
.method-card:nth-child(1) {
  --mc-color: #edb471;   /* warm amber — matches L_FA / v_θ boxes */
  --mc-bg:    #f6f4e4;   /* warm cream — left panel background */
}
.method-card:nth-child(2) {
  --mc-color: #95b3c4;   /* muted steel blue — top-right panel accent */
  --mc-bg:    #eaf7fd;   /* cyan-blue — top-right panel background */
}
.method-card:nth-child(3) {
  --mc-color: #638080;   /* dark muted teal — bottom-right panel border */
  --mc-bg:    #e4f2ef;   /* light teal — bottom-right panel background */
}

.method-card h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.method-card p {
  font-size: 0.855rem;
  color: var(--text-muted);
  line-height: 1.65;
}

@media (max-width: 700px) {
  .method-cards { grid-template-columns: 1fr; }
}

/* Subsections */
.subsection { margin-top: 3.5rem; }

.sub-heading {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.sub-lead {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 600px;
  margin-bottom: 1.25rem;
}

/* ================================================================
   MOTIVATION — SCROLL STORY
================================================================ */
.story {
  display: flex;
  flex-direction: column;
  gap: 6rem;
}

.story-step {}

/* Two-column layout for steps 1, 2, 4 */
.story-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.story-fig { margin: 0; }
.story-fig img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

/* Step tag: "01", "02" … */
.story-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  margin-bottom: 0.65rem;
}
.story-tag.ours { color: var(--ours); background: #d1fae5; }

.story-text h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.7rem;
  color: var(--text);
}
.story-text p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* Step 4: FlowBender — green headline */
.story-ours .story-text h3 { color: var(--ours); }

/* Guidance step — centered header + 3-col grid */
.story-guidance-hdr {
  text-align: center;
  margin-bottom: 2.25rem;
}
.story-guidance-hdr h3 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.65rem;
}
.story-guidance-hdr p {
  max-width: 600px;
  margin: 0 auto;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.guidance-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.guidance-item img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #fff;
}
.guidance-cap {
  text-align: center;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Scroll-reveal animation */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 680px) {
  .story-inner      { grid-template-columns: 1fr; gap: 1.75rem; }
  .story-flip .story-inner { direction: ltr; }
  .guidance-trio    { grid-template-columns: 1fr; }
  .story           { gap: 4rem; }
}

/* ================================================================
   TASK TABS
================================================================ */
.task-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.tab {
  padding: 0.4rem 1.1rem;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

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

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

/* Column labels */
.col-labels {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
  text-align: center;
}
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-5 { grid-template-columns: repeat(5, 1fr); }

.col-labels span {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ours-label { color: var(--ours) !important; }

.fig-caption {
  margin-top: 0.875rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ================================================================
   COMPARISON GRID (image-to-image results)
================================================================ */
.comparison-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comparison-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.comparison-row.c5 {
  grid-template-columns: repeat(5, 1fr);
}

.comparison-row img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
}

.comparison-row img.ours-img {
  outline: 2.5px solid var(--ours);
  outline-offset: -1px;
}

.comparison-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ================================================================
   3D TEXTURING SECTION
================================================================ */

/* 3D renders on white bg — use contain so object isn't cropped */
#texturing-results .comparison-row img {
  object-fit: contain;
  background: #fff;
}

/* Groups one image row + its video sub-row (tight gap = they read as one unit) */
.example-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* 5-col video sub-row — column widths match .comparison-row.c5 exactly */
.vid-row-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  position: relative;
}

/* Combined 4-wide video spanning columns 2-5 */
.vid-combined {
  grid-column: 2 / 6;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-alt);
}
.vid-combined video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 1;
  object-fit: cover;
  border-radius: 0;
}
/* Green ours outline over the first quarter (ours column) */
.vid-combined::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 25%;
  height: 100%;
  box-shadow: inset 0 0 0 2.5px var(--ours);
  pointer-events: none;
}

/* Play button — abs-positioned over the three video columns (cols 2, 3, 5).
   Center of the right 4/5 of a 5-col grid ≈ 60% from left. */
.play-all-btn {
  position: absolute;
  top: 50%;
  left: 60%;
  transform: translate(-50%, -50%);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 2;
}

.play-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 1.15rem;
  padding-left: 4px;
  box-shadow: 0 2px 18px rgba(0,0,0,0.28);
  transition: transform 0.15s, box-shadow 0.15s;
}
.play-all-btn:hover .play-icon {
  transform: scale(1.1);
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
}

/* ================================================================
   PLACEHOLDERS
================================================================ */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-alt);
  color: var(--text-muted);
  gap: 0.5rem;
  text-align: center;
  padding: 2rem;
}

.placeholder i    { font-size: 2rem; opacity: 0.25; }
.placeholder p    { font-size: 0.875rem; font-weight: 500; }
.placeholder code { font-family: var(--font-mono); font-size: 0.75rem; opacity: 0.65; }

.placeholder.tall       { height: 380px; }
.placeholder.wide       { height: 280px; }
.placeholder.comparison { height: 320px; }
.placeholder.video      { height: 240px; }

/* ================================================================
   BIBTEX
================================================================ */
.bibtex-wrap {
  position: relative;
  margin-top: 1.5rem;
}

.bibtex {
  display: block;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: var(--radius);
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.75;
  color: #e6edf3;
  overflow-x: auto;
  white-space: pre;
}

.copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.copy-btn:hover   { background: #30363d; color: #f0f6fc; }
.copy-btn.copied  { color: #3fb950; border-color: #3fb950; }

/* ================================================================
   FOOTER
================================================================ */
.footer {
  padding: 2.25rem 0;
  text-align: center;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.footer p + p { margin-top: 0.35rem; }

.footer-credits { font-size: 0.8rem; }
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 700px) {
  .method-steps { grid-template-columns: 1fr; }
  .video-grid   { grid-template-columns: 1fr; }
  .col-labels   { display: none; }
  .comparison-grid { overflow-x: auto; }
  .comparison-row  { min-width: 600px; }
  .hero         { padding: 3.5rem 0 3rem; }
  .section      { padding: 3.5rem 0; }
}

@media (max-width: 420px) {
  .tab { font-size: 0.78rem; padding: 0.35rem 0.85rem; }
  .paper-title { font-size: 1.5rem; }
}
