/* ============================================
   PMI Plus — Reusable Components
   ============================================ */

/* --- Chapter Card (index page) --- */
.chapter-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.chapter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--ch01-color));
}

.chapter-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-secondary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-2px);
}

.chapter-card .card-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--card-accent, var(--text-tertiary));
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-2);
}

.chapter-card .card-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
  line-height: 1.4;
}

.chapter-card .card-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
  line-height: 1.5;
}

.chapter-card .card-formulas {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.chapter-card .card-badge {
  display: inline-block;
  margin-top: var(--sp-3);
}

/* --- Difficulty Badge --- */
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--sp-2);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.difficulty-badge.beginner {
  background: #dcfce7;
  color: #166534;
}

.difficulty-badge.intermediate {
  background: #fef3c7;
  color: #92400e;
}

.difficulty-badge.advanced {
  background: #fce7f3;
  color: #9d174d;
}

[data-theme="dark"] .difficulty-badge.beginner {
  background: #052e16;
  color: #86efac;
}

[data-theme="dark"] .difficulty-badge.intermediate {
  background: #451a03;
  color: #fcd34d;
}

[data-theme="dark"] .difficulty-badge.advanced {
  background: #500724;
  color: #f9a8d4;
}

/* --- Callout Boxes --- */
.callout {
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-6);
  border-left: 4px solid;
}

.callout-title {
  font-weight: 600;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.callout p {
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
}

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

.callout-info {
  background: #eff6ff;
  border-color: #3b82f6;
}
.callout-info .callout-title { color: #1d4ed8; }

.callout-tip {
  background: #f0fdf4;
  border-color: #22c55e;
}
.callout-tip .callout-title { color: #15803d; }

.callout-warning {
  background: #fffbeb;
  border-color: #f59e0b;
}
.callout-warning .callout-title { color: #b45309; }

.callout-history {
  background: #faf5ff;
  border-color: #a855f7;
}
.callout-history .callout-title { color: #7e22ce; }

.callout-math {
  background: var(--bg-formula);
  border-color: var(--ch04-color);
}
.callout-math .callout-title { color: var(--ch04-color); }

[data-theme="dark"] .callout-info {
  background: #172554;
  border-color: #3b82f6;
}

[data-theme="dark"] .callout-tip {
  background: #052e16;
  border-color: #22c55e;
}

[data-theme="dark"] .callout-warning {
  background: #451a03;
  border-color: #f59e0b;
}

[data-theme="dark"] .callout-history {
  background: #2e1065;
  border-color: #a855f7;
}

/* --- Comparison Table --- */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--sp-6);
  font-size: var(--text-sm);
}

.comparison-table thead {
  position: sticky;
  top: var(--nav-height);
  z-index: 5;
}

.comparison-table th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 2px solid var(--border-primary);
  white-space: nowrap;
}

.comparison-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-secondary);
  vertical-align: top;
}

.comparison-table tbody tr:hover {
  background: var(--bg-secondary);
}

.comparison-table .formula-cell {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-primary);
  margin-bottom: var(--sp-6);
  gap: var(--sp-1);
  overflow-x: auto;
}

.tab-btn {
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-link);
  border-bottom-color: var(--text-link);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* --- Tag Pills --- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  list-style: none;
  padding: 0;
}

.tag {
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-radius: 999px;
  border: 1px solid var(--border-primary);
}

/* --- Prerequisite Links --- */
.prerequisites {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-bottom: var(--sp-4);
}

.prerequisites .label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  font-weight: 500;
}

.prereq-link {
  font-size: var(--text-xs);
  padding: var(--sp-1) var(--sp-2);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-link);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.prereq-link:hover {
  background: var(--bg-tertiary);
  text-decoration: none;
}

/* --- Scroll to top button --- */
.scroll-top-btn {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  font-size: var(--text-lg);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  z-index: 50;
}

.scroll-top-btn.visible {
  display: flex;
}

.scroll-top-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
