/* ============================================================
   DAS KAPITAL — ACADEMIC JOURNAL REDESIGN
   Warm academic palette · Playfair Display + Source Serif 4
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;1,400;1,600&family=Source+Serif+4:ital,opsz,wght@0,8..60,300..900;1,8..60,300..900&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Warm academic colour palette --- */
:root {
  --bg:          #FAFAF8;
  --bg-sidebar:  #F5F3EF;
  --ink:         #1A1A1A;
  --ink-muted:   #5A5040;
  --accent:      #8B4513;
  --accent-hover:#C05621;
  --accent-bg:   #FDF6EE;
  --rule:        #E0D8CC;
  --surface:     #F2EDE6;
  --code-bg:     #F5F0EB;
  --white:       #FFFFFF;
}

/* Dark mode overrides */
[data-md-color-scheme="slate"] {
  --bg:          #1C1A18;
  --bg-sidebar:  #211F1C;
  --ink:         #E8E0D5;
  --ink-muted:   #A09080;
  --accent:      #C87941;
  --accent-hover:#E0935A;
  --accent-bg:   #2A2318;
  --rule:        #3A342C;
  --surface:     #252018;
  --code-bg:     #221E18;
}

/* --- Global reset & base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--bg);
}

/* ============================================================
   HIDE MATERIAL CHROME WE DON'T WANT
   ============================================================ */
.md-search                { display: none !important; }
.md-sidebar--secondary    { display: none !important; }
.md-header__source        { display: none !important; }
.md-source                { display: none !important; }
.md-tabs                  { display: none !important; }
.md-header__topic         { display: none !important; }
.md-path                  { display: none !important; }

/* Hide dark/light toggle button */
label.md-header__button[for="__palette"] { display: none !important; }

/* ============================================================
   HEADER
   ============================================================ */
.md-header {
  background: var(--bg) !important;
  border-bottom: 1px solid var(--rule) !important;
  box-shadow: none !important;
}

.md-header__inner {
  padding: 0 1.5rem;
}

.md-header__title {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-weight: 700 !important;
  font-size: 1.05rem !important;
  letter-spacing: 0.01em;
  color: var(--ink) !important;
}

/* ============================================================
   LEFT SIDEBAR — chapter navigation
   ============================================================ */
.md-sidebar--primary {
  background: var(--bg-sidebar) !important;
  border-right: 1px solid var(--rule) !important;
}

.md-nav {
  font-family: 'Source Serif 4', Georgia, serif !important;
  font-size: 0.87rem !important;
}

.md-nav__title {
  display: none !important;
}

.md-nav__item--active > .md-nav__link,
.md-nav__link--active {
  font-weight: 700 !important;
  color: var(--accent) !important;
}

.md-nav__link {
  color: var(--ink-muted) !important;
  transition: color 0.12s;
  padding: 0.3rem 0.75rem;
}

.md-nav__link:hover {
  color: var(--accent-hover) !important;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.md-content {
  background: var(--bg) !important;
}

.md-content__inner {
  max-width: 720px !important;
  margin: 0 auto !important;
  padding: 2.5rem 2rem 4rem !important;
}

/* ============================================================
   TYPOGRAPHY — headings
   ============================================================ */
.md-typeset h1 {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-size: 2.2rem !important;
  font-weight: 800 !important;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink) !important;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
  margin-top: 0 !important;
  margin-bottom: 2rem !important;
}

.md-typeset h2 {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink) !important;
  margin-top: 2.8rem !important;
  margin-bottom: 0.9rem !important;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35rem;
}

.md-typeset h3 {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-size: 1.15rem !important;
  font-weight: 600 !important;
  font-style: italic;
  color: var(--ink) !important;
  margin-top: 2rem !important;
  margin-bottom: 0.6rem !important;
}

.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: 'Source Serif 4', Georgia, serif !important;
  font-weight: 700 !important;
  color: var(--ink) !important;
  margin-top: 1.5rem !important;
}

/* ============================================================
   TYPOGRAPHY — body
   ============================================================ */
.md-typeset p {
  font-family: 'Source Serif 4', Georgia, serif !important;
  line-height: 1.85;
  margin-bottom: 1.25em !important;
  color: var(--ink) !important;
}

.md-typeset strong {
  font-weight: 700;
  color: var(--ink) !important;
}

/* Links */
.md-typeset a {
  color: var(--accent) !important;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}

.md-typeset a:hover {
  color: var(--accent-hover) !important;
  border-bottom-color: var(--accent-hover);
}

/* Blockquotes — Marx quotations */
.md-typeset blockquote {
  border-left: 3px solid var(--accent) !important;
  background: var(--accent-bg) !important;
  padding: 1rem 1.5rem !important;
  border-radius: 0 4px 4px 0 !important;
  font-style: italic;
  margin: 2rem 0 !important;
  color: var(--ink-muted) !important;
}

.md-typeset blockquote p {
  margin: 0 !important;
  font-size: 1rem;
  line-height: 1.7;
}

/* Lists */
.md-typeset ul,
.md-typeset ol {
  padding-left: 1.5rem !important;
  margin-bottom: 1.2em !important;
}

.md-typeset li {
  line-height: 1.8;
  margin-bottom: 0.3em;
}

/* ============================================================
   EQUATIONS — code blocks used for economic formulae
   ============================================================ */
.md-typeset pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 4px !important;
  padding: 1.1rem 1.4rem !important;
  margin: 1.8rem 0 !important;
  overflow-x: auto;
}

.md-typeset pre code {
  font-family: 'JetBrains Mono', 'Source Code Pro', 'Courier New', monospace !important;
  font-size: 0.9rem !important;
  line-height: 1.65;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  color: var(--ink) !important;
}

/* Inline code */
.md-typeset code {
  font-family: 'JetBrains Mono', 'Source Code Pro', 'Courier New', monospace !important;
  font-size: 0.84em !important;
  background: var(--code-bg) !important;
  border: 1px solid var(--rule) !important;
  border-radius: 3px !important;
  padding: 0.1em 0.35em !important;
  color: var(--ink) !important;
}

/* ============================================================
   TABLES
   ============================================================ */
.md-typeset table {
  border-collapse: collapse !important;
  width: 100%;
  font-size: 0.9rem !important;
  margin: 1.8rem 0 !important;
  font-family: 'Source Serif 4', Georgia, serif !important;
}

.md-typeset table th {
  background: var(--surface) !important;
  font-family: 'Playfair Display', Georgia, serif !important;
  font-weight: 700 !important;
  border-bottom: 2px solid var(--rule) !important;
  border-top: 1px solid var(--rule) !important;
  padding: 0.6rem 1rem !important;
  text-align: left;
  color: var(--ink) !important;
}

.md-typeset table td {
  border-bottom: 1px solid var(--rule) !important;
  padding: 0.55rem 1rem !important;
  vertical-align: top;
  color: var(--ink) !important;
}

.md-typeset table tr:last-child td {
  border-bottom: none !important;
}

.md-typeset table tr:hover td {
  background: var(--accent-bg) !important;
}

/* ============================================================
   HORIZONTAL RULES
   ============================================================ */
.md-typeset hr {
  border: none !important;
  border-top: 1px solid var(--rule) !important;
  margin: 2.8rem 0 !important;
}

/* ============================================================
   HOVER TOOLTIPS — .term elements with data-def
   ============================================================ */
.term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  position: relative;
  color: inherit;
}

.term::after {
  content: attr(data-def);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #1A1A1A;
  color: #F5F0EB;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.77rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.55;
  padding: 0.5em 0.8em;
  border-radius: 4px;
  white-space: normal;
  max-width: 300px;
  width: max-content;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  word-wrap: break-word;
}

.term:hover::after {
  opacity: 1;
}

/* Tooltip arrow */
.term::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1A1A1A;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
  z-index: 501;
}

.term:hover::before {
  opacity: 1;
}

/* ============================================================
   DIAGRAM CONTAINERS (SVG wrappers)
   ============================================================ */
.diagram-container {
  text-align: center;
  margin: 2.5rem 0;
  padding: 1.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.diagram-container svg {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

.diagram-caption {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--ink-muted);
  margin-top: 0.9rem;
  text-align: center;
}

/* ============================================================
   FOOTER — prev/next chapter navigation
   ============================================================ */
.md-footer {
  background: var(--surface) !important;
  border-top: 1px solid var(--rule) !important;
}

.md-footer__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.md-footer__link {
  font-family: 'Source Serif 4', Georgia, serif !important;
  font-size: 0.9rem;
  color: var(--ink-muted) !important;
  text-decoration: none;
  transition: color 0.12s;
  display: flex;
  flex-direction: column;
  max-width: 45%;
}

.md-footer__link:hover {
  color: var(--accent-hover) !important;
}

.md-footer__link--prev { align-items: flex-start; }
.md-footer__link--next { align-items: flex-end; }

.md-footer__link-title {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink) !important;
}

.md-footer__link:hover .md-footer__link-title {
  color: var(--accent-hover) !important;
}

.md-footer__link-subtitle {
  font-size: 0.78rem;
  font-style: italic;
  opacity: 0.7;
  margin-top: 0.15rem;
}

.md-footer__title { display: none !important; }

/* Copyright strip */
.md-footer-meta {
  background: var(--bg) !important;
  border-top: 1px solid var(--rule) !important;
}

.md-footer-meta__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.75rem 2rem;
  font-size: 0.78rem;
  color: var(--ink-muted) !important;
  font-family: 'Source Serif 4', Georgia, serif !important;
}

/* ============================================================
   ADMONITIONS (callouts)
   ============================================================ */
.md-typeset .admonition {
  border-radius: 4px !important;
  border-left-width: 3px !important;
  background: var(--accent-bg) !important;
  border-left-color: var(--accent) !important;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 76.1875em) {
  .md-content__inner {
    padding: 1.75rem 1.25rem 3rem !important;
  }
}

@media (max-width: 600px) {
  .md-typeset h1 {
    font-size: 1.75rem !important;
  }
  .md-typeset h2 {
    font-size: 1.25rem !important;
  }
  .md-footer__inner {
    flex-direction: column;
    gap: 1rem;
  }
  .md-footer__link {
    max-width: 100%;
  }
  .md-footer__link--next {
    align-items: flex-start;
  }
}
