/* ═══════════════════════════════════════════════════════════════
   THE MPRC FRAMEWORK — Book Design System
   Dark academic monograph · Crimson Pro + Inter + JetBrains Mono
   © 2025-2026 Muhammad Arshad. All Rights Reserved.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Palette: dark academic ── */
  --bg:         #0a0e17;
  --bg2:        #0f1420;
  --bg3:        #161c2a;
  --surface:    #1a2035;
  --surface2:   #1e2640;
  --border:     #2a3050;
  --border-light:#3a4570;

  --text:       #e2e8f0;
  --text-main:  #e2e8f0;
  --text-muted: #8892a8;
  --muted:      #8892a8;

  --primary:    #60a5fa;
  --accent:     #38bdf8;
  --cyan:       #38bdf8;
  --blue:       #60a5fa;
  --green:      #34d399;
  --red:        #f87171;
  --gold:       #fbbf24;

  /* ── Typography ── */
  --font-body:  'Crimson Pro', Georgia, 'Times New Roman', serif;
  --font-ui:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;
}


/* ═══════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg, object { max-width: 100%; height: auto; }

hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 4em auto;
  max-width: 120px;
}

::selection {
  background: rgba(56,189,248,0.25);
  color: #fff;
}


/* ═══════════════════════════════════════
   LAYOUT — Book Spine + Reading Pane
   ═══════════════════════════════════════ */
.book-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar / Book Spine ── */
.book-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-header {
  padding: 36px 28px 28px;
  border-bottom: 1px solid var(--border);
}

.book-title {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.book-title:hover { text-decoration: none; opacity: 0.85; }

.sidebar-nav {
  padding: 20px 0;
  flex: 1;
}

.sidebar-nav ul { list-style: none; }

.sidebar-nav a {
  display: block;
  padding: 10px 28px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  transition: color 0.15s, background 0.15s, border-left 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a:focus {
  color: #fff;
  background: rgba(56,189,248,0.06);
  border-left-color: var(--accent);
  text-decoration: none;
}

.nav-group-label {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  color: var(--accent);
  letter-spacing: 0.20em;
  text-transform: uppercase;
  padding: 16px 28px 4px;
  opacity: 0.65;
  pointer-events: none;
  list-style: none;
}

/* ── Main Reading Pane ── */
.book-main {
  flex: 1;
  min-width: 0;
  padding: 72px 64px 48px;
  background: var(--bg);
}

.book-content {
  max-width: 740px;
  margin: 0 auto;
}


/* ═══════════════════════════════════════
   CHAPTER HEADER
   ═══════════════════════════════════════ */
.chapter-header {
  margin-bottom: 64px;
  text-align: center;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--border);
}

.chapter-header h1 {
  font-family: var(--font-ui);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: #fff;
  margin-bottom: 20px;
}

.chapter-header h1 span {
  color: var(--accent);
}

.chapter-subtitle {
  font-family: var(--font-body);
  font-size: 1.2rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}


/* ═══════════════════════════════════════
   TYPOGRAPHY — Book Interior
   ═══════════════════════════════════════ */
.chapter-body p {
  margin-bottom: 1.5em;
  color: var(--text);
}

.chapter-body strong {
  font-weight: 600;
  color: #fff;
}

.chapter-body em {
  font-style: italic;
}

.chapter-body h2 {
  font-family: var(--font-ui);
  font-size: 1.65rem;
  font-weight: 600;
  margin: 3.5em 0 1em;
  color: #fff;
  letter-spacing: -0.01em;
  padding-bottom: 0.6em;
  border-bottom: 1px solid var(--border);
}

.chapter-body h3 {
  font-family: var(--font-ui);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2.5em 0 1em;
  color: #fff;
  letter-spacing: 0.01em;
}

.section-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  display: block;
}


/* ═══════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════ */

/* ── Pull Quote ── */
.pull-quote {
  border-left: 3px solid var(--accent);
  padding: 12px 0 12px 28px;
  margin: 2.5em 0;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.6;
}

.pull-quote p { margin: 0; color: var(--text-muted); }

/* ── Equation Block ── */
.eq-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px 28px;
  margin: 2.5em 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  overflow-x: auto;
  line-height: 1.7;
}

.eq-block .eq-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.eq-row {
  margin-bottom: 8px;
  color: var(--text);
}

.eq-row.cyan,
.eq-row.highlight { color: var(--cyan); }
.eq-row.green     { color: var(--green); }
.eq-row.red       { color: var(--red); }
.eq-row.fail      { color: var(--red); }
.eq-row .note     { color: var(--text-muted); font-size: 0.8rem; font-family: var(--font-ui); }

/* ── Data Table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2.5em 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
}

.data-table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.data-table tr:nth-child(even) {
  background: rgba(26,32,53,0.5);
}

/* ── Compare Table ── */
.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 2.5em 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.compare th, .compare td {
  border: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  color: var(--text);
}

.compare th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}


/* ═══════════════════════════════════════
   INDEX PAGE — Book Cover & TOC
   ═══════════════════════════════════════ */

/* ── Book Intro ── */
.book-intro {
  margin-bottom: 3em;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.book-intro p {
  color: var(--text-muted);
  line-height: 1.9;
}

/* ── Author Section ── */
.author-intro {
  margin: 0 0 3em;
  padding: 32px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.author-intro h2 {
  border-bottom: none;
  margin-top: 0;
  padding-bottom: 0;
}

.author-intro p:last-child { margin-bottom: 0; }

.author-block {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.author-photo {
  width: 160px;
  height: 160px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.author-text {
  flex: 1;
  min-width: 0;
}

.author-text h2 {
  border-bottom: none;
  margin-top: 0;
  padding-bottom: 0;
}

.author-text p:last-child {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .author-block {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .author-photo {
    width: 120px;
    height: 120px;
  }
}

/* ── Scorecard ── */
.scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 3em 0;
  font-family: var(--font-ui);
}

.score-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 16px;
  text-align: center;
}

.score-val {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 10px;
}

.score-val.green { color: var(--green); }
.score-val.cyan  { color: var(--cyan); }

.score-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.4;
}

/* ── TOC Grid (Chapter Cards) ── */
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin: 2.5em 0;
  font-family: var(--font-ui);
}

.ch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.ch-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  text-decoration: none;
}

.ch-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.ch-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 12px;
  line-height: 1.4;
  color: #fff;
}

.ch-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 16px;
  line-height: 1.6;
  flex: 1;
}

.ch-status {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 4px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(56,189,248,0.1);
  color: var(--accent);
}

.ch-status.verified   { background: rgba(52,211,153,0.12); color: var(--green); }
.ch-status.active     { background: rgba(251,191,36,0.12);  color: var(--gold); }
.ch-status.derived    { background: rgba(96,165,250,0.12);  color: var(--primary); }
.ch-status.foundation { background: rgba(136,146,168,0.1);  color: var(--text-muted); }


/* ═══════════════════════════════════════
   HIGHLIGHT BOX
   ═══════════════════════════════════════ */
.highlight-box {
  border: 1px solid var(--accent);
  background: var(--surface);
  border-radius: 6px;
  padding: 32px;
  margin: 2.5em 0;
  text-align: center;
}

.highlight-box .big {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.highlight-box .sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  margin: 0;
  font-family: var(--font-ui);
}


/* ═══════════════════════════════════════
   STEPS GRID
   ═══════════════════════════════════════ */
.steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 2.5em 0;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.3;
  line-height: 1;
  margin-bottom: 10px;
}

.step h4 {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.step p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
  font-family: var(--font-ui);
}


/* ═══════════════════════════════════════
   EPISTEMIC STATUS
   ═══════════════════════════════════════ */
.ok   { color: var(--green); font-weight: 600; }
.warn { color: var(--gold);  font-weight: 600; }
.fail { color: var(--red);   font-weight: 600; }
.open { color: var(--text-muted); font-weight: 600; }
.accent { color: var(--accent); }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

.badge.ver  { background: rgba(52,211,153,0.15);  color: var(--green); }
.badge.der  { background: rgba(96,165,250,0.15);  color: var(--primary); }
.badge.pred { background: rgba(251,191,36,0.15);  color: var(--gold); }
.badge.fail { background: rgba(247,113,113,0.15); color: var(--red); }
.badge.open { background: rgba(136,146,168,0.15); color: var(--text-muted); }


/* ═══════════════════════════════════════
   FIGURES
   ═══════════════════════════════════════ */
.figure {
  margin: 3em 0;
}

.figure object,
.figure img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.figure-caption {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 14px;
  letter-spacing: 0.02em;
}


/* ═══════════════════════════════════════
   CHAPTER NAV FOOTER
   ═══════════════════════════════════════ */
.chapter-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5em;
  padding-top: 2em;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.chapter-nav-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.chapter-nav-footer a:hover {
  text-decoration: underline;
}


/* ═══════════════════════════════════════
   COPYRIGHT FOOTER
   ═══════════════════════════════════════ */
.site-copyright {
  text-align: center;
  padding: 28px 40px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  letter-spacing: 0.02em;
}


/* ═══════════════════════════════════════
   RIGHT-CLICK / COPY PROTECTION (basic)
   ═══════════════════════════════════════ */
.book-content {
  -webkit-user-select: text;
  user-select: text;
}


/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 900px) {
  .book-main {
    padding: 48px 32px;
  }
  .toc-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .book-layout {
    flex-direction: column;
  }

  .book-sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 12px 0;
  }

  .sidebar-nav ul {
    display: flex;
    gap: 0;
  }

  .sidebar-nav a {
    white-space: nowrap;
    padding: 8px 16px;
    border-left: none;
    border-bottom: 2px solid transparent;
    font-size: 0.8rem;
  }

  .sidebar-nav a:hover {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  .book-main {
    padding: 36px 20px 32px;
  }

  .chapter-header h1 {
    font-size: 1.8rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .scorecard {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .scorecard {
    grid-template-columns: 1fr;
  }
}
