/* ═══════════════════════════════════════════════════════════════
   THE MPRC FRAMEWORK — Design System v2
   © 2025-2026 Muhammad Arshad. All Rights Reserved.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:           #04060e;
  --bg2:          #070b16;
  --bg3:          #0c1120;
  --surface:      #0f1629;
  --surface2:     #131d35;
  --surface3:     #182240;
  --border:       #1e2d4d;
  --border-light: #2a3f6a;
  --border-glow:  rgba(56,189,248,0.18);

  --text:         #c8d3e8;
  --text-main:    #c8d3e8;
  --text-muted:   #5f718f;
  --text-dim:     #3d5070;
  --muted:        #5f718f;

  --primary:      #5b9cf6;
  --accent:       #38bdf8;
  --accent-dim:   rgba(56,189,248,0.08);
  --accent-glow:  rgba(56,189,248,0.12);
  --cyan:         #38bdf8;
  --blue:         #5b9cf6;
  --green:        #34d399;
  --red:          #f87171;
  --gold:         #f59e0b;
  --violet:       #a78bfa;

  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-ui:      'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'Cascadia Code', monospace;

  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg:    0 12px 40px rgba(0,0,0,0.6);
  --glow-accent:  0 0 32px rgba(56,189,248,0.10);
  --glow-card:    0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(56,189,248,0.06);
}


/* ═══════════════════════════════════════
   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: 1rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(56,189,248,0.055) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(91,156,246,0.035) 0%, transparent 55%);
  background-attachment: fixed;
}

/* Subtle dot grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(56,189,248,0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; }

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

hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
  margin: 4.5em auto;
  max-width: 180px;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }


/* ═══════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════ */
.book-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}


/* ═══════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════ */
.book-sidebar {
  width: 268px;
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(7,11,22,0.98) 0%, rgba(7,11,22,0.95) 100%);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.book-sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(56,189,248,0.12) 25%,
    rgba(56,189,248,0.06) 75%,
    transparent 100%
  );
  pointer-events: none;
}

.sidebar-header {
  padding: 28px 24px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.book-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  display: block;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.book-title:hover { opacity: 1; color: var(--accent); }

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

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

.sidebar-nav a {
  display: block;
  padding: 7px 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.005em;
  transition: color 0.15s, background 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(56,189,248,0.04);
  border-left-color: rgba(56,189,248,0.3);
  text-decoration: none;
}

.nav-group-label {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  color: var(--text-dim);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 18px 24px 5px;
  pointer-events: none;
  list-style: none;
}


/* ═══════════════════════════════════════
   MAIN READING PANE
   ═══════════════════════════════════════ */
.book-main {
  flex: 1;
  min-width: 0;
  padding: 64px 72px 80px;
  position: relative;
}

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


/* ═══════════════════════════════════════
   CHAPTER HEADER
   ═══════════════════════════════════════ */
.chapter-header {
  margin-bottom: 72px;
  text-align: center;
  padding-bottom: 56px;
  position: relative;
}

.chapter-header::after {
  content: '';
  display: block;
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light) 30%, var(--border-light) 70%, transparent);
}

.chapter-header h1 {
  font-family: var(--font-ui);
  font-size: clamp(2.4rem, 4.5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 22px;
  text-shadow: 0 0 80px rgba(56,189,248,0.1);
}

.chapter-header h1 span {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chapter-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-style: italic;
  max-width: 580px;
  margin: 0 auto;
  line-height: 1.65;
}


/* ═══════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════ */
.chapter-body p {
  margin-bottom: 1.5em;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.8;
}

.chapter-body strong { font-weight: 600; color: #dde6f5; }
.chapter-body em { font-style: italic; }

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

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

.section-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: 10px;
  display: block;
  opacity: 0.7;
}


/* ── Pull Quote ── */
.pull-quote {
  border-left: 2px solid var(--accent);
  padding: 14px 0 14px 28px;
  margin: 2.5em 0;
  font-size: 1.1rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.65;
  background: linear-gradient(90deg, rgba(56,189,248,0.025) 0%, transparent 100%);
  border-radius: 0 var(--radius) var(--radius) 0;
}

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


/* ── Equation Block ── */
.eq-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 28px 22px 32px;
  margin: 2.5em 0;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  overflow-x: auto;
  line-height: 1.8;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.025);
  position: relative;
}

.eq-block::before {
  content: '';
  position: absolute;
  top: 12px; left: 0;
  width: 3px;
  height: calc(100% - 24px);
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 0 2px 2px 0;
  opacity: 0.5;
}

.eq-block .eq-label {
  font-size: 0.63rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.eq-row { margin-bottom: 5px; 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 Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2.5em 0;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

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

.data-table tr:nth-child(even) td { background: rgba(15,22,41,0.5); }
.data-table tr:hover td { background: rgba(56,189,248,0.025); }

.compare {
  width: 100%;
  border-collapse: collapse;
  margin: 2.5em 0;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

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

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


/* ═══════════════════════════════════════
   INDEX PAGE
   ═══════════════════════════════════════ */
.book-intro {
  margin-bottom: 3em;
  font-size: 1.02rem;
  color: var(--text-muted);
}

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

.author-intro {
  margin: 0 0 3em;
  padding: 32px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.author-intro::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,0.22) 40%, rgba(91,156,246,0.18) 60%, transparent);
}

.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: 110px;
  height: 110px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-light);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.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: 96px; height: 96px; }
}


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

.score-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px 18px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.score-item:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

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

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

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


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

.ch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.25s, transform 0.2s;
  position: relative;
  overflow: hidden;
}

.ch-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(56,189,248,0.15), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.ch-card:hover {
  border-color: rgba(56,189,248,0.22);
  box-shadow: 0 8px 30px rgba(0,0,0,0.45), 0 0 0 1px rgba(56,189,248,0.05);
  transform: translateY(-2px);
  text-decoration: none;
}

.ch-card:hover::after { opacity: 1; }

.ch-num {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 9px;
}

.ch-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 9px;
  line-height: 1.4;
  color: #dde6f5;
  letter-spacing: -0.01em;
}

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

.ch-status {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: rgba(56,189,248,0.07);
  color: var(--accent);
  border: 1px solid rgba(56,189,248,0.14);
}

.ch-status.verified   { background: rgba(52,211,153,0.07);  color: var(--green);   border-color: rgba(52,211,153,0.18); }
.ch-status.active     { background: rgba(245,158,11,0.07);  color: var(--gold);    border-color: rgba(245,158,11,0.18); }
.ch-status.derived    { background: rgba(91,156,246,0.07);  color: var(--primary); border-color: rgba(91,156,246,0.18); }
.ch-status.foundation { background: rgba(95,113,143,0.07);  color: var(--text-muted); border-color: rgba(95,113,143,0.15); }


/* ═══════════════════════════════════════
   HIGHLIGHT BOX
   ═══════════════════════════════════════ */
.highlight-box {
  border: 1px solid rgba(56,189,248,0.18);
  background: linear-gradient(135deg, rgba(56,189,248,0.04) 0%, rgba(91,156,246,0.025) 100%);
  border-radius: var(--radius-xl);
  padding: 32px;
  margin: 2.5em 0;
  text-align: center;
  box-shadow: var(--glow-accent);
}

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

.highlight-box .sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}


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

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  transition: border-color 0.2s;
}

.step:hover { border-color: var(--border-light); }

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

.step h4 {
  font-size: 0.77rem;
  font-weight: 600;
  color: #dde6f5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.step p {
  font-size: 0.865rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}


/* ═══════════════════════════════════════
   EPISTEMIC STATUS & BADGES
   ═══════════════════════════════════════ */
.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); }

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.57rem;
  letter-spacing: 0.07em;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid transparent;
}

.badge.ver  { background: rgba(52,211,153,0.07);  color: var(--green);   border-color: rgba(52,211,153,0.18); }
.badge.der  { background: rgba(91,156,246,0.07);  color: var(--primary); border-color: rgba(91,156,246,0.18); }
.badge.pred { background: rgba(245,158,11,0.07);  color: var(--gold);    border-color: rgba(245,158,11,0.18); }
.badge.fail { background: rgba(248,113,113,0.07); color: var(--red);     border-color: rgba(248,113,113,0.18); }
.badge.open { background: rgba(95,113,143,0.07);  color: var(--text-muted); border-color: rgba(95,113,143,0.15); }


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

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

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


/* ── Code ── */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface2);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  margin: 2em 0;
}

pre code { background: none; border: none; padding: 0; color: var(--text); }


/* ═══════════════════════════════════════
   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.875rem;
}

.chapter-nav-footer a { color: var(--accent); font-weight: 500; }
.chapter-nav-footer a:hover { color: #fff; }


/* ═══════════════════════════════════════
   COPYRIGHT FOOTER
   ═══════════════════════════════════════ */
.site-copyright {
  text-align: center;
  padding: 22px 40px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  letter-spacing: 0.03em;
  position: relative;
  z-index: 1;
}


/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 1100px) {
  .book-main { padding: 56px 48px 64px; }
}

@media (max-width: 900px) {
  .book-main { padding: 48px 32px 48px; }
  .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: 8px 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.79rem;
  }

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

  .book-main { padding: 36px 20px 40px; }
  .chapter-header h1 { font-size: 2rem; }
  .steps { grid-template-columns: 1fr; }
  .scorecard { grid-template-columns: repeat(2, 1fr); }
}

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