/* Layout: single centered 960px reading column, same structure as the CW-Net page. */
:root {
    --text-main: #333333;
    --text-strong: #111111;
    --text-light: #666666;
    --bg-color: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;
    --link-color: #0056b3;
    --border-color: #eaeaea;
    --btn-bg: #f4f4f4;
    --btn-hover: #e0e0e0;
    --btn-primary-bg: #111111;
    --btn-primary-fg: #ffffff;
    --good: var(--motional-purple);
    --logo-filter: none;
    --motional-purple: #5c49f4;
    --shadow: 0 2px 6px rgba(17, 24, 39, 0.08), 0 12px 32px rgba(17, 24, 39, 0.12);
    color-scheme: light;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
    color: var(--text-main);
    background-color: var(--bg-color);
    line-height: 1.6;
    margin: 0;
    padding: 0 16px;
}

h1, h2, h3, h4, .sans-serif {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    text-wrap: balance;
}

a { color: var(--link-color); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, .btn:focus-visible { outline: 2px solid var(--link-color); outline-offset: 2px; }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding-block: 40px;
}

/* Header & logos */
.header { text-align: center; margin-bottom: 30px; }

.logos {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 28px;
    margin: 0 auto 30px;
}
.logos img {
    display: block;
    height: auto;
    max-width: 100%;
    max-height: 56px;
    object-fit: contain;
    opacity: 0.9;
    filter: var(--logo-filter);
}
.logo-motional { width: 225px; }
.logo-cmu { width: 190px; }
.logo-nyu { width: 170px; }

.publication-badge {
    display: block;
    margin: 4px 0 6px;
    font-family: "Open Sans", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1.9em;
    font-weight: 400;
    letter-spacing: 0;
    color: #333333;
}

.title {
    font-size: clamp(1.7rem, 4vw, 2.2rem);
    line-height: 1.2;
    font-weight: 600;
    margin: 0 0 18px;
    color: var(--text-strong);
}

.authors { font-size: 1.1em; line-height: 1.75; margin-bottom: 12px; }
.authors a {
    color: var(--text-main);
    text-decoration: underline;
    text-decoration-color: #aaa;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}
.authors a:hover { color: var(--link-color); text-decoration-color: var(--link-color); }
.authors .author { white-space: nowrap; }
.affiliations { font-size: 0.95em; color: var(--text-light); margin-bottom: 8px; }
.author-notes {
    font-size: 0.88em;
    color: var(--text-light);
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Nav buttons */
.nav-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 20px 0 40px;
}
.btn {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--btn-bg);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    font-size: 0.95em;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
}
.btn:hover { background-color: var(--btn-hover); text-decoration: none; transform: translateY(-1px); }
.btn-primary { background-color: var(--motional-purple); color: #ffffff; border-color: var(--motional-purple); }
.btn-primary:hover { background-color: #ffffff; color: var(--motional-purple); border-color: var(--motional-purple); }
.btn-disabled { opacity: 0.6; cursor: default; }
.btn-disabled:hover { background-color: var(--btn-bg); transform: none; }

/* Content */
.content-section { margin-bottom: 80px; }
.section-title {
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    line-height: 1.25;
    color: var(--text-strong);
    margin: 0 0 40px;
}
.abstract-text { text-align: justify; font-size: 1.05em; hyphens: auto; }
.abstract-text p { margin: 0 0 1em; }

/* Figures */
.figure-img {
    display: block;
    width: 100%;
    max-width: 850px;
    height: auto;
    margin: 30px auto 15px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}
.figure-caption {
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9em;
    color: var(--text-light);
    margin-bottom: 30px;
}

/* Placeholder box shown until a real figure/video is dropped in. Delete once replaced. */
.placeholder {
    display: grid;
    place-items: center;
    text-align: center;
    width: 100%;
    max-width: 850px;
    aspect-ratio: 16 / 7;
    margin: 30px auto 15px;
    padding: 16px;
    border: 1.5px dashed var(--border-color);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text-light);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
}
.video-container .placeholder {
    position: absolute;
    inset: 0;
    margin: 0;
    max-width: none;
    aspect-ratio: auto;
    border-radius: 4px;
}

/* Results table */
.table-wrap { overflow-x: auto; margin: 30px 0 12px; }
.results-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.95em;
    font-variant-numeric: tabular-nums;
}
.results-table th, .results-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
}
.results-table th:first-child, .results-table td:first-child { text-align: left; }
.results-table thead th {
    font-weight: 600;
    color: var(--text-strong);
    border-bottom: 2px solid var(--text-main);
}
.results-table .group td {
    padding-top: 18px;
    font-weight: 600;
    color: var(--text-strong);
    font-size: 0.85em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.results-table .ours-col { background: var(--surface-alt); }
.results-table .best { font-weight: 700; color: var(--text-strong); }
.results-table td.ours-col.best { color: var(--text-strong); }

/* Real-world stat pair */
.stat-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.stat {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface);
    padding: 18px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.stat-label { font-size: 0.8em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-light); }
.stat-values {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}
.stat-before { font-size: 1.3em; color: var(--text-light); }
.stat-arrow { color: var(--text-light); }
.stat-after { font-size: 1.9em; font-weight: 600; color: var(--good); }
.stat-unit { font-size: 0.9em; color: var(--text-light); }

/* Videos */
.video-grid-2-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 30px 0 40px;
}
.grid-header {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 1.05em;
    font-weight: 600;
    text-align: center;
    margin-bottom: -10px;
    color: var(--text-main);
}
.video-wrapper {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
}
.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 4px; }
.video-container iframe, .video-container video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-caption {
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.9em;
    color: var(--text-light);
    margin-top: 10px;
    font-weight: 500;
}

.concept-block { margin-bottom: 56px; padding-bottom: 48px; border-bottom: 1px solid var(--border-color); }
.concept-block:last-of-type { border-bottom: none; padding-bottom: 0; }
.concept-header { font-size: 1.3em; font-weight: 600; color: var(--text-strong); margin: 8px 0 20px; }

/* Citation */
.citation-block {
    background: var(--surface-alt);
    padding: 20px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    white-space: pre;
    overflow-x: auto;
    color: var(--text-main);
}

.footer {
    text-align: center;
    margin-top: 80px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 0.9em;
    color: var(--text-light);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (max-width: 768px) {
    .container { padding-block: 24px; }
    .video-grid-2-col, .stat-row { grid-template-columns: 1fr; }
    .grid-header { display: none; }
    .abstract-text { text-align: left; }
}

@media (max-width: 420px) {
    .btn { width: 100%; text-align: center; }
    .logos { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .btn { transition: none; }
}

/* Additions for the final-paper version */
.figure-narrow { max-width: 460px; }
.tight-list { margin: 0 0 1em; padding-left: 1.3em; display: grid; gap: 0.5em; }
.math { font-style: italic; white-space: nowrap; }
.stat-sub { margin-top: 6px; font-size: 0.85em; color: var(--text-light); }

.btn-stack { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.btn-note {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.78em;
    color: var(--text-light);
}
.coming-soon {
    margin: 0;
    padding: 16px 20px;
    border: 1.5px dashed var(--border-color);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--text-main);
    font-size: 1.05em;
}
@media (max-width: 420px) { .btn-stack { width: 100%; } }

.disclaimer {
    margin: 0;
    padding: 12px 16px;
    border-radius: 4px;
    background: var(--surface-alt);
    color: var(--text-main);
    font-size: 0.92em;
    font-style: italic;
}

/* Video comparisons: Self-play | SHIFT, one scenario per row */
.video-grid-2 {
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
}
.video-grid-2 .grid-header { margin-bottom: -6px; display: block; }
@media (max-width: 480px) { .video-grid-2 .grid-header { display: none; } }
.pair-label {
    grid-column: 1 / -1;
    margin-top: 12px;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-light);
}
@media (max-width: 480px) {
    .video-grid-2 { grid-template-columns: 1fr; }
}

/* TL;DR */
.tldr { font-size: 1.3em; line-height: 1.6; }
.tldr p { margin: 0 0 0.8em; }
.tldr-points { margin: 0; padding-left: 1.3em; display: grid; gap: 0.4em; }

/* On-road clips are 1600x708 (top strip cropped) */
.video-container.video-wide { padding-bottom: 50%; background: #000; }
.video-container.video-wide video { object-fit: fill; }
.video-container video { object-fit: contain; }

/* Let the paired clips break out of the 960px text column */
.video-grid-2 {
    width: min(1180px, calc(100vw - 48px));
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    gap: 14px 16px;
}
.video-grid-2 .video-wrapper { padding: 6px; }

.btn-star { font-size: 0.75em; margin-left: 1px; }
.code-note { margin: 12px 0 0; color: var(--text-light); font-size: 0.98em; }

/* Same lift as the figures */
.stat, .video-wrapper { box-shadow: var(--shadow); }

/* Top navbar */
.topnav {
    position: sticky;
    top: 0;
    z-index: 10;
    margin: 0 -16px;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border-color);
}
.topnav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.topnav-brand {
    flex: none;
    font-weight: 700;
    font-size: 1.05em;
    letter-spacing: 0.04em;
    color: var(--text-strong);
}
.topnav-links {
    display: flex;
    gap: 22px;
    margin-left: auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    white-space: nowrap;
}
.topnav-links::-webkit-scrollbar { display: none; }
.topnav a { color: var(--text-main); font-size: 0.95em; text-decoration: none; }
.topnav-links a { color: var(--text-light); padding: 6px 0; }
.topnav a:hover, .topnav a:focus-visible { color: var(--motional-purple); text-decoration: none; }
.content-section, #top { scroll-margin-top: 64px; }
@media (max-width: 600px) {
    .topnav-inner { gap: 16px; }
    .topnav-links { gap: 16px; margin-left: 0; }
}
.topnav sup { line-height: 0; vertical-align: 0.5em; }
@media (max-width: 600px) {
    .topnav-links {
        -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
        mask-image: linear-gradient(to right, #000 85%, transparent);
        padding-right: 24px;
    }
}
.topnav a { transition: color 0.15s; }

/* TL;DR stat groups */
.stat-group-label {
    margin: 22px 0 -14px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-light);
}
.stat-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 768px) { .stat-row-4 { grid-template-columns: 1fr; } }

/* Factor cards: big headline number, label, raw values */
.stat-factor { display: flex; flex-direction: column; gap: 2px; }
.stat-big {
    font-size: 2.4em;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    color: var(--good);
    font-variant-numeric: tabular-nums;
}
.stat-what { font-size: 1em; font-weight: 600; color: var(--text-strong); }

.stat-factor .stat-sub { margin-top: 6px; }

/* Whatever directly follows a section heading starts flush, so the heading's own margin sets the gap */
.section-title + * , .section-title + .figure-img { margin-top: 0; }
.stat-row { margin: 0 0 30px; }

/* One-line description under a scenario label, spanning both videos */
.pair-desc {
    grid-column: 1 / -1;
    margin: -8px 0 2px;
    font-size: 1em;
    color: var(--text-main);
}
