/* Palette douce, contrastée et ludique pour enfants */
:root {
  --bg: #fff7ef;
  --bg-top: #fff0e6;
  --text: #1f1f1f;
  --primary: #ff7f50;      /* corail */
  --primary-700: #ff6a34;
  --accent: #4dabff;       /* bleu ciel */
  --accent-700: #2d8be6;
  --success: #2ecc71;
  --danger: #e74c3c;
  --card: #ffffff;
  --chip: #ffe6db;
  --chip-active: #ffd9cc;
  --border: #e8e8e8;
  --focus: #4dabff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Fredoka", "Baloo 2", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: linear-gradient(180deg, var(--bg-top), var(--bg));
  color: var(--text);
  font-size: 18px;
}

.hidden { display: none !important; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
}
.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.18);
}

.mode-toggle { display: flex; gap: 10px; }
.toggle-btn {
  border: 1px solid rgba(255,255,255,0.5);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.95);
  color: #2b2b2b;
  font-weight: 700;
  cursor: pointer;
}
.toggle-btn.active {
  background: #ffe8e0;
  color: var(--primary-700);
  border-color: #ffb39b;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.categories { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--chip);
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
  font-weight: 700;
}
.chip.active {
  background: var(--chip-active);
  border-color: var(--primary);
}

.settings { display: flex; align-items: center; gap: 12px; }
#voiceRate { width: 160px; }
#muteBtn {
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

main { padding: 6px 20px 20px; }
.view.hidden { display: none; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.visual { display: flex; align-items: center; justify-content: center; min-height: 110px; }
.swatch {
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.06);
  background: var(--swatch, #ddd);
}
.emoji { font-size: 68px; line-height: 1; }
.word { font-size: 22px; font-weight: 700; margin-top: 12px; letter-spacing: 0.4px; }
.actions { margin-top: 10px; }
.btn {
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary);
  color: white; font-weight: 700; cursor: pointer;
}
.btn.secondary { background: var(--accent); }
.btn.listen::before { content: "🔈"; margin-right: 8px; }
.btn:active { transform: translateY(1px); }

.quiz-header { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 700; }
.quiz-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.badge { background: var(--chip); border: 1px solid var(--border); border-radius: 999px; padding: 6px 10px; font-weight: 700; }
.progress-bar { width: 100%; height: 10px; background: #eee; border-radius: 999px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border); }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 200ms ease; }
.quiz-prompt {
  display: flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px; min-height: 160px; margin-bottom: 12px;
}
.quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.quiz-option {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
}
.quiz-option .label { margin-top: 8px; font-size: 16px; }
.visual-mini { display: flex; align-items: center; justify-content: center; min-height: 80px; }
.visual-mini .swatch { width: 60px; height: 60px; }
.visual-mini .emoji { font-size: 48px; line-height: 1; }
.quiz-option.correct { border-color: var(--success); box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2); }
.quiz-option.wrong { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.15); }
.quiz-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* Boutons de contrôle du quiz */
.quiz-actions button {
  min-width: 160px;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  cursor: pointer;
}
.quiz-actions button:active { transform: translateY(1px); }
#quizStart { background: var(--primary); }
#quizNext { background: var(--accent); }
#quizRestart { background: var(--primary-700); }

@keyframes pulseCorrect { from { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.35);} to { box-shadow: 0 0 0 12px rgba(46, 204, 113, 0);} }
.quiz-option.correct { animation: pulseCorrect 600ms ease-out; }

.app-footer {
  padding: 18px 20px;
  text-align: center;
  color: #666;
}

@media (min-width: 900px) {
  .app-header h1 { font-size: 1.8rem; }
}

/* Accessibilité et confort */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
}
/* Overlay de feedback ✔/✖ */
.feedback-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1000;
}
.feedback-icon {
  position: relative;
  font-size: 110px;
  line-height: 1;
  text-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.feedback-overlay.ok .feedback-icon { color: var(--success); }
.feedback-overlay.ko .feedback-icon { color: var(--danger); }
.feedback-overlay.ok .feedback-icon::after,
.feedback-overlay.ko .feedback-icon::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 120px; height: 120px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 8px solid currentColor;
  animation: ringPulse 1000ms ease-out forwards;
  opacity: 0.9;
}
@keyframes ringPulse {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0.95; }
  to   { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}