/* ============================================================
   Dense Temporal Contrast Synthesis — project page
   No external assets: system fonts only, self-contained.

   Chart colors come from the validated data-viz palette:
     ordinal ramp  #86b6ef → #2a78d6 → #184f95   (--ordinal, PASS light+dark)
     diverging     #2a78d6 ↔ #e34948 light / #3987e5 ↔ #e66767 dark (PASS both)
   Validated against this page's chart surfaces (#ffffff / #171c22).
   Re-run scripts/validate_palette.js after changing any of them.
   ============================================================ */

:root {
  --bg:            #ffffff;
  --bg-band:       #f6f7f9;
  --bg-raised:     #ffffff;
  --fg:            #1a1d21;
  --fg-muted:      #5c6470;
  --fg-faint:      #838b96;
  --border:        #e2e5ea;
  --accent:        #1c5cab;   /* 6.6:1 on white — safe for link text */
  --accent-strong: #184f95;
  --accent-soft:   #e9f1fd;
  --ours:          #fff8e8;
  --ours-border:   #f0c96b;
  --caution:       #fff4f0;
  --caution-border:#e9a68d;

  /* chart tokens */
  --viz-surface:   #ffffff;
  --viz-series:    #2a78d6;
  --viz-neg:       #e34948;
  --viz-mute:      #898781;
  --viz-ord-1:     #86b6ef;
  --viz-ord-2:     #2a78d6;
  --viz-ord-3:     #184f95;
  --viz-grid:      #e1e0d9;
  --viz-axis:      #c3c2b7;
  --viz-ink:       #1a1d21;
  --viz-muted-ink: #6a7280;

  --radius:        10px;
  --wrap:          1140px;
  --shadow:        0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0f1216;
    --bg-band:       #14181d;
    --bg-raised:     #171c22;
    --fg:            #e6e9ee;
    --fg-muted:      #a3adb9;
    --fg-faint:      #78828f;
    --border:        #262c34;
    --accent:        #6da7ec;   /* 7.5:1 on the dark page surface */
    --accent-strong: #86b6ef;
    --accent-soft:   #14243a;
    --ours:          #2a2314;
    --ours-border:   #7a6428;
    --caution:       #2c1b16;
    --caution-border:#7d4a38;

    --viz-surface:   #171c22;
    --viz-series:    #3987e5;
    --viz-neg:       #e66767;
    --viz-mute:      #898781;
    --viz-ord-1:     #86b6ef;
    --viz-ord-2:     #2a78d6;
    --viz-ord-3:     #184f95;
    --viz-grid:      #2c2c2a;
    --viz-axis:      #383835;
    --viz-ink:       #e6e9ee;
    --viz-muted-ink: #9aa4b0;

    --shadow:        0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; height: auto; display: block; }

/* keep sub/sup from stretching the line box they sit in */
sub, sup { font-size: .72em; line-height: 0; position: relative; vertical-align: baseline; }
sub { bottom: -0.28em; }
sup { top: -0.45em; }

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

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 780px; margin-left: auto; margin-right: auto; }
.wrap.narrow { padding: 0 24px; }

/* ── Nav ─────────────────────────────────────────────────── */
#nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.nav-brand { font-weight: 650; color: var(--fg); letter-spacing: -0.01em; }
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.nav-links { list-style: none; display: flex; gap: 20px; margin: 0 0 0 auto; padding: 0; }
.nav-links a { color: var(--fg-muted); font-size: 15px; font-weight: 500; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }

#nav-toggle {
  display: none; margin-left: auto; background: none; border: 0; cursor: pointer;
  padding: 8px; flex-direction: column; gap: 4px;
}
#nav-toggle span { display: block; width: 20px; height: 2px; background: var(--fg); border-radius: 2px; }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  padding: 64px 0 52px;
  background: radial-gradient(900px 380px at 50% -120px, var(--accent-soft), transparent 70%);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.eyebrow {
  margin: 0 0 18px; font-size: 13px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent);
}
.hero h1 {
  margin: 0 auto 26px; max-width: 940px;
  font-size: clamp(30px, 4.6vw, 50px); font-weight: 700; letter-spacing: -0.03em;
}
.authors { max-width: 900px; margin: 0 auto 8px; font-size: 16.5px; line-height: 1.9; }
.authors sup { color: var(--fg-faint); font-size: .72em; }
.author-note { margin: 0 0 22px; font-size: 13.5px; color: var(--fg-faint); }

.affiliations { max-width: 820px; margin: 0 auto 30px; text-align: left; }
.affiliations summary {
  cursor: pointer; text-align: center; font-size: 14px; color: var(--fg-muted);
  list-style: none; padding: 6px 0;
}
.affiliations summary::-webkit-details-marker { display: none; }
.affiliations summary::after { content: " ▾"; color: var(--fg-faint); }
.affiliations[open] summary::after { content: " ▴"; }
.affiliations ol {
  list-style: none; margin: 12px 0 0; padding: 16px 20px;
  background: var(--bg-band); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--fg-muted);
}
.affiliations li { margin: 5px 0; }
.affiliations sup { color: var(--accent); font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────── */
.buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-raised);
  color: var(--fg); font-size: 15px; font-weight: 570;
  box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--accent); }
.btn svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #08121f; } }
.btn-lg { padding: 14px 26px; font-size: 16.5px; }
.btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.soon {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 999px; background: var(--bg-band); color: var(--fg-faint);
}

/* ── Sections ────────────────────────────────────────────── */
.section { padding: 62px 0; }
.section.band { background: var(--bg-band); border-block: 1px solid var(--border); }

.part-tag {
  margin: 0 0 6px; font-size: 12.5px; font-weight: 650; letter-spacing: .09em;
  text-transform: uppercase; color: var(--fg-faint);
}
h2 { font-size: clamp(24px, 3vw, 33px); font-weight: 680; margin: 0 0 18px; }
h3 {
  font-size: 20px; font-weight: 650; margin: 46px 0 10px;
  display: flex; align-items: center; gap: 11px;
}
h3 .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: none; border-radius: 7px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 14px; font-weight: 700; letter-spacing: 0;
}

.lead { color: var(--fg-muted); max-width: 880px; margin: 0 0 22px; }
.abstract {
  font-size: 15px; line-height: 1.75; color: var(--fg-muted);
  text-align: justify; hyphens: auto;
}
.abstract strong, .abstract em { color: var(--fg); }

/* ── Method steps ────────────────────────────────────────── */
.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.steps li {
  position: relative; padding: 20px 20px 18px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 7px; margin-bottom: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 700;
}
.steps h4 { margin: 0 0 6px; font-size: 16px; font-weight: 650; line-height: 1.3; }
.steps p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--fg-muted); }
.note {
  font-size: 13.5px; color: var(--fg-faint); line-height: 1.6;
  margin: 12px 0 0; max-width: 980px;
}

/* ── Stats ───────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 8px; }
.stat {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stat-val {
  font-size: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--accent);
  line-height: 1.1; margin-bottom: 8px;
}
.stat-val .unit { font-size: 17px; margin-left: 5px; color: var(--fg-faint); font-weight: 600; }
.stat-label { font-size: 14px; color: var(--fg-muted); line-height: 1.5; }

/* ── Figures ─────────────────────────────────────────────── */
.figure {
  margin: 26px 0 0; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.figure img { margin: 0 auto; border-radius: 6px; cursor: zoom-in; }
.figure figcaption { margin-top: 14px; font-size: 14px; color: var(--fg-muted); line-height: 1.6; }

/* ── Tables ──────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-raised); box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
table.data {
  width: 100%; border-collapse: collapse;
  font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap;
}
table.data th, table.data td { padding: 10px 14px; text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; white-space: normal; }
table.data thead th {
  background: var(--bg-band); color: var(--fg); font-weight: 620;
  border-bottom: 1px solid var(--border);
}
table.data tbody tr + tr td { border-top: 1px solid var(--border); }
table.data tr.ours { background: var(--ours); }
table.data tr.ours td { border-top-color: var(--ours-border); }
table.data tr.bound td { color: var(--fg-faint); font-style: italic; }
table.data tr.group td {
  background: var(--bg-band); font-style: italic; color: var(--fg-muted);
  font-size: 13px; text-align: left;
}
table.data sup { color: var(--fg-faint); }
/* cap the framed container, not the table inside it, so the border
   hugs the data instead of trailing off across the column */
.table-scroll.compact { max-width: 580px; }

/* ── Videos ──────────────────────────────────────────────── */
/* One-at-a-time carousel: only the .active card is shown, the rest wait
   in the DOM so script.js can flip .active on prev/next. */
.video-gallery { margin-top: 22px; }
.video-gallery .video-card { display: none; }
.video-gallery .video-card.active { display: block; }
.video-card {
  margin: 0; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
}
/* width/height attributes on each <video> give the exact intrinsic ratio,
   so the box is reserved before metadata lands with no letterboxing —
   the sources are not all the same ratio (1.59-1.63). */
.video-card video { width: 100%; height: auto; border-radius: 6px; background: #000; }
.video-card figcaption { margin-top: 10px; font-size: 13.5px; color: var(--fg-muted); }
.vlabel { display: inline-block; font-weight: 650; color: var(--accent); margin-right: 6px; }

.gallery-row { display: flex; align-items: center; gap: 14px; }
.video-gallery-viewport { flex: 1 1 auto; min-width: 0; }
.gallery-arrow {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-raised); box-shadow: var(--shadow);
  color: var(--fg); font-size: 26px; line-height: 1; cursor: pointer;
}
.gallery-arrow:hover, .gallery-arrow:focus-visible {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.gallery-counter {
  margin-top: 12px; font-size: 13px; color: var(--fg-muted); text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Charts ──────────────────────────────────────────────── */
.chart-card {
  margin: 26px 0 0; background: var(--viz-surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px 18px; box-shadow: var(--shadow);
}
.chart-head { margin: 0 0 6px; }
.chart-head h3 { margin: 0 0 4px; font-size: 18.5px; }
.chart-head p { margin: 0; font-size: 14px; color: var(--fg-muted); max-width: 780px; }
.chart-body { overflow-x: auto; margin: 4px -4px 0; padding: 0 4px; }
.viz { width: 100%; min-width: 520px; height: auto; display: block; overflow: visible; }
.chart-note {
  margin: 14px 0 0; font-size: 13.5px; line-height: 1.6; color: var(--fg-muted);
  max-width: 900px;
}
.chart-note.caution {
  border-left: 3px solid var(--caution-border); background: var(--caution);
  padding: 10px 14px; border-radius: 0 8px 8px 0; color: var(--fg);
}

/* chart marks */
.viz .mark { transition: opacity .12s ease; }
.viz .mark:hover, .viz .mark:focus-visible { opacity: .82; outline: none; }
.viz .m-accent { fill: var(--viz-series); }
.viz .m-mute   { fill: var(--viz-mute); }
.viz .m-ord1   { fill: var(--viz-ord-1); }
.viz .m-ord2   { fill: var(--viz-ord-2); }
.viz .m-ord3   { fill: var(--viz-ord-3); }
.viz .m-pos    { fill: var(--viz-series); }
.viz .m-neg    { fill: var(--viz-neg); }
.viz .m-ns     { fill: var(--viz-mute); }
.viz .dot { stroke: var(--viz-surface); stroke-width: 2; }
.viz .dot:focus-visible { outline: none; stroke: var(--viz-ink); }
.viz .ci { stroke: var(--viz-series); stroke-width: 2; }
.viz .ci-cap { stroke: var(--viz-series); stroke-width: 2; opacity: .55; }

/* chart chrome */
.viz .axis     { stroke: var(--viz-axis); stroke-width: 1; }
.viz .axis-x   { stroke: var(--viz-axis); stroke-width: 1; }
.viz .grid     { stroke: var(--viz-grid); stroke-width: 1; }
.viz .ref-line { stroke: var(--viz-muted-ink); stroke-width: 1; }
.viz .bracket { stroke: var(--viz-axis); stroke-width: 1; fill: none; }

/* chart text — always text tokens, never the series color */
.viz text { font-family: inherit; fill: var(--viz-muted-ink); font-size: 13px; }
.viz .cat { fill: var(--viz-ink); font-size: 13.5px; font-weight: 550; text-anchor: end; }
.viz .cat.left { text-anchor: start; }
.viz .val { fill: var(--viz-ink); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.viz .val.right { text-anchor: end; }
.viz .val.strong { font-weight: 680; }
.viz .val.muted { fill: var(--viz-muted-ink); }
.viz .seg-label { font-size: 13.5px; font-weight: 620; text-anchor: middle; }
.viz .seg-label.on-dark { fill: #ffffff; }
.viz .seg-label.on-light { fill: #0b0b0b; }
.viz .axis-label { font-size: 12px; text-anchor: middle; }
.viz .axis-label.ref { font-weight: 620; fill: var(--viz-ink); }
.viz .axis-title { font-size: 12px; text-anchor: middle; }
.viz .bracket-label { font-size: 12.5px; font-weight: 620; fill: var(--viz-ink); text-anchor: middle; }
.viz .legend text { font-size: 12.5px; dominant-baseline: middle; }
.viz .legend .sw { rx: 2.5; }

.table-view { margin-top: 14px; }
.table-view summary {
  cursor: pointer; font-size: 13.5px; color: var(--fg-muted);
  list-style: none; display: inline-block; padding: 4px 0;
}
.table-view summary:hover { color: var(--accent); }
.table-view summary::-webkit-details-marker { display: none; }
.table-view summary::before { content: "▸ "; color: var(--fg-faint); }
.table-view[open] summary::before { content: "▾ "; }
/* direct child only, so a table already wrapped in .table-scroll
   (which carries its own border) is not double-framed */
.table-view > table.data {
  margin-top: 8px; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; font-size: 13.5px;
}
.table-view > .table-scroll { margin-top: 10px; }

/* tooltip */
#viz-tip {
  position: fixed; z-index: 90; pointer-events: none; opacity: 0;
  transform: translate(-50%, -100%);
  background: var(--fg); color: var(--bg);
  padding: 6px 10px; border-radius: 7px; font-size: 12.5px; line-height: 1.4;
  max-width: 280px; box-shadow: 0 4px 14px rgba(0,0,0,.22);
  transition: opacity .1s ease;
}
#viz-tip.show { opacity: 1; }

/* ── CTA ─────────────────────────────────────────────────── */
.cta {
  margin-top: 34px; text-align: center; padding: 30px 24px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.cta.cta-top { margin-top: 8px; padding: 22px 24px; }
.cta p { margin: 0 0 18px; color: var(--fg-muted); }

/* ── Data / BibTeX ───────────────────────────────────────── */
.links { margin: 0 0 12px; padding-left: 20px; font-size: 15.5px; color: var(--fg-muted); }
.links li { margin-bottom: 10px; }
.alt-link { font-size: 14px; color: var(--fg-faint); }

.bibtex { position: relative; }
.bibtex pre {
  margin: 0; overflow-x: auto; padding: 18px 18px 18px 20px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 12.5px; line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color: var(--fg-muted);
}
.copy-btn {
  position: absolute; top: 10px; right: 10px; z-index: 1;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-band);
  color: var(--fg-muted); font: inherit; font-size: 12.5px;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Footer ──────────────────────────────────────────────── */
footer { padding: 40px 0 56px; border-top: 1px solid var(--border); text-align: center; }
footer p { margin: 0 0 8px; color: var(--fg-muted); font-size: 15px; }
footer .fine { font-size: 13px; color: var(--fg-faint); }

/* ── Lightbox ────────────────────────────────────────────── */
#lightbox {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(8, 10, 13, .92); padding: 24px;
  align-items: center; justify-content: center; cursor: zoom-out;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .hero { padding: 44px 0 40px; }
  .section { padding: 46px 0; }
  .abstract { text-align: left; }
  .stats { grid-template-columns: 1fr; }
  .chart-card { padding: 18px 14px 14px; }
  .gallery-row { gap: 8px; }
  .gallery-arrow { width: 38px; height: 38px; font-size: 20px; }
  #nav-toggle { display: flex; }
  .nav-links {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px 24px 16px; margin: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .nav-links.open { display: flex; }
  .nav-links li { padding: 8px 0; }
}

/* ── Forced colors / print: texture is the backup channel ── */
@media (forced-colors: active) {
  .viz .mark, .viz .dot { forced-color-adjust: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
