/* Pixels-to-Phase project page.
   Layout: one centered 1040px column for every section, so text, figures, charts and tables share
   the same left and right edges. Section titles are centered; paragraphs are justified like the paper.
   Type: Latin Modern (the paper's typeface) for reading, Latin Modern Sans for interface text.
   Color: the paper's figure palette. Purple is Pixels-to-Phase and the corrected phase, blue is the
   video observation, amber is the propagated prior, green is reliability.
   Theme: light by default; the toggle in the top bar switches to dark. */

@font-face { font-family: "LM Roman 12"; src: url("../fonts/lmroman12-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "LM Roman 12"; src: url("../fonts/lmroman12-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "LM Roman 12"; src: url("../fonts/lmroman12-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "LM Roman 17"; src: url("../fonts/lmroman17-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "LM Sans 10"; src: url("../fonts/lmsans10-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "LM Sans 10"; src: url("../fonts/lmsans10-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #ffffff;
  --band: #f6f7f9;
  --well: #eef0f4;
  --ink: #1b1d24;
  --ink-2: #555b68;
  --rule: #dfe2e8;
  --phase: #5d4398;
  --phase-wash: #efeaf8;
  --obs: #2a66ad;
  --prior: #b9740f;
  --rel: #2d7f52;
  --bad: #b8403a;
  --bad-wash: #fbecea;
  --plate: #ffffff;
  --shadow: 0 1px 2px rgb(20 22 30 / 0.06), 0 4px 16px rgb(20 22 30 / 0.06);

  --display: "LM Roman 17", "Latin Modern Roman", "CMU Serif", "Computer Modern Serif", Georgia, serif;
  --serif: "LM Roman 12", "Latin Modern Roman", "CMU Serif", "Computer Modern Serif", Georgia, serif;
  --sans: "LM Sans 10", "Latin Modern Sans", "CMU Sans Serif", "Helvetica Neue", Arial, sans-serif;

  --content: 1040px;
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #15161b;
  --band: #1a1c22;
  --well: #24262e;
  --ink: #e8e8ee;
  --ink-2: #a5a9b5;
  --rule: #31343e;
  --phase: #ab95e6;
  --phase-wash: #2a2340;
  --obs: #74a9ea;
  --prior: #e3a650;
  --rel: #63c08b;
  --bad: #ea8079;
  --bad-wash: #3a2223;
  --plate: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(64px + env(safe-area-inset-top, 0px)); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.62;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--phase); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--phase); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; font-weight: 700; }
.greek { font-family: var(--serif); font-style: italic; }

.container { max-width: var(--content); margin-left: auto; margin-right: auto; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner { max-width: var(--content); margin: 0 auto; display: flex; align-items: center; gap: 20px; min-height: 54px; }
.brand { font-family: var(--display); font-size: 1.2rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar ul { list-style: none; margin: 0 0 0 auto; padding: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.topbar ul::-webkit-scrollbar { display: none; }
.topbar li a { display: block; padding: 6px 10px; border-radius: 6px; font-family: var(--sans); font-size: 0.9rem; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.topbar li a:hover { color: var(--ink); background: var(--well); }
.theme-toggle { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.theme-toggle:hover { background: var(--well); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------------------------------------------------------------- title block */
.hero { text-align: center; padding-block: 64px 56px; }
.venue { display: inline-flex; margin: 0 0 26px; font-family: var(--sans); font-size: 0.95rem; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.venue span { padding: 5px 15px 6px; }
.venue-conf { background: var(--ink); color: var(--paper); font-weight: 700; letter-spacing: 0.02em; }
.venue-track { color: var(--ink); }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(2.9rem, 7vw, 5.2rem); line-height: 1; letter-spacing: -0.01em; margin: 0 0 16px; }
.subtitle { font-size: clamp(1.25rem, 2.3vw, 1.65rem); line-height: 1.35; margin: 0 auto 30px; max-width: 34em; }
.authors { margin: 0 0 4px; font-size: 1.3rem; display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 34px; }
.authors a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.authors a:hover { border-bottom-color: var(--ink); }
.affils { margin: 0 0 32px; color: var(--ink-2); font-size: 1.08rem; }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px 8px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans); font-size: 0.94rem; font-weight: 700;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn:hover { background: var(--phase); border-color: var(--phase); text-decoration: none; }
.btn .soon { display: none; font-size: 0.72rem; font-weight: 400; padding: 0 6px; border-radius: 999px; }
.btn.has-soon .soon { display: inline; background: color-mix(in srgb, var(--paper) 22%, transparent); }
.btn[aria-disabled="true"] { background: var(--paper); border-color: var(--rule); color: var(--ink-2); font-weight: 400; cursor: default; }
.btn[aria-disabled="true"]:hover { background: var(--paper); border-color: var(--rule); }
.btn[aria-disabled="true"] .soon { display: inline; background: var(--well); color: var(--ink-2); }

/* ---------------------------------------------------------------- sections */
.section, .band { padding-block: 64px; }
.band {
  background: var(--band);
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.section + .section { padding-top: 0; }
.section + .section > .container { border-top: 1px solid var(--rule); padding-top: 64px; }
.section h2, .band h2 { font-size: clamp(1.75rem, 3vw, 2.15rem); line-height: 1.15; margin: 0 0 22px; text-align: center; }
.section h3 { font-size: 1.25rem; margin: 0 0 8px; }
.prose { margin: 0; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.prose.center { text-align: center; max-width: 46rem; margin: 0 auto; }

.video-frame { border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; max-width: 100%; box-shadow: var(--shadow); }
.video-frame video { width: 100%; height: 100%; display: block; }
.tldr { max-width: 48rem; margin: 26px auto 0; font-size: 1.25rem; line-height: 1.5; font-style: italic; text-align: center; }

.fig { margin: 32px 0 0; }
.fig img { background: var(--plate); border-radius: 8px; border: 1px solid var(--rule); width: 100%; }
.fig figcaption { font-size: 0.98rem; line-height: 1.55; color: var(--ink-2); margin-top: 12px; }
.fig figcaption b { color: var(--ink); }
.zoom { display: block; cursor: zoom-in; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; align-items: start; }

/* ---------------------------------------------------------------- method explorer */
.explorer { margin-top: 30px; }
.stage-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.stage-tabs button {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 15px; border-radius: 999px;
  border: 1.5px solid var(--rule); background: var(--paper); color: var(--ink-2); cursor: pointer;
}
.stage-tabs button .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--well); color: var(--ink); font-size: 0.78rem; }
.stage-tabs button:hover { color: var(--ink); border-color: var(--ink-2); }
.stage-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.stage-tabs button[aria-selected="true"] .n { background: var(--paper); color: var(--ink); }
.explorer .fig { margin-top: 18px; }
.ov-wrap { position: relative; }
.ov-mask { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; border-radius: 8px; }
.ov-mask .dim { fill: #ffffff; transition: opacity 260ms ease; }
.ov-mask .ring { fill: none; stroke-width: 4; vector-effect: non-scaling-stroke; }
@media (prefers-reduced-motion: reduce) { .ov-mask .dim { transition: none; } }
.stage-panel { margin-top: 24px; padding: 20px 24px; border-left: 3px solid var(--phase); background: var(--band); border-radius: 0 var(--radius) var(--radius) 0; }
.stage-panel p { margin: 0; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.eqs { margin-top: 14px; overflow-x: auto; overflow-y: hidden; padding-bottom: 4px; }
.eqs .katex-display { margin: 0; }
.katex { font-size: 1.05em; }

/* ---------------------------------------------------------------- interactive demo */
.instrument {
  margin-top: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
  gap: 28px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
}
.inst-plot { min-width: 0; }
#phasor { width: 100%; height: 300px; display: block; touch-action: pan-y; }
.inst-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.88rem; color: var(--ink-2); }
.inst-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 3px solid; }
.sw-truth { border-top: 2px dashed var(--ink-2); }
.sw-obs { border-color: var(--obs); }
.sw-prior { border-color: var(--prior); }
.sw-ours { border-color: var(--phase); border-top-width: 4px; }
.sw-rho { border-color: var(--rel); border-top-width: 2px; }
.inst-side { min-width: 0; display: flex; flex-direction: column; gap: 22px; padding-left: 24px; border-left: 1px solid var(--rule); }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 700; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--rule); position: relative; transition: background-color 150ms ease; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 150ms ease; }
.switch input:checked + .track { background: var(--bad); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--phase); outline-offset: 3px; }
.rho-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.95rem; }
.rho-top output { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--rel); }
.rho input[type="range"] { width: 100%; accent-color: var(--rel); margin: 6px 0 4px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 0.86rem; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--phase); margin: 0; }
.inst-readout { margin: 0; display: grid; gap: 8px; }
.inst-readout div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 12px; background: var(--band); border-radius: 8px; }
.inst-readout dt { font-size: 0.88rem; color: var(--ink-2); }
.inst-readout dd { margin: 0; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inst-readout div:first-child dd { color: var(--phase); }
.inst-readout div:nth-child(2) dd { color: var(--obs); }
.inst-play { align-self: start; font: inherit; font-weight: 700; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }

/* ---------------------------------------------------------------- results */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; margin-top: 34px; }
.chart { margin: 0; min-width: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--sans); }
.chart figcaption { font-size: 0.95rem; color: var(--ink-2); margin-top: 10px; }
.chart .grid line { stroke: var(--rule); }
.chart .tick { fill: var(--ink-2); font-size: 13px; }
.chart .lab { fill: var(--ink); font-size: 14px; font-weight: 700; }
.chart .val { font-size: 13px; font-variant-numeric: tabular-nums; }
.chart .flow { fill: var(--ink-2); }
.chart .ours { fill: var(--phase); }
.chart .link { stroke: var(--phase); stroke-width: 3; opacity: 0.35; }
.chart .gain { fill: var(--phase); font-weight: 700; font-size: 13px; }
.chart .ci { stroke: var(--phase); stroke-width: 2.5; }
.chart .zero { stroke: var(--ink-2); stroke-dasharray: 4 4; }
.chart .muted { fill: var(--ink-2); font-size: 12px; }

.tables { margin-top: 44px; }
.table-tools { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: space-between; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1.5px solid var(--ink); border-radius: 9px; overflow: hidden; }
.seg-btn { font-family: var(--sans); font-size: 0.93rem; padding: 7px 15px; border: 0; background: var(--paper); color: var(--ink); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1.5px solid var(--ink); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { background: var(--ink); color: var(--paper); font-weight: 700; }
.table-title { font-family: var(--serif); font-size: 1rem; margin: 18px 0 8px; color: var(--ink-2); }
.table-scroll { overflow-x: auto; min-width: 0; }
table.data { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 0.95rem; font-variant-numeric: tabular-nums; }
table.data caption { caption-side: top; text-align: left; font-family: var(--serif); font-size: 1rem; color: var(--ink-2); padding-bottom: 8px; }
table.data th, table.data td { padding: 7px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
table.data th[scope="row"], table.data thead th:first-child { text-align: left; font-weight: 400; }
table.data thead th { font-weight: 700; border-bottom: 1.5px solid var(--ink); }
table.data tbody tr.group-start th, table.data tbody tr.group-start td { border-top: 1.5px solid var(--ink-2); }
table.data tr.ours th, table.data tr.ours td { background: var(--phase-wash); color: var(--ink); font-weight: 700; }
table.data tr.ours th { color: var(--phase); }
table.data .best { font-weight: 700; }
table.data .dash { color: var(--ink-2); }
table.data .fam { font-size: 0.75rem; color: var(--ink-2); display: block; }
table.small { font-size: 0.9rem; }
.table-note { font-size: 0.9rem; color: var(--ink-2); margin: 10px 0 0; }
.more { margin-top: 28px; border-top: 1px solid var(--rule); padding-top: 14px; }
.more summary { font-family: var(--sans); font-weight: 700; cursor: pointer; padding: 4px 0; }
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; margin-top: 18px; }
.more-grid .span-2 { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- evidence viewer */
.viewer { margin-top: 30px; text-align: center; }
.viewer .fig { text-align: left; margin-top: 18px; }
.ev-stage img { width: 100%; height: auto; margin: 0 auto; }

/* ---------------------------------------------------------------- dataset */
.h-row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 22px; }
.h-row h2 { margin: 0 !important; }
.status { font-family: var(--sans); font-size: 0.88rem; font-weight: 700; color: var(--prior); border: 1.5px solid var(--prior); border-radius: 999px; padding: 3px 12px; }
.status.is-live { color: var(--rel); border-color: var(--rel); }
.ds-figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; align-items: start; }
.ds-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 40px; margin-top: 36px; align-items: start; }
.facts { margin: 0; display: grid; }
.facts div { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.facts div:first-child { border-top: 1px solid var(--rule); }
.facts dt { font-family: var(--sans); font-weight: 700; font-size: 0.92rem; padding-top: 3px; }
.facts dd { margin: 0; font-size: 1.02rem; line-height: 1.5; }
.ds-side { min-width: 0; display: grid; gap: 26px; }
.ds-links { justify-content: flex-start; }

/* ---------------------------------------------------------------- citation and footer */
.bib { position: relative; }
.bib pre { margin: 0; padding: 20px 22px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); overflow-x: auto; font-size: 0.9rem; line-height: 1.55; }
.bib code { font-family: "LM Mono 10", "Latin Modern Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink); }
.copy { position: absolute; top: 12px; right: 12px; font-family: var(--sans); font-size: 0.85rem; font-weight: 700; padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }
.copy:hover { background: var(--phase); border-color: var(--phase); }
.footer { padding-block: 26px 36px; color: var(--ink-2); font-family: var(--sans); font-size: 0.88rem; }
.footer-inner { text-align: center; }
.footer p { margin: 0 0 4px; }
.footer a { color: var(--ink-2); }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 900px) {
  .instrument { grid-template-columns: minmax(0, 1fr); }
  .inst-side { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); padding-top: 20px; }
  .charts, .pair, .more-grid, .ds-figs, .ds-body { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 1.06rem; }
  .br-wide { display: none; }
  .brand { font-size: 1.05rem; }
  .topbar-inner { gap: 10px; }
  .hero { padding-block: 40px 40px; }
  .authors { font-size: 1.15rem; }
  .instrument { padding: 16px; }
  #phasor { height: 380px; }
  .facts div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .stage-panel { padding: 16px 16px; }
  .section, .band { padding-block: 44px; }
  .section + .section { padding-top: 0; }
  .section + .section > .container { padding-top: 44px; }
  .prose, .stage-panel p, .fig figcaption { text-align: left; }
}
.ds-name { font-weight: 400; color: var(--ink-2); }
