/* ============================================================
   paper.css: shared style for paper / project pages (SPLICE, STEP).
   Plain white or dark background, one reading column, serif titles,
   Inter body. Load after v2.css, with <body class="paper">.
   ============================================================ */
html body.paper {
    --p-bg:      #ffffff;
    --p-text:    #1c1d21;
    --p-muted:   #5d6068;
    --p-faint:   #8b8e96;
    --p-rule:    #e5e6ea;
    --p-rule-strong: #c9cbd1;
    --p-soft:    #f5f6f8;
    --p-accent:  #1d4ed8;
    --p-serif:   "Source Serif 4", "Newsreader", Georgia, serif;
    --p-sans:    "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --p-mono:    "JetBrains Mono", ui-monospace, Menlo, monospace;
    background: var(--p-bg);
    color: var(--p-text);
    font-family: var(--p-sans);
    font-size: 17px;
    line-height: 1.75;
    overflow-x: clip;
}
html[data-theme="dark"] body.paper {
    --p-bg:     #111216;
    --p-text:   #e7e8ea;
    --p-muted:  #a6a9b0;
    --p-faint:  #7d8088;
    --p-rule:   #26282e;
    --p-rule-strong: #3a3d45;
    --p-soft:   #181a1f;
    --p-accent: #8fb3ff;
}
/* the shared site chrome, toned down for this page */
html body.paper .site-header,
html body.paper header.site-header.scrolled {
    background: color-mix(in srgb, var(--p-bg) 88%, transparent);
    border-bottom: 1px solid var(--p-rule);
    backdrop-filter: blur(8px);
}
body.paper .site-nav a, body.paper .theme-toggle { color: var(--p-muted); }
body.paper .site-nav a:hover, body.paper .theme-toggle:hover { color: var(--p-text); }
body.paper .logo.v3-brand .term-brand__path { color: var(--p-muted); }
html body.paper .site-header { padding-top: 16px; padding-bottom: 16px; }
body.paper a { color: var(--p-accent); border-bottom: 0; text-decoration: none; }
body.paper a:hover { text-decoration: underline; text-underline-offset: 3px; color: var(--p-accent); }
body.paper ::selection { background: #dbe6ff; color: #111; }

/* ---------- layout ---------- */
.paper-wrap {
    position: relative;
    max-width: 1400px;
    margin: 0 auto;
    padding: 128px 28px 80px;
}
.paper-col { max-width: 760px; margin: 0 auto; }

/* ---------- title card: the landing-page terminal, made readable ---------- */
.title-card {
    max-width: 900px;
    margin: 0 auto 56px;
    border: 1px solid var(--p-rule);
    border-radius: 10px;
    background: var(--p-bg);
    box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 18px 48px -28px rgba(0,0,0,.18);
    overflow: hidden;
}
.title-card__bar {
    display: flex; align-items: center; gap: 7px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--p-rule);
    background: var(--p-soft);
    font-family: var(--p-mono); font-size: 12px; color: var(--p-faint);
}
.title-card__bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--p-rule); display: inline-block; }
.title-card__bar span { margin-left: auto; }
.title-card__body { padding: 34px 44px 38px; text-align: center; }
.title-card__cmd {
    font-family: var(--p-mono); font-size: 13px; color: var(--p-faint);
    margin: 0 0 18px;
}
.title-card__cmd b { color: var(--p-accent); font-weight: 500; }
.paper-title {
    font-family: var(--p-serif);
    font-weight: 600;
    font-size: clamp(30px, 4.2vw, 44px);
    line-height: 1.18;
    letter-spacing: -0.01em;
    color: var(--p-text);
    margin: 0 0 22px;
}
.paper-authors {
    font-size: 17px; line-height: 1.6; margin: 0 0 6px;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 22px;
}
.paper-authors a { color: var(--p-text); }
.paper-authors sup, .paper-affil sup { font-size: 11px; color: var(--p-muted); margin-left: 1px; }
.paper-affil {
    font-size: 14px; color: var(--p-muted); margin: 0 0 24px;
    display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 18px;
}
.paper-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
html body.paper .paper-buttons a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 18px; border-radius: 999px;
    background: var(--p-bg); color: var(--p-text);
    border: 1px solid var(--p-rule-strong);
    font-size: 14px; font-weight: 500; line-height: 1.4;
    transition: border-color .15s, background .15s;
}
html body.paper .paper-buttons a:hover { text-decoration: none; color: var(--p-text); background: var(--p-soft); border-color: var(--p-text); }
.paper-buttons svg { width: 15px; height: 15px; }

/* ---------- table of contents ---------- */
.paper-body { position: relative; }
.paper-toc {
    position: absolute; top: 0; left: 0; width: 160px;
    height: 100%;
}
.paper-toc nav { position: sticky; top: 96px; font-size: 13.5px; line-height: 1.5; padding-top: 70px; }
.paper-toc p { font-weight: 600; color: var(--p-text); margin: 0 0 10px; font-size: 13px; letter-spacing: .02em; }
html body.paper .paper-toc a { display: block; color: var(--p-faint); padding: 4px 0 4px 12px; border-left: 2px solid var(--p-rule); }
html body.paper .paper-toc a:hover { color: var(--p-text); text-decoration: none; }
html body.paper .paper-toc a.is-active { color: var(--p-text); border-left-color: var(--p-text); }
@media (max-width: 1340px) { .paper-toc { display: none; } }

/* ---------- prose ---------- */
.paper-col h2 {
    font-family: var(--p-serif); font-weight: 600;
    font-size: 28px; line-height: 1.25; letter-spacing: -0.005em;
    margin: 64px 0 18px; color: var(--p-text);
    scroll-margin-top: 90px;
}
.paper-col h3 {
    font-family: var(--p-sans); font-weight: 600; font-size: 17px;
    margin: 32px 0 6px; color: var(--p-text);
}
.paper-col p { margin: 0 0 20px; color: var(--p-text); }
.paper-col p.muted { color: var(--p-muted); }
.paper-col strong { font-weight: 600; }
.paper-col code {
    font-family: var(--p-mono); font-size: .88em;
    padding: 1px 5px; border-radius: 4px; background: var(--p-soft); color: var(--p-text);
}

/* ---------- figures (white card in both themes, to match the images) ---------- */
.paper-fig { margin: 36px 0 40px; }
.paper-fig.wide { margin-left: -90px; margin-right: -90px; }
@media (max-width: 960px) { .paper-fig.wide { margin-left: 0; margin-right: 0; } }
.paper-fig .frame {
    display: block; background: #fff; border-radius: 8px; overflow: hidden;
}
html[data-theme="dark"] .paper-fig .frame { padding: 14px; }
.paper-fig img, .paper-fig video { display: block; width: 100%; height: auto; }
.paper-fig video { max-width: 620px; margin: 0 auto; }
.paper-fig figcaption {
    margin-top: 12px; font-size: 14.5px; line-height: 1.6;
    color: var(--p-muted); font-style: italic;
}
.paper-fig figcaption b { font-style: italic; color: var(--p-text); font-weight: 600; }

/* ---------- equations ---------- */
.paper-eq { margin: 22px 0 24px; overflow-x: auto; font-size: 19px; color: var(--p-text); }
.paper-eq math { font-family: "STIX Two Math", "Cambria Math", var(--p-serif); }

/* ---------- table, booktabs style ---------- */
.paper-table-wrap { overflow-x: auto; margin: 22px 0 10px; }
.paper-table {
    width: 100%; min-width: 560px; border-collapse: collapse;
    font-size: 14.5px; font-variant-numeric: tabular-nums;
    border-top: 1.5px solid var(--p-text); border-bottom: 1.5px solid var(--p-text);
}
.paper-table th, .paper-table td { padding: 9px 12px; text-align: right; }
.paper-table th:first-child, .paper-table td:first-child { text-align: left; }
.paper-table thead th { font-weight: 600; border-bottom: 1px solid var(--p-text); }
.paper-table .best { font-weight: 700; }
.paper-note { font-size: 14px; color: var(--p-muted); margin: 8px 0 24px; }

/* ---------- citation ---------- */
.paper-cite {
    font-family: var(--p-mono); font-size: 13px; line-height: 1.65;
    background: var(--p-soft); border: 1px solid var(--p-rule); border-radius: 8px;
    padding: 18px 20px; overflow-x: auto; white-space: pre; color: var(--p-text);
}

.paper-footer {
    max-width: 760px; margin: 72px auto 0; padding: 24px 0 0;
    border-top: 1px solid var(--p-rule);
    font-size: 14px; color: var(--p-faint); text-align: center;
}

@media (max-width: 640px) {
    .paper-wrap { padding: 104px 18px 60px; }
    .title-card__body { padding: 26px 20px 28px; }
    body.paper { font-size: 16.5px; }
}

/* ---------- optional live flow behind the title (canvas[data-ns]) ---------- */
.paper-hero { position: relative; }
.paper-hero__flow {
    position: absolute; z-index: 0;
    top: -128px; left: 50%; width: 100vw; transform: translateX(-50%);
    height: calc(100% + 200px);
    pointer-events: none; overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
            mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
}
/* opacity is set from paper.js on scroll; this is the starting value */
.paper-hero__flow { --flow-opacity: .22; }
html[data-theme="dark"] .paper-hero__flow { --flow-opacity: .30; }
.paper-hero__flow canvas {
    width: 100%; height: 100%; display: block; object-fit: cover;
    opacity: var(--flow-opacity);
    transition: opacity .2s linear;
}
html[data-theme="dark"] .paper-hero__flow canvas[data-ns] { filter: invert(1) hue-rotate(180deg); }
.paper-hero .title-card {
    position: relative; z-index: 1;
    background: color-mix(in srgb, var(--p-bg) 90%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
@media (prefers-reduced-motion: reduce) { .paper-hero__flow canvas { opacity: .14; } }


/* ---------- extras used by the STEP page ---------- */
.paper-fig .frame.narrow { max-width: 560px; margin: 0 auto; }
.paper-fig-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: center; }
.paper-fig-pair .frame { height: 100%; display: flex; align-items: center; }
@media (max-width: 640px) { .paper-fig-pair { grid-template-columns: 1fr; } }

.paper-table-wrap.wide { margin-left: -100px; margin-right: -100px; }
@media (max-width: 1000px) { .paper-table-wrap.wide { margin-left: 0; margin-right: 0; } }
.paper-table .group-head td {
    padding-top: 16px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--p-muted); text-align: left;
    border-bottom: 1px solid var(--p-rule);
}
.paper-table tbody tr:first-child.group-head td { padding-top: 10px; }
.paper-table .ref { color: var(--p-faint); font-size: .92em; }
.paper-table .is-ours td { background: var(--p-soft); }
.paper-table td:nth-child(2), .paper-table th:nth-child(2) { text-align: center; }
.paper-table sup a { color: var(--p-muted); }

.paper-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px;
    margin: 8px 0 28px; padding: 22px 0;
    border-top: 1px solid var(--p-rule); border-bottom: 1px solid var(--p-rule);
}
.paper-stats b {
    display: block; font-family: var(--p-serif); font-weight: 600;
    font-size: 30px; line-height: 1.2; color: var(--p-text); margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.paper-stats span { display: block; font-size: 14px; line-height: 1.55; color: var(--p-muted); }
@media (max-width: 640px) { .paper-stats { grid-template-columns: 1fr; gap: 18px; } }

.paper-buttons .is-soon {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 18px; border-radius: 999px;
    border: 1px dashed var(--p-rule-strong); color: var(--p-faint);
    font-size: 14px; font-weight: 500; line-height: 1.4; cursor: default;
}
.paper-buttons .is-soon svg { width: 15px; height: 15px; }

/* STEP: latent paths header (canvas[data-latent], step-latent.js) */
.paper-hero__flow--latent { --flow-opacity: .75; }
html[data-theme="dark"] .paper-hero__flow--latent { --flow-opacity: .8; }
.paper-hero__flow--latent {
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
            mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
}
.paper-hero__flow--latent canvas { object-fit: fill; }
.paper-hero--latent .title-card { background: color-mix(in srgb, var(--p-bg) 82%, transparent); }
