/* ===================== LAYOUT / WRAPPER ===================== */

.quiz-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* ===================== SETUP (CONFIG) ===================== */

.quiz-setup {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
  margin-bottom: 20px;
}

.quiz-setup h3 {
  margin-top: 0;
  color: var(--primary-color);
}

/* Field groups */
.setup-group {
  margin-bottom: 20px;
}

.setup-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: var(--text-color);
}

/* Checkbox list with virtual scroll window */
.checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  background: var(--bg-color);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
}

/* Slight baseline alignment nudge for text beside checkbox */
.checkbox-item label {
  transform: translateY(3.5px);
}

.checkbox-item input[type="checkbox"] {
  accent-color: var(--primary-color);
}

.checkbox-item img {
  height: 50px;
  border: 1px solid #ccc;
  border-radius: 2px;
  background: #fff;
}

/* Numeric input used in setup */
.number-input {
  font-family: "HornetDisplay", sans-serif;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--card-text);
  width: 100px;
}

/* ===================== GAME (ACTIVE QUESTION) ===================== */

.quiz-game {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
  text-align: center;
  display: none; /* toggled by JS */
}

.question-counter {
  font-size: 1.1em;
  margin-bottom: 20px;
  color: var(--highlight);
}

/* Prompted symbol / image pair */
.symbol-display {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.symbol-display img {
  height: 80px;
  border: 2px solid var(--primary-color);
  border-radius: 4px;
  background: #fff;
  padding: 4px;
}

/* Optional audio control row */
.audio-controls {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ===================== ANSWER CHOICES ===================== */

/* Two-column grid by default; stacks on small screens */
.answer-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin: 20px auto;
  max-width: 500px;
}

/* Answer card */
.answer-choice {
  position: relative; /* anchor for tooltip */
  padding: 12px 16px;
  border: 2px solid #ccc;
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--card-text);
  cursor: pointer;
  font-family: "HornetDisplay", sans-serif;
  font-size: 1em;
  transition: all var(--transition-fast);
}

.answer-choice:hover {
  border-color: var(--primary-color);
  background: rgba(33, 150, 243, 0.1);
}

/* States — keep base consistent; colorize via modifiers */
.answer-choice.correct {
  border-color: var(--success-color);
  background: rgba(76, 175, 80, 0.2);
  color: var(--success-color);
  font-weight: bold;
}

/* Primary vs Secondary (alternative) correct answers */
.answer-choice.correct.primary-correct {
  /* same palette as .correct for emphasis continuity */
}

.answer-choice.correct.primary-correct:hover {
  background: rgba(76, 175, 80, 0.2);
}

.answer-choice.correct.secondary-correct {
  border-color: var(--success-color-2);
  background: rgba(41, 128, 185, 0.2);
  color: var(--success-color-2);
}

.answer-choice.correct.secondary-correct:hover {
  background: rgba(41, 128, 185, 0.2);
}

/* Icon and/or text indicator for alternative answers */
/* .answer-choice.correct.secondary-correct::after {
  content: " ✓";
  font-weight: bold;
  margin-left: 5px;
}

.answer-choice.correct.primary-correct::after {
  content: " ✓✓";
  font-weight: bold;
  margin-left: 5px;
} */

.answer-choice.incorrect {
  border-color: var(--danger-color);
  background: rgba(244, 67, 54, 0.2);
  color: var(--danger-color);
}

.answer-choice.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Inline tooltip for answer reasoning or hints */
.answer-choice-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.9em;
  z-index: 1000;
  width: max-content;
  max-width: 300px;
  text-align: left;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.answer-choice-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

.answer-choice:hover .answer-choice-tooltip {
  visibility: visible;
  opacity: 1;
}

/* ===================== RESULTS ===================== */

.quiz-results {
  background: var(--card-bg);
  padding: 30px;
  border-radius: 10px;
  box-shadow: var(--box-shadow);
  text-align: center;
  display: none; /* toggled by JS */
}

.score-display {
  font-size: 2em;
  margin: 20px 0;
  color: var(--primary-color);
}

.results-breakdown {
  margin: 20px 0;
  text-align: left;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px;
  margin: 5px 0;
  border-radius: 5px;
}

.result-item.correct {
  background: rgba(76, 175, 80, 0.1);
  border-left: 4px solid var(--success-color);
}

.result-item.correct.primary-correct {
  /* same treatment as .correct */
}

.result-item.correct.secondary-correct {
  background: rgba(41, 128, 185, 0.1);
  border-left: 4px solid var(--success-color-2);
}

.result-item.incorrect {
  background: rgba(244, 67, 54, 0.1);
  border-left: 4px solid var(--danger-color);
}

.result-item img {
  height: 32px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 2px;
}

/* ===================== GENERIC TOOLTIP (ALT ANSWERS, ETC.) ===================== */

/* Use when you need a tooltip outside of .answer-choice cards */
.question-desc-tooltip,
.alt-desc-tooltip,
.answer-desc-tooltip,
.alternative-answer-tooltip {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted currentColor;
}

.question-desc-tooltip::after,
.alt-desc-tooltip::after,
.answer-desc-tooltip::after,
.alternative-answer-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.85em;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  width: max-content;
  max-width: 300px;
  white-space: normal;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s, visibility 0.3s;
}

.question-desc-tooltip::before,
.alt-desc-tooltip::before,
.answer-desc-tooltip::before,
.alternative-answer-tooltip::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(1px);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.question-desc-tooltip:hover::after,
.question-desc-tooltip:hover::before,
.alt-desc-tooltip:hover::after,
.alt-desc-tooltip:hover::before,
.answer-desc-tooltip:hover::after,
.answer-desc-tooltip:hover::before,
.alternative-answer-tooltip:hover::after,
.alternative-answer-tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Dark theme adjustment */
[data-theme="dark"] .question-desc-tooltip::after,
.alt-desc-tooltip::after,
.answer-desc-tooltip::after,
.alternative-answer-tooltip::after {
  color: var(--text-color);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ===================== CONTROLS & HINTS ===================== */

.next-question-btn {
  margin-top: 20px;
  margin-right: 10px;
  padding: 12px 24px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: "HornetDisplay", sans-serif;
  font-size: 1em;
  cursor: pointer;
  opacity: 0; /* hidden by default */
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.next-question-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.next-question-btn:hover {
  background: #1976d2;
}

.table-hint {
  background: rgba(33, 150, 243, 0.1);
  border: 1px solid rgba(33, 150, 243, 0.3);
  border-radius: 5px;
  padding: 10px;
  text-align: center;
  font-style: italic;
}

[data-theme="dark"] .table-hint {
  background: rgba(0, 255, 231, 0.1);
  border-color: rgba(0, 255, 231, 0.3);
}

/* ===================== TRANSITIONS / VIEW STATES ===================== */

/* When swapping between setup/game/results, we animate opacity & Y */
.quiz-setup,
.quiz-game,
.quiz-results {
  opacity: 1;
  transform: translateY(0);
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.fade-out {
  opacity: 0 !important;
  transform: translateY(20px) !important;
  pointer-events: none;
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 768px) {
  .answer-choices {
    grid-template-columns: 1fr; /* stack answers */
  }

  .answer-choice-tooltip {
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8em;
    padding: 8px 10px;
    max-width: 240px;
    white-space: normal;
  }

  .answer-choice-tooltip::after {
    left: 50%;
    margin-left: -5px;
  }

  .audio-controls {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 600px) {
  .checkbox-group {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  /* Fine-tune standalone tooltip on narrow screens */
  .alternative-answer-tooltip::after {
    max-width: 250px;
    font-size: 0.8em;
    left: 0;
    transform: none;
  }

  .alternative-answer-tooltip::before {
    left: 20px;
    transform: translateX(-50%) translateY(1px);
  }
}
