/* ==========================================================================
   TMA project page
   Palette follows the paper's figures: TMA teal, reactive-policy amber,
   RMA gray, tactile green/blue.
   ========================================================================== */

:root {
  --ink: #15202b;
  --ink-2: #2b3744;
  --muted: #5a6573;
  --line: #e3e7eb;
  --bg: #ffffff;
  --bg-tint: #f5f7f8;
  --card: #ffffff;

  --accent: #00839b;          /* TMA teal (validated with the chart palette) */
  --accent-strong: #006c80;
  --accent-soft: #e4f3f6;
  --accent-bright: #6fd6e4;   /* teal for use on the dark hero */
  --rice-blue: #00205b;       /* Rice Blue: section nav */
  --rice-blue-mid: #6b7ea3;   /* inactive nav links (tint of Rice Blue) */
  --rice-blue-line: #cbd3e2;  /* nav track (light tint of Rice Blue) */
  /* Results chart: TMA / RMA / reactive policy, each with a lighter "grasp only" step.
     Validated (dataviz validator, all pairs, white surface): CVD ΔE >= 16. */
  --tma: #00839b;      --tma-light: #a7d8e0;
  --rma: #a9afb7;      --rma-light: #dfe2e6;
  --reactive: #e0a526; --reactive-light: #f3dca6;
  --green: #009e73;
  --blue: #0b63a8;
  --success: #1f8a55;
  --fail: #b4322f;

  --maxw: 1000px;
  --maxw-wide: 1200px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --nav-h: 60px;              /* top spacing above the hero title */

  /* Type follows contact-grounded-policy.github.io: Google Sans for display, Noto Sans for text. */
  --font: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Google Sans", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 650; color: var(--ink); }
sup, sub { line-height: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 14px; border-radius: 8px;
  background: var(--ink); color: #fff; font-weight: 600;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

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

.br-lg { display: inline; }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   Section nav (after contact-grounded-policy.github.io): a thin vertical line
   on the left with the section links; the active one gets a darker segment.
   -------------------------------------------------------------------------- */
.sidenav {
  position: fixed; left: 18px; top: 50%; z-index: 50;
  max-width: 150px;
  transform: translateY(-50%);
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
  font-family: var(--font-display);
}
.sidenav.is-visible { opacity: 1; pointer-events: auto; }
.sidenav ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--rice-blue-line); }
.sidenav a {
  display: block;
  margin-left: -2px;
  padding: 6px 0 6px 12px;
  border-left: 2px solid transparent;
  font-size: .88rem; line-height: 1.3;
  color: var(--rice-blue-mid);
  transition: color .2s ease, border-color .2s ease;
}
.sidenav a:hover { color: var(--rice-blue); text-decoration: none; }
.sidenav a.is-active { color: var(--rice-blue); font-weight: 700; border-left-color: var(--rice-blue); }

/* Keep content clear of the nav while it is shown. */
@media (min-width: 1101px) {
  .wrap { max-width: min(var(--maxw), calc(100vw - 390px)); }
  .wrap.wide { max-width: min(var(--maxw-wide), calc(100vw - 390px)); }
}
@media (max-width: 1100px) {
  .sidenav { display: none; }
}

/* --------------------------------------------------------------------------
   Hero: full-screen video with overlaid title
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--nav-h) + 40px) 24px 120px;
  overflow: hidden;
  text-align: center;
  color: #fff;
  background: #0c1117 url("../media/hero_poster.jpg") center / cover no-repeat;
}
.hero-video {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}
@media (max-aspect-ratio: 4/5) {
  .hero { background-image: url("../media/hero_portrait_poster.jpg"); }
}
.hero-overlay {
  position: absolute; inset: 0; z-index: 1;
  background:
    radial-gradient(ellipse 70% 60% at 50% 48%, rgba(6, 12, 20, .30) 0%, rgba(6, 12, 20, 0) 100%),
    linear-gradient(180deg,
      rgba(6, 12, 20, .62) 0%,
      rgba(6, 12, 20, .42) 28%,
      rgba(6, 12, 20, .46) 62%,
      rgba(6, 12, 20, .80) 100%);
}
.hero-main { position: relative; z-index: 2; max-width: 1100px; margin-top: -2vh; }

.hero-title, .hero-subtitle, .authors, .affiliations, .footnote, .hero-caption,
.section-title, .subsection-title, .hl h3, .knob-title, .knob-label, .baseline-title,
.vlabel, .vtag, .vdone, .chart-legend, .chart-xaxis, .chart-table summary {
  font-family: var(--font-display);
}

.hero-title {
  margin: 0 0 6px;
  font-size: clamp(3.4rem, 7.5vw, 6rem);
  font-weight: 900;
  line-height: .95;
  letter-spacing: .07em;
  padding-left: .07em;           /* balance trailing letter-spacing */
  color: #fff;
  text-shadow: 0 4px 30px rgba(0, 0, 0, .45);
}
.hero-subtitle {
  margin: 14px auto 28px;
  font-size: clamp(1.35rem, 3.1vw, 2.6rem);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -.01em;
  color: rgba(255, 255, 255, .97);
  text-shadow: 0 2px 16px rgba(0, 0, 0, .45);
  text-wrap: balance;
}
.hero-subtitle .ini {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.authors {
  margin: 0 auto 6px;
  font-size: 1.42rem; font-weight: 500; line-height: 1.8; color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, .45);
}
.authors .au { white-space: nowrap; margin: 0 .55em; }
.authors a { color: #fff; text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s ease; }
.authors a:hover, .authors a:focus-visible { text-decoration: none; border-bottom-color: #fff; }
.authors sup, .affiliations sup, .footnote sup {
  font-size: .62em; font-weight: 700; margin-left: 1px; color: inherit;
}
.affiliations {
  max-width: 820px;   /* wraps as 3 + 2 rather than leaving one name alone */
  margin: 26px auto 2px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0 26px;
  font-size: 1.42rem; line-height: 1.6; color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .4);
}
.footnote {
  margin: 10px 0 0;
  font-size: 1.02rem; line-height: 1.5; color: #fff;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .4);
}

.hero-caption {
  position: absolute; left: 24px; bottom: 24px; z-index: 2;
  display: flex; align-items: flex-start; gap: 10px;
  text-align: left; font-size: 1.02rem; font-weight: 500; line-height: 1.5;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

.live-dot {
  flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%;
  background: #ff5a4f; box-shadow: 0 0 0 0 rgba(255, 90, 79, .6);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 90, 79, .55); }
  70% { box-shadow: 0 0 0 9px rgba(255, 90, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 90, 79, 0); }
}

/* --------------------------------------------------------------------------
   Sections (clean, LadderMan-style: white page, centered claim headings)
   -------------------------------------------------------------------------- */
.section { padding: 80px 0 8px; }
.section:last-of-type { padding-bottom: 72px; }

.section-title {
  margin: 0 auto 10px;
  max-width: 900px;
  text-align: center;
  color: #1f2933;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.25;
  text-wrap: balance;
}
h2.section-title { font-size: clamp(1.8rem, 3vw, 2.4rem); margin-bottom: 26px; }
h3.section-title { font-size: clamp(1.45rem, 2.4vw, 1.95rem); }
.section-sub {
  max-width: 760px;
  margin: 0 auto 32px;
  text-align: center;
  font-size: 1.06rem;
  color: var(--muted);
  text-wrap: balance;
}

.subsection-title {
  margin: 80px auto 8px;
  text-align: center;
  font-size: clamp(1.3rem, 2vw, 1.6rem); font-weight: 700; letter-spacing: -.015em;
  color: #1f2933;
}

/* Overview highlights */
.highlights {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px;
  margin: 4px 0 0;
}
.hl {
  padding: 22px 20px 20px;
  border-radius: 12px;
  background: #f6f8f9;
  border: 1px solid #edf0f2;
}
.hl svg { display: block; width: 30px; height: 30px; color: var(--accent); }
.hl h3 { margin: 14px 0 6px; font-size: 1.06rem; font-weight: 700; line-height: 1.3; color: #1f2933; }
.hl p { margin: 0; font-size: .94rem; line-height: 1.58; color: var(--muted); }

.abstract-text {
  max-width: 820px;
  margin: 0 auto;
  text-align: justify;
  font-size: 1.04rem;
  line-height: 1.75;
  color: #3d4752;
}

.c-green { color: #009e73; font-weight: 700; }
.c-blue { color: #0b63a8; font-weight: 700; }

/* Figures: plain, no frame, like the paper */
.fig { margin: 44px 0 0; }
.fig img { width: 100%; height: auto; background: #fff; }
.fig img.zoomable { cursor: zoom-in; }
.fig figcaption {
  max-width: 820px;
  margin: 14px auto 0;
  text-align: center;
  font-size: .95rem; line-height: 1.6;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   Videos
   -------------------------------------------------------------------------- */
.playback-note {
  display: flex; align-items: flex-start; justify-content: center; gap: 10px;
  max-width: 760px;
  margin: -12px auto 36px;
  font-size: .98rem;
  color: var(--muted);
}
.playback-note svg { flex: none; margin-top: 3px; color: var(--accent); }
.fig.fig-lead { max-width: 860px; margin: 48px auto 0; }
.subsection-title + .fig-lead { margin-top: 20px; }
.highlights + .subsection-title { margin-top: 64px; }

.knob-picker {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  max-width: 600px; margin: 0 auto;
}
.knob-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.knob-card img { height: 104px; width: auto; object-fit: contain; }
.knob-card:hover {
  text-decoration: none;
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(16, 24, 40, .08);
  transform: translateY(-2px);
}
.knob-label { font-size: .92rem; font-weight: 700; color: var(--ink); }
.knob-card:hover .knob-label { color: var(--accent); }
.knob-hint { margin: 14px 0 0; text-align: center; font-size: 1rem; color: var(--muted); }

.knob-group { margin-top: 56px; }
.knob-title {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  margin: 0 0 16px;
  font-size: 1.35rem; font-weight: 700; color: #1f2933;
}
.knob-title span { font-size: 1rem; font-weight: 500; color: var(--muted); }
.knob-views {
  width: 100%; height: auto; aspect-ratio: 16 / 9;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.video-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.video-grid.is-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.vcard { margin: 0; min-width: 0; }
.vframe {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: #0c1117;
  box-shadow: 0 4px 12px rgba(16, 24, 40, .10);
}
.vframe video { width: 100%; height: 100%; object-fit: cover; background: #0c1117; }
.vlabel { margin: 10px 0 0; text-align: center; font-size: .98rem; font-weight: 600; color: #2b3744; }

.vtag, .vdone {
  position: absolute; top: 10px; z-index: 2;
  padding: 4px 10px; border-radius: 7px;
  font-size: .8rem; font-weight: 650; line-height: 1.4;
  color: #fff;
  pointer-events: none;
}
.vtag { left: 10px; background: rgba(12, 17, 23, .62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.vdone {
  right: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  background: #1f8a55;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
.vdone svg { width: 14px; height: 14px; flex: none; }
.vframe[data-outcome="failed"] .vdone { background: #b4322f; }
.vframe.is-complete .vdone {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .18s ease, transform .18s ease, visibility 0s;
}

.baseline-intro { max-width: 760px; margin: 56px auto 8px; text-align: center; color: var(--muted); }
.baseline-group { margin-top: 28px; }
.baseline-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
  font-size: 1.12rem; font-weight: 700; color: #1f2933;
}

/* --------------------------------------------------------------------------
   Results chart (HTML, from the paper's real-world results figure)
   -------------------------------------------------------------------------- */
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.sw-tma { background: var(--tma); }
.sw-tma-light { background: var(--tma-light); }
.sw-rma { background: var(--rma); }
.sw-reactive { background: var(--reactive); }

.chart { max-width: 680px; margin: 0 auto; }
.chart-legend {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px;
  font-size: .98rem; font-weight: 600; color: var(--ink);
}
.lg { display: inline-flex; align-items: center; gap: 8px; }
.lg em { font-style: normal; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-key {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  margin: 8px 0 18px;
  font-size: .88rem; color: var(--muted);
}
.key-swatch { display: inline-flex; gap: 2px; }

.chart-frame { position: relative; padding-left: 34px; }
.chart-ytitle { display: block; margin: 0 0 10px -34px; font-size: .8rem; color: var(--muted); }
.chart-plot {
  position: relative;
  height: 260px;
  display: flex;
}
.gridline {
  position: absolute; left: 0; right: 0; height: 0;
  border-top: 1px solid #eceef1;
}
.gridline:first-child { border-top-color: #c9ced4; }
.gridline span {
  position: absolute; right: calc(100% + 10px); top: -.62em;
  font-size: .8rem; line-height: 1.2; color: var(--muted); font-variant-numeric: tabular-nums;
}
.chart-group {
  position: relative; z-index: 1;
  flex: 1;
  display: flex; justify-content: center; align-items: stretch; gap: 2px;
}
.bar {
  position: relative;
  width: 24px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  cursor: default;
  outline-offset: 2px;
}
.bar .seg { display: block; width: 100%; }
.bar .seg:first-child { border-radius: 4px 4px 0 0; }
.bar-tma .seg-dark { background: var(--tma); }
.bar-tma .seg-light { background: var(--tma-light); }
.bar-rma .seg-dark { background: var(--rma); }
.bar-rma .seg-light { background: var(--rma-light); }
.bar-reactive .seg-dark { background: var(--reactive); }
.bar-reactive .seg-light { background: var(--reactive-light); }
.bar-label {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: .8rem; font-weight: 650; color: var(--ink); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chart-plot:hover .bar:not(:hover) .seg, .chart-plot:focus-within .bar:not(:focus) .seg { opacity: .55; }
.bar .seg { transition: opacity .15s ease; }

.chart-xaxis { display: flex; margin-top: 10px; }
.chart-xaxis span { flex: 1; text-align: center; font-size: .92rem; font-weight: 600; color: var(--ink-2); }

.chart-tooltip {
  position: absolute; z-index: 5;
  min-width: 150px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(16, 24, 40, .14);
  font-size: .85rem; line-height: 1.45; color: var(--muted);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}
.chart-tooltip b { display: block; color: var(--ink); font-size: .9rem; }
.chart-tooltip strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.chart-table { margin: 22px auto 0; max-width: 680px; font-size: .92rem; color: var(--muted); }
.chart-table summary { cursor: pointer; text-align: center; font-weight: 600; color: var(--accent); }
.chart-table table { width: 100%; margin-top: 12px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.chart-table caption { padding-bottom: 8px; font-size: .86rem; }
.chart-table th, .chart-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; }
.chart-table th[scope="row"] { text-align: left; color: var(--ink); font-weight: 600; }
.chart-table thead th { color: var(--ink-2); font-weight: 600; }

/* --------------------------------------------------------------------------
   BibTeX
   -------------------------------------------------------------------------- */
.cite { position: relative; max-width: 860px; margin: 0 auto; }
.cite pre {
  margin: 0;
  padding: 22px 24px;
  overflow-x: auto;
  border-radius: 10px;
  background: #f5f6f7;
  border: 1px solid var(--line);
}
.cite code { font-family: var(--mono); font-size: .86rem; line-height: 1.7; color: #24303c; white-space: pre; }
.copybtn {
  position: absolute; top: 12px; right: 12px;
  padding: 6px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
  font: inherit; font-size: .82rem; font-weight: 600; color: var(--ink);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.copybtn:hover { border-color: var(--accent); color: var(--accent); }


.supp-video {
  max-width: 960px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #0c1117;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .14);
}
.supp-video video { width: 100%; height: 100%; object-fit: contain; background: #0c1117; }

/* --------------------------------------------------------------------------
   Lightbox
   -------------------------------------------------------------------------- */
.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(8, 12, 18, .92);
  overflow: auto;
}
.lightbox::backdrop { background: rgba(8, 12, 18, .6); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox img {
  max-width: min(96vw, 2400px); max-height: 92vh;
  width: auto; height: auto;
  border-radius: 10px;
  background: #fff;
  cursor: zoom-out;
}
.lightbox.is-pan[open] { display: block; }
.lightbox.is-pan img { max-width: none; max-height: none; height: min(78vh, 560px); width: auto; margin: max(11vh, 60px) 16px; }
.lightbox-close {
  position: fixed; top: 14px; right: 18px;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 1.8rem; line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .24); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1020px) {
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .br-lg { display: none; }
}

@media (max-width: 680px) {
  :root { --nav-h: 52px; }
  .wrap { padding: 0 16px; }

  .hero { padding: calc(var(--nav-h) + 28px) 16px 104px; }
  .hero-title { letter-spacing: .04em; }
  .hero-subtitle { margin-bottom: 18px; }
  .authors { font-size: 1.1rem; line-height: 1.7; }
  .authors .au { margin: 0 .35em; }
  .affiliations { font-size: 1.1rem; gap: 0 14px; margin-top: 18px; }
  .footnote { font-size: .86rem; }
  .hero-caption { left: 16px; bottom: 18px; font-size: .86rem; }

  .section { padding-top: 56px; }
  .abstract-text { text-align: left; }
  .fig { margin-top: 28px; }
  .knob-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .highlights { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .subsection-title { margin-top: 56px; }
  .video-grid, .video-grid.is-pair { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .knob-group { margin-top: 40px; }
  .chart-plot { height: 220px; }
  .chart-legend { gap: 6px 16px; font-size: .9rem; }
}

@media (max-width: 400px) {
  .hero-subtitle .nowrap { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .live-dot { animation: none; }
  .knob-card, .vdone, .vframe.is-complete .vdone, .bar .seg { transition: none; }
  .knob-card:hover { transform: none; }
}
