/* =============================================================================
   UPIQAL · Research paper (paper.html)
   Academic journal aesthetic — serif display, wide measure, KaTeX math.
   ========================================================================== */

.paper {
  --paper-max: 780px;
  display: block;
  padding-top: var(--sp-9);
  padding-bottom: var(--sp-12);
  position: relative;
  z-index: 1;
}

.paper-hero {
  max-width: var(--paper-max);
  margin: 0 auto var(--sp-9);
  padding: var(--sp-9) 0;
  text-align: left;
}
.paper-hero__eyebrow { margin-bottom: var(--sp-4); color: var(--accent); }
.paper-hero__title {
  font-family: var(--font-serif);
  font-size: clamp(36px, 5vw, 60px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin-bottom: var(--sp-6);
  max-width: 22ch;
}
.paper-hero__meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: var(--text-sm); color: var(--text-2);
  margin-bottom: var(--sp-7);
}
.paper-hero__meta strong { color: var(--text-0); font-weight: 600; }

.abstract {
  border-left: 3px solid var(--accent);
  background: var(--surface-1);
  padding: var(--sp-6) var(--sp-7);
  border-radius: var(--r-md);
  font-size: var(--text-md);
  line-height: var(--leading-prose);
  color: var(--text-1);
}
.abstract::before {
  content: "ABSTRACT";
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 10px;
}

/* --------------------------------------------------------------------------
   Layout with sticky side-nav
   -------------------------------------------------------------------------- */

.paper-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-8);
}
@media (min-width: 1024px) {
  .paper-layout { grid-template-columns: 220px minmax(0, 1fr); }
}

.paper-sidenav {
  position: sticky; top: calc(var(--nav-h) + 24px);
  align-self: start;
  display: none;
}
@media (min-width: 1024px) { .paper-sidenav { display: block; } }
.paper-sidenav__label {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-2); font-weight: 600; margin-bottom: 12px;
}
.paper-sidenav ol {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.paper-sidenav a {
  display: block;
  padding: 8px 12px;
  border-left: 2px solid var(--hairline);
  font-size: var(--text-sm);
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-out-quint);
}
.paper-sidenav a:hover { color: var(--text-0); border-color: var(--hairline-strong); }
.paper-sidenav a.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.paper-body {
  max-width: var(--paper-max);
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Prose
   -------------------------------------------------------------------------- */

.prose {
  color: var(--text-1);
  font-size: var(--text-md);
  line-height: var(--leading-prose);
}
.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--text-0);
  font-weight: 600;
  margin-top: var(--sp-9);
  margin-bottom: var(--sp-4);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.prose h3 {
  font-size: var(--text-lg);
  color: var(--text-0);
  font-weight: 700;
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-3);
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.prose p { color: var(--text-1); }
.prose strong { color: var(--text-0); font-weight: 600; }
.prose em { color: var(--text-0); font-style: italic; }

.prose a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-ring);
  transition: border-color var(--dur-fast) var(--ease-out-quint);
}
.prose a:hover { border-color: var(--accent); }

.prose ul, .prose ol { padding-left: 1.3em; color: var(--text-1); }
.prose li + li { margin-top: 0.3em; }

.prose code {
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  font-size: 0.92em;
  color: var(--text-0);
}

/* Callout / pull-quote */
.callout {
  margin: var(--sp-6) 0;
  padding: var(--sp-5) var(--sp-6);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  color: var(--text-1);
}
.callout__kind {
  font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}

/* Comparison table */
.cmp-table-wrap { overflow-x: auto; margin: var(--sp-6) 0; }
.cmp-table {
  width: 100%; min-width: 720px;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface-1);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--hairline);
}
.cmp-table thead {
  /* NOTE: previously position:sticky + backdrop-filter:blur left the
     first data row (SSIM / MS-SSIM) visually chopped — a translucent
     thead bled the row below it through itself. A solid-background,
     non-sticky header renders correctly on every row. */
  background: var(--surface-2);
}
.cmp-table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-0);
  border-bottom: 1px solid var(--hairline);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cmp-table td {
  padding: 14px 16px;
  vertical-align: top;
  color: var(--text-1);
  border-bottom: 1px solid var(--hairline);
}
.cmp-table tr:nth-child(even) td { background: var(--surface-2); }
.cmp-table tr:last-child td { border-bottom: 0; }
.cmp-table td strong { color: var(--text-0); font-weight: 600; }

@media (max-width: 720px) {
  .cmp-table-wrap { overflow: visible; }
  .cmp-table { min-width: 0; border: 0; background: transparent; border-radius: 0; }
  .cmp-table thead { display: none; }
  .cmp-table tr {
    display: block; margin-bottom: var(--sp-4);
    background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--r-md);
    overflow: hidden;
  }
  .cmp-table tr:nth-child(even) td { background: transparent; }
  .cmp-table td {
    display: grid; grid-template-columns: 110px 1fr;
    gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--hairline);
  }
  .cmp-table td::before {
    content: attr(data-label);
    font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-2); font-weight: 600; align-self: center;
  }
  .cmp-table tr td:last-child { border-bottom: 0; }
}

/* Module accordion cards */
.module {
  margin: var(--sp-5) 0;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease-out-quint);
}
.module[open] { border-color: var(--accent-ring); }
.module__summary {
  display: flex; align-items: center; gap: 16px;
  padding: var(--sp-5) var(--sp-6);
  cursor: pointer;
  list-style: none;
}
.module__summary::-webkit-details-marker { display: none; }
.module__num {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono); font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.module__title { font-weight: 600; font-size: var(--text-md); color: var(--text-0); flex: 1; }
.module__chev {
  transition: transform var(--dur-med) var(--ease-out-quint);
  color: var(--text-2);
}
.module[open] .module__chev { transform: rotate(90deg); }
.module__body {
  padding: 0 var(--sp-6) var(--sp-6);
  border-top: 1px solid var(--hairline);
  padding-top: var(--sp-5);
}

/* Numbered display equation — CSS Grid so the equation truly centers and the
   number sits flush-right without fighting flex overflow. */
.eqn {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: var(--sp-6) 0;
  padding: var(--sp-6) var(--sp-5);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  overflow-x: auto;
}
/* Left spacer (empty) · Math (centered) · Number (right) */
.eqn::before { content: ""; }
.eqn__tex {
  min-width: 0;
  text-align: center;
}
.eqn__num {
  justify-self: end;
  font-family: var(--font-mono);
  color: var(--text-2);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  padding-left: 12px;
}

/* KaTeX — slightly larger than body for readability; warm off-white. */
.katex {
  font-size: 1.18em !important;
  color: var(--text-0);
  line-height: 1.2 !important;
}
.katex-display { margin: 0 !important; padding: 0 !important; }
.katex-display > .katex { display: inline-block; text-align: center; }
/* Inline math keeps the surrounding line-height tight. */
p .katex, li .katex, summary .katex { font-size: 1.05em !important; }

/* SVG pipeline diagram */
.pipeline {
  margin: var(--sp-6) 0;
  padding: var(--sp-5) var(--sp-4);
  background:
    radial-gradient(60% 60% at 50% 55%, var(--accent-soft) 0%, transparent 75%),
    var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
}
.pipeline svg { display: block; width: 100%; height: auto; }
.pipeline svg text { font-family: var(--font-sans); }

/* Output spec table */
.output-spec {
  display: grid; gap: 12px;
  margin: var(--sp-5) 0;
}
.output-spec > div {
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  display: grid; grid-template-columns: 160px 1fr; gap: 16px;
  font-size: var(--text-sm);
}
.output-spec > div strong { color: var(--text-0); font-family: var(--font-mono); font-weight: 600; }
@media (max-width: 560px) { .output-spec > div { grid-template-columns: 1fr; gap: 4px; } }

/* References list */
.refs ol {
  padding-left: 2em;
  color: var(--text-2);
  font-size: var(--text-sm);
  line-height: 1.65;
}
.refs li { padding-left: 0.5em; }
.refs li + li { margin-top: 10px; }
.refs li a { color: var(--text-1); border-color: var(--hairline); }
.refs li a:hover { color: var(--accent); border-color: var(--accent); }
