/*
 * Scientific paper layout. Single column, serif body, justified text,
 * white background. No dark mode, no README-style chrome, no decorative
 * accents. Modeled on TMLR / JMLR / NeurIPS PDF camera-ready style.
 */

:root {
  color-scheme: light only;

  --fg:        #111418;
  --fg-soft:   #2c3138;
  --muted:     #5a626c;
  --bg:        #ffffff;
  --bg-soft:   #fafafa;
  --accent:    #14385c;
  --accent-2:  #6e0e10;
  --rule:      #d1d4d8;
  --code-bg:   #f4f5f7;
  --code-fg:   #14181d;

  --max-w: 720px;

  --font-body:  "Charter", "Iowan Old Style", "Source Serif Pro", Georgia, "Times New Roman", "Liberation Serif", serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --font-title: "Charter", "Source Serif Pro", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html { background: #ffffff; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  font-size: 11pt;
  font-feature-settings: "lnum", "kern";
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3rem 1.3rem 4rem;
}

/* ---------- Title block (academic) ---------- */

header.paper-title {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
}

header.paper-title h1 {
  font-family: var(--font-title);
  font-size: 19pt;
  font-weight: 600;
  line-height: 1.22;
  margin: 0 0 0.8rem;
  letter-spacing: -0.005em;
  color: var(--fg);
}

header.paper-title .subtitle {
  font-family: var(--font-body);
  font-size: 11pt;
  color: var(--fg-soft);
  font-style: italic;
  margin: 0 0 1.1rem;
  text-align: center;
  font-weight: normal;
  line-height: 1.4;
}

header.paper-title .authors {
  font-family: var(--font-body);
  font-size: 12pt;
  color: var(--fg);
  margin-bottom: 0.25rem;
}

header.paper-title .authors strong {
  font-weight: 600;
}

header.paper-title .authors sup,
header.paper-title .affiliations sup {
  font-size: 0.7em;
  color: var(--muted);
  font-weight: normal;
  vertical-align: super;
  line-height: 0;
}

header.paper-title .affiliations {
  font-size: 10pt;
  color: var(--fg-soft);
  margin-bottom: 0.4rem;
  font-style: italic;
}

header.paper-title .meta {
  font-size: 9pt;
  color: var(--muted);
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

/* ---------- Download badges: small, paper-style links (1-col + 2-col) ---------- */

.download-badges {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
}

.download-badge {
  font-family: var(--font-body);
  font-size: 10pt;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--accent);
  color: var(--accent) !important;
  background: var(--bg);
  text-decoration: none !important;
  border-radius: 3px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.download-badge:hover {
  background: var(--accent);
  color: var(--bg) !important;
  text-decoration: none !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

@media (max-width: 720px) {
  .download-badges {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.3rem;
  }
  .download-badge {
    font-size: 9pt;
    padding: 0.3rem 0.6rem;
  }
}

@media print {
  .download-badge { display: none; }
}


/* ---------- Critic-coverage matrix (Table 0) ---------- */

/* The matrix has 9 columns of text content (Critic role + AttrForge + 7 competitors + DSPy/TextGrad).
   At default font sizes it overflows the text column on narrow viewports. Constrain layout,
   reduce font, allow horizontal scroll as fallback. */

figure:has(.critic-coverage) {
  max-width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}

table.critic-coverage {
  width: 100%;
  table-layout: fixed;
  font-size: 8.5pt;
  border-collapse: collapse;
  line-height: 1.25;
}

table.critic-coverage th,
table.critic-coverage td {
  padding: 0.3rem 0.4rem;
  text-align: left;
  vertical-align: top;
  border: 1px solid #d0d0d0;
  word-break: break-word;
  hyphens: auto;
}

table.critic-coverage thead th {
  font-weight: 700;
  background: #f5f5f5;
  font-size: 8pt;
  text-align: center;
}

/* First column (critic role) wider; subsequent are equal */
table.critic-coverage th:first-child,
table.critic-coverage td:first-child {
  width: 18%;
  font-weight: 500;
}

/* Bold AttrForge column for emphasis (it's the paper's framework) */
table.critic-coverage th:nth-child(2),
table.critic-coverage td:nth-child(2) {
  background: #fafafa;
  font-weight: 600;
  text-align: center;
}

table.critic-coverage td:not(:first-child) {
  text-align: center;
  font-size: 8pt;
}

@media (max-width: 720px) {
  table.critic-coverage {
    font-size: 7.5pt;
  }
}


/* ---------- Abstract ---------- */

.abstract {
  margin: 1.5rem 0 2rem;
  padding: 0 1.2rem;
}

.abstract h2 {
  font-family: var(--font-body);
  font-size: 10.5pt;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  margin: 0 0 0.5rem;
  border: none;
  padding: 0;
  color: var(--fg);
  font-variant: small-caps;
}

.abstract p {
  margin: 0.55rem 0;
  font-size: 10pt;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  color: var(--fg);
}

/* ---------- Sections ---------- */

h2 {
  font-family: var(--font-title);
  font-size: 13pt;
  font-weight: 700;
  margin: 2rem 0 0.6rem;
  padding-top: 0.8rem;
  border-top: none;
  letter-spacing: -0.005em;
  color: var(--fg);
}

h2 .section-num {
  color: var(--fg);
  font-weight: 700;
  font-feature-settings: "tnum";
  margin-right: 0.4rem;
}

h3 {
  font-family: var(--font-title);
  font-size: 11.5pt;
  font-weight: 700;
  margin: 1.3rem 0 0.45rem;
  color: var(--fg);
}

h3 .subsection-num {
  color: var(--fg);
  font-weight: 700;
  font-feature-settings: "tnum";
  margin-right: 0.4rem;
}

h4 {
  font-size: 10.5pt;
  font-weight: 700;
  margin: 1rem 0 0.3rem;
  color: var(--fg);
}

p {
  margin: 0.55rem 0;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  line-height: 1.55;
}

li, td, th { text-align: left; }
td.num, th.num { text-align: right; }

/* ---------- Code ---------- */

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.08em 0.28em;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.7rem 0.9rem;
  overflow-x: auto;
  font-size: 9pt;
  line-height: 1.45;
  margin: 0.9rem 0;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.2rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 9.5pt;
  font-feature-settings: "tnum";
  border-top: 1.5px solid var(--fg);
  border-bottom: 1.5px solid var(--fg);
}

th, td {
  padding: 0.4rem 0.55rem;
  text-align: left;
  border-bottom: 0.5px solid var(--rule);
  vertical-align: top;
}

th {
  font-weight: 700;
  color: var(--fg);
  background: var(--bg);
  border-bottom: 1px solid var(--fg);
  border-top: none;
}

table caption {
  caption-side: top;
  font-size: 9.5pt;
  color: var(--fg);
  margin-bottom: 0.5rem;
  text-align: left;
  font-style: normal;
  padding: 0 0 0.4rem 0;
  border-bottom: none;
}

table caption::before {
  content: "";
}

tr.highlight td {
  background: rgba(20, 56, 92, 0.04);
  font-weight: 600;
}

/* ---------- Figures ---------- */

figure {
  margin: 1.4rem auto;
  text-align: center;
  max-width: 100%;
}

figure img {
  max-width: 100%;
  height: auto;
  border: 0.5px solid var(--rule);
  border-radius: 0;
  display: block;
  margin: 0 auto;
}

figure figcaption {
  font-size: 9.5pt;
  color: var(--fg);
  margin-top: 0.5rem;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  padding: 0 0.5rem;
}

/* ---------- Math (KaTeX overrides) ---------- */

.katex-display {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  font-size: 1em;
}

.katex { font-size: 1em; }

/* ---------- Citations and links ---------- */

a.cite {
  color: var(--accent);
  text-decoration: none;
  font-feature-settings: "tnum";
  font-size: 0.9em;
}

a.cite:hover { text-decoration: underline; }

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

ol.references {
  font-size: 9pt;
  padding-left: 1.4rem;
  color: var(--fg);
  line-height: 1.45;
}

ol.references li {
  margin-bottom: 0.45rem;
  text-align: left;
}

/* TOC and callout boxes removed. The paper uses inline prose only. */

/* ---------- Footer ---------- */

footer.paper-footer {
  margin-top: 3rem;
  padding-top: 0.9rem;
  border-top: 0.5px solid var(--rule);
  font-size: 9pt;
  color: var(--muted);
  text-align: center;
  font-family: var(--font-body);
}

/* ---------- Print ---------- */

@media print {
  body { font-size: 10pt; }
  main { max-width: none; padding: 0; }
  pre, table, figure { page-break-inside: avoid; }
  h2 { page-break-after: avoid; }
  nav.toc { page-break-after: always; }
  .download-badge { display: none; }
}
