/* ==========================================================================
   WarmPrior project page
   Design language adapted from a clean minimalist academic template
   (Inter + JetBrains Mono, monochrome, thin borders, subtle rules).
   ========================================================================== */

:root {
  --primary:       #222;
  --primary-dark:  #000;
  --accent:        #555;

  --bg:            #ffffff;
  --bg-alt:        #fafafa;
  --bg-hero:       #f7f8fa;
  --text:          #1a1a1a;
  --text-muted:    #777;
  --text-light:    #999;
  --border:        #e0e0e0;

  --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;

  --good:  #147837;
  --pos:   #888;
  --neg:   #b23a3a;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

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; }

b, strong { font-weight: 600; }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-alt);
  padding: 0.12em 0.4em;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
pre {
  font-family: var(--font-mono);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; border: none; font-size: inherit; }

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

.section { padding: var(--section-padding); }
.section.alt-bg { background: var(--bg-alt); }

/* Section headings: left-aligned with a trailing hairline rule */
.section h2 {
  font-size: 1.725rem;
  font-weight: 600;
  text-align: left;
  margin: 0 0 1.25rem;
  color: var(--text);
  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.2rem;
  font-weight: 600;
  margin: 0 0 0.85rem;
  color: var(--text);
}

p { margin: 0 0 1rem; }
.section > .container > p:last-child,
.lead:last-child { margin-bottom: 0; }

.lead {
  color: var(--text);
  text-align: justify;
}
.muted { color: var(--text-muted); }
.center { text-align: center; }

/* Two-column helper */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.two-col.vcenter { align-items: center; }
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Media-over-caption grid: captions live in their own row so their top
   edges align across columns regardless of media height. */
.curv-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "mediaL mediaR"
    "capL   capR";
  column-gap: 1.5rem;
  align-items: start;
}
.curv-layout .m-left  { grid-area: mediaL; }
.curv-layout .m-right { grid-area: mediaR; align-self: center; }
.curv-layout .c-left  { grid-area: capL; }
.curv-layout .c-right { grid-area: capR; }
/* Widen the right column so two figures with different aspect ratios
   render at the same height (right image is wider per unit height). */
.curv-layout.rl-figs { grid-template-columns: 1fr 1.13fr; }
@media (max-width: 768px) {
  .curv-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "mediaL"
      "capL"
      "mediaR"
      "capR";
  }
  .curv-layout.rl-figs { grid-template-columns: 1fr; }
}

/* ── Hero ──────────────────────────────────────────────────── */
.hero {
  background: var(--bg-hero);
  color: var(--text);
  padding: 3rem 1.5rem 2.25rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.paper-title {
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 1.1rem;
  letter-spacing: -0.02em;
}
.paper-title .subtitle {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 400;
  opacity: 0.9;
  font-size: 0.6em;
  letter-spacing: -0.01em;
}
/* Title gradient (kept from the previous design) */
.brand-gradient {
  background: linear-gradient(90deg, #ff8486, #151515);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
}
/* Bump the title up on narrow / mobile screens, where the fluid size
   would otherwise bottom out and feel small. */
@media (max-width: 700px) {
  .paper-title { font-size: clamp(2rem, 7vw, 2.5rem); }
}

.author-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem 1.4rem;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}
.author a {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
}
.author a:hover { text-decoration-color: var(--text); }
.author sup { font-size: 0.7em; margin-left: 1px; opacity: 0.7; }

.affiliations {
  font-size: 0.95rem;
  opacity: 0.8;
  margin-bottom: 0.9rem;
}
.affiliations span { margin: 0 0.55rem; }

/* Link buttons */
.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, color .15s;
  text-decoration: none;
}
.btn:hover { border-color: var(--text); color: var(--text); text-decoration: none; }
.btn[disabled], .btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.venue-line {
  margin-top: 0.9rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
}

/* ── TL;DR callout ─────────────────────────────────────────── */
.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--text);
  background: var(--bg-alt);
  border-radius: 0;
  padding: 0.85rem 1.05rem;
  margin: 0 auto;
  max-width: calc(var(--max-width-narrow) * 0.92);
  font-size: 0.94rem;
  line-height: 1.55;
}
.callout p { margin: 0; }
.callout .tag { font-weight: 700; margin-right: 0.35rem; }

mark.hl {
  background: #fff8dc;
  padding: 0 0.18em;
  border-radius: 2px;
}

/* ── Figures ───────────────────────────────────────────────── */
.figure-full { margin: 1.25rem 0; text-align: center; }
.figure-full img { width: 100%; border-radius: var(--radius); }
figcaption, .caption {
  margin: 0.6rem auto 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
  max-width: 820px;
}
.caption.justify { text-align: justify; }

/* ── Method cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  height: 100%;
}
.card h3 { margin-top: 0; }
.card .tag-note { font-size: 0.88rem; color: var(--text-muted); font-style: italic; margin: 0; }

/* Equation box */
.eq {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
  text-align: center;
  overflow-x: auto;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0.5rem 0; }
.data-table {
  width: auto;
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.data-table thead th {
  background: var(--bg-alt);
  text-align: center;
  vertical-align: middle;
  padding: 0.35rem 0.7rem;
  border-bottom: 2px solid #ccc;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}
.data-table tbody td {
  text-align: center;
  vertical-align: middle;
  padding: 0.22rem 0.7rem;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  line-height: 1.25;
}
.data-table tbody td:first-child { font-weight: 500; }
.section-row td {
  background: var(--bg-alt);
  text-align: left !important;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.3rem 0.7rem !important;
}
.curv-table { font-size: 0.85rem; }

/* Per-cell delta annotations */
.d-pos, .d-good, .d-neg { font-size: 0.9em; margin-left: 0.15em; }
.d-pos  { color: var(--pos); }
.d-good { color: var(--good); font-weight: 600; }
.d-neg  { color: var(--neg); }

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

/* ── Sticky header (appears on scroll) ─────────────────────── */
.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;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sticky-title strong { font-weight: 600; }
.sticky-sep { color: var(--text-light); margin: 0 0.3rem; }
.sticky-authors { color: var(--text-muted); }
.sticky-venue { color: var(--text-light); }
.sticky-links { display: flex; gap: 0.35rem; flex-shrink: 0; }
.sticky-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
.sticky-btn:hover { border-color: var(--text); color: var(--text); }
@media (max-width: 640px) {
  .sticky-authors, .sticky-venue, .sticky-sep { display: none; }
}

/* ── Floating table of contents ────────────────────────────── */
.dynamic-toc {
  position: fixed;
  top: 55%;
  right: 1.5rem;
  transform: translateY(-50%);
  z-index: 100;
  max-height: 75vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0.6rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  padding: 0.75rem 0;
  min-width: 12.5rem;
  max-width: 14rem;
}
.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: var(--text-light);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 0.35rem;
}
.dynamic-toc ul { list-style: none; margin: 0; padding: 0; }
.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,0.04); }
.dynamic-toc a.active {
  color: var(--text);
  border-left-color: var(--text);
  font-weight: 600;
  background: rgba(0,0,0,0.05);
}
@media (max-width: 1400px) { .dynamic-toc { display: none; } }
