/* ============================================================
   MessyNav — project page.

   Warm minimal cards: a warm off-white ground, white rounded
   cards carrying one idea each, geometric display type, and a
   single accent doing the emphasis.

   Every colour is from the affordance-reasoning bar chart
   (paper_figures/fig4_affordance_reasoning.py) or one of its
   values tinted over white, so page and figure stay in step.
   ============================================================ */

:root {
  /* Straight from the figure. */
  --ink:         #1b1b1a;   /* INK   — bar outlines, primary text */
  --ink-2:       #4a4a47;   /* INK_2 — secondary text, axis spine */
  --muted:       #8b8a85;   /* MUTED */
  --hair:        #dcdbd5;   /* GRID  — hairline rules */
  --orange:      #eb6834;   /* OURS  — MessyNav */
  --green-dark:  #2c6351;
  --green-mid:   #4d9078;
  --green-light: #7cb49b;

  /* The figure's values tinted over white — no new hues. */
  --ground:      #faf8f5;                  /* warm off-white page */
  --card:        #ffffff;
  --edge:        #eceae4;                  /* grid @ ~0.45, card hairline */
  --panel:       #f6f4f0;                  /* inset panels, code */
  --wash:        rgba(235, 104, 52, 0.09); /* the figure's own wash */
  --wash-deep:   rgba(235, 104, 52, 0.15);
  --chip:        rgba(235, 104, 52, 0.12);
  --faint:       rgba(27, 27, 26, 0.16);

  --shadow-sm: 0 1px 2px rgba(27, 27, 26, 0.04);
  --shadow:    0 1px 2px rgba(27, 27, 26, 0.04), 0 14px 34px rgba(27, 27, 26, 0.055);
  --shadow-lg: 0 2px 4px rgba(27, 27, 26, 0.05), 0 26px 60px rgba(27, 27, 26, 0.085);

  /* Jost is the geometric face closest to the figure's own URW Gothic. */
  --display: "Jost", "Century Gothic", "Trebuchet MS", sans-serif;
  --text: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --code: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* ---------------------------------------------------------------
     Type scale. Every piece of text on the page picks one of these;
     nothing sets a font-size of its own. Weight and colour, not
     size, separate a step title from its description or an
     affiliation from an author name.
     --------------------------------------------------------------- */
  --fs-display: clamp(34px, 5.4vw, 62px);   /* page title */
  --fs-h2:      clamp(27px, 3.4vw, 40px);   /* section heads, stat figures */
  --fs-h3:      clamp(20px, 2.2vw, 26px);   /* subsection heads */
  --fs-body:    16.5px;                     /* all running text */
  --fs-ui:      14.5px;                     /* controls, nav, table cells */
  --fs-cap:     13.5px;                     /* captions, footer, stat labels */
  --fs-micro:   11.5px;                     /* uppercase labels and badges */
  --fs-code:    13px;                       /* the BibTeX block */

  /* Three leadings, matched to the registers above. */
  --lh-head: 1.08;   /* display and section heads */
  --lh-text: 1.62;   /* running text, captions, code */
  --lh-ui:   1.5;    /* controls, nav, table cells */

  --maxw: 1120px;
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--text);
  font-size: var(--fs-body);
  line-height: var(--lh-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; }
::selection { background: var(--chip); }

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

/* ---------- floating pill nav ---------- */
.nav {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  transform: translate(-50%, -140%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(.22,.61,.36,1), opacity 0.22s ease;
}

.nav.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }

.nav-home {
  font-family: var(--display);
  font-size: var(--fs-ui);
  line-height: var(--lh-ui);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 7px 14px 7px 16px;
  border-radius: 999px;
}

.nav-home:hover { background: var(--panel); }

.nav a {
  font-size: var(--fs-ui);
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { color: var(--ink); background: var(--panel); }

/* Current section, tracked while scrolling. */
.nav a.current { color: var(--ink); background: var(--chip); }

@media (max-width: 820px) {
  .nav { gap: 0; padding: 5px; max-width: calc(100vw - 24px); overflow-x: auto; }
  .nav-home { display: none; }
  .nav a { padding: 7px 11px; }
}

/* ---------- hero ---------- */
.hero {
  padding: clamp(52px, 7vw, 104px) 0 0;
  text-align: center;
}

.venue {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 15px 7px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: var(--fs-ui);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.venue::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange);
}

.hero h1 {
  font-family: var(--display);
  font-size: var(--fs-display);
  font-weight: 600;
  letter-spacing: -0.022em;
  line-height: var(--lh-head);
  margin: 26px auto 0;
  max-width: 24ch;
  text-wrap: balance;
}

.byline { margin: 26px auto 0; max-width: 820px; }

.byline .names {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 18px;
  justify-content: center;
  font-size: var(--fs-body);
  line-height: var(--lh-text);
  font-weight: 500;
}

.byline .names a {
  text-decoration: none;
  border-bottom: 1px solid var(--faint);
  transition: border-color 0.15s;
}

.byline .names a:hover { border-bottom-color: var(--orange); }
.byline sup { font-size: 0.66em; font-weight: 600; color: var(--ink-2); }

.byline .where {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  justify-content: center;
  color: var(--ink-2);
  font-size: var(--fs-body);
  line-height: var(--lh-text);
}

.btnrow {
  margin: 26px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: var(--fs-ui);
  font-weight: 600;
  text-decoration: none;
  background: var(--ink);
  color: #fff;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn:hover { background: var(--ink-2); }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn.is-quiet {
  background: var(--card);
  color: var(--ink-2);
  border-color: var(--edge);
  box-shadow: var(--shadow-sm);
  cursor: default;
}

/* ---------- stat strip ---------- */
.stats {
  margin: clamp(30px, 4vw, 44px) auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 20px 18px;
  text-align: left;
}

.stat .v {
  margin: 0;
  font-family: var(--display);
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--lh-head);
}

.stat.is-ours { background: var(--wash); border-color: rgba(235, 104, 52, 0.22); }
.stat.is-ours .v { color: var(--orange); }

.stat .k {
  margin: 8px 0 0;
  font-size: var(--fs-cap);
  line-height: var(--lh-text);
  font-weight: 500;
  color: var(--ink-2);
}

/* ---------- media mosaic ---------- */
.mosaic {
  margin: clamp(30px, 4vw, 46px) auto 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.mosaic > * { grid-column: span 2; }
.mosaic > :nth-child(4), .mosaic > :nth-child(5) { grid-column: span 3; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(26px, 3.4vw, 48px);
}

.sec { padding: clamp(18px, 2.4vw, 30px) 0; }
.sec:first-of-type { padding-top: clamp(34px, 4.5vw, 56px); }

/* Section label: a coloured dot and a quiet uppercase word. */
.label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.label::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex: none;
}

h2.head {
  font-family: var(--display);
  font-size: var(--fs-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--lh-head);
  margin: 14px 0 0;
  max-width: 30ch;
  text-wrap: balance;
}

h3.sub {
  font-family: var(--display);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: var(--lh-head);
  margin: 0;
}

/* ---------- running text ---------- */
.prose {
  font-size: var(--fs-body);
  line-height: var(--lh-text);
  color: #33332f;
  margin: 18px 0 0;
  text-wrap: pretty;
}

/* The line under a section head: same size and leading as any other
   paragraph, set apart by colour only. */
.prose.is-lede { color: var(--ink-2); }
.prose b { font-weight: 600; color: var(--ink); }

.prose a {
  text-decoration: none;
  border-bottom: 1px solid var(--faint);
  transition: border-color 0.15s;
}

.prose a:hover { border-bottom-color: var(--orange); }

/* Caption under a figure, table, or media grid. */
.cap {
  margin: 14px 0 0;
  font-size: var(--fs-cap);
  line-height: var(--lh-text);
  color: var(--ink-2);
}

.cap b { color: var(--ink); font-weight: 600; }

.cap.is-centered { margin-left: auto; margin-right: auto; text-align: center; }

.stack { margin-top: clamp(22px, 2.8vw, 34px); }
.stack-sm { margin-top: 16px; }
.stack-lg { margin-top: clamp(34px, 4.4vw, 56px); }

/* An inset group inside a card. The example media sits in one of these so a
   card reads as two beats -- the numbers, then what they looked like --
   rather than two full-width blocks of equal weight butted together. */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: clamp(16px, 2.2vw, 26px);
}

.panel > .cap:first-child,
.panel > :first-child { margin-top: 0; }

/* ---------- framework steps ---------- */
.steps {
  margin: clamp(22px, 2.8vw, 34px) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-size: var(--fs-body);
  line-height: var(--lh-text);
  color: #33332f;
}

.steps li::before {
  content: counter(step, decimal-leading-zero);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  margin-bottom: 14px;
  border-radius: 9px;
  font-family: var(--display);
  font-size: var(--fs-micro);
  font-weight: 600;
  color: #fff;
}

/* The figure's ordinal green ramp, reused as a sequence marker. */
.steps li:nth-child(1)::before { background: var(--green-dark); }
.steps li:nth-child(2)::before { background: var(--green-mid); }
.steps li:nth-child(3)::before { background: var(--green-light); }

.steps li b {
  display: block;
  font-family: var(--display);
  font-size: var(--fs-body);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

/* ---------- media ---------- */
.media {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0f0f0e;
  box-shadow: var(--shadow-sm);
}

.media.is-tile { aspect-ratio: 16 / 9; }
.media.is-tile video { width: 100%; height: 100%; object-fit: cover; }
.media video { width: 100%; }

.shot {
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.diagram {
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--edge);
  padding: 8px;
}

.diagram img { width: 100%; border-radius: 8px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ---------- affordance pairs ---------- */
.pair {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  line-height: 0;
  box-shadow: var(--shadow-sm);
}

.pair img { width: 100%; }

.pair .pair-eval {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* :focus-within keeps this keyboard-reachable and covers tap. */
.pair:hover .pair-eval,
.pair:focus-within .pair-eval { opacity: 1; }

.pair::after {
  content: "hover";
  position: absolute;
  right: 10px; bottom: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  transition: opacity 0.2s ease;
}

.pair:hover::after, .pair:focus-within::after { opacity: 0; }

.tag-interactive { color: var(--green-mid); font-weight: 600; }
.tag-non-interactive { color: var(--ink-2); font-weight: 600; }

/* ---------- tables ---------- */
/* .results-table is what the live demo builds, so both are styled here. */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}

.res, .results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-ui);
  font-variant-numeric: tabular-nums;
}

.res th, .res td,
.results-table th, .results-table td {
  padding: 13px 16px;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--edge);
  transition: background 120ms ease;
}

.res thead th,
.results-table thead th {
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--hair);
}

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

.res tbody td, .results-table tbody td { color: var(--ink); }

.res tbody td:first-child,
.results-table tbody td:first-child { color: var(--ink-2); font-weight: 500; }

.res td.num, .res th.num { text-align: right; }

/* The figure's wash: on our row where rows are methods, on our column
   where columns are methods. */
.res tr.is-ours td, .res .is-ours-col { background: var(--wash); }
.res tr.is-ours td { color: var(--ink); font-weight: 600; }
.res tr.is-ours td:first-child { color: var(--ink); }
.res thead .is-ours-col { color: var(--orange); }

/* Table 2's first row is an overall summary, not a method. */
.res tr.is-summary td { font-weight: 600; border-bottom-color: var(--hair); }
.res tr.is-summary td:first-child { color: var(--ink); }

.res tbody tr:hover td, .results-table tbody tr:hover td { background: var(--panel); }
.res tbody tr.is-ours:hover td { background: var(--wash-deep); }
.res tbody tr:hover td.is-ours-col { background: var(--wash-deep); }

@media (hover: none) {
  .res tbody tr:hover td, .results-table tbody tr:hover td { background: none; }
  .res tbody tr.is-ours:hover td, .res tbody tr:hover td.is-ours-col { background: var(--wash); }
}

/* The chart carries its own white ground, so it sits on the card with no
   container of its own — a panel behind it only draws a box. */
.plot { padding: 0; }

.plot img { width: 100%; max-width: 680px; margin: 0 auto; }

/* ---------- interactive demo ---------- */
.demo-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.demo-upload {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: var(--fs-ui);
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}

.demo-upload:hover { filter: brightness(0.93); }
.demo-upload svg { width: 16px; height: 16px; }

.demo-examples {
  color: var(--ink-2);
  font-size: var(--fs-ui);
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.demo-example {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-ui);
  font-weight: 500;
  color: var(--ink-2);
  padding: 6px 14px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.demo-example:hover { border-color: rgba(235, 104, 52, 0.4); color: var(--ink); background: var(--wash); }

.demo-status { color: var(--ink-2); font-size: var(--fs-ui); min-height: 1.5em; margin: 14px 0 0; }

.demo-status.is-busy::after {
  animation: demo-pulse 1s ease-in-out infinite;
  content: "";
  display: inline-block;
  height: 0.5em; width: 0.5em;
  margin-left: 0.45em;
  border-radius: 50%;
  background: var(--orange);
}

.demo-status.is-error { color: #b23c14; }

@keyframes demo-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

#demo-canvas {
  border-radius: var(--radius-sm);
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow-sm);
}

#demo-table { margin-top: 18px; }
#demo-table:empty { margin-top: 0; }

/* ---------- bibtex ---------- */
.bibtex {
  margin-top: 22px;
  background: var(--panel);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bibtex .bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--edge);
}

.bibtex .bar span {
  font-size: var(--fs-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.copy {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--edge);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-ui);
  font-weight: 600;
  padding: 6px 14px;
  transition: background 0.15s;
}

.copy:hover { background: var(--panel); }

.bibtex pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  color: #33332f;
  font-family: var(--code);
  font-size: var(--fs-code);
  line-height: var(--lh-text);
}

/* ---------- footer ---------- */
.footer {
  padding: clamp(34px, 4vw, 52px) 0 clamp(40px, 5vw, 64px);
  text-align: center;
  color: var(--ink-2);
  font-size: var(--fs-cap);
  line-height: var(--lh-text);
}

.footer p { margin: 0 0 7px; }
.footer p:last-child { margin-bottom: 0; }

.footer a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--faint);
}

.footer a:hover { border-bottom-color: var(--orange); }

/* ---------- back to top ---------- */
.to-top {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 60;
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background 0.15s, color 0.15s;
}

.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.to-top svg { width: 18px; height: 18px; }

/* ---------- reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(.2,.7,.2,1);
}

.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .nav, .to-top { transition: opacity 0.2s ease; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .mosaic { grid-template-columns: repeat(2, 1fr); }
  .mosaic > *, .mosaic > :nth-child(4), .mosaic > :nth-child(5) { grid-column: span 1; }
  .mosaic > :nth-child(5) { grid-column: span 2; }
}

@media (max-width: 620px) {
  .wrap { padding: 0 16px; }
  .stats { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .prose.is-centered { text-align: left; }
  h2.head { max-width: none; }
  .to-top { right: 14px; bottom: 14px; }
}
