/* ---------- Question Bank ---------- */
.question-bank {
  background: var(--color-bg);
  padding: 40px 0 72px;
}

/* Breadcrumb */
.qb-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
  font-size: 14px;
  font-weight: 800;
}

.qb-crumb {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  color: var(--color-secondary);
}

.qb-crumb:hover {
  text-decoration: underline;
}

.qb-crumb.is-current {
  color: var(--color-text-light);
  cursor: default;
}

.qb-crumb.is-current:hover {
  text-decoration: none;
}

.qb-crumb-sep {
  color: var(--color-text-light);
  font-weight: 800;
}

/* Domain tabs */
.qb-domain-tabs {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.qb-domain-tabs .btn {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
}

/* Topic cards */
.qb-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.qb-topic-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--color-bg);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 2px 0 var(--color-border);
}

.qb-topic-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
}

.qb-topic-card:active {
  transform: translateY(0);
}

.qb-topic-icon {
  flex: none;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--color-bg-soft);
  border-radius: 14px;
}

.qb-topic-body {
  flex: 1;
  min-width: 0;
}

.qb-topic-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-heading);
}

.qb-topic-meta {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-light);
}

.qb-topic-arrow {
  flex: none;
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
  transition: transform 0.15s ease;
}

.qb-topic-card:hover .qb-topic-arrow {
  transform: translateX(4px);
}

/* Level cards */
.qb-levels-intro {
  text-align: center;
  color: var(--color-text-light);
  font-weight: 700;
  margin-bottom: 24px;
}

.qb-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.qb-level-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--color-bg);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 2px 0 var(--color-border);
}

.qb-level-card:hover {
  transform: translateY(-3px);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
}

.qb-level-card:active {
  transform: translateY(0);
}

.qb-level-icon-box {
  flex: none;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--color-bg-soft);
  border-radius: 14px;
}

.qb-level-body {
  flex: 1;
  min-width: 0;
}

.qb-level-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--color-heading);
}

.qb-level-meta {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-light);
}

.qb-level-arrow {
  flex: none;
  font-size: 22px;
  font-weight: 800;
  color: var(--color-primary);
  transition: transform 0.15s ease;
}

.qb-level-card:hover .qb-level-arrow {
  transform: translateX(4px);
}

/* Quiz */
.qb-quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 24px;
  align-items: start;
  max-width: 1060px;
  margin: 0 auto;
}

@media (max-width: 860px) {
  .qb-quiz-layout {
    grid-template-columns: 1fr;
  }
}

.qb-quiz-main {
  min-width: 0;
}

.qb-quiz-sidebar {
  position: sticky;
  top: 90px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.qb-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--color-bg-soft);
}

.qb-sidebar-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-heading);
  margin: 0;
}

.qb-sidebar-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--color-bg-soft);
  color: var(--color-text-light);
}

.qb-sidebar-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 11px;
  font-weight: 800;
  color: var(--color-text-light);
}

.qb-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qb-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.qb-legend-dot.is-current { background: var(--color-primary); box-shadow: 0 0 0 2px rgba(88, 204, 2, 0.3); }
.qb-legend-dot.is-correct { background: var(--color-primary); }
.qb-legend-dot.is-wrong { background: var(--color-danger); }

.qb-sidebar-scroll {
  max-height: 440px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom scrollbar */
.qb-sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}
.qb-sidebar-scroll::-webkit-scrollbar-track {
  background: var(--color-bg-soft);
  border-radius: 999px;
}
.qb-sidebar-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 999px;
}
.qb-sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

.qb-palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.qb-palette-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  width: 100%;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  position: relative;
}

.qb-palette-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-soft);
  transform: translateY(-2px);
}

.qb-palette-btn.is-current {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.12);
  color: var(--color-primary-dark);
  box-shadow: 0 0 0 2px var(--color-primary);
  font-weight: 900;
}

.qb-palette-btn.is-correct {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.2);
  color: var(--color-primary-dark);
}

.qb-palette-btn.is-wrong {
  border-color: var(--color-danger);
  background: rgba(255, 75, 75, 0.18);
  color: var(--color-danger);
}

.qb-reattempt-btn {
  border-color: var(--color-border);
  color: var(--color-text);
}

.qb-reattempt-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-bg-soft);
}

.qb-quiz-progress {
  margin-bottom: 18px;
}

.qb-question-count {
  font-size: 13px;
  font-weight: 800;
  color: var(--color-text-light);
  margin-bottom: 8px;
}

.qb-progress-bar {
  height: 12px;
  background: var(--color-bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.qb-progress-fill {
  height: 100%;
  width: 0;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.qb-question-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.qb-question-tag {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary-dark);
  margin-bottom: 10px;
}

.qb-question-text {
  margin: 0 0 22px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--color-heading);
}

.qb-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.qb-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 2px solid var(--color-border);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--color-bg);
  cursor: pointer;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}

.qb-option:hover {
  background: var(--color-bg-soft);
  border-color: var(--color-primary);
}

.qb-option-key {
  flex: none;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  font-weight: 800;
  color: var(--color-primary-dark);
  background: var(--color-bg);
}

.qb-option.selected {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.08);
  box-shadow: 0 2px 0 var(--color-primary);
}

.qb-option.selected .qb-option-key {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.qb-option.locked {
  cursor: default;
}

.qb-option.dim {
  opacity: 0.45;
}

.qb-option.correct {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.15);
}

.qb-option.correct .qb-option-key {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.qb-option.wrong {
  border-color: var(--color-danger);
  background: rgba(255, 75, 75, 0.12);
}

.qb-option.wrong .qb-option-key {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

.qb-feedback {
  min-height: 24px;
  margin-top: 18px;
  font-size: 16px;
  font-weight: 800;
}

.qb-feedback.is-correct {
  color: var(--color-primary-dark);
}

.qb-feedback.is-wrong {
  color: var(--color-danger);
}

.qb-quiz-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

/* Summary */
.qb-summary {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  padding: 36px 28px;
  box-shadow: var(--shadow);
}

.qb-summary-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.qb-summary-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 900;
  color: var(--color-heading);
}

.qb-summary-score {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 800;
  color: var(--color-text);
}

.qb-summary-upsell {
  margin: 0 0 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-light);
}

.qb-summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Empty / skeletons */
.qb-empty {
  text-align: center;
  padding: 48px 16px;
}

.qb-empty-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--color-heading);
  margin: 0 0 8px;
}

.qb-empty-text {
  color: var(--color-text-light);
  margin: 0 0 18px;
}

.qb-skeleton {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  min-height: 92px;
  background: linear-gradient(90deg, var(--skeleton-a), var(--skeleton-b));
  animation: qb-pulse 1.2s ease-in-out infinite;
}

@keyframes qb-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* Wrong questions card & tags */
.qb-wrong-card {
  border-color: rgba(255, 75, 75, 0.4);
}

.qb-wrong-card:hover {
  border-color: var(--color-danger);
}

.qb-wrong-icon-box {
  background: rgba(255, 75, 75, 0.1);
}

.qb-wrong-card:hover .qb-level-title {
  color: var(--color-danger);
}

.qb-wrong-card .qb-level-arrow {
  color: var(--color-danger);
}

.qb-tag-wrong {
  color: var(--color-danger) !important;
  margin-top: 8px;
}

/* Spot the Bug (bugfind) styles */
.qb-bugfind-card {
  border-color: rgba(255, 179, 0, 0.4);
}

.qb-bugfind-card:hover {
  border-color: #ffb300;
}

.qb-bugfind-icon-box {
  background: rgba(255, 179, 0, 0.12);
}

.qb-bugfind-card:hover .qb-level-title {
  color: #ffb300;
}

.qb-bugfind-code {
  background: #1e1e2e;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
  margin: 16px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.qb-code-line {
  display: flex;
  align-items: stretch;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
  border-left: 4px solid transparent;
}

.qb-code-line:hover {
  background: rgba(255, 255, 255, 0.08);
}

.qb-line-num {
  flex: none;
  width: 44px;
  padding: 8px 12px;
  text-align: right;
  color: #6c7086;
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.qb-line-text {
  flex: 1;
  padding: 8px 16px;
  color: #cdd6f4;
  white-space: pre-wrap;
  word-break: break-word;
}

.qb-code-line.is-selected {
  background: rgba(88, 204, 2, 0.15) !important;
  border-left-color: var(--color-primary) !important;
}

.qb-code-line.is-selected .qb-line-num {
  color: var(--color-primary);
  background: rgba(88, 204, 2, 0.25);
}

.qb-code-line.is-correct {
  background: rgba(88, 204, 2, 0.25) !important;
  border-left-color: var(--color-primary) !important;
}

.qb-code-line.is-correct .qb-line-num {
  color: #fff;
  background: var(--color-primary);
}

.qb-code-line.is-correct .qb-line-text {
  color: #a6e3a1;
  font-weight: 700;
}

.qb-code-line.is-wrong {
  background: rgba(255, 75, 75, 0.25) !important;
  border-left-color: var(--color-danger) !important;
}

.qb-code-line.is-wrong .qb-line-num {
  color: #fff;
  background: var(--color-danger);
}

.qb-code-line.is-wrong .qb-line-text {
  color: #f38ba8;
  font-weight: 700;
}

.qb-code-line.is-dim {
  opacity: 0.4;
}

.qb-code-line.is-locked {
  cursor: default;
}

/* ---------- Code Reordering (Parson's Problems) ---------- */
.qb-reorder-card {
  background: var(--color-card-bg);
  border: 2px solid #a6e3a1;
}

.qb-reorder-icon-box {
  background: rgba(166, 227, 161, 0.15);
  color: #a6e3a1;
}

.qb-reorder-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #1e1e2e;
  border: 2px solid #313244;
  border-radius: var(--radius-lg);
  padding: 16px;
  font-family: var(--font-mono, monospace);
  margin-top: 16px;
  user-select: none;
}

.qb-reorder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #181825;
  border: 2px solid #45475a;
  border-radius: var(--radius-md, 8px);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.qb-reorder-item:hover {
  border-color: #89b4fa;
  background: #1e1e2e;
}

.qb-reorder-item.is-selected {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.15);
  box-shadow: 0 0 10px rgba(88, 204, 2, 0.2);
}

.qb-reorder-item.is-correct {
  border-color: var(--color-primary);
  background: rgba(88, 204, 2, 0.2);
  cursor: default;
}

.qb-reorder-item.is-correct .qb-reorder-num {
  background: var(--color-primary);
  color: #fff;
}

.qb-reorder-item.is-wrong {
  border-color: var(--color-danger);
  background: rgba(255, 75, 75, 0.2);
  cursor: default;
}

.qb-reorder-item.is-wrong .qb-reorder-num {
  background: var(--color-danger);
  color: #fff;
}

.qb-reorder-num {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #313244;
  color: #cdd6f4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font);
}

.qb-reorder-text {
  flex: 1;
  color: #cdd6f4;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.qb-reorder-controls {
  flex: none;
  display: flex;
  gap: 4px;
}

.qb-reorder-btn {
  background: #313244;
  border: 1px solid #45475a;
  color: #cdd6f4;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.qb-reorder-btn:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.qb-reorder-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Output Question Styles */
.qb-output-card {
  border-color: rgba(249, 226, 175, 0.4);
}

.qb-output-card:hover {
  border-color: #f9e2af;
  background: rgba(249, 226, 175, 0.08);
  box-shadow: 0 4px 16px rgba(249, 226, 175, 0.15);
}

.qb-output-icon-box {
  background: rgba(249, 226, 175, 0.15);
  border-color: rgba(249, 226, 175, 0.4);
}

.qb-output-code {
  background: #1e1e2e;
  border: 1px solid #313244;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  font-family: var(--font-mono, monospace);
  font-size: 14px;
  color: #cdd6f4;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Performance & Mobile Responsiveness Optimizations */
.qb-topic-card,
.qb-level-card,
.qb-palette-btn,
.qb-code-line,
.qb-reorder-item {
  transform: translateZ(0);
  backface-visibility: hidden;
}

@media (max-width: 768px) {
  .qb-quiz-layout {
    flex-direction: column;
    gap: 20px;
  }
  .qb-quiz-sidebar {
    width: 100%;
    max-height: 240px;
  }
  .qb-palette-grid {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  }
  .qb-topic-grid,
  .qb-level-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .question-bank {
    padding: 20px 0 48px;
  }
  .qb-question-text {
    font-size: 18px;
  }
  .qb-code-block,
  .qb-bugfind-code,
  .qb-output-code {
    font-size: 13px;
    padding: 12px;
  }
  .qb-palette-btn {
    height: 38px;
    font-size: 13px;
  }
}
