/* XCAT-3 project page — editorial academic theme.
   Tokens first; everything below references them. */
:root {
  --paper: #fdfdfb;
  --panel: #f6f5f1;
  --ink: #1b1d22;
  --ink-2: #4b4f58;
  --ink-3: #727680;
  --rule: #e2e0d9;
  --rule-strong: #c9c6bc;
  --accent: #1f3a5f;
  --accent-ink: #162c49;
  --flag: #8e3b3b;

  --serif: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --page: 1180px;
  --gutter: clamp(20px, 4vw, 48px);
  --label-col: 200px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 1px; }
::selection { background: #d8e1ee; }

.wrap { max-width: calc(var(--page) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- top bar ---------- */
.topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(253, 253, 251, 0.96);
  border-bottom: 1px solid var(--rule);
}
.topnav .wrap { display: flex; align-items: stretch; justify-content: space-between; }
.topnav-brand {
  font: 700 1.25rem/1 var(--serif);
  letter-spacing: 0.01em;
  color: var(--ink);
  padding: 20px 0;
}
.topnav-tabs { display: flex; gap: clamp(16px, 3vw, 36px); }
.tab-btn {
  background: none; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font: 500 0.9375rem/1 var(--sans);
  color: var(--ink-3);
  padding: 0 2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-section { display: none; }
.tab-section.active { display: block; }

/* ---------- title page ---------- */
.masthead { padding: clamp(40px, 7vw, 88px) 0 clamp(32px, 5vw, 56px); border-bottom: 1px solid var(--rule); }
.masthead h1, .page-head h1 {
  margin: 0;
  font: 600 clamp(1.9rem, 1.2rem + 2.6vw, 3.05rem)/1.12 var(--serif);
  letter-spacing: -0.012em;
  max-width: 30ch;
  text-wrap: balance;
}
.authors {
  margin: clamp(24px, 3vw, 36px) 0 0;
  max-width: 62rem;
  font-size: 1.0625rem; line-height: 1.75;
  color: var(--ink);
}
.authors a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule-strong); }
.authors a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.authors a[href="#"] { border-bottom: 0; pointer-events: none; cursor: text; }
.authors sup { font-size: 0.7em; line-height: 0; margin-left: 1px; color: var(--accent); }
.affiliation { margin: 18px 0 0; font-size: 0.9375rem; line-height: 1.65; color: var(--ink-2); max-width: 46rem; }
.affiliation small { display: block; margin-top: 8px; font-size: 0.875rem; color: var(--ink-3); }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 10px 18px;
  font: 500 0.9375rem/1 var(--sans);
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 2px;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn i { font-size: 0.9em; }
.btn:hover { background: var(--accent); color: #fff; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }

/* ---------- sections ---------- */
.section {
  display: grid;
  grid-template-columns: var(--label-col) minmax(0, 1fr);
  column-gap: clamp(24px, 4vw, 56px);
  padding: clamp(36px, 5vw, 64px) 0;
  border-bottom: 1px solid var(--rule);
}
.section:last-of-type { border-bottom: 0; }
.section-title {
  margin: 0; padding-top: 0.25rem;
  font: 600 1.375rem/1.3 var(--serif);
  letter-spacing: -0.005em;
}
.section.wide { grid-template-columns: minmax(0, 1fr); row-gap: 24px; }
.section-body { min-width: 0; }
.prose { max-width: 40rem; }
.prose p { margin: 0; }

.abstract-text { font-size: 1.125rem; line-height: 1.75; color: var(--ink); }

figure { margin: 0; }
figcaption, .note { font-size: 0.9375rem; line-height: 1.6; color: var(--ink-3); margin-top: 12px; }

.video-frame { position: relative; aspect-ratio: 16 / 9; background: #0d0f13; border: 1px solid var(--rule); }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.viewer-frame {
  display: block; width: 100%; height: 700px;
  border: 1px solid var(--rule-strong); background: #fff;
}
.section.wide .note { margin-top: 0; }

.figure-plate { background: #f5f7fa; border: 1px solid var(--rule); }
.figure-plate img { width: 100%; aspect-ratio: 1178 / 640; object-fit: cover; object-position: 0 0; }

/* ---------- BibTeX ---------- */
.cite-lead { margin: 0 0 16px; font-size: 1rem; color: var(--ink-2); }
.code-block { position: relative; }
pre {
  margin: 0; padding: 22px 24px;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--rule);
  font: 400 0.875rem/1.75 var(--mono);
  color: var(--ink);
  tab-size: 2;
}
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  padding: 6px 12px;
  font: 500 0.8125rem/1 var(--sans);
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  cursor: pointer;
  opacity: .85;
  transition: opacity .15s, color .15s, border-color .15s;
}
.copy-btn:hover, .copy-btn:focus-visible, .code-block:hover .copy-btn { opacity: 1; color: var(--accent); border-color: var(--accent); }

/* ---------- motion explorer ---------- */
.page-head { padding: clamp(36px, 5vw, 64px) 0 clamp(24px, 3vw, 36px); border-bottom: 1px solid var(--rule); }
.page-head h1 { font-size: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem); max-width: none; }
.page-head p { margin: 14px 0 0; font-size: 1.0625rem; color: var(--ink-2); max-width: 40rem; }

.explorer { padding: clamp(28px, 4vw, 48px) 0 clamp(48px, 6vw, 80px); }
.controls-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.control-title { margin: 0 0 14px; font: 600 1.25rem/1.3 var(--serif); }

.case-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-btn {
  font: 500 0.9375rem/1 var(--sans);
  padding: 12px 16px;
  color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: 2px;
  cursor: pointer; transition: border-color .15s, color .15s, background .15s;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }
.pill-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.motion-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 32px; border-top: 1px solid var(--rule); }
.motion-card {
  position: relative; text-align: left;
  display: block; width: 100%;
  padding: 14px 14px 14px 18px;
  background: transparent; border: 0; border-bottom: 1px solid var(--rule);
  font-family: inherit; cursor: pointer;
  transition: background .15s;
}
.motion-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: transparent; transition: background .15s;
}
.motion-card:hover, .motion-card.active { background: var(--panel); }
.motion-card.active::before { background: var(--accent); }
.motion-card.pathological::before { background: var(--flag); opacity: .55; }
.motion-card.pathological.active::before { opacity: 1; }
.mc-name { display: block; font: 600 1.0625rem/1.35 var(--sans); color: var(--ink); }
.motion-card.active .mc-name { color: var(--accent); }
.mc-desc { display: block; margin-top: 3px; font-size: 0.9375rem; line-height: 1.5; color: var(--ink-2); }

.results { margin-top: clamp(32px, 4vw, 52px); padding-top: clamp(28px, 3vw, 40px); border-top: 1px solid var(--rule); min-width: 0; }
.motion-badge { margin: 0 0 24px; font: 500 1.1875rem/1.5 var(--serif); color: var(--ink); }
.gif-strip { display: flex; flex-direction: column; gap: 40px; }
.gif-panel a { display: block; cursor: zoom-in; }
.gif-panel img { width: 100%; min-height: 100px; background: #0d0f13; border: 1px solid var(--rule); }
.gif-label { margin-top: 12px; font: 500 1.0625rem/1.4 var(--sans); color: var(--ink); }
.gif-label small { font-weight: 400; font-size: 0.9375rem; color: var(--ink-3); margin-left: 8px; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); padding: 28px 0 40px; font-size: 0.875rem; color: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .section { grid-template-columns: minmax(0, 1fr); row-gap: 20px; }
  .section-title { padding-top: 0; }
  .motion-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer-frame { height: 920px; }
}
@media (max-width: 700px) {
  .figure-plate { overflow-x: auto; }
  .figure-plate img { width: auto; min-width: 900px; max-width: none; }
}
@media (max-width: 560px) {
  .motion-type-grid { grid-template-columns: minmax(0, 1fr); }
  .pill-btn { padding: 11px 13px; font-size: 0.875rem; }
  body { font-size: 1rem; }
  .abstract-text { font-size: 1.0625rem; }
  pre { padding: 18px 16px; padding-top: 48px; font-size: 0.75rem; }
  .btn { padding: 10px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
