/* ============================================================
   Flex-Forcing — Project Page (TMD-inspired dark theme)
   ============================================================ */

:root {
  --bg-color: #ffffff;
  --text-color: #1a1a1a;
  --text-secondary: #6b7280;
  --accent-color: #1a1a1a;
  --accent-blue: #2563eb;
  --panel: #f7f7f9;
  --line: #e5e7eb;
  --container-width: 1760px;
  --grid-gap: 8px;
  --font-main: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-main);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

.narrow {
  max-width: 1340px;
  margin: 0 auto;
}

section {
  padding: 60px 0 30px;
  border-bottom: 1px solid var(--line);
  background-color: var(--bg-color);
}
section:last-of-type {
  border-bottom: none;
}

/* ---------------- Header ---------------- */
header {
  text-align: center;
  padding: 56px 0 64px;
  border-bottom: 1px solid var(--line);
}

.venue {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-blue);
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 24px;
  padding: 5px 16px;
  margin-bottom: 26px;
}

h1 {
  font-size: 3.4rem;
  font-weight: 800;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  line-height: 1.16;
}
h1 .accent {
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 1.35rem;
  font-weight: 300;
  color: var(--text-secondary);
  max-width: 1040px;
  margin: 0 auto;
}

.authors {
  font-size: 1.3rem;
  margin-top: 26px;
}
.authors span {
  margin: 0 6px;
  white-space: nowrap;
}
sup {
  font-size: 0.6em;
  vertical-align: super;
  line-height: 0;
  color: var(--accent-blue);
}
.affiliations {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-top: 8px;
}
.affiliations span {
  margin: 0 15px;
}
.equal-note {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

.links {
  margin-top: 28px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-color);
  color: white;
  padding: 11px 22px;
  border-radius: 24px;
  font-weight: 500;
  margin: 6px 7px;
  transition: background 0.3s;
  font-size: 1.05rem;
}
.btn:hover {
  background: #555;
  text-decoration: none;
  color: #fff;
}

/* ---------------- Section titles ---------------- */
.section-title {
  text-align: center;
  font-size: 2.5rem;
  margin: 0 0 10px;
  font-weight: 300;
  letter-spacing: -0.3px;
}
.section-caption {
  text-align: center;
  color: var(--text-secondary);
  margin: 0 auto 34px;
  font-weight: 300;
  font-size: 1.3rem;
  max-width: 1100px;
}

/* ---------------- Abstract ---------------- */
.abstract-box {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 30px 40px;
  border-radius: 8px;
  max-width: 1340px;
  margin: 0 auto;
}
.text-block {
  text-align: justify;
  font-size: 1.25rem;
  font-weight: 300;
  margin: 0;
}
.text-block b {
  font-weight: 600;
  color: #000;
}

/* ---------------- Figures ---------------- */
.figure {
  text-align: center;
}
.figure img {
  width: 100%;
  height: auto;
  display: block;
  margin: 10px auto;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}
.pipeline-figure {
  max-width: 1280px;
}
.acceleration-figure {
  max-width: 940px;
}
.result-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 34px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
}
.result-pair .figure img {
  max-width: 100%;
}
@media (max-width: 768px) {
  .result-pair {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}
.fig-caption {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 300;
  margin-top: 16px;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}
.fig-caption b {
  color: #000;
  font-weight: 600;
}

/* ---------------- Grids / videos ---------------- */
.grid {
  display: grid;
  gap: var(--grid-gap);
  width: 100%;
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.teaser-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
  width: 100%;
  grid-auto-flow: dense;
}
.teaser-grid .video-wrapper:nth-child(6n + 1) {
  grid-column: span 2;
  grid-row: span 2;
}
.teaser-grid .video-wrapper:nth-child(6n + 6) {
  grid-column: 2 / span 2;
  grid-row: span 2;
}
.teaser-grid .video-wrapper:nth-child(6n + 4),
.teaser-grid .video-wrapper:nth-child(6n + 5) {
  grid-column: 1;
}

.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--line);
}
.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.grid .video-wrapper,
.teaser-grid .video-wrapper {
  aspect-ratio: 832 / 480;
}
.teaser-grid .video-wrapper:nth-child(6n + 1),
.teaser-grid .video-wrapper:nth-child(6n + 6) {
  aspect-ratio: auto;
  height: 100%;
}

.prompt-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.7) 60%,
    transparent 100%
  );
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.video-wrapper:hover .prompt-overlay {
  opacity: 1;
}

.corner-label {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 24px;
  color: #fff;
}
.corner-label.ours {
  background: rgba(79, 134, 255, 0.92);
}
.corner-label.base {
  background: rgba(90, 90, 90, 0.92);
}

/* ---------------- Horizontal scrolling gallery (marquee) ---------------- */
.marquee {
  position: relative;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto; /* roughly the body-text width, a touch wider */
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 4%,
    #000 96%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 4%,
    #000 96%,
    transparent 100%
  );
}
.marquee-track {
  display: flex;
  gap: 14px;
  width: max-content;
  padding: 6px 0;
  animation: marquee-scroll 60s linear infinite;
}
.marquee:hover .marquee-track {
  animation-play-state: paused;
}
.marquee .video-wrapper {
  flex: 0 0 auto;
  width: 420px;
  aspect-ratio: 832 / 480;
  border-radius: 8px;
}
@keyframes marquee-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* Masonry layout inside the horizontal scroller:
   alternating [one big tile] [a column of two small tiles] */
.marquee.hwall {
  --rh: 215px;
  --mgap: 14px;
}
.marquee.hwall .marquee-track {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: var(--rh) var(--rh);
  gap: var(--mgap);
}
.marquee.hwall .video-wrapper {
  width: calc(var(--rh) * 832 / 480);
  height: 100%;
  aspect-ratio: auto;
}
.marquee.hwall .video-wrapper.big {
  grid-row: span 2;
  width: calc((var(--rh) * 2 + var(--mgap)) * 832 / 480);
}
@media (max-width: 768px) {
  .marquee.hwall {
    --rh: 130px;
  }
  .marquee.hwall .video-wrapper {
    width: calc(var(--rh) * 832 / 480);
  }
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track {
    animation: none;
  }
  .marquee {
    overflow-x: auto;
  }
}
@media (max-width: 768px) {
  .marquee .video-wrapper {
    width: 280px;
  }
}

/* ---------------- Comparison headers ---------------- */
.comparison-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: var(--text-secondary);
  gap: var(--grid-gap);
}
.compare-block {
  /* Each block occupies two parent rows (prompt + video pair) and inherits
     them as a subgrid, so prompts in the same visual row share a height and
     the videos beneath them stay vertically aligned regardless of line count. */
  display: grid;
  grid-row: span 2;
  grid-template-rows: subgrid;
  row-gap: 12px; /* prompt → video spacing (overrides the larger parent row-gap) */
}
.compare-prompt {
  text-align: center;
  color: var(--text-secondary);
  font-weight: 300;
  font-style: italic;
  font-size: 1.05rem;
  margin: 0;
  align-self: end; /* sit just above the video */
  min-height: 2.95rem; /* fallback: reserves ~2 lines where subgrid is unsupported */
}

/* ---------------- Chunk-size slider ---------------- */
.ablation {
  max-width: 1200px;
  margin: 0 auto;
}
.abl-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.abl-pane {
  display: flex;
  flex-direction: column;
}
.abl-select {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-color);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.abl-select:hover {
  border-color: var(--accent-blue);
}
.abl-readout .label em {
  font-style: normal;
  color: var(--accent-blue);
  font-weight: 500;
}
.abl-stage {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 832 / 480;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--line);
}
.abl-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.abl-stage video.active {
  opacity: 1;
}
.abl-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  background: rgba(79, 134, 255, 0.92);
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 24px;
}
.abl-chunkcount {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 400;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 24px;
}
.abl-slider-wrap {
  margin: 30px 6px 6px;
}
.abl-readout {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.abl-readout .label {
  font-size: 1rem;
  font-weight: 300;
  color: var(--text-secondary);
}
.abl-readout .value {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
}
input[type="range"].abl-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4f86ff, #9b6bff);
  outline: none;
  cursor: pointer;
}
input[type="range"].abl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-blue);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 0.1s ease;
}
input[type="range"].abl-range::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}
input[type="range"].abl-range::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent-blue);
  cursor: pointer;
}
.abl-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}
.abl-ticks .tick {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 0.12s;
}
.abl-ticks .tick:first-child {
  text-align: left;
}
.abl-ticks .tick:last-child {
  text-align: right;
}
.abl-ticks .tick.on {
  color: var(--accent-blue);
  font-weight: 700;
}
.abl-ends {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-secondary);
}
.abl-ends b {
  color: #000;
  font-weight: 600;
}
.abl-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 28px;
}
.abl-groups button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 7px 15px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.15s;
}
.abl-groups button:hover {
  border-color: var(--accent-blue);
}
.abl-groups button.on {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}
.abl-prompt {
  max-width: 1100px;
  margin: 18px auto 0;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 300;
  line-height: 1.55;
  color: #333;
  text-align: left;
}
.abl-prompt::before {
  content: "Prompt: ";
  font-weight: 600;
  color: #000;
}

/* ---------------- BibTeX ---------------- */
.bibtex {
  background: #f5f5f7;
  border: 1px solid var(--line);
  color: #1a1a1a;
  border-radius: 8px;
  padding: 24px 26px;
  overflow-x: auto;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  max-width: 1240px;
  margin: 0 auto;
  cursor: pointer;
}
.bibtex code {
  white-space: pre;
}

/* ---------------- Footer ---------------- */
.footer-links {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 30px 0 50px;
  font-weight: 300;
}
.footer-links a {
  color: var(--text-secondary);
  margin: 0 6px;
}
.footer-links a:hover {
  color: var(--accent-blue);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
  .teaser-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .teaser-grid .video-wrapper:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 832 / 480;
    height: auto;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 18px;
  }
  h1 {
    font-size: 2.2rem;
  }
  .section-title {
    font-size: 1.8rem;
  }
  .section-caption,
  .tagline {
    font-size: 1.1rem;
  }
  .text-block {
    font-size: 1.1rem;
  }
  .grid-3,
  .grid-2,
  .teaser-grid {
    grid-template-columns: 1fr;
  }
  .teaser-grid .video-wrapper:nth-child(n) {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 832 / 480;
    height: auto;
  }
  .abl-ends {
    flex-direction: column;
    gap: 6px;
    align-items: center;
    text-align: center;
  }
  .abl-pair {
    grid-template-columns: 1fr;
  }
}

/* ---------------- Subsection title ---------------- */
.subsection-title {
  text-align: center;
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: -0.2px;
  margin: 36px 0 8px;
}

/* ---------------- Application: any-order / any-timestep editing ---------------- */
.edit-block {
  width: 100%;
  margin: 16px 0 8px;
}
.edit-seg-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin-bottom: 8px;
}
.edit-seg-labels > div {
  text-align: center;
  padding: 0 8px;
  font-size: 0.95rem;
  line-height: 1.35;
  color: var(--text-color);
  border-left: 1px solid var(--line);
}
.edit-seg-labels > div:first-child { border-left: none; }
.edit-seg-labels .seg-title { font-weight: 500; }
.edit-seg-labels .seg-desc { color: var(--text-secondary); font-style: italic; font-size: 0.85rem; }
.edit-clip {
  margin-bottom: 18px;
}
.edit-method-label {
  margin: 0 0 6px;
}
.edit-method-label .tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 24px;
  color: #fff;
}
.edit-method-label .tag.ours { background: rgba(79, 134, 255, 0.92); }
.edit-method-label .tag.base { background: rgba(90, 90, 90, 0.92); }
.edit-clip video {
  width: 100%;
  display: block;
  border-radius: 4px;
}
@media (max-width: 768px) {
  .edit-seg-labels { font-size: 0.7rem; }
  .edit-seg-labels .seg-desc { font-size: 0.62rem; }
}

/* ---------------- Qualitative comparison: 2 pairs (4 videos) per row ---------------- */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
  column-gap: 24px;
  row-gap: 34px; /* separation between block rows; inner prompt→video gap set on .compare-block */
  align-items: start;
}
@media (max-width: 768px) {
  .compare-grid {
    grid-template-columns: 1fr;
    row-gap: 26px;
  }
}

/* ---------------- NVIDIA required footer links ---------------- */
.nv-footer {
  border-top: 1px solid var(--line);
  margin-top: 48px;
  padding: 28px 0 36px;
  text-align: center;
}
.nv-footer .container {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.9;
}
.nv-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}
.nv-footer a:hover {
  color: var(--accent-blue);
  text-decoration: underline;
}
