/* ===== SORTING VISUALIZER ===== */

.viz-controls {
  margin-bottom: 20px;
}

.viz-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.range-group {
  display: flex;
  flex-direction: column;
}

.form-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  margin-top: 8px;
}

.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.form-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.viz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.viz-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 320px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  overflow: hidden;
}

.viz-bar {
  flex: 1;
  min-width: 2px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: height 0.05s ease, background 0.15s ease;
}

.viz-bar.compare {
  background: var(--warning);
}

.viz-bar.swap {
  background: var(--danger);
}

.viz-bar.sorted {
  background: var(--success);
}

.viz-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend-bar {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  display: inline-block;
}

.legend-bar.default { background: var(--primary); }
.legend-bar.compare { background: var(--warning); }
.legend-bar.swap { background: var(--danger); }
.legend-bar.sorted { background: var(--success); }

.viz-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  text-align: center;
}

/* Algorithm cards */
.algo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.algo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.algo-card:hover {
  box-shadow: var(--shadow-hover);
}

.algo-card h3 {
  font-size: 1.1rem;
  margin-bottom: 8px;
  color: var(--text);
}

.algo-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.algo-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0f4ff;
  color: var(--primary-dark);
}

.algo-desc {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.algo-complexity {
  font-size: 0.82rem;
  color: var(--muted);
}

.algo-complexity code {
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  background: rgba(102,126,234,0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

.pseudo-details {
  margin-top: 12px;
}

.pseudo-summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  user-select: none;
}

.pseudo-summary:hover {
  text-decoration: underline;
}

.pseudo-block {
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
  overflow-x: auto;
  color: var(--text);
}

@media (max-width: 768px) {
  .viz-container {
    height: 260px;
    padding: 10px;
  }
}
