/* Code-switching DPO project page. Same template as the IMAVB page, reduced. No framework, one stylesheet. */

:root {
  --bg: #f7f5f0;
  --bg-alt: #efece4;
  --surface: #ffffff;
  --ink: #1b2230;
  --ink-2: #3d4657;
  --muted: #5d6677;
  --line: #ddd8cc;
  --line-2: #c9c2b2;
  --accent: #2c5f9e;
  --accent-ink: #ffffff;
  --ours: #eaf1fa;
  --ours-line: #9bb8dd;
  --grp: #f3f0e8;
  --hopA: #3f74ab;
  --hopB: #7b62a8;
  --hopC: #2f8f86;
  --hopD: #b8693f;
  --shadow: 0 1px 2px rgba(27, 34, 48, .06), 0 8px 24px -12px rgba(27, 34, 48, .18);
  --radius: 14px;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --bg-alt: #161b24;
    --surface: #1c222d;
    --ink: #e9ecf2;
    --ink-2: #c6ccd8;
    --muted: #9aa3b4;
    --line: #2b3240;
    --line-2: #3a4353;
    --accent: #7fb0ec;
    --accent-ink: #0d1520;
    --ours: #1d2b40;
    --ours-line: #3f6597;
    --grp: #181e28;
    --hopA: #7ea9d8;
    --hopB: #a894d0;
    --hopC: #62bfb4;
    --hopD: #e0976c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
sup { line-height: 0; }
var { font-style: italic; font-family: var(--serif); font-size: 1.1em; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 860px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 22px; white-space: nowrap; }
.brand em, .title em { font-style: italic; }
.chain { display: inline-flex; gap: 4px; }
.chain i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.a { --c: var(--hopA); } .b { --c: var(--hopB); } .c { --c: var(--hopC); } .d { --c: var(--hopD); }
.chain i, .chainline i { background: var(--c); }
.toc { margin-left: auto; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.toc::-webkit-scrollbar { display: none; }
.toc a { color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.toc a:hover { background: var(--bg-alt); color: var(--ink); }

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: 72px 0 64px;
  text-align: center;
  background:
    radial-gradient(900px 380px at 50% -80px, color-mix(in srgb, var(--hopA) 13%, transparent), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--line);
}
.venue { margin: 0 0 18px; font: 500 13px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.title { margin: 0; font: 400 clamp(52px, 9vw, 104px)/1 var(--serif); letter-spacing: -.01em; }
.subtitle { margin: 16px auto 0; max-width: 900px; text-wrap: balance; font: 400 clamp(20px, 2.6vw, 28px)/1.3 var(--serif); color: var(--ink-2); }
.chainline { display: flex; align-items: center; justify-content: center; margin: 28px auto 26px; width: 180px; }
.chainline i { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }
.chainline b { flex: 1; height: 2px; background: var(--line-2); }

.authors, .affils { list-style: none; padding: 0; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: center; }
.authors { gap: 6px 22px; font-size: 18px; font-weight: 500; max-width: 820px; }
.authors li { white-space: nowrap; }
.authors sup, .affils sup, .corr sup { font-size: .68em; color: var(--muted); margin-left: 1px; }
.affils { gap: 4px 20px; margin-top: 12px; font-size: 15px; color: var(--ink-2); }
.corr { margin: 6px 0 0; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.env { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; vertical-align: super; }
.authors .env { width: 12px; height: 12px; color: var(--muted); margin-left: 1px; }
.corr .env { vertical-align: middle; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 30px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 15px; text-decoration: none;
  border: 1px solid var(--ink);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.fill { fill: currentColor; stroke: none; }

/* ---------- sections ---------- */
.section { padding: 88px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.band { padding: 56px 0 64px; }

.sec-head { max-width: 820px; margin: 0 0 36px; }
.wrap.narrow .sec-head { margin-left: auto; margin-right: auto; }
.kicker { margin: 0 0 10px; font: 600 12.5px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
h2 { text-wrap: balance; margin: 0; font: 400 clamp(32px, 4.4vw, 46px)/1.1 var(--serif); letter-spacing: -.005em; }
.lede { margin: 16px 0 0; font-size: 18px; color: var(--ink-2); }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
h3.sub { margin: 64px 0 20px; font: 400 clamp(24px, 3vw, 30px)/1.2 var(--serif); }

.prose p, .prose-p { color: var(--ink-2); margin: 0 0 1.1em; max-width: 72ch; }
.prose { max-width: 72ch; }
.note { color: var(--muted); font-size: 15px; margin: 18px 0 0; max-width: 80ch; }
.note.small { font-size: 13.5px; line-height: 1.6; }

/* ---------- TL;DR + stats ---------- */
.tldr {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 32px 28px 36px; box-shadow: var(--shadow); overflow: hidden;
}
.tldr::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(var(--hopA) 0 25%, var(--hopB) 25% 50%, var(--hopC) 50% 75%, var(--hopD) 75%); }
.tldr-text { margin: 0; font-size: 19px; line-height: 1.6; color: var(--ink); }
.num { font-family: var(--mono); font-weight: 500; font-size: .92em; padding: 1px 6px; border-radius: 6px; background: var(--bg-alt); }
.num.hi { background: var(--ours); color: var(--accent); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 28px 0 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stats > div { padding: 20px 22px; border-left: 1px solid var(--line); }
.stats > div:first-child { border-left: 0; }
.stats dt { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.stats dd { margin: 4px 0 0; font: 400 40px/1.05 var(--serif); }

/* ---------- video ---------- */
.video-frame { border-radius: var(--radius); overflow: hidden; background: #0e131b; box-shadow: var(--shadow); border: 1px solid var(--line); aspect-ratio: 16 / 9; }
.video-frame video { width: 100%; height: 100%; display: block; background: #0e131b; object-fit: contain; }

/* ---------- figures ---------- */
.fig { margin: 0; min-width: 0; }
.fig > a { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.fig img { border-radius: 4px; }
.fig figcaption { margin-top: 12px; font-size: 14.5px; color: var(--muted); line-height: 1.55; }
.fig.wide { margin: 0 auto; max-width: 980px; }
#results > .wrap > .fig { margin-top: 40px; }

/* ---------- worked example ---------- */
.example { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
.example .fig { max-width: 1040px; margin: 0 auto; width: 100%; }
.hops { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hop { position: relative; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 12px 14px 12px 50px; }
.hop p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.hop var { color: var(--c); font-weight: 600; font-style: italic; }
.hop .badge { position: absolute; left: 13px; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font: 700 13px/26px var(--sans); text-align: center; }
.ref { color: var(--c); font-weight: 600; }

/* ---------- cards ---------- */
.cards { display: grid; gap: 16px; margin-top: 36px; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.cards.four { grid-template-columns: repeat(4, 1fr); margin-top: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.card p { margin: 0; font-size: 15px; color: var(--ink-2); line-height: 1.6; }
.card.step { position: relative; padding-top: 52px; }
.card.step .n { position: absolute; top: 18px; left: 22px; font: 400 26px/1 var(--serif); color: var(--accent); }

/* ---------- pipeline split ---------- */
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 36px; align-items: start; }
.pipe .steps { grid-template-columns: repeat(4, 1fr); gap: 20px; margin: 28px auto 0; max-width: 980px; }
.pipe .steps li { padding: 44px 0 0; }
.split.rev { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 16px; }
.steps li { counter-increment: s; position: relative; padding-left: 44px; color: var(--ink-2); font-size: 15.5px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-2); font: 600 13px/27px var(--sans); text-align: center; color: var(--ink); background: var(--surface); }
.steps strong { color: var(--ink); }

/* ---------- results ---------- */
.headline { display: flex; align-items: stretch; gap: 10px; margin: 0 0 28px; flex-wrap: wrap; }
.hl { flex: 1 1 0; min-width: 130px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.hl .v { display: block; font: 400 36px/1 var(--serif); }
.hl .l { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.35; }
.hl.ours { background: var(--ours); border-color: var(--ours-line); }
.hl.ours .v { color: var(--accent); }
.arr { align-self: center; color: var(--line-2); font-size: 20px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.tcap { margin: 10px 2px 0; font-size: 13.5px; color: var(--muted); line-height: 1.55; max-width: 90ch; }
.tcap sup { font-size: .75em; }
.tbl th, .tbl td { padding: 10px 12px; text-align: center; white-space: nowrap; }
.tbl thead th { font-size: 12.5px; font-weight: 600; text-transform: none; letter-spacing: .02em; color: var(--muted); border-bottom: 1px solid var(--line-2); background: var(--bg-alt); }
.tbl .l { text-align: left; }
.tbl tbody th { font-weight: 500; }
.tbl tbody tr + tr > * { border-top: 1px solid var(--line); }
.tbl .sep { border-left: 1px solid var(--line-2); }
.tbl b { font-weight: 700; color: var(--ink); }
.tbl u { text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.tbl sup { font-size: .7em; color: var(--muted); margin-left: 1px; }
.tbl tr.ours > * { background: var(--ours); }
.tbl tr.ours th { font-weight: 700; color: var(--accent); }
.tbl tr.grp th { text-align: left; font-style: italic; font-weight: 500; color: var(--muted); font-size: 13px; background: var(--grp); padding-top: 7px; padding-bottom: 7px; }
.tbl tbody th, .tbl tbody td.l { color: var(--ink); }
.tbl td { color: var(--ink-2); }
.tbl tr.rule > * { border-top: 1.5px solid var(--line-2) !important; }
.small-tbl { font-size: 14.5px; }
#comparison + .prose-p { margin-bottom: 20px; }

/* ---------- bibtex ---------- */
.bib { background: #151b26; border-radius: var(--radius); border: 1px solid #263042; overflow: hidden; }
.bib-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 20px; border-bottom: 1px solid #263042; font: 500 12px var(--mono); color: #8d99ad; letter-spacing: .06em; }
.bib pre { margin: 0; color: #dbe3f0; padding: 18px 20px 22px; white-space: pre-wrap; word-break: break-word; font: 13px/1.7 var(--mono); }
.copy { display: inline-flex; align-items: center; gap: 6px; background: #273246; color: #e6ecf6; border: 1px solid #3a475e; border-radius: 8px; padding: 6px 11px; font: 600 13px var(--sans); cursor: pointer; }
.copy:hover { background: #33415a; }
.copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.copy.done { background: #2d6a4f; border-color: #3c8a66; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--line); background: var(--bg-alt); padding: 40px 0 48px; font-size: 14px; color: var(--muted); }
.foot { display: grid; grid-template-columns: 1fr auto; gap: 16px 32px; align-items: start; }
.foot p { margin: 0; }
.brand.small { font-size: 20px; color: var(--ink); margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-links a { color: var(--ink-2); text-decoration: none; font-weight: 500; }
.foot-links a:hover { color: var(--accent); }
.lic { grid-column: 1 / -1; font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .split, .split.rev { grid-template-columns: 1fr; }
  .pipe .steps { grid-template-columns: 1fr 1fr; }
  .cards.four { grid-template-columns: repeat(2, 1fr); }
  .cards.three { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .wrap, .topbar-inner { padding: 0 16px; }
  .topbar-inner { gap: 12px; }
  .brand { font-size: 19px; }
  .toc { mask-image: linear-gradient(90deg, #000 85%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .toc a { padding: 6px 8px; font-size: 13.5px; }
  .hero { padding: 48px 0 44px; }
  .authors { font-size: 16px; gap: 4px 14px; }
  .affils { font-size: 14px; flex-direction: column; }
  .btn { padding: 9px 14px; font-size: 14px; }
  .section { padding: 60px 0; }
  .band { padding: 40px 0 48px; }
  .tldr { padding: 22px 20px 22px 24px; }
  .tldr-text { font-size: 17px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div:nth-child(3) { border-left: 0; }
  .stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stats dd { font-size: 32px; }
  .fig > a { padding: 8px; }
  .cards.four { grid-template-columns: 1fr; }
  .headline { display: grid; grid-template-columns: 1fr 1fr; }
  .headline .arr { display: none; }
  .hl .v { font-size: 30px; }
  h3.sub { margin-top: 48px; }
  .foot { grid-template-columns: 1fr; }
  .bib pre { font-size: 12px; padding: 14px 14px 18px; }
  .hops { grid-template-columns: 1fr; }
  .pipe .steps { grid-template-columns: 1fr; }
  .pipe .steps li { padding: 0 0 0 44px; }
  /* wide figures scroll sideways on a phone instead of shrinking to unreadable */
  .fig.scroll > a { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .fig.scroll img { min-width: 720px; }
  .fig.scroll figcaption::before { content: "Scroll the figure sideways, or tap it to open it full size. "; font-style: italic; }
  .tbl th.l:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); max-width: 44vw; white-space: normal; min-width: 140px; }
  .tbl thead th.l:first-child { background: var(--bg-alt); }
  .tbl tr.ours th.l:first-child { background: var(--ours); }
  .tbl tr.grp th { position: sticky; left: 0; }
  .tbl th, .tbl td { padding: 9px 10px; }
}

/* link from a table row to its released checkpoint */
.ckpt { margin-left: 6px; font-family: var(--mono, ui-monospace, monospace); font-size: 0.72em; font-weight: 500; color: var(--accent, #2f6fb5); text-decoration: none; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; vertical-align: 1px; opacity: 0.85; }
.ckpt:hover { opacity: 1; }

/* the abstract sits in one quiet box, with no section title */
.abstract-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 32px 12px; margin: 0 auto; }
.abstract-box .kicker { margin-bottom: 14px; }
@media (max-width: 720px) { .abstract-box { padding: 20px 18px 6px; } }

/* ---------- code-switching DPO additions ---------- */
:root { --en: #2f6fb5; --zh: #b8692f; --good: #2d7a52; --good-bg: #e7f4ec; --bad: #b23a3a; --bad-bg: #fbeaea; }
@media (prefers-color-scheme: dark) { :root { --en: #7fb0ec; --zh: #e0976c; --good: #7fd1a3; --good-bg: #1d3328; --bad: #ef8a8a; --bad-bg: #3a1f22; } }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.dots .e { background: var(--en); } .dots .z { background: var(--zh); }
.hero { background: radial-gradient(900px 380px at 50% -80px, color-mix(in srgb, var(--en) 12%, transparent), transparent 70%), var(--bg); }
.hero .title { font-size: clamp(34px, 5.4vw, 58px); line-height: 1.12; max-width: 980px; margin: 0 auto; text-wrap: balance; }
.hero .authors { margin-top: 30px; }
.tldr::before { background: linear-gradient(var(--en) 0 50%, var(--zh) 50%); }
.num.bad { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
.fig.scroll > a img { width: 100%; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ex { margin: 12px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.ex span { display: block; }
.ex b { font: 600 11.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
.ex .gt, .ex .good { color: var(--ink); }
.ex .bad { color: var(--bad); }
.ex .good { color: var(--good); }
.ex .mer { margin-top: 6px; font: 500 13px/1.4 var(--mono); color: var(--muted); }
.card .tag { display: inline-block; font: 600 11.5px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.tbl td.gain { color: var(--ink); font-weight: 500; }
.tbl tr.mstart > * { border-top: 1.5px solid var(--line-2) !important; }
.tbl tbody th[rowspan] { vertical-align: middle; }
.code { background: #151b26; border: 1px solid #263042; border-radius: var(--radius); overflow: auto; }
.code pre { margin: 0; padding: 16px 20px; color: #dbe3f0; font: 13px/1.7 var(--mono); white-space: pre; }
.split .table-wrap { align-self: start; }
@media (max-width: 960px) { .modes { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .fig.scroll img { min-width: 900px; }
  .tbl tbody th[rowspan] { white-space: normal; min-width: 0; max-width: 32vw; }
}
.prose code { font: 500 .88em var(--mono); background: var(--bg-alt); padding: 1px 5px; border-radius: 5px; }
.split .prose .code { margin-top: 4px; }
.prose .code code { background: none; padding: 0; color: inherit; font: inherit; border-radius: 0; }
.split > * { min-width: 0; }
@media (max-width: 960px) { .split, .split.rev { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  #results .tbl { font-size: 12.5px; }
  #results .tbl th, #results .tbl td { padding: 8px 5px; }
  #results .tbl tbody th[rowspan] { position: static; box-shadow: none; min-width: 0; max-width: 92px; }
}
@media (max-width: 720px) { #results .tbl td.l { white-space: normal; min-width: 70px; } }
