/* ===== Macro Study Guide — Design System ===== */
:root {
  /* Colors */
  --bg-primary: #0a0b0f;
  --bg-secondary: #12131a;
  --bg-card: #181a24;
  --bg-card-hover: #1e2030;
  --bg-sidebar: #0e0f16;
  --bg-glass: rgba(24, 26, 36, 0.85);

  --text-primary: #e8eaf0;
  --text-secondary: #9498ab;
  --text-muted: #6b6f82;
  --text-heading: #f0f2f8;

  --accent-1: #6c5ce7;
  --accent-2: #a29bfe;
  --accent-3: #00cec9;
  --accent-4: #fd79a8;
  --accent-5: #fdcb6e;

  --gradient-primary: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --gradient-accent: linear-gradient(135deg, #6c5ce7, #00cec9);
  --gradient-warm: linear-gradient(135deg, #fd79a8, #fdcb6e);
  --gradient-hero: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 40%, #00cec9 100%);

  --border-color: rgba(108, 92, 231, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.06);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.15);

  --sidebar-width: 280px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;
  --transition-slow: 0.4s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 15px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: rgba(108, 92, 231, 0.35);
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: rgba(108, 92, 231, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108, 92, 231, 0.5); }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-med);
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
}

.logo h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-heading);
}

.logo p {
  font-size: 0.73rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 500;
}

/* Search */
.search-box {
  padding: 12px 16px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.search-box input:focus {
  border-color: var(--accent-1);
  background: rgba(108, 92, 231, 0.05);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Nav Links */
.nav-links {
  list-style: none;
  padding: 8px 10px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-category {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  padding: 16px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background: rgba(108, 92, 231, 0.08);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(108, 92, 231, 0.12);
  color: var(--accent-2);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--gradient-primary);
  border-radius: 2px;
}

.nav-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 22px;
}

.nav-link.active .nav-num { color: var(--accent-1); }

.nav-link.hidden { display: none; }

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}

.cheatsheet-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  justify-content: center;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.cheatsheet-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Mobile Toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all var(--transition-fast);
}

/* ===== Main Content ===== */
.content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 40px 80px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 80px 0 60px;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
  letter-spacing: 0.5px;
  margin-bottom: 24px;
}

.hero-title {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1.1;
  color: var(--text-heading);
  margin-bottom: 16px;
}

.gradient-text {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto 36px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-num {
  font-size: 2rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

/* ===== Sections ===== */
.section {
  padding-top: 40px;
  margin-bottom: 28px;
  animation: fadeInUp 0.5s ease both;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-1);
  background: rgba(108, 92, 231, 0.1);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

.section-header h2 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-heading);
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all var(--transition-med);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-med);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(108, 92, 231, 0.2);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

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

.card.full-width { grid-column: 1 / -1; }

.card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 12px;
}

.card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-2);
  margin: 16px 0 8px;
}

.card p {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

.card ul, .card ol {
  padding-left: 20px;
  color: var(--text-secondary);
}

.card li {
  margin-bottom: 4px;
}

.card strong { color: var(--text-primary); }

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 10px 14px;
  background: rgba(108, 92, 231, 0.08);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

tr:last-child td { border-bottom: none; }

td.up { color: #00b894; font-weight: 600; }
td.down { color: #e17055; font-weight: 600; }

/* ===== Formula Blocks ===== */
.formula-block {
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--accent-2);
  text-align: center;
  margin: 12px 0;
  font-weight: 500;
}

.formula-table code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(108, 92, 231, 0.08);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent-2);
}

/* ===== Callout Boxes ===== */
.callout-box {
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.callout-box.definition {
  background: rgba(108, 92, 231, 0.06);
  border-left: 3px solid var(--accent-1);
  color: var(--text-secondary);
}

.callout-box.important {
  background: rgba(253, 203, 110, 0.06);
  border-left: 3px solid var(--accent-5);
  color: var(--text-secondary);
}

.callout-box.warning {
  background: rgba(225, 112, 85, 0.06);
  border-left: 3px solid #e17055;
  color: var(--text-secondary);
}

.callout-box.note-small {
  background: rgba(0, 206, 201, 0.06);
  border-left: 3px solid var(--accent-3);
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 12px;
}

/* ===== Example Box ===== */
.example-box {
  background: rgba(0, 206, 201, 0.06);
  border: 1px solid rgba(0, 206, 201, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.example-box strong { color: var(--accent-3); }

/* ===== Note ===== */
.note {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tag.demand { background: rgba(108, 92, 231, 0.15); color: var(--accent-2); }
.tag.supply { background: rgba(225, 112, 85, 0.15); color: #e17055; }
.tag.frictional { background: rgba(0, 206, 201, 0.15); color: var(--accent-3); }
.tag.structural { background: rgba(253, 203, 110, 0.15); color: var(--accent-5); }
.tag.cyclical { background: rgba(253, 121, 168, 0.15); color: var(--accent-4); }
.tag.recessionary { background: rgba(225, 112, 85, 0.15); color: #e17055; }
.tag.inflationary { background: rgba(253, 203, 110, 0.15); color: var(--accent-5); }

.tag-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* ===== Costs Grid ===== */
.costs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.cost-item {
  text-align: center;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.cost-icon { font-size: 1.5rem; display: block; margin-bottom: 8px; }
.cost-item strong { font-size: 0.82rem; color: var(--text-primary); }
.cost-item p { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Flow Diagram ===== */
.flow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.flow-item {
  padding: 10px 20px;
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--accent-2);
  font-size: 0.88rem;
}

.flow-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===== Cycle Phases ===== */
.cycle-phases {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.phase {
  text-align: center;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  min-width: 120px;
}

.phase-icon { font-size: 1.5rem; margin-bottom: 8px; }
.phase h4 { font-size: 0.9rem; margin-bottom: 6px; }
.phase p { font-size: 0.78rem; margin: 2px 0; }

.phase.expansion { background: rgba(0, 184, 148, 0.08); border: 1px solid rgba(0, 184, 148, 0.2); }
.phase.expansion h4 { color: #00b894; }
.phase.peak { background: rgba(108, 92, 231, 0.08); border: 1px solid rgba(108, 92, 231, 0.2); }
.phase.peak h4 { color: var(--accent-2); }
.phase.contraction { background: rgba(225, 112, 85, 0.08); border: 1px solid rgba(225, 112, 85, 0.2); }
.phase.contraction h4 { color: #e17055; }
.phase.trough { background: rgba(253, 203, 110, 0.08); border: 1px solid rgba(253, 203, 110, 0.2); }
.phase.trough h4 { color: var(--accent-5); }

.phase-arrow {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ===== Correction Grid ===== */
.correction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.correction-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.correction-item h4 {
  margin-bottom: 10px;
}

.chain {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.chain-arrow {
  color: var(--accent-1);
  font-weight: 700;
}

/* ===== Transmission Chain ===== */
.transmission-chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.chain-step {
  text-align: center;
  padding: 12px 16px;
  background: rgba(108, 92, 231, 0.08);
  border: 1px solid rgba(108, 92, 231, 0.15);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 100px;
}

.chain-arrow-big {
  font-size: 1.3rem;
  color: var(--accent-1);
  font-weight: 700;
}

/* ===== Three Column ===== */
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.three-col > div {
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.three-col h4 {
  font-size: 0.9rem;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.three-col p {
  font-size: 0.88rem;
}

/* ===== Icon List ===== */
.icon-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.icon-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.icon-item span {
  font-size: 1.2rem;
  min-width: 28px;
  text-align: center;
}

.icon-item strong { color: var(--text-primary); margin-right: 4px; }

/* ===== Diagram Cards ===== */
.diagrams-grid .diagram-card {
  position: relative;
  padding-top: 40px;
}

.diagram-num {
  position: absolute;
  top: 16px;
  right: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 800;
  color: rgba(108, 92, 231, 0.12);
}

/* ===== Tip Cards ===== */
.tip-card {
  position: relative;
  padding-top: 48px !important;
}

.tip-icon {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 1.4rem;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 60px 0 40px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 40px;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.cheatsheet-btn-footer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--gradient-primary);
  border-radius: 100px;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.cheatsheet-btn-footer:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr; }
  .card.full-width { grid-column: 1; }
  .three-col { grid-template-columns: 1fr; }
  .correction-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 2.4rem; }
  .content-inner { padding: 24px 20px 80px; }
}

@media (max-width: 768px) {
  .mobile-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .content {
    margin-left: 0;
  }

  .content-inner {
    padding: 70px 16px 80px;
  }

  .hero { padding: 40px 0 40px; }
  .hero-title { font-size: 2rem; letter-spacing: -1px; }
  .hero-stats { gap: 24px; }
  .stat-num { font-size: 1.5rem; }

  .cycle-phases { flex-direction: column; }
  .phase-arrow { transform: rotate(90deg); }
  .transmission-chain { flex-direction: column; }
  .chain-arrow-big { transform: rotate(90deg); }
}
