/* ==========================================================================
   TrackEverything project page
   Minimal academic layout: single column, centered sections, neutral palette.
   ========================================================================== */

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

* {
    margin: 0;
    padding: 0;
}

:root {
    --bg: #ffffff;
    --surface: #f7f8fa;
    --border: #e2e6eb;
    --border-strong: #cfd5dd;
    --text: #14181d;
    --text-soft: #43505f;
    --text-muted: #6b7684;
    --accent: #1c4e80;
    --accent-soft: #eaf1f9;
    --ours: #f4f8fd;

    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --content: 900px;
    --content-wide: 1160px;
    --radius: 6px;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

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

.container-wide {
    max-width: var(--content-wide);
}

.section {
    padding: 56px 0;
    border-top: 1px solid var(--border);
}

.section-alt {
    background: var(--surface);
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1,
h2,
h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

h1 {
    font-size: 2.4rem;
    line-height: 1.2;
    margin-bottom: 1.25rem;
}

h1 .method-name {
    font-style: italic;
}

h2 {
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 0.85rem;
}

h3 {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0;
}

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

a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

strong {
    font-weight: 600;
}

.section-intro {
    max-width: 760px;
    margin: 0 auto 1.75rem;
    text-align: center;
    color: var(--text-soft);
    font-size: 1rem;
}

.section-intro:last-child {
    margin-bottom: 0;
}

.label-red {
    color: #c0392b;
    font-weight: 600;
}

.label-blue {
    color: #2471a3;
    font-weight: 600;
}

.body-copy {
    max-width: 760px;
    margin: 0 auto;
    color: var(--text-soft);
    text-align: justify;
    hyphens: auto;
}

.body-copy p + p {
    margin-top: 1.1rem;
}

.eyebrow {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.55rem;
}

.footnote {
    max-width: 780px;
    margin: 1.5rem auto 0;
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
    padding: 72px 0 48px;
    text-align: center;
}

.venue {
    display: inline-block;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 5px 14px;
    margin-bottom: 1.4rem;
}

.authors {
    font-size: 1.02rem;
    line-height: 1.9;
    color: var(--text-soft);
    margin-bottom: 0.45rem;
}

.authors a {
    white-space: nowrap;
}

.authors sup {
    font-size: 0.7em;
    color: var(--text-muted);
    padding-left: 1px;
}

.affiliations {
    font-size: 0.95rem;
    color: var(--text-muted);
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.equal-contrib {
    margin-top: 0.35rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.affiliations sup {
    font-size: 0.7em;
    padding-right: 2px;
}

.button-group {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.85rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 9px 20px;
    font-family: var(--font-sans);
    font-size: 0.92rem;
    font-weight: 500;
    color: #fff;
    background: var(--text);
    border: 1px solid var(--text);
    border-radius: 999px;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    text-decoration: none;
}

.btn i {
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Highlights
   -------------------------------------------------------------------------- */

.highlights {
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    gap: 0.8rem;
}

.hero .highlights {
    margin-top: 1.85rem;
    text-align: left;
}

.highlight {
    display: flex;
    gap: 0.8rem;
    align-items: baseline;
    font-size: 0.98rem;
    color: var(--text-soft);
}

.highlight::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    margin-top: 0.6rem;
    border-radius: 50%;
    background: var(--accent);
}

.highlight strong {
    color: var(--text);
}

/* --------------------------------------------------------------------------
   Media
   -------------------------------------------------------------------------- */

.media-frame {
    margin: 1.75rem auto 0;
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
}

.media-frame video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.media-frame.is-teaser {
    aspect-ratio: 16 / 9;
}

.media-frame.is-viewer {
    aspect-ratio: 5 / 2;
}

.figure-frame {
    margin: 1.5rem auto 0;
    max-width: 960px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

.figure-frame img {
    display: block;
    width: 100%;
    height: auto;
}

figcaption,
.media-caption {
    max-width: 820px;
    margin: 0.9rem auto 0;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-muted);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Ablation figure
   -------------------------------------------------------------------------- */

.ablation-figure {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1080px;
    margin: 0 auto;
}

.ablation-panel-title {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.ablation-grid {
    display: grid;
    grid-template-columns: 1.65rem repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    align-items: stretch;
}

.ablation-grid img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #000;
}

.ablation-row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-soft);
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Sequence selector
   -------------------------------------------------------------------------- */

.sequence-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
    max-width: 900px;
    margin: 1.15rem auto 0;
}

.sequence-item {
    appearance: none;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-soft);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    cursor: pointer;
    text-align: center;
    line-height: 1.35;
    transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.sequence-item:hover {
    border-color: var(--border-strong);
    background: var(--surface);
}

.sequence-item .sequence-source {
    display: block;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 1px;
}

.sequence-item.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.sequence-item.is-active .sequence-source {
    color: var(--accent);
}

/* --------------------------------------------------------------------------
   Plot grid
   -------------------------------------------------------------------------- */

.plot-legend {
    max-width: 720px;
    margin: 1.4rem auto 0;
}

.plot-legend img {
    display: block;
    width: 100%;
    height: auto;
}

.plot-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.6rem 1.4rem;
    max-width: 720px;
    margin: 1.4rem auto 0;
}

.plot {
    margin: 0;
}

.plot .figure-frame {
    margin: 0;
    max-width: none;
    padding: 14px;
}

.plot figcaption {
    margin-top: 0.7rem;
}

/* --------------------------------------------------------------------------
   Clip grid
   -------------------------------------------------------------------------- */

.subsection {
    margin-top: 2.5rem;
}

.subsection:first-of-type {
    margin-top: 0;
}

.subsection-title {
    text-align: center;
    margin-bottom: 0.4rem;
}

.clip-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.1rem;
    margin-top: 1.4rem;
}

.clip-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Ours-vs-baselines table: one row per sequence, ours in the rightmost column. */
.compare-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.8rem 1.1rem;
    align-items: center;
    max-width: 820px;
    margin-inline: auto;
}

.compare-col-label {
    text-align: center;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.compare-col-label.is-ours {
    color: var(--accent);
}

.clip {
    margin: 0;
}

.clip-media {
    aspect-ratio: 4 / 3;
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: zoom-in;
}

.clip-media.is-wide {
    aspect-ratio: 8 / 3;
}

.hero .clip-media {
    background: #fff;
}

.clip-media.is-wide video {
    object-fit: cover;
}

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

.hero .clip-carousel {
    margin-top: 2rem;
}

/* Hero rail: 2x2 wide pages (same footprint as the old static hero grid). */
.hero .clip-rail {
    --per-view: 2;
}

.clip figcaption {
    margin: 0.55rem 0 0;
    text-align: left;
    font-size: 0.88rem;
    color: var(--text-soft);
}

.clip figcaption .clip-source {
    display: block;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.68rem;
}

/* --------------------------------------------------------------------------
   Clip carousel: horizontal, snap-scrolled strip of clip cards
   -------------------------------------------------------------------------- */

.clip-carousel {
    margin-top: 1.4rem;
}

.rail-shell {
    position: relative;
}

/* Edge fades show the strip continues; hidden once you reach that end. */
.rail-shell::before,
.rail-shell::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 46px;
    pointer-events: none;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.18s ease;
}

.rail-shell::before {
    left: 0;
    background: linear-gradient(to right, var(--bg), rgba(255, 255, 255, 0));
}

.rail-shell::after {
    right: 0;
    background: linear-gradient(to left, var(--bg), rgba(255, 255, 255, 0));
}

.section-alt .rail-shell::before {
    background: linear-gradient(to right, var(--surface), rgba(247, 248, 250, 0));
}

.section-alt .rail-shell::after {
    background: linear-gradient(to left, var(--surface), rgba(247, 248, 250, 0));
}

.rail-shell.is-start::before,
.rail-shell.is-end::after {
    opacity: 0;
}

.clip-rail {
    --per-view: 3;
    --rail-rows: 1;
    --rail-gap: 1.1rem;

    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--rail-rows), auto);
    grid-auto-columns: calc((100% - (var(--per-view) - 1) * var(--rail-gap)) / var(--per-view));
    gap: var(--rail-gap);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
}

.clip-rail::-webkit-scrollbar {
    display: none;
}

.clip-rail:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: var(--radius);
}

/* Two clips deep: a page becomes --per-view columns by two rows. Column flow
   means DOM order runs down each column before moving right. */
.clip-rail-2row {
    --rail-rows: 2;
}

.clip-rail-3row {
    --rail-rows: 3;
}

/* Long-video strip: 2 columns × 3 rows = 6 clips on the first page. */
.clip-rail-long {
    --per-view: 2;
}

.clip-rail > .clip {
    scroll-snap-align: start;
}

/* Snapping fights a pointer drag, so it is off while one is in progress. */
.clip-rail.is-dragging {
    scroll-snap-type: none;
    scroll-behavior: auto;
}

.clip-rail.is-dragging .clip-media {
    cursor: grabbing;
}

.rail-nav {
    position: absolute;
    top: calc(50% - 1.1rem);
    z-index: 2;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0 0 3px;
    transform: translateY(-50%);
    appearance: none;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--text-soft);
    font-family: var(--font-sans);
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(20, 24, 29, 0.14);
    transition: opacity 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.rail-nav:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
}

.rail-nav:disabled {
    opacity: 0;
    pointer-events: none;
}

.rail-nav-prev {
    left: 10px;
}

.rail-nav-next {
    right: 10px;
}

.rail-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.9rem;
}

.rail-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rail-dot {
    appearance: none;
    width: 7px;
    height: 7px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: var(--border-strong);
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.rail-dot:hover {
    background: var(--text-muted);
}

.rail-dot.is-active {
    background: var(--accent);
    transform: scale(1.35);
}

.rail-count {
    flex: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Results table
   -------------------------------------------------------------------------- */

.table-scroll {
    max-width: var(--content-wide);
    margin: 1.5rem auto 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table.results {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table.results th,
table.results td {
    padding: 8px 10px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

table.results thead th {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text-soft);
    background: var(--surface);
    line-height: 1.3;
}

table.results thead th small {
    display: block;
    font-weight: 400;
    font-size: 0.72rem;
    color: var(--text-muted);
}

table.results th.group {
    border-bottom: 1px solid var(--border-strong);
    letter-spacing: 0.04em;
}

table.results th.group + th.group {
    border-left: 1px solid var(--border);
}

table.results .method {
    text-align: left;
    font-weight: 500;
    color: var(--text);
    position: sticky;
    left: 0;
    background: #fff;
}

table.results thead .method {
    background: var(--surface);
}

table.results tr.group-row td {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--surface);
}

table.results tr.ours td {
    background: var(--ours);
    font-weight: 600;
    color: var(--text);
}

table.results td.na {
    color: var(--text-muted);
    font-style: italic;
    font-weight: 400;
}

table.results tbody tr:last-child td {
    border-bottom: none;
}

/* --------------------------------------------------------------------------
   Citation
   -------------------------------------------------------------------------- */

.citation {
    max-width: 820px;
    margin: 1.5rem auto 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    overflow-x: auto;
}

.citation pre {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-soft);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
    padding: 30px 0 44px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(12, 15, 19, 0.92);
}

.lightbox.is-open {
    display: flex;
}

.lightbox-inner {
    width: min(1100px, 100%);
}

.lightbox video {
    display: block;
    width: 100%;
    max-height: 78vh;
    background: #000;
    border-radius: var(--radius);
}

.lightbox-caption {
    margin-top: 0.7rem;
    color: #d7dce3;
    font-size: 0.9rem;
    text-align: center;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 22px;
    appearance: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.75;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0 0 4px;
    transform: translateY(-50%);
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(20, 24, 29, 0.55);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.18s ease, background 0.18s ease;
}

.lightbox-nav:hover:not(:disabled) {
    opacity: 1;
    background: rgba(20, 24, 29, 0.8);
}

.lightbox-nav:disabled {
    opacity: 0.2;
    cursor: default;
}

.lightbox-nav[hidden] {
    display: none;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .clip-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .clip-grid-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .compare-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .clip-rail {
        --per-view: 2;
    }

    .sequence-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    body {
        font-size: 16px;
    }

    .hero {
        padding: 44px 0 32px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    .section {
        padding: 40px 0;
    }

    .clip-grid {
        grid-template-columns: 1fr;
    }

    .compare-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.5rem 0.5rem;
    }

    .plot-grid {
        grid-template-columns: 1fr;
    }

    .clip-rail {
        --per-view: 1;
    }

    .rail-footer {
        flex-direction: column-reverse;
        align-items: center;
        gap: 0.5rem;
    }

    .sequence-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .media-frame.is-viewer {
        aspect-ratio: 16 / 9;
    }

    .body-copy {
        text-align: left;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.88rem;
    }

    .lightbox {
        padding: 16px;
    }

    .ablation-grid {
        grid-template-columns: 1.25rem repeat(3, minmax(0, 1fr));
        gap: 0.25rem;
    }

    .ablation-row-label {
        font-size: 0.65rem;
    }
}

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

    * {
        transition: none !important;
    }
}
