/* =========================================================
   PETIT QUIZ CURIEUX — feuille de style
   Palette : teal profond #1d4854, corail #ff8a5c, soleil #ffd166,
             vert réussite #3ecf8e, rouge doux #f2545b, crème #fdf8ec
   ========================================================= */

:root {
  --teal-deep:   #1d4854;
  --teal-mid:    #2c6373;
  --teal-light:  #4a8a99;
  --cream:       #fdf8ec;
  --coral:       #ff8a5c;
  --coral-dark:  #f2703a;
  --sun:         #ffd166;
  --good:        #3ecf8e;
  --good-dark:   #1f9e68;
  --bad:         #f2545b;
  --bad-dark:    #d13640;
  --ink:         #17343d;

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-soft: 0 10px 24px rgba(15, 40, 46, 0.25);
  --shadow-pop:  0 4px 0 rgba(0, 0, 0, 0.15);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  color: var(--ink);
  background-color: var(--teal-deep);
  background-image:
    /* ---------- linear-gradient(180deg, rgba(15, 35, 41, 0.55), rgba(15, 35, 41, 0.75)), ---------- */
    url('images/image-fond.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Conteneur du jeu ---------- */

.game {
  width: 100%;
  max-width: 640px;
}

.screen {
  background: var(--cream);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  animation: screen-in 0.4s ease both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Écran de chargement ---------- */

.loading-screen[hidden] { display: none; }

.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 420px;
  padding: 34px 24px;
  text-align: center;
}

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 6px solid rgba(29, 72, 84, 0.15);
  border-top-color: var(--coral);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-label {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--teal-deep);
  margin: 0;
}

.loading-track {
  width: 100%;
  max-width: 320px;
  height: 14px;
}

.loading-percent {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  color: var(--teal-mid);
  margin: 0;
}

/* ---------- Écran d'accueil ---------- */

.start-screen[hidden] { display: none; }

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 520px;
  padding: 34px 24px 24px;
  gap: 26px;
}

.start-title {
  display: block;
  width: 300px;
  max-width: 100%;
  height: 210px;
  object-fit: contain;
}

.play-btn {
  border: none;
  background: var(--coral);
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 1.7rem;
  letter-spacing: 0.04em;
  padding: 18px 80px;
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--coral-dark);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.play-btn:hover { transform: translateY(-2px); }

.play-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--coral-dark);
}

.start-footer {
  width: 100%;
  margin-top: auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.start-image {
  width: 145px;
  height: 104px;
  object-fit: cover;
 border-radius: var(--radius-md); 
   /* ---------- box-shadow: var(--shadow-pop); ---------- */
  flex: 0 0 auto;
}

.start-text {
  width: 250px;
  max-width: 100%;
  height: 70px;
    /* ----------box-sizing: border-box;
  background: #fff; ---------- */
    /* ---------- border: 3px solid var(--teal-deep);
  border-radius: var(--radius-md);   ---------- */
  padding: 16px 18px;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
  overflow: auto;
  flex: 0 0 auto;
}

@media (max-width: 560px) {
  .start-footer { justify-content: center; }
  .start-image { width: 145px; height: 104px; }
  .start-text { width: 100%; height: auto; min-height: 140px; }
}

/* ---------- Rangée de pastilles (une par question) ---------- */

.dots-row[hidden] { display: none; }

.dots-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  background: var(--teal-deep);
  padding: 10px 16px;
  border-radius: 999px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}

.dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d9d9d9;
  transition: background-color 0.25s ease, transform 0.2s ease;
}

.dot.correct { background: var(--good); }
.dot.wrong   { background: var(--bad); }

/* ---------- Barre du haut ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--teal-deep);
  color: var(--cream);
}

.icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--teal-mid);
  color: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover { background: var(--teal-light); }
.icon-btn:active { transform: scale(0.9); }

.icon-btn.is-playing {
  background: var(--coral);
  animation: pulse-ring 0.9s ease infinite;
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(255, 138, 92, 0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(255, 138, 92, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 138, 92, 0); }
}

.progress-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.counter {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 0.02em;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sun), var(--coral));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- Corps du quiz ---------- */

.quiz-body {
  padding: 22px 22px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.question-bubble {
  position: relative;
  width: 100%;
  background: #fff;
  border: 3px solid var(--teal-deep);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  text-align: center;
}

.question-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  border-width: 12px 10px 0 10px;
  border-style: solid;
  border-color: var(--teal-deep) transparent transparent transparent;
}

.question-bubble::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  border-width: 10px 8px 0 8px;
  border-style: solid;
  border-color: #fff transparent transparent transparent;
  z-index: 1;
}

.mic-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  margin-right: 8px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mic-dot.is-active {
  opacity: 1;
  animation: pulse-dot 0.8s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.6); }
}

#questionText {
  display: inline;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  line-height: 1.4;
  color: var(--teal-deep);
  margin: 0;
}

/* ---------- Grille des réponses ---------- */

.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, 120px);
  gap: 18px;
  justify-content: center;
}

.answer-btn {
  position: relative;
  width: 120px;
  height: 120px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 5px solid transparent;
  background: #fff;
  box-shadow: var(--shadow-pop);
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.answer-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--radius-sm) - 5px);
}

.answer-btn:not(:disabled):hover {
  transform: translateY(-3px);
  border-color: var(--sun);
}

.answer-btn:not(:disabled):active {
  transform: translateY(1px);
}

.answer-btn .badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.answer-btn.correct {
  border-color: var(--good);
  box-shadow: 0 0 0 4px rgba(62, 207, 142, 0.25), var(--shadow-pop);
}

.answer-btn.correct .badge {
  background: var(--good-dark);
  opacity: 1;
  transform: scale(1);
}

.answer-btn.correct .badge::before { content: "✓"; }

.answer-btn.wrong {
  border-color: var(--bad);
  animation: shake 0.4s ease;
}

.answer-btn.wrong .badge {
  background: var(--bad-dark);
  opacity: 1;
  transform: scale(1);
}

.answer-btn.wrong .badge::before { content: "✕"; }

.answer-btn:disabled { cursor: default; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* ---------- Explication ---------- */

.explanation[hidden] {
  display: none;
}

.explanation {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fff2df;
  border: 2px dashed var(--coral);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  animation: pop-in 0.3s ease both;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.explanation-icon { font-size: 1.4rem; line-height: 1; }

.explanation p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--ink);
}

/* ---------- Bouton suivant ---------- */

.next-btn {
  align-self: center;
  border: none;
  background: var(--coral);
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 28px;
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--coral-dark);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.next-btn:hover { transform: translateY(-2px); }

.next-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--coral-dark);
}

/* ---------- Écran de fin ---------- */

.end-screen {
  text-align: center;
}

.end-card {
  padding: 40px 28px;
}

.end-card h1 {
  font-family: 'Baloo 2', sans-serif;
  color: var(--teal-deep);
  font-size: 2rem;
  margin: 0 0 12px;
}

.stars {
  font-size: 2.6rem;
  letter-spacing: 6px;
  margin-bottom: 10px;
}

.score {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--teal-mid);
  margin: 0 0 22px;
}

.replay-btn {
  border: none;
  background: var(--good-dark);
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px 32px;
  border-radius: 999px;
  box-shadow: 0 4px 0 #167350;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.replay-btn:hover { transform: translateY(-2px); }

.replay-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #167350;
}

/* ---------- Petits écrans ---------- */

@media (max-width: 400px) {
  .answers-grid { grid-template-columns: repeat(2, 100px); gap: 12px; }
  .answer-btn { width: 100px; height: 100px; }
  #questionText { font-size: 1.1rem; }
}

/* ---------- Accessibilité : mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
