/*
 * scholars-tribune.css
 * Scholar's Tribune styling for Solomon Negash's standalone econometrics HTML pages.
 * Cream/parchment editorial aesthetic — Playfair Display headlines, Source Serif 4 body.
 *
 * Upload to: solomonegash.com/scholars-tribune.css
 * Then update inject_nightlab.py: change CSS_URL to point to this file instead.
 */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Source+Serif+4:ital,wght@0,300;0,400;0,600;1,300;1,400;1,600&display=swap');

/* ── Tokens ── */
:root {
  --bg:        #faf8f2;
  --bg2:       #f2ede3;
  --bg3:       #ece6d9;
  --ink:       #1c1510;
  --muted:     #7a6e62;
  --muted2:    #a09386;
  --accent:    #8b2020;
  --accent2:   #c9773a;
  --rule:      #d8cfc4;
  --rule2:     #e8e0d5;
  --stata:     #2b5fa8;
  --r:         #276f42;
  --python:    #a0521a;
  --radius:    4px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

/* ── Body ── */
html, body {
  background-color: var(--bg) !important;
  color: var(--ink) !important;
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif !important;
  font-size: 16px;
  line-height: 1.8;
  margin: 0;
  padding: 0;
}

/* Subtle paper texture via repeating gradient */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      rgba(28,21,16,.018) 28px,
      rgba(28,21,16,.018) 29px
    );
  pointer-events: none;
  z-index: 0;
}

/* ── Topbar ── */
.nl-topbar {
  background: var(--ink);
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: 9px 0;
  position: sticky;
  top: 0;
  z-index: 999;
}
.nl-topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.nl-topbar-home {
  font-family: 'Playfair Display', serif;
  font-size: 13px;
  font-style: italic;
  color: rgba(255,255,255,.6) !important;
  text-decoration: none !important;
  transition: color .2s;
  border-bottom: none !important;
}
.nl-topbar-home em { color: #d4954a; font-style: normal; }
.nl-topbar-home:hover { color: #fff !important; }

.nl-topbar-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nl-topbar-nav a {
  font-family: 'Source Serif 4', serif;
  font-size: 10.5px;
  font-weight: 300;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45) !important;
  text-decoration: none !important;
  padding: 3px 10px;
  border-bottom: none !important;
  transition: color .2s;
}
.nl-topbar-nav a:hover { color: rgba(255,255,255,.9) !important; }
.nl-topbar-nav a + a::before {
  content: '·';
  margin-right: 4px;
  color: rgba(255,255,255,.2);
}

/* ── All content above bg texture ── */
body > * { position: relative; z-index: 1; }

/* ── Main wrapper ── */
body > *:not(style):not(script):not(.nl-topbar) {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 32px;
  padding-right: 32px;
}

/* ── Masthead / page title band ── */
.nl-masthead {
  text-align: center;
  border-bottom: 2px solid var(--ink);
  padding: 48px 32px 32px;
  margin-bottom: 40px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
}
.nl-masthead-kicker {
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 14px;
}
.nl-masthead h1 {
  font-family: 'Playfair Display', serif !important;
  font-size: clamp(1.7rem, 4.5vw, 2.8rem) !important;
  font-weight: 900 !important;
  line-height: 1.15 !important;
  letter-spacing: -.01em;
  color: var(--ink) !important;
  margin-bottom: 14px !important;
  padding-top: 0 !important;
  border-bottom: none !important;
}
.nl-masthead h1 em { font-style: italic; color: var(--accent); }

/* ── Headings ── */
h1 {
  font-family: 'Playfair Display', serif !important;
  font-size: clamp(1.7rem, 4.5vw, 2.8rem) !important;
  font-weight: 900 !important;
  line-height: 1.18 !important;
  color: var(--ink) !important;
  margin-bottom: .5em !important;
  padding-top: 48px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 16px;
}

h2 {
  font-family: 'Playfair Display', serif !important;
  font-size: 1.45rem !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  color: var(--ink) !important;
  margin-top: 2.4em !important;
  margin-bottom: .6em !important;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 12px;
}
h2::before {
  content: '§';
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
}

h3 {
  font-family: 'Playfair Display', serif !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  font-style: italic !important;
  color: var(--ink) !important;
  margin-top: 1.8em !important;
  margin-bottom: .4em !important;
}

h4 {
  font-size: .78rem !important;
  font-family: 'Source Serif 4', serif !important;
  font-weight: 600 !important;
  letter-spacing: .14em !important;
  text-transform: uppercase !important;
  color: var(--accent2) !important;
  margin-top: 1.4em !important;
  margin-bottom: .3em !important;
}

/* ── Paragraphs ── */
p {
  color: var(--ink) !important;
  font-size: 16px;
  line-height: 1.85;
  margin-bottom: 1.15em;
  font-weight: 400;
}

/* Intro / lead paragraph */
p:first-of-type {
  font-size: 17px;
  font-weight: 300;
  color: var(--ink) !important;
}

/* ── Links ── */
a {
  color: var(--accent) !important;
  text-decoration: none !important;
  border-bottom: 1px solid rgba(139,32,32,.25) !important;
  transition: border-color .2s, color .2s;
}
a:hover {
  color: var(--ink) !important;
  border-color: var(--accent) !important;
}

/* ── Chapter / section list — styled as editorial contents ── */
body > ul,
body > ol,
.chapter-list {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 0 36px !important;
}

body > ul li,
body > ol li,
.chapter-list li {
  border-bottom: 1px solid var(--rule2);
  margin: 0 !important;
}
body > ul li:first-child,
body > ol li:first-child { border-top: 1px solid var(--rule2); }

body > ul li a,
body > ol li a,
.chapter-list li a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 13px 4px;
  font-family: 'Source Serif 4', serif;
  font-size: 15px;
  color: var(--ink) !important;
  border-bottom: none !important;
  transition: color .2s, padding-left .15s;
}
body > ul li a:hover,
body > ol li a:hover,
.chapter-list li a:hover {
  color: var(--accent) !important;
  padding-left: 8px;
}

/* Chapter number / counter */
body > ul { counter-reset: chapter; }
body > ul li { counter-increment: chapter; }
body > ul li a::before {
  content: counter(chapter, decimal-leading-zero);
  font-family: 'Playfair Display', serif;
  font-size: 11px;
  color: var(--muted2);
  flex-shrink: 0;
  min-width: 28px;
  font-style: italic;
}

/* Dots fill between chapter name and right side */
body > ul li a::after {
  content: '';
  flex: 1;
  border-bottom: 1px dotted var(--rule);
  margin: 0 6px;
  align-self: center;
}

/* Part headings (bold text in lists) */
body > p > strong:only-child,
.part-title {
  display: block;
  font-family: 'Playfair Display', serif !important;
  font-size: .78rem !important;
  font-weight: 900 !important;
  letter-spacing: .16em !important;
  text-transform: uppercase !important;
  color: var(--muted) !important;
  margin: 36px 0 8px !important;
  padding: 8px 0 8px 0;
  border-top: 2px solid var(--ink);
}

/* ── Code blocks ── */
pre, code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace !important;
  background: var(--bg2) !important;
  color: var(--ink) !important;
  border: 1px solid var(--rule) !important;
  border-radius: var(--radius) !important;
}
code {
  padding: 2px 6px;
  font-size: .84em;
  color: var(--accent) !important;
}
pre {
  padding: 20px 24px !important;
  overflow-x: auto;
  font-size: .84em;
  line-height: 1.65;
  margin: 1.6em 0 !important;
  border-left: 3px solid var(--rule) !important;
  color: var(--ink) !important;
}
pre code {
  background: transparent !important;
  border: none !important;
  padding: 0;
  color: inherit !important;
}

/* Language-specific left border accent */
pre.stata, .stata-output { border-left-color: var(--stata) !important; }
pre.r,     .r-output     { border-left-color: var(--r)     !important; }
pre.python,.python-output { border-left-color: var(--python)!important; }

/* ── Language badges (inline) ── */
.badge-stata, .badge-r, .badge-python {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 2px;
  vertical-align: middle;
}
.badge-stata  { background: rgba(43,95,168,.12);  color: var(--stata);  border: 1px solid rgba(43,95,168,.25); }
.badge-r      { background: rgba(39,111,66,.12);  color: var(--r);      border: 1px solid rgba(39,111,66,.25); }
.badge-python { background: rgba(160,82,26,.12);  color: var(--python); border: 1px solid rgba(160,82,26,.25); }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.8em 0;
  font-size: 14px;
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
thead tr { border-bottom: 1px solid var(--ink); }
th {
  padding: 8px 14px;
  text-align: left;
  font-family: 'Source Serif 4', serif;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted) !important;
}
td {
  padding: 9px 14px;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--rule2);
}
tr:last-child td { border-bottom: none; }

/* ── Blockquotes ── */
blockquote {
  border-left: 3px solid var(--accent) !important;
  background: var(--bg2) !important;
  padding: 16px 22px !important;
  margin: 24px 0 !important;
  font-style: italic;
  color: var(--muted) !important;
  font-size: 15.5px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
blockquote p { color: var(--muted) !important; margin: 0; }

/* ── Horizontal rule / section divider ── */
hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 40px 0;
  position: relative;
}
hr::after {
  content: '✦';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 10px;
  color: var(--muted2);
  font-size: 11px;
}

/* ── Images ── */
img {
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: block;
  margin: 1.5em auto;
}

/* ── Footer nav ── */
.nl-footer {
  border-top: 2px solid var(--ink);
  margin-top: 64px;
  padding: 28px 0 56px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 32px;
  padding-right: 32px;
}
.nl-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  padding: 0;
}
.nl-footer-nav a {
  font-family: 'Source Serif 4', serif;
  font-size: 11.5px;
  font-weight: 300;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted) !important;
  text-decoration: none !important;
  border-bottom: none !important;
  padding: 4px 16px 4px 0;
  transition: color .2s;
}
.nl-footer-nav a + a {
  padding-left: 16px;
  border-left: 1px solid var(--rule);
}
.nl-footer-nav a:hover { color: var(--accent) !important; }

/* ── Responsive ── */
@media (max-width: 640px) {
  body > *:not(style):not(script):not(.nl-topbar) {
    padding-left: 18px;
    padding-right: 18px;
  }
  .nl-topbar-inner { gap: 10px; }
  h1 { padding-top: 36px; }
  .nl-topbar-nav a + a::before { display: none; }
}
