/* ═══════════════════════════════════════════════════════════════
   Blind Precise Assembly — project page
   Visual language follows younghyopark.me/tune-to-learn and
   younghyopark.me/inertia-mismatch: monochrome, Inter + JetBrains Mono,
   hairline rules, interactive iframes.
   Colors follow the paper's figures (paper/figures/scripts/style.py):
   blue = blind (proprioceptive) policy and mjfit, orange = visual policy
   and CoACD, aqua = fused policy and V-HACD, yellow = mesh SDF.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --primary:      #222;
  --bg:           #ffffff;
  --bg-alt:       #fafafa;
  --bg-hero:      #f7f8fa;
  --text:         #1a1a1a;
  --text-muted:   #6b6b6b;
  --text-light:   #999;
  --border:       #e0e0e0;

  --blue:         #2a78d6;
  --blue-soft:    rgba(42, 120, 214, 0.08);
  --orange:       #eb6834;
  --orange-soft:  rgba(235, 104, 52, 0.08);
  --aqua:         #1baf7a;
  --yellow:       #eda100;
  --magenta:      #e87ba4;

  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  --max-width:        1100px;
  --max-width-medium:  900px;
  --max-width-narrow:  760px;
  --section-padding:   2.5rem 0;
  --radius:            4px;
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-sans); font-size: 1rem; line-height: 1.65; color: var(--text); background: var(--bg); counter-reset: cite-counter; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; transition: text-decoration-color .15s; }
a:hover { text-decoration-color: var(--text); }
img, video, iframe { max-width: 100%; display: block; border: none; }
figure { margin: 0; }
p + p { margin-top: 0.9rem; }
code { font-family: var(--font-mono); font-size: 0.875em; background: var(--bg-alt); padding: 0.15em 0.4em; border-radius: 4px; border: 1px solid var(--border); }
pre code { background: none; border: 0; padding: 0; font-size: inherit; }
strong { font-weight: 600; }
.c-blue { color: var(--blue); }
.c-orange { color: var(--orange); }
.c-aqua { color: var(--aqua); }
.c-yellow { color: #b47a00; }
.pkg { font-family: var(--font-mono); font-size: 0.92em; font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

iframe[data-src] {
  background: linear-gradient(110deg, #f5f5f5 8%, #e8e8e8 18%, #f5f5f5 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { to { background-position-x: -200%; } }

/* ── Layout ────────────────────────────────────────────────── */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
.container-medium { max-width: var(--max-width-medium); margin: 0 auto; }
.container-narrow { max-width: var(--max-width-narrow); margin: 0 auto; }
.section { padding: var(--section-padding); }

.section h2 { font-size: 1.725rem; font-weight: 600; margin-bottom: 1.25rem; letter-spacing: 0.01em; display: flex; align-items: center; gap: 0.75rem; }
.section h2::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.section h3 { font-size: 1.3rem; font-weight: 600; margin: 2.25rem 0 0.9rem; letter-spacing: 0.01em; display: flex; align-items: center; gap: 0.75rem; }
.section h3::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.section-kicker { font-size: 1.05rem; color: var(--text-muted); font-weight: 500; letter-spacing: 0.02em; }
.section-kicker + h2 { margin-top: -0.2rem; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: start; }
.text-fig { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr); gap: 1.75rem; align-items: center; }

/* ── Hero ──────────────────────────────────────────────────── */
.hero { background: var(--bg-hero); padding: 2.75rem 1.5rem 2rem; text-align: center; border-bottom: 1px solid var(--border); }
.paper-title { font-size: clamp(1.5rem, 3.5vw, 2.3rem); font-weight: 700; line-height: 1.25; margin-bottom: 1rem; letter-spacing: -0.02em; }
.paper-title .subtitle { font-weight: 400; opacity: 0.85; font-size: 0.85em; }
.author-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem 1.5rem; margin-bottom: 0.4rem; font-size: 1.05rem; }
.author a { font-weight: 500; text-underline-offset: 3px; }
.author sup { font-size: 0.7em; margin-left: 1px; opacity: 0.7; }
.equal-note { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.affiliations { font-size: 0.9rem; opacity: 0.8; margin-bottom: 1rem; display: flex; justify-content: center; align-items: center; gap: 0.4rem; }
.affiliations img { height: 40px; display: inline; }
.link-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }
.btn { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.45rem 1rem; border-radius: var(--radius); font-size: 0.85rem; font-weight: 500; color: var(--text); background: transparent; border: 1px solid var(--border); transition: border-color .15s; text-decoration: none; }
.btn:hover { border-color: var(--text); }
.btn.disabled { color: var(--text-light); pointer-events: none; }
.btn.disabled small { font-size: 0.72rem; }
.venue-line { margin-top: 0.85rem; color: var(--text-muted); font-size: 1.05rem; font-weight: 500; }

/* Teaser video under the hero */
.teaser-video { position: relative; border-radius: 8px; overflow: hidden; background: #111; box-shadow: 0 4px 20px rgba(0,0,0,.08); aspect-ratio: 16 / 9; }
.teaser-video video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Abstract ──────────────────────────────────────────────── */
.abstract-text { line-height: 1.65; text-align: justify; }
.tldr { margin: 0 0 1.1rem; padding: 0.85rem 1.1rem; border-left: 3px solid var(--blue); background: var(--blue-soft); border-radius: 0 6px 6px 0; font-size: 1.05rem; line-height: 1.55; }
.tldr b { font-weight: 600; }

/* ── Figures ───────────────────────────────────────────────── */
.figure-full { margin: 1.5rem 0; text-align: center; }
.figure-full img { width: 100%; margin: 0 auto; }
figcaption { margin-top: 0.6rem; font-size: 0.92rem; color: var(--text-muted); text-align: center; line-height: 1.5; }
figcaption strong { color: var(--text); }
.figure-full figcaption { text-align: left; }
.figure-grid { display: grid; gap: 1rem; align-items: end; }
.figure-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.figure-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.figure-grid img { width: 100%; }
.figure-grid .sub { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin-top: 0.3rem; }
.fig-narrow img { max-width: 560px; margin: 0 auto; }

/* Interactive widget frame */
.widget { margin: 1.5rem 0 0.5rem; }
.widget.wide { width: min(1100px, calc(100vw - 3rem)); margin-left: calc(50% - min(550px, 50vw - 1.5rem)); }
.widget-frame { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #f4f4f2; }
.widget-frame iframe { width: 100%; height: 100%; border: 0; }
.widget-tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.45rem; }
.widget-tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.widget figcaption { text-align: left; }
.try-list { margin: 0.8rem 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.55rem; }
.try-list li { font-size: 0.88rem; line-height: 1.45; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 0.55rem 0.7rem; }
.try-list li strong { display: block; color: var(--text); font-size: 0.82rem; margin-bottom: 0.1rem; }
button.linkish { font: inherit; font-weight: 600; color: var(--blue); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

details.fine-print { margin: 0.9rem 0 0; font-size: 0.88rem; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 0.6rem; }
details.fine-print summary { cursor: pointer; font-weight: 600; color: var(--text); font-size: 0.85rem; }
details.fine-print p { margin-top: 0.4rem; line-height: 1.55; }
.task-notes { margin-top: 0.4rem; }

/* Placeholder for widgets still being built */
.coming { border: 1px dashed #cfcfcf; border-radius: 8px; padding: 1.1rem 1.25rem; margin: 1.25rem 0; background: repeating-linear-gradient(135deg, #fbfbfb 0 12px, #f7f7f7 12px 24px); }
.coming .coming-tag { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-light); }
.coming h4 { font-size: 1rem; font-weight: 600; margin: 0.15rem 0 0.3rem; }
.coming p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; }

/* ── Findings (the paper's claims) ─────────────────────────── */
/* No box: each claim sits between a dark rule and a hairline, its number set
   large and light in the left margin beside the title and the claim. */
.finding { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); column-gap: 1.1rem; margin: 2rem 0 1.75rem; padding: 1.1rem 0 1.2rem; border-top: 1px solid var(--text); border-bottom: 1px solid var(--border); }
.finding-num { grid-row: 1 / span 2; font-size: 3.1rem; font-weight: 300; line-height: 0.95; letter-spacing: -0.03em; color: var(--blue); }
.finding-title { grid-column: 2; font-size: 1.1rem; font-weight: 600; line-height: 1.35; }
.finding p { grid-column: 2; margin-top: 0.2rem; font-size: 1.05rem; line-height: 1.6; }
.finding.orange .finding-num { color: var(--orange); }

/* Contribution list */
.contrib { list-style: none; counter-reset: contrib; display: grid; gap: 0.6rem; margin: 1rem 0 0.25rem; }
.contrib li { counter-increment: contrib; position: relative; padding: 0.7rem 0.9rem 0.7rem 2.6rem; border: 1px solid var(--border); border-radius: 8px; line-height: 1.5; }
.contrib li::before { content: counter(contrib); position: absolute; left: 0.85rem; top: 0.72rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--text); color: #fff; font-size: 0.72rem; font-weight: 700; display: grid; place-items: center; }
.contrib li a.jump { font-size: 0.85rem; color: var(--blue); white-space: nowrap; }

/* ── Video ── */
.video-embed { aspect-ratio: 16 / 9; overflow: hidden; border-radius: 8px; background: #000; box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.video-embed iframe, .video-embed video { width: 100%; height: 100%; }

/* Equation block */
.eq { margin: 1rem 0; overflow-x: auto; }

/* ── Inline citations with hover tooltip ──────────────────── */
.cite { counter-increment: cite-counter; display: inline; position: relative; color: #4f46e5; font-size: 0.85em; font-weight: 500; cursor: pointer; text-decoration: none; border-bottom: 1px dashed rgba(79, 70, 229, 0.3); }
.cite::before { content: '[' counter(cite-counter) ']'; }
.cite .cite-tooltip { display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: #1e1e2e; color: #e0e0e0; font-size: 0.75rem; font-weight: 400; line-height: 1.5; padding: 0.5rem 0.75rem; border-radius: 6px; min-width: 280px; max-width: 420px; white-space: normal; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 100; pointer-events: none; }
.cite:hover .cite-tooltip { display: block; }

/* ── BibTeX ────────────────────────────────────────────────── */
.bibtex-block { position: relative; background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; overflow-x: auto; }
.bibtex-block pre { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.copy-btn { position: absolute; top: 0.75rem; right: 0.75rem; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); padding: 0.3rem 0.75rem; border-radius: var(--radius); font-size: 0.75rem; cursor: pointer; font-family: var(--font-sans); }
.copy-btn:hover { border-color: var(--text); color: var(--text); }
.copy-btn.copied { background: #22c55e; border-color: #22c55e; color: #fff; }

/* ── Footer ────────────────────────────────────────────────── */
.footer { padding: 1.25rem 1.5rem; text-align: center; font-size: 0.85rem; color: var(--text-light); border-top: 1px solid var(--border); }

/* ── Sticky header ─────────────────────────────────────────── */
.sticky-header { position: fixed; top: 0; left: 0; right: 0; z-index: 200; background: var(--bg-hero); border-bottom: 1px solid var(--border); transform: translateY(-100%); opacity: 0; transition: transform .35s ease, opacity .35s ease; pointer-events: none; }
.sticky-header.visible { transform: translateY(0); opacity: 1; pointer-events: auto; }
.sticky-header-inner { max-width: var(--max-width); margin: 0 auto; padding: 0.5rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sticky-title { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.sticky-title strong { font-weight: 600; }
.sticky-sep { color: var(--text-light); margin: 0 0.25rem; }
.sticky-authors { color: var(--text-muted); }
.sticky-venue { color: var(--text-light); }

/* ── Table of contents (floating, right) ───────────────────── */
.dynamic-toc { position: fixed; top: 58%; right: 1.5rem; transform: translateY(-50%); z-index: 100; max-height: 75vh; overflow-y: auto; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(0,0,0,.08); border-radius: 0.75rem; box-shadow: 0 4px 24px rgba(0,0,0,.07), 0 1px 4px rgba(0,0,0,.04); padding: 0.75rem 0; min-width: 12.5rem; max-width: 15rem; transition: opacity .25s; }
.dynamic-toc .toc-title { display: block; padding: 0.15rem 1rem 0.55rem; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #999; border-bottom: 1px solid rgba(0,0,0,.06); margin-bottom: 0.35rem; }
.dynamic-toc ul { list-style: none; }
.dynamic-toc a { display: block; padding: 0.32rem 1rem 0.32rem 0.85rem; font-size: 0.73rem; color: var(--text-light); text-decoration: none; line-height: 1.4; border-left: 2.5px solid transparent; transition: color .2s, background .2s, border-color .2s; }
.dynamic-toc a:hover { color: var(--text); background: rgba(0,0,0,.03); }
.dynamic-toc a.active { color: var(--text); border-left-color: var(--blue); font-weight: 600; background: var(--blue-soft); }
.dynamic-toc .toc-sub a { padding-left: 1.6rem; color: #aaa; }
.dynamic-toc.dimmed { opacity: 0; pointer-events: none; }
@media (max-width: 1400px) { .dynamic-toc { display: none; } }

/* ── Native figures (static/js/figures) ────────────────────── */
:root {
  --viz-text: #1f1f1f;
  --viz-text-2: #5f5f5b;
  --viz-muted: #8f8f8a;
  --viz-grid: #ececea;
  --viz-axis: #cfcfca;
}
figure.viz { margin: 1.75rem 0 1.5rem; }
figure.viz > figcaption { text-align: left; margin-top: 0.75rem; }
.viz-mount { position: relative; min-height: 120px; }
.viz-svg { display: block; overflow: visible; font-family: var(--font-sans); }
.viz-svg text { font-family: var(--font-sans); }
.viz-tick { font-size: 10.5px; fill: var(--viz-muted); font-variant-numeric: tabular-nums; }
.viz-axis-title { font-size: 11.5px; fill: var(--viz-text-2); font-weight: 500; }
.viz-axis-line, .viz-tick-line { stroke: var(--viz-axis); stroke-width: 1; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-ref-line { stroke: #9a9a95; stroke-width: 1; stroke-dasharray: 4 4; }
.viz-ref-label { font-size: 10px; fill: #8a8a85; font-style: italic; }
.viz-panel-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-light); margin-bottom: 0.15rem; }
.viz-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 1.1rem; margin-bottom: 0.9rem; }
.viz-control { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem; min-width: 0; max-width: 100%; }
.viz-control-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-light); }
.viz-seg { display: inline-flex; max-width: 100%; border: 1px solid var(--border); border-radius: 7px; overflow-x: auto; overflow-y: hidden; background: #fff; scrollbar-width: none; }
.viz-seg::-webkit-scrollbar { display: none; }
.viz-seg button { font: inherit; font-size: 0.8rem; color: var(--text-muted); background: transparent; border: 0; padding: 0.3rem 0.7rem; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.viz-seg button + button { border-left: 1px solid var(--border); }
.viz-seg button:hover:not(.on):not(:disabled) { background: #f4f4f2; color: var(--text); }
.viz-seg button.on { background: var(--text); color: #fff; }
.viz-spine { stroke: #c3c2b7; stroke-width: 1; }
.viz-panel-caption { text-align: center; font-size: 0.86rem; color: var(--text); margin-top: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viz-player { display: flex; align-items: center; gap: 0.6rem; margin: 0.5rem 0 0.2rem; }
.viz-play { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: #fff; cursor: pointer; position: relative; }
.viz-play::before { content: ''; position: absolute; left: 11px; top: 9px; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent var(--text); }
.viz-play.on::before { left: 10px; top: 9px; width: 3px; height: 12px; border: 0; border-left: 3px solid var(--text); border-right: 3px solid var(--text); box-sizing: content-box; width: 4px; }
.viz-range { flex: 1; min-width: 80px; accent-color: var(--text); }
.viz-time { flex: none; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.viz-note { font-size: 0.78rem; color: var(--text-light); text-align: center; margin-top: 0.2rem; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8rem; color: var(--text-muted); margin: 0.6rem 0 0.2rem; justify-content: center; }
.viz-legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.viz-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.viz-tip { position: absolute; z-index: 30; pointer-events: none; background: #fff; border: 1px solid #e3e3e0; border-radius: 8px; box-shadow: 0 6px 22px rgba(0,0,0,.08); padding: 0.45rem 0.6rem; font-size: 0.78rem; line-height: 1.45; color: var(--text-muted); min-width: 140px; max-width: 300px; opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s; }
.viz-tip.show { opacity: 1; transform: none; }
.viz-tip strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .viz-tip { transition: none; }
}

/* ── Tabs (one widget at a time) ───────────────────────────── */
.tabset { margin-top: 1.1rem; }
.tabset-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tabset-tabs::-webkit-scrollbar { display: none; }
.tabset-tabs button { font: inherit; font-size: 0.95rem; font-weight: 600; color: var(--text-muted); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 0.55rem 0.95rem 0.6rem; cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; }
.tabset-tabs button:hover { color: var(--text); }
.tabset-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tabset-tabs button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; border-radius: 4px 4px 0 0; }
.tabset-panel[hidden] { display: none; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 860px) {
  .two-col, .text-fig { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
  .hero { padding: 2rem 1rem 1.5rem; }
  .section { padding: 1.75rem 0; }
  .section h2 { font-size: 1.45rem; }
  .section h3 { font-size: 1.1rem; }
  .container { padding: 0 1rem; }
  .author-list { font-size: 0.95rem; gap: 0.2rem 1rem; }
  .abstract-text { text-align: left; }
  .figure-grid.cols-3 { grid-template-columns: 1fr; }
  .finding { grid-template-columns: auto minmax(0, 1fr); column-gap: 0.85rem; align-items: center; }
  .finding-num { grid-row: 1; font-size: 2.6rem; }
  .finding p { grid-column: 1 / -1; margin-top: 0.55rem; }
  .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }
  .sticky-authors, .sticky-venue, .sticky-sep { display: none; }
  .widget.wide { width: auto; margin-left: 0; }
  .widget-frame.policies { height: 980px !important; }
  .widget-frame.mjfit { height: 640px !important; }
  .widget-frame.mjfit.gears { height: 780px !important; }
}
@media print {
  .btn, .copy-btn, .widget, .dynamic-toc, .sticky-header { display: none; }
}
