/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #1a2a3a;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#app {
  width: 100%;
  max-width: 700px;
}

/* --- Écrans --- */
.ecran {
  display: none;
  animation: apparition 0.3s ease;
}

.ecran.actif {
  display: block;
}

@keyframes apparition {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Accueil --- */
#ecran-accueil {
  text-align: center;
}

#ecran-accueil h1 {
  font-size: 2rem;
  color: #2563eb;
  margin-bottom: 0.25rem;
}

#ecran-accueil h2 {
  font-size: 1.3rem;
  font-weight: 400;
  color: #64748b;
  margin-bottom: 1.5rem;
}

.explication {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  text-align: left;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.explication p {
  margin-bottom: 0.75rem;
}

.explication p:last-child {
  margin-bottom: 0;
}

.menu-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.menu-modes button {
  padding: 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
}

.menu-modes button:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.menu-modes button:active {
  transform: translateY(0);
}

.credit {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* --- Exercice --- */
#ecran-exercice {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.rappel {
  background: #fef3c7;
  color: #92400e;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

/* --- Équation --- */
.equation-ligne {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

.molecule {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.formule {
  font-weight: 600;
}

.separateur {
  font-size: 1.3rem;
  color: #64748b;
  padding: 0 0.3rem;
}

.fleche {
  font-size: 1.5rem;
  color: #2563eb;
}

/* --- Inputs coefficients --- */
.coeff-input {
  width: 3rem;
  height: 2.5rem;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -moz-appearance: textfield;
}

.coeff-input::-webkit-inner-spin-button,
.coeff-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.coeff-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.coeff-input.correct {
  border-color: #16a34a;
  background: #dcfce7;
}

.coeff-input.faux {
  border-color: #dc2626;
  background: #fee2e2;
}

.coeff-input.proportionnel {
  border-color: #d97706;
  background: #fef3c7;
}

/* --- Feedback --- */
.feedback {
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  line-height: 1.5;
  font-size: 0.95rem;
}

.feedback.succes {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.feedback.erreur {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.feedback.attention {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* --- Boutons exercice --- */
#boutons-exercice {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

#boutons-exercice button {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
}

#btn-valider {
  background: #2563eb;
  color: white;
}

#btn-valider:hover {
  background: #1d4ed8;
}

#btn-suivant {
  background: #16a34a;
  color: white;
}

#btn-suivant:hover {
  background: #15803d;
}

/* --- Progression --- */
#progression {
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
}

/* --- Résultat --- */
#ecran-resultat {
  text-align: center;
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

#ecran-resultat h2 {
  font-size: 1.5rem;
  color: #2563eb;
  margin-bottom: 1rem;
}

#score {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

#note {
  font-size: 1.2rem;
  color: #64748b;
  margin-bottom: 1.5rem;
}

#ecran-resultat button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  margin: 0.25rem;
  transition: background 0.2s;
}

#btn-recommencer {
  background: #2563eb;
  color: white;
}

#btn-recommencer:hover {
  background: #1d4ed8;
}

#btn-accueil {
  background: #e2e8f0;
  color: #475569;
}

#btn-accueil:hover {
  background: #cbd5e1;
}

/* --- Responsive --- */
@media (max-width: 500px) {
  html {
    font-size: 16px;
  }

  .menu-modes {
    grid-template-columns: 1fr;
  }

  .equation-ligne {
    font-size: 1rem;
  }

  .coeff-input {
    width: 2.5rem;
    height: 2.2rem;
    font-size: 1rem;
  }

  #ecran-exercice {
    padding: 1rem;
  }
}


/* --- Mode Apprentissage guidé --- */
.apprentissage-guide {
  margin-bottom: 1.25rem;
}

.guide-texte {
  background: #eff6ff;
  color: #1e40af;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.btn-indice {
  display: block;
  margin: 0 auto 0.75rem;
  padding: 0.5rem 1.25rem;
  font-size: 0.9rem;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  background: white;
  color: #3b82f6;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.btn-indice:hover {
  background: #3b82f6;
  color: white;
}

.guide-atomes {
  display: none;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.guide-atomes.visible {
  display: block;
}

.guide-atome-ligne {
  display: grid;
  grid-template-columns: 3rem 1fr 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
  align-items: center;
}

.guide-atome-ligne:last-child {
  border-bottom: none;
}

.atome-nom {
  font-weight: 700;
  color: #2563eb;
  font-size: 1rem;
}

.atome-gauche {
  color: #475569;
}

.atome-droite {
  color: #475569;
}
