/* ============================================================
   STATS_style.css — page « Statistiques à deux variables »
   Quiz interactifs + activité Canicule à Lisieux
   Dépend de styles.css du site (variables CSS : --brand, --line…)

   Familles : .quiz-* (structure quiz) · réponses (.option, .qcm-*,
   .drag-*) · .act-* (activité) · .data-* (tableaux) · responsive
   ============================================================ */

/* ============================================================
   QUIZ — structure commune
   .quiz > .quiz-instruction? + .quiz-card + .quiz-score
   ============================================================ */
.quiz-card,
.quiz-score {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.quiz-score {
  text-align: center;
}

.quiz-instruction {
  display: block;
  margin-bottom: 1.25rem;
  color: var(--ink);
}

/* Pastilles de progression */
.progress {
  display: flex;
  gap: 6px;
  margin: 0 0 1.125rem;
  flex-wrap: wrap;
}

.dot-q {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  transition: all 0.2s ease;
}

.dot-q.current {
  background: var(--brand);
  transform: scale(1.25);
}

.dot-q.ok {
  background: var(--ok);
}

.dot-q.bad {
  background: var(--error);
}

/* Énoncé et aide */
.question-text {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--ink);
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

/* Feedback — commun à toutes les interactions */
.feedback {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  display: none;
}

.feedback.ok {
  display: block;
  background: #dcfce7;
  color: #166534;
}

.feedback.bad {
  display: block;
  background: #fee2e2;
  color: #991b1b;
}

.dark-mode .feedback.ok {
  background: rgba(22, 163, 74, 0.15);
  color: #4ade80;
}

.dark-mode .feedback.bad {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Boutons */
.quiz-btn {
  margin-top: 1.25rem;
  padding: 0.5rem 1.25rem;
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.quiz-btn:hover:not(:disabled) {
  background: #0d5bd6;
}

.dark-mode .quiz-btn:hover:not(:disabled) {
  background: #2563eb;
}

.quiz-btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: default;
}

.btn-valider {
  margin-top: 1rem;
}

/* Écran de score */
.quiz-score .emoji {
  font-size: 3rem;
}

.quiz-score .value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--brand);
  margin: 0.5rem 0;
}

.quiz-score .subtitle {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 1rem;
  line-height: 1.6;
}

.hidden {
  display: none;
}

/* ============================================================
   FORMULES MATHÉMATIQUES (KaTeX / LaTeX)
   ============================================================ */
.katex {
  font-size: 1.05em;
}

/* ============================================================
   RÉPONSES — type "image"
   ============================================================ */
.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  border: 2px solid var(--line);
  border-radius: var(--border-radius-md);
  background: var(--card);
  cursor: pointer;
  padding: 0.75rem;
  font: inherit;
  text-align: center;
  transition:
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.option:hover:not(:disabled) {
  border-color: var(--brand);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.option:disabled {
  cursor: default;
  opacity: 0.9;
}

.option img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--border-radius-sm);
}

.option .label {
  font-weight: 600;
  font-size: 0.85rem;
}

.option .mark {
  font-size: 1.25rem;
  line-height: 1;
}

/* États ok/ko — partagés par .option, .qcm-item et .drag-target */
.option.correct,
.qcm-item.correct,
.drag-target.correct {
  border-color: var(--ok);
  background: rgba(22, 163, 74, 0.08);
}

.option.wrong,
.qcm-item.wrong,
.drag-target.wrong {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.08);
}

.option.correct .mark {
  color: var(--ok);
}

.option.wrong .mark {
  color: var(--error);
}

/* Illustration (question vrai/faux) */
.illustration {
  display: block;
  max-width: 100%;
  max-height: 240px;
  margin: 0 auto 1rem;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--line);
}

/* ============================================================
   RÉPONSES — type "qcm" (unique ou multiple)
   ============================================================ */
.qcm-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.qcm-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--border-radius-sm);
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  background: var(--card);
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast);
  font: inherit;
  text-align: left;
  color: var(--ink);
}

.qcm-item:hover:not(:disabled) {
  border-color: var(--brand);
  background: var(--soft);
}

.qcm-item:disabled {
  cursor: default;
}

.qcm-item .box {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid #94a3b8;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
  font-weight: 800;
}

.qcm-item.checked .box {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.qcm-item.checked.correct .box {
  background: var(--ok);
  border-color: var(--ok);
}

/* ============================================================
   RÉPONSES — type "drag" (glisser PC / tap-tap mobile)
   ============================================================ */
.drag-bank,
.drag-targets {
  overscroll-behavior: contain;
  touch-action: manipulation;
}

.drag-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.drag-chip {
  display: inline-block;
  padding: 0.4rem 0.875rem;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: grab;
  user-select: none;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    box-shadow var(--transition-fast);
}

.drag-chip:hover,
.drag-chip.selected {
  border-color: var(--brand);
}

.drag-chip.selected {
  background: rgba(15, 98, 254, 0.1);
  box-shadow: var(--shadow-md);
}

.drag-chip.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.drag-targets {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.drag-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--border-radius-sm);
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast);
}

.drag-target .drag-target-name {
  font-size: 0.95rem;
}

.drag-target .drag-slot {
  min-width: 110px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--border-radius-sm);
  background: var(--soft);
}

.drag-target.filled .drag-slot {
  background: transparent;
  color: var(--ink);
}

/* ============================================================
   ACTIVITÉ — contenu
   ============================================================ */
.act-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--border-radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.act-text {
  font-size: 0.95rem;
  color: var(--ink);
  margin: 0 0 1rem;
  line-height: 1.6;
}

.act-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 1.5rem 0 0.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.act-list {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.8;
}

/* Encadré « problématique » */
.act-question {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--border-radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: #1e40af;
  font-weight: 600;
  text-align: center;
}

.dark-mode .act-question {
  background: rgba(59, 130, 246, 0.12);
  border-color: #1e40af;
  color: #93c5fd;
}

/* ============================================================
   TABLEAUX DE DONNÉES
   ============================================================ */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 0 1rem;
}

.table-scroll .data-table {
  margin: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 0.5rem 0.75rem;
  text-align: center;
}

.data-table th {
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.dark-mode .data-table th {
  background: #1e293b;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .options {
    grid-template-columns: repeat(2, 1fr);
  }
  .quiz-card,
  .quiz-score,
  .act-card {
    padding: 1rem;
  }
  .question-text {
    font-size: 1.05rem;
  }
}

@media (max-width: 480px) {
  .options {
    grid-template-columns: 1fr;
  }
  .quiz-btn {
    width: 100%;
  }
  .drag-target {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .drag-target .drag-slot {
    min-width: 0;
    width: 100%;
  }
  .drag-chip {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }
  .qcm-item {
    padding: 0.875rem 1rem;
  }
  .dot-q {
    width: 14px;
    height: 14px;
  }
}

/* ============================================================
   FORMULES MATHÉMATIQUES (KaTeX / LaTeX)
   ============================================================ */
.katex {
  font-size: 1.05em;
}

/* ============================================================
   EXERCICES D'APPLICATION
   ============================================================ */
/* Numéro de question mis en valeur */
.exo-question {
  font-weight: 600;
}

/* Emplacement d'image : si le fichier manque, cadre pointillé visible */
.figure {
  margin: 0 0 1.25rem;
  text-align: center;
}

.figure img {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--line);
  background: var(--soft);
}

/* Placeholder quand l'image n'est pas encore en ligne (géré par le JS) */
.figure.missing img {
  display: none;
}

.figure.missing::before {
  content: "🖼️ Emplacement image manquante";
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 2px dashed var(--line);
  border-radius: var(--border-radius-md);
  background: var(--soft);
  color: var(--muted);
  font-size: 0.9rem;
}

.figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

/* Image d'illustration « ci-contre » : flottante sur grand écran */
.figure-side {
  float: right;
  max-width: 260px;
  margin: 0 0 1rem 1.25rem;
}

@media (max-width: 768px) {
  .figure-side {
    float: none;
    max-width: 100%;
    margin: 0 0 1.25rem;
  }
}

/* Correction repliable */
.correction {
  margin: 0 0 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--border-radius-sm);
  background: var(--soft);
}

.correction summary {
  cursor: pointer;
  padding: 0.625rem 0.875rem;
  font-weight: 700;
  color: var(--ok);
  user-select: none;
}

.correction summary:hover {
  text-decoration: underline;
}

.correction[open] summary {
  border-bottom: 1px solid var(--line);
}

/* Contenu de la correction */
.correction .act-text,
.correction .figure,
.correction .table-scroll {
  margin: 0.875rem;
}

.dark-mode .correction {
  background: rgba(22, 163, 74, 0.06);
}