/* ================================================================
   Markets Atlas Design System — Precision Atlas
   Premium encyclopedia aesthetic: navy + gold, card-based, type-forward
   ================================================================ */

/* ── CSS Custom Properties ── */
:root {
  /* Palette */
  --bg:            #fafaf7;
  --surface:       #ffffff;
  --navy:          #162035;
  --navy-light:    #233656;
  --navy-muted:    #3a4f6f;
  --gold:          #9e7627;
  --gold-light:    #c49a3c;
  --gold-pale:     #f8f2e3;
  --text:          #1c1c1c;
  --text-secondary:#5a5a5a;
  --text-muted:    #8c8c8c;
  --border:        #e4e2db;
  --border-light:  #f0eee8;
  --accent-green:  #1a6b4a;
  --accent-red:    #b3304a;
  --accent-amber:  #b8721e;
  --accent-blue:   #2969b0;

  /* Typography */
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  --font-display:  'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Scale */
  --text-xs:       0.75rem;
  --text-sm:       0.8125rem;
  --text-base:     0.9375rem;
  --text-md:       1.0625rem;
  --text-lg:       1.1875rem;
  --text-xl:       1.375rem;
  --text-2xl:      1.625rem;
  --text-3xl:      2rem;
  --text-4xl:      2.5rem;

  /* Spacing */
  --space-2xs:     0.25rem;
  --space-xs:      0.5rem;
  --space-sm:      0.75rem;
  --space-md:      1rem;
  --space-lg:      1.5rem;
  --space-xl:      2rem;
  --space-2xl:     3rem;
  --space-3xl:     4rem;
  --space-4xl:     6rem;

  /* Radii */
  --radius-sm:     4px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-xl:     16px;

  /* Shadows */
  --shadow-card:   0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-elevated: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-overlay:  0 8px 30px rgba(0,0,0,0.10);

  /* Layout */
  --sidebar-w:     260px;
  --content-max:   800px;
  --content-wide:  960px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
  color: var(--navy);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-3xl); margin-bottom: var(--space-md); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-md); margin-top: var(--space-2xl); }
h3 { font-size: var(--text-xl); margin-bottom: var(--space-sm); margin-top: var(--space-lg); }
h4 { font-size: var(--text-lg); }
p  { margin-bottom: var(--space-md); }
strong { font-weight: 600; }
a  { color: var(--accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--gold-pale);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--navy);
}
ul, ol { margin-bottom: var(--space-md); padding-left: 1.5em; }
li { margin-bottom: var(--space-xs); }

/* ── Layout ── */
.site-layout {
  display: flex;
  min-height: 100vh;
}

.page-shell {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}

.page-shell main {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3xl) var(--space-2xl) var(--space-4xl);
}

/* ── Sidebar ── */
.site-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #c8d0dc;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  font-size: var(--text-sm);
}

.sidebar-brand {
  display: block;
  padding: var(--space-xl) var(--space-lg);
  text-decoration: none !important;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand h3 {
  color: #fff;
  font-size: var(--text-lg);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  display: block;
  color: var(--gold-light);
  font-size: var(--text-xs);
  margin-top: 2px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-sm) 0;
}

.sidebar-section-title {
  padding: var(--space-md) var(--space-lg) var(--space-xs);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
}

.sidebar-module {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  color: #b0bac8;
  text-decoration: none !important;
  transition: all 0.15s;
  border-left: 2px solid transparent;
  font-weight: 500;
}

.sidebar-module:hover {
  color: #fff;
  background: rgba(255,255,255,0.04);
  border-left-color: var(--gold);
}

.sidebar-module.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--gold);
}

.mod-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--gold-light);
  flex-shrink: 0;
}

.sidebar-chapters {
  padding: var(--space-2xs) 0;
}

.sidebar-chapter {
  display: block;
  padding: 3px var(--space-lg) 3px 52px;
  color: #8896aa;
  text-decoration: none !important;
  font-size: var(--text-xs);
  transition: color 0.15s;
  border-left: 2px solid transparent;
}

.sidebar-chapter:hover { color: #d0d8e4; }
.sidebar-chapter.active { color: var(--gold-light); }

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-tool {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  color: #8896aa;
  text-decoration: none !important;
  font-size: var(--text-xs);
  transition: color 0.15s;
}

.sidebar-tool:hover { color: #d0d8e4; }
.sidebar-tool .tool-icon { font-size: 0.875rem; width: 20px; text-align: center; }

/* ── Homepage ── */
.course-hero {
  padding: var(--space-3xl) 0 var(--space-xl);
  text-align: center;
}

.course-hero .eyebrow {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.course-hero h1 {
  font-size: var(--text-4xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-sm);
  color: var(--navy);
}

.course-hero .subtitle {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  font-weight: 400;
}

.story-block {
  max-width: 680px;
  margin: 0 auto var(--space-3xl);
}

.story-block p { font-size: var(--text-md); line-height: 1.85; }

.atlas-map {
  margin: var(--space-2xl) auto var(--space-3xl);
  overflow-x: auto;
}

.atlas-map h2 {
  text-align: center;
  font-size: var(--text-xl);
  color: var(--navy);
  margin-bottom: var(--space-xl);
}

.atlas-map svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-3xl);
  max-width: var(--content-wide);
  margin-left: auto; margin-right: auto;
}

.module-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  transition: all 0.15s;
  box-shadow: var(--shadow-card);
}

.module-row:hover {
  border-color: var(--navy-muted);
  box-shadow: var(--shadow-elevated);
  transform: translateY(-1px);
}

.mod-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: var(--navy);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.mod-info h3 {
  margin: 0 0 2px;
  font-size: var(--text-md);
  color: var(--navy);
}

.mod-info p {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.lens-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  max-width: var(--content-wide);
  margin: 0 auto var(--space-3xl);
}

.lens-card {
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.lens-card h3 {
  font-size: var(--text-base);
  margin: 0 0 var(--space-sm);
  color: var(--navy);
}

.lens-card p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

.lens-card.browse { border-top: 3px solid var(--navy); }
.lens-card.find  { border-top: 3px solid var(--gold); }
.lens-card.tools { border-top: 3px solid var(--accent-green); }

/* ── Chapter Hero ── */
.chapter-hero {
  padding-bottom: var(--space-xl);
  margin-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--border);
}

.chapter-num {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: var(--space-xs);
}

.hero-lead {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: var(--space-sm);
}

.breadcrumb {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--navy); }
.breadcrumb-sep { margin: 0 var(--space-xs); }

/* ── Eyebrow labels ── */
.eyebrow {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy-muted);
  margin-bottom: var(--space-sm);
}

/* ── One-Liner ── */
.one-liner-block {
  padding: var(--space-lg);
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: #fff;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
}

.one-liner-block .eyebrow { color: var(--gold-light); }
.one-liner-text {
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: 1.6;
  margin: 0;
}

/* ── Market Card ── */
.market-card-block {
  margin-bottom: var(--space-xl);
}

.market-card-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.market-card-table tr {
  border-bottom: 1px solid var(--border-light);
}

.market-card-table tr:last-child { border-bottom: none; }

.market-card-table th {
  width: 140px;
  padding: var(--space-sm) var(--space-md);
  background: #f8f7f4;
  color: var(--navy-muted);
  font-weight: 600;
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.market-card-table td {
  padding: var(--space-sm) var(--space-md);
  color: var(--text);
}

/* ── Situation ── */
.situation-section {
  margin-bottom: var(--space-xl);
}

.situation-block {
  padding: var(--space-lg);
  background: var(--gold-pale);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.situation-block p {
  margin: 0;
  font-size: var(--text-md);
  line-height: 1.7;
  color: var(--navy);
}

/* ── Mechanics Diagram ── */
.mechanics-view {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.mechanics-view svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Use Cases ── */
.use-cases-block {
  margin-bottom: var(--space-xl);
}

.use-cases-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-md);
}

.use-cases-content p {
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin: 0;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-card);
}

/* ── Anti-Use Cases ── */
.anti-use-block {
  margin-bottom: var(--space-xl);
}

.anti-use-content {
  padding: var(--space-lg);
  background: #fdf7f8;
  border: 1px solid #f0d0d4;
  border-left: 3px solid var(--accent-red);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.anti-use-content p { margin: 0; }

/* ── Comparison Table ── */
.comparison-block {
  margin-bottom: var(--space-xl);
}

.comparison-scroll {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.comparison-table thead th {
  padding: var(--space-sm) var(--space-md);
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.comparison-table tbody td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.comparison-table tbody tr:last-child td { border-bottom: none; }
.comparison-table tbody tr:nth-child(even) td { background: #fafaf8; }

/* ── Pitfalls ── */
.pitfall-block {
  margin-bottom: var(--space-xl);
}

.pitfall-item {
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.pitfall-title {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.pitfall-title .icon {
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.pitfall-title strong {
  color: var(--accent-red);
  font-size: var(--text-base);
}

.pitfall-body {
  margin-left: 1.75rem;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.pitfall-body p { margin-bottom: var(--space-xs); }

/* ── Quick Card ── */
.quick-card-block {
  margin-bottom: var(--space-xl);
}

.quick-card-content {
  padding: var(--space-lg);
  background: linear-gradient(135deg, #fafaf7, #f4f2ec);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.quick-card-content ul { margin: 0; }

/* ── Scene (standard chapters) ── */
.scene-section {
  margin-bottom: var(--space-xl);
}

.scene-block {
  font-size: var(--text-md);
  line-height: 1.7;
}

/* ── Diagram (standard chapters) ── */
.diagram-section {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.diagram-section svg { max-width: 100%; height: auto; }

/* ── Steps (standard chapters) ── */
.steps-section { margin-bottom: var(--space-xl); }
.steps-list { counter-reset: step; list-style: none; padding: 0; }
.steps-list li {
  counter-increment: step;
  padding: var(--space-md) var(--space-md) var(--space-md) 3rem;
  position: relative;
  margin-bottom: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.steps-list li::before {
  content: counter(step);
  position: absolute;
  left: var(--space-md);
  top: var(--space-md);
  width: 24px; height: 24px;
  background: var(--navy);
  color: var(--gold-light);
  border-radius: 50%;
  font-size: 0.625rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Explanations (standard chapters) ── */
.explanation-block { margin-bottom: var(--space-xl); }
.explanation-step {
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}

.step-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--navy-muted);
  background: var(--border-light);
  padding: 1px 8px;
  border-radius: 3px;
  margin-bottom: var(--space-xs);
}

/* ── Try Block ── */
.try-block {
  padding: var(--space-lg);
  background: #f0f5fa;
  border: 1px solid #c8d8e8;
  border-left: 3px solid var(--accent-blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: var(--space-xl);
}

.try-block .question {
  font-weight: 600;
  color: var(--navy);
  margin-bottom: var(--space-sm);
}

/* ── Math Block ── */
.math-block {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.formula {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: #f8f7f4;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  text-align: center;
  overflow-x: auto;
}

.vars { display: grid; grid-template-columns: auto 1fr; gap: var(--space-xs) var(--space-md); font-size: var(--text-sm); }
.vars dt { font-family: var(--font-mono); color: var(--navy); font-weight: 600; }
.vars dd { color: var(--text-secondary); }

/* ── Takeaways ── */
.takeaways {
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: #f0f6f4;
  border: 1px solid #c8dcd0;
  border-radius: var(--radius-md);
}

.takeaway-list li {
  margin-bottom: var(--space-xs);
  line-height: 1.5;
}

/* ── Forward Hook ── */
.forward-hook {
  text-align: center;
  padding: var(--space-xl) 0;
  color: var(--navy-muted);
  font-size: var(--text-md);
  font-style: italic;
}

.forward-hook .arrow {
  display: block;
  font-style: normal;
  font-size: var(--text-xl);
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

/* ── Module Page ── */
.module-hero {
  padding-bottom: var(--space-xl);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.module-hero .eyebrow {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.module-hero h1 {
  font-size: var(--text-3xl);
  color: var(--navy);
}

.big-question {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-top: var(--space-sm);
  font-style: italic;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.chapter-card {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none !important;
  box-shadow: var(--shadow-card);
  transition: all 0.15s;
  align-items: flex-start;
}

.chapter-card:hover {
  border-color: var(--navy-muted);
  box-shadow: var(--shadow-elevated);
  transform: translateY(-1px);
}

.ch-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8em;
  height: 1.8em;
  background: var(--navy);
  color: var(--gold-light);
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.chapter-card h3 {
  margin: 0 0 2px;
  font-size: var(--text-sm);
  color: var(--navy);
}

.chapter-card p {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Pager (prev/next) ── */
.pager {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border);
}

.pager a {
  color: var(--navy);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
}

.pager a:hover { color: var(--gold); }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: var(--space-2xl) 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ── Scrollbar ── */
.site-sidebar::-webkit-scrollbar { width: 4px; }
.site-sidebar::-webkit-scrollbar-track { background: transparent; }
.site-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .module-grid { grid-template-columns: 1fr; }
  .lens-nav { grid-template-columns: 1fr; }
  .chapter-grid { grid-template-columns: 1fr; }
  .use-cases-content { grid-template-columns: 1fr; }
  .site-sidebar {
    position: static;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: var(--space-sm);
  }
  .page-shell { margin-left: 0; }
  .page-shell main { padding: var(--space-lg); }
  .site-sidebar .sidebar-nav { display: none; }
  .site-sidebar .sidebar-footer { display: none; }
  .course-hero h1 { font-size: var(--text-2xl); }
}

@media (max-width: 600px) {
  :root { --content-wide: 100%; }
}
