/* Paper CSS — print-quality typography for aimrank.io/paper
 * Optimized for both on-screen reading and browser print-to-PDF.
 * Print width ≈ A4 with 2cm margins.
 */

:root {
  --text: #1a1a1a;
  --muted: #555;
  --accent: #b8860b;          /* dark amber — matches AimRank brand */
  --rule: #d4d4d4;
  --bg: #ffffff;
  --code-bg: #f5f5f5;
  --table-stripe: #fafafa;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0 auto;
  max-width: 760px;
  padding: 3rem 1.5rem 4rem;
  font-family: "Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

/* === Title block === */
h1.title, header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}
p.author, header .author {
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.3rem;
}
p.date, header .date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

/* === Headings === */
h1, h2, h3, h4 {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 600;
  margin-top: 2.4rem;
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 1.7rem; border-bottom: 2px solid var(--rule); padding-bottom: 0.3rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; color: #333; }
h4 { font-size: 1rem; color: #444; font-style: italic; }

h1::before, h2::before {
  /* Subtle anchor-mark on hover */
  content: "";
}

/* === Body text === */
p { margin: 0.7rem 0 0.9rem; }
strong { font-weight: 600; }
em { font-style: italic; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
a:hover { border-bottom-color: var(--accent); }

/* === Block quotes === */
blockquote {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  background: #fdfaf2;
  color: var(--text);
  font-style: italic;
}
blockquote p { margin: 0.4rem 0; }

/* === Code === */
code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
pre {
  background: var(--code-bg);
  padding: 0.9rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  border-left: 3px solid var(--rule);
}
pre code { background: transparent; padding: 0; }

/* === Tables === */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0 1.5rem;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th {
  border-bottom: 2px solid var(--rule);
  font-family: "Inter", -apple-system, sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
tr:nth-child(even) td { background: var(--table-stripe); }

/* === Lists === */
ul, ol { margin: 0.6rem 0 0.9rem; padding-left: 1.5rem; }
li { margin: 0.25rem 0; }

/* === TOC === */
nav#TOC {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0 2.5rem;
  background: #fafafa;
  font-size: 0.92rem;
}
nav#TOC > ul { margin: 0; padding-left: 1rem; }
nav#TOC ul ul { font-size: 0.95em; color: var(--muted); }
nav#TOC::before {
  content: "Contents";
  display: block;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

/* === Horizontal rules === */
hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2rem 0;
}

/* === Math (MathJax) === */
.MathJax { font-size: 1em !important; }

/* === Print === */
@media print {
  body {
    max-width: none;
    padding: 1.5cm 2cm;
    font-size: 11pt;
  }
  h1 { page-break-before: auto; page-break-after: avoid; }
  h2, h3, h4 { page-break-after: avoid; }
  pre, table, blockquote { page-break-inside: avoid; }
  a { color: var(--text); border-bottom: none; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--muted); }
  nav#TOC { page-break-after: always; }
}

/* === Mobile === */
@media (max-width: 640px) {
  body { padding: 1.5rem 1rem 3rem; font-size: 15px; }
  h1.title, header h1 { font-size: 1.5rem; }
  pre { font-size: 0.8rem; }
  table { font-size: 0.85rem; }
}
