/* ar5iv-style academic paper styling */
/* Note: This file depends on common.css being loaded first.
   common.css provides: sbs layout, proof toggles, Lean syntax, CSS variables */

/* ---------------------------------------------
   Paper Container
   --------------------------------------------- */

.ar5iv-paper {
  font-family: "Computer Modern Serif", "Latin Modern Roman", Georgia, serif;
  width: 100%;
  max-width: 95%;
  margin: 0 auto;  /* Center horizontally */
  padding: 1.5rem 2rem;
  background: var(--sbs-bg-surface);
  color: var(--sbs-text);
  line-height: 1.7;
}

/* When inside sidebar layout, center within content area */
.content .ar5iv-paper {
  width: 100%;
  max-width: 95%;
  margin: 0 auto;
}

/* ---------------------------------------------
   Paper Header
   --------------------------------------------- */

.paper-header {
  text-align: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--sbs-border);
}

.paper-title {
  font-size: 1.75rem;
  font-weight: normal;
  margin: 0 0 0.75rem 0;
}

.paper-authors {
  font-size: 1.1rem;
  color: var(--sbs-text-muted);
  margin-bottom: 1rem;
}

.paper-abstract {
  text-align: left;
  font-size: 0.95rem;
  margin: 1.5rem 2rem;
  padding: 1rem;
  background: var(--sbs-bg-surface);
  border-left: 3px solid var(--sbs-border);
}

/* ---------------------------------------------
   Paper Content Sections
   --------------------------------------------- */

.paper-content h1 { font-size: 1.4rem; margin-top: 2rem; font-weight: bold; }
.paper-content h2 { font-size: 1.2rem; margin-top: 1.5rem; font-weight: bold; }
.paper-content h3 { font-size: 1.1rem; margin-top: 1.25rem; font-weight: bold; }

.paper-content p {
  margin: 1rem 0;
  text-align: justify;
}

/* ---------------------------------------------
   Theorem Environments
   --------------------------------------------- */

.paper-theorem {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  background: var(--sbs-bg-surface);
  border-radius: 3px;
}

.paper-definition {
  background: var(--sbs-bg-surface);
}

.paper-lemma {
  background: var(--sbs-bg-surface);
}

.paper-theorem-header {
  margin-bottom: 0.5rem;
}

.paper-theorem-type {
  font-weight: bold;
  font-style: italic;
}

.paper-theorem-statement {
  margin-left: 0.5rem;
}

/* ---------------------------------------------
   Side-by-Side Display
   Uses standardized styles from common.css
   --------------------------------------------- */

.paper-theorem .sbs-signature pre,
.paper-theorem .sbs-proof-lean pre {
  margin: 0;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* Legacy fallback for dep graph modals */
.paper-theorem .sbs-lean-column pre {
  margin: 0;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* ---------------------------------------------
   Proofs (non-toggle, inline proofs)
   --------------------------------------------- */

.paper-proof {
  margin: 0.75rem 0 1.5rem 0;
}

.paper-proof-header {
  font-style: italic;
}

/* ---------------------------------------------
   Verification Badges
   --------------------------------------------- */

.verification-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.7rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.5rem;
  vertical-align: middle;
  font-style: normal;
}

.verification-badge.verified {
  background: var(--sbs-badge-verified-bg);
  color: var(--sbs-badge-verified-text);
  border: 1px solid var(--sbs-badge-verified-border);
}

.verification-badge.in-progress {
  background: var(--sbs-badge-progress-bg);
  color: var(--sbs-badge-progress-text);
  border: 1px solid var(--sbs-badge-progress-border);
}

.verification-badge.not-started {
  background: var(--sbs-bg-surface);
  color: var(--sbs-text-muted);
  border: 1px solid var(--sbs-border);
}

.badge-icon { font-size: 0.8em; }
.badge-text { font-size: 0.85em; }

/* ---------------------------------------------
   Blueprint Link
   --------------------------------------------- */

.blueprint-link {
  font-size: 0.75rem;
  color: var(--sbs-link);
  text-decoration: none;
  margin-left: 0.4rem;
  font-style: normal;
}

.blueprint-link:hover {
  text-decoration: underline;
  color: var(--sbs-link-hover);
}

/* ---------------------------------------------
   Math Display
   --------------------------------------------- */

.paper-content .MathJax {
  font-size: 1.1em;
}

.paper-displaymath {
  margin: 1.5rem 0;
  text-align: center;
}

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

.paper-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--sbs-border);
  font-size: 0.85rem;
  color: var(--sbs-text-muted);
  text-align: center;
}

.paper-footer a {
  color: var(--sbs-link);
  text-decoration: none;
}

.paper-footer a:hover {
  text-decoration: underline;
  color: var(--sbs-link-hover);
}

/* ---------------------------------------------
   Responsive
   --------------------------------------------- */

@media (max-width: 900px) {
  /* Stack side-by-side on smaller screens */
  .paper-theorem.sbs-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .ar5iv-paper { padding: 1rem; width: 100%; max-width: 100%; }
  .content .ar5iv-paper { width: 100%; max-width: 100%; }
  .paper-abstract { margin: 1rem 0; }
  .paper-theorem { padding: 0.5rem; }
}

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

@media print {
  .ar5iv-paper {
    max-width: none;
    padding: 0;
  }

  .verification-badge {
    border: 1px solid #999;
  }

  .blueprint-link {
    display: none;
  }

  .paper-footer {
    display: none;
  }
}

/* ========== Hide Verification Badges on Paper Pages ========== */
/* Status dots replace the old (Verified)/(In Progress) text badges.
   Hide the legacy badge entirely on paper pages. */

.ar5iv-paper .verification-badge {
  display: none;
}

/* ========== MathJax Error Styling ========== */
/* Tone down MathJax rendering errors so they don't dominate the page.
   Errors like "Unknown environment 'center'" show red-on-yellow by default. */

.ar5iv-paper .MathJax .noError,
.ar5iv-paper .MathJax .merror,
.ar5iv-paper mjx-merror,
.ar5iv-paper [data-mjx-error] {
  font-size: 0.8rem;
  color: var(--sbs-text-muted);
  background: transparent;
  border: 1px dashed var(--sbs-border);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
}

/* ========== Proof Toggle for Paper Pages ========== */
/* Paper uses plain [show]/[hide] text instead of the styled button toggle */

.ar5iv-paper .proof_heading {
  font-family: inherit;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  font-weight: bold;
  font-style: italic;
  display: inline;
  gap: 0;
}

.ar5iv-paper .proof_heading:hover {
  background: none;
  border: none;
  box-shadow: none;
}

.ar5iv-paper .proof_heading:active {
  background: none;
}

/* Hide the chevron, replace with [show]/[hide] text */
.ar5iv-paper .expand-proof {
  font-size: 0;
  color: var(--sbs-text);
  transform: none !important;
  display: inline;
}

.ar5iv-paper .expand-proof::before {
  content: '[show]';
  font-size: 0.85rem;
  color: var(--sbs-text);
  text-decoration: underline;
  font-style: normal;
  font-weight: normal;
}

.ar5iv-paper .proof_wrapper.expanded .expand-proof::before {
  content: '[hide]';
}

.ar5iv-paper .expand-proof svg,
.ar5iv-paper .expand-proof .chevron {
  display: none;
}

/* Proof caption styling */
.ar5iv-paper .proof_caption {
  font-style: italic;
  margin-right: 0.25rem;
}

/* Dark mode for paper toggle text */
html[data-theme="dark"] .ar5iv-paper .expand-proof::before {
  color: var(--sbs-text);
}

/* ========== Anti-Zebra Striping for Paper Pages ========== */
/* Paper pages should NOT have alternating row backgrounds from blueprint.css */

.ar5iv-paper section:has(.sbs-container):nth-child(even of section:has(.sbs-container)) .sbs-container {
  background: var(--sbs-bg-surface);
}
