/* =========================================================
   Séries de calcul mental : compléments à rule-style.css
   Pas de règle sur body : la mise en page générale vient de haut.php.
   ========================================================= */
.hidden { display: none !important; }

.serie-sous-titre { margin: 6px 0 0; color: var(--ms-navy-soft); }
.serie-etoiles { color: var(--ms-orange); letter-spacing: 2px; }

.consigne { margin: 0 0 12px; font-size: 1.05rem; line-height: 1.5; }
kbd {
    padding: 1px 6px; font-size: .9em;
    border: 1px solid var(--ms-border); border-bottom-width: 2px; border-radius: 4px; background: #fff;
}

.serie-depart { text-align: center; padding: 10px 0 20px; }
.serie-exemple {
    display: inline-block; margin: 6px 0 4px; padding: 8px 20px;
    font-size: 1.6rem; font-weight: bold; color: var(--ms-navy);
    background: var(--ms-cream); border: 2px dashed var(--ms-border); border-radius: 12px;
}

/* Barre du haut : compteur + chrono */
.serie-barre { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.compteur, .chrono {
    padding: 4px 14px; font-weight: bold; border-radius: 999px;
    color: var(--ms-violet-hover); background: var(--ms-lavender);
}
.chrono { font-variant-numeric: tabular-nums; min-width: 90px; text-align: center; }
.serie-progression {
    height: 10px; margin: 12px 0 24px;
    background: var(--ms-cream); border: 1px solid var(--ms-border-light); border-radius: 999px; overflow: hidden;
}
.serie-progression div { height: 100%; width: 0; background: var(--ms-violet-soft); transition: width .3s ease; }

/* Le calcul en grand */
.serie-operation {
    display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 14px;
    font-size: 3rem; font-weight: bold; color: var(--ms-navy);
    font-variant-numeric: tabular-nums;
}
.serie-operation .signe { color: var(--ms-violet); }
.quiz-box .serie-operation input#reponse {
    width: 150px; padding: 6px 10px;
    font-size: 3rem; font-weight: bold; text-align: center;
    color: var(--ms-navy); background: #fff;
    border: 3px solid #9fc2e8; border-radius: 14px;
}
.quiz-box .serie-operation input#reponse:focus { outline: none; border-color: var(--ms-violet-soft); box-shadow: 0 0 0 4px rgba(55,138,221,.25); }
.quiz-box .serie-operation input#reponse.correct { background: #e3f4e4; border-color: var(--ms-green); color: #1b5e20; }
.quiz-box .serie-operation input#reponse.wrong   { background: #fbe4e1; border-color: #b71c1c; color: #8e1414; }

.serie-feedback { min-height: 1.6em; margin: 14px 0 0; text-align: center; font-size: 1.25rem; font-weight: bold; }
.serie-feedback.ok { color: #1b5e20; }
.serie-feedback.ko { color: #8e1414; }

/* Petites pastilles des calculs déjà faits */
.serie-historique { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 18px 0 0; padding: 0; }
.serie-historique li { padding: 3px 10px; font-size: .9rem; font-weight: bold; border-radius: 999px; border: 2px solid; }
.serie-historique li.ok { color: #1b5e20; background: #e3f4e4; border-color: #8bc34a; }
.serie-historique li.ko { color: #8e1414; background: #fbe4e1; border-color: #e57373; }

/* Résultat */
.serie-bilan { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.bilan-case {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px;
    background: var(--ms-gradient); border: 2px solid var(--ms-border); border-radius: 12px;
}
.bilan-valeur { font-size: 1.5rem; font-weight: bold; color: var(--ms-navy); }
.bilan-label { font-size: .9rem; color: var(--ms-navy-soft); }

.serie-correction {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
    list-style: none; margin: 20px 0 0; padding: 0; counter-reset: calc;
}
.serie-correction li {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 8px 14px; font-size: 1.1rem; border: 2px solid var(--ms-border); border-radius: 10px;
}
.serie-correction li.ok { background: #eef8ee; }
.serie-correction li.ko { background: #fdf0ee; }
.serie-correction .etat { font-size: .95rem; color: #8e1414; white-space: nowrap; }

.exercise-navigation .btn-suivant { color: #27500a; background: #eaf3de; border-color: #639922; }

@media (max-width: 600px) {
    .serie-operation, .quiz-box .serie-operation input#reponse { font-size: 2.2rem; }
    .quiz-box .serie-operation input#reponse { width: 110px; }
    .serie-bilan, .serie-correction { grid-template-columns: 1fr; }
}

/* =========================================================
   Opérations posées en colonnes
   ========================================================= */
.posee-zone { display: flex; flex-direction: column; align-items: center; margin: 10px 0 4px; }
.posee {
    --posee-case: 58px;
    display: grid;
    gap: 6px 4px;
    justify-content: center;
    align-items: center;
    padding: 18px 26px;
    background: #fff;
    background-image: linear-gradient(var(--ms-border-light) 1px, transparent 1px), linear-gradient(90deg, var(--ms-border-light) 1px, transparent 1px);
    background-size: 20px 20px;
    border: 2px solid var(--ms-border);
    border-radius: 14px;
    font-variant-numeric: tabular-nums;
}
.posee .chiffre, .posee .signe {
    height: var(--posee-case);
    display: flex; align-items: center; justify-content: center;
    font-size: 2.4rem; font-weight: bold; color: var(--ms-navy);
}
.posee .signe { color: var(--ms-violet); }
.posee .chiffre.col-unites { background: rgba(239, 143, 0, .10); border-radius: 8px; }
.posee .trait { height: 0; border-top: 4px solid var(--ms-navy); margin: 2px 0; }

.quiz-box .posee input {
    width: var(--posee-case); height: var(--posee-case);
    padding: 0; box-sizing: border-box;
    font-size: 2.2rem; font-weight: bold; text-align: center;
    color: var(--ms-navy); background: #fff;
    border: 3px solid #9fc2e8; border-radius: 10px;
}
.quiz-box .posee input.col-unites { border-color: #f0b65a; }
.quiz-box .posee input:focus { outline: none; border-color: var(--ms-violet-soft); box-shadow: 0 0 0 4px rgba(55,138,221,.25); }
.quiz-box .posee input.retenue {
    width: 36px; height: 36px; justify-self: end; align-self: end;
    font-size: 1.2rem; color: #b45309; border: 2px dashed #f0b65a; border-radius: 50%;
}
.quiz-box .posee input.correct, .quiz-box .posee input.col-unites.correct { background: #e3f4e4; border-color: var(--ms-green); color: #1b5e20; }
.quiz-box .posee input.wrong, .quiz-box .posee input.col-unites.wrong { background: #fbe4e1; border-color: #b71c1c; color: #8e1414; }
.quiz-box .posee input.oubli   { background: #fff3d6; border-style: solid; border-color: #b45309; color: #b45309; }
.quiz-box .posee input:disabled { opacity: 1; }

.posee-legende { margin-top: 8px; font-size: .9rem; color: var(--ms-navy-soft); }
.posee-legende .leg-col {
    display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px;
    background: rgba(239, 143, 0, .18); border: 2px solid #f0b65a; border-radius: 4px;
}
.posee-actions { display: flex; justify-content: center; }
.posee-actions .submit-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

@media (max-width: 600px) {
    .posee { --posee-case: 44px; padding: 12px 14px; }
    .posee .chiffre, .posee .signe, .quiz-box .posee input { font-size: 1.8rem; }
}
.serie-bilan.sans-chrono { grid-template-columns: 1fr; max-width: 320px; margin-left: auto; margin-right: auto; }

/* Virgule des nombres décimaux posés */
.posee .virgule {
    display: flex; align-items: flex-end; justify-content: center;
    height: var(--posee-case); padding-bottom: 6px; box-sizing: border-box;
    font-size: 2.4rem; font-weight: bold; color: var(--ms-highlight);
}
.quiz-box .posee input.resultat.col-unites + .virgule { color: var(--ms-highlight); }

/* Multiplication posée : zéros de décalage déjà écrits, produits partiels */
.posee .chiffre.zero-decale { color: #9aa7b8; font-weight: normal; }
.quiz-box .posee input.partiel { border-style: dashed; }

/* =========================================================
   Division posée (potence)
   ========================================================= */
.potence { grid-auto-rows: var(--posee-case); }
.posee .pot-diviseur { border-bottom: 4px solid var(--ms-navy); }
.posee .pot-gauche   { border-left: 4px solid var(--ms-navy); }
.quiz-box .posee input.pot-gauche { border-left-width: 4px; border-left-color: var(--ms-navy); }
.quiz-box .posee input.quotient { border-color: #b39ddb; }
.posee .pot-trait { box-shadow: 0 4px 0 -1px var(--ms-navy); }
.posee .signe.pot-trait { box-shadow: none; }
.posee .chiffre.abaisse { color: #7a8aa0; font-weight: normal; }
.quiz-box .posee input.reste-final { border-color: #f0b65a; }
.potence-etape {
    min-height: 1.5em; margin: 10px 0 0; text-align: center;
    font-size: 1.15rem; font-weight: bold; color: var(--ms-violet-hover);
}

/* =========================================================
   Exercices à questions (numération)
   ========================================================= */
.q-zone { text-align: center; margin: 18px 0 6px; }
.q-enonce { font-size: 1.35rem; font-weight: bold; color: var(--ms-navy); margin: 0 0 16px; line-height: 1.8; }
.quiz-box .q-champ {
    width: 150px; padding: 8px 10px; font-size: 1.6rem; font-weight: bold; text-align: center;
    border: 3px solid var(--ms-border); border-radius: 10px; background: #fff; color: var(--ms-navy); margin: 0 4px;
}
.quiz-box .q-enonce .q-champ { width: 120px; font-size: 1.3rem; padding: 4px 8px; }
.quiz-box .q-champ.q-texte { width: min(100%, 560px); font-size: 1.3rem; text-align: left; }
.quiz-box .q-champ:focus { outline: none; border-color: var(--ms-violet-soft); box-shadow: 0 0 0 4px rgba(55,138,221,.25); }
.quiz-box .q-champ.correct { background: #e3f4e4; border-color: var(--ms-green); color: #1b5e20; }
.quiz-box .q-champ.wrong   { background: #fbe4e1; border-color: #b71c1c; color: #8e1414; }

.q-ecouter, .q-effacer {
    padding: 8px 20px; margin: 0 0 14px; font-size: 1.05rem; font-weight: bold; cursor: pointer;
    background: #eef4fb; color: var(--ms-navy); border: 2px solid var(--ms-border); border-radius: 999px;
}
.q-ecouter:hover, .q-effacer:hover { background: #dde9f7; }
.q-effacer { margin: 14px 0 0; font-size: .95rem; }

.q-comparer { display: flex; justify-content: center; align-items: center; gap: 18px; font-size: 2.2rem; font-weight: bold; color: var(--ms-navy); margin-bottom: 16px; }
.q-signe { min-width: 64px; padding: 2px 10px; border: 3px dashed var(--ms-border); border-radius: 10px; color: var(--ms-violet); }
.q-signe.correct { border-style: solid; border-color: var(--ms-green); background: #e3f4e4; color: #1b5e20; }
.q-signe.wrong   { border-style: solid; border-color: #b71c1c; background: #fbe4e1; color: #8e1414; }

.q-choix { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.q-bouton {
    min-width: 72px; padding: 10px 18px; font-size: 1.8rem; font-weight: bold; cursor: pointer;
    background: #fff; color: var(--ms-navy); border: 3px solid var(--ms-border); border-radius: 12px;
    transition: transform .1s, background .2s;
}
.q-bouton:hover:not(:disabled) { background: #eef4fb; transform: translateY(-2px); }
.q-bouton:disabled { opacity: .35; cursor: default; }
.q-bouton.q-nombre { font-size: 1.4rem; }

.q-rangee {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px;
    min-height: 58px; margin-bottom: 16px; padding: 8px; border: 3px dashed var(--ms-border-light, #c9c2b0); border-radius: 12px;
}
.q-rangee.correct { border-style: solid; border-color: var(--ms-green); background: #eef8ee; }
.q-rangee.wrong   { border-style: solid; border-color: #b71c1c; background: #fdf0ee; }
.q-place { padding: 6px 14px; font-size: 1.3rem; font-weight: bold; background: #eef4fb; border: 2px solid var(--ms-border); border-radius: 10px; color: var(--ms-navy); }
.q-place + .q-place::before { content: none; }

.q-droite { max-width: 640px; margin: 0 auto 16px; }
.q-droite svg { width: 100%; height: auto; }
.q-droite .axe { stroke: var(--ms-navy); stroke-width: 3; }
.q-droite .trait { stroke: var(--ms-navy); stroke-width: 2; }
.q-droite .trait-fort { stroke: var(--ms-navy); stroke-width: 3; }
.q-droite text { font: bold 17px sans-serif; fill: var(--ms-navy); }
.q-droite .fleche { fill: #e65100; }

.q-actions { text-align: center; }
.serie-correction li .q-donne { display: block; font-size: .9rem; }

@media (max-width: 600px) {
    .q-enonce { font-size: 1.1rem; }
    .q-comparer { font-size: 1.6rem; gap: 10px; }
    .q-bouton { font-size: 1.4rem; min-width: 60px; }
}

/* =========================================================
   Fractions : écriture verticale, figures à lire ou à colorier
   ========================================================= */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .2em; line-height: 1.15; }
.frac > :first-child { border-bottom: 2px solid currentColor; padding: 0 .2em .05em; }
.frac > :last-child  { padding: .05em .2em 0; }
.quiz-box .q-enonce .frac .q-champ.q-frac { width: 70px; margin: 3px 0; font-size: 1.25rem; padding: 2px 4px; }
.q-enonce .frac .q-champ.q-frac:first-child { border-bottom-width: 3px; }

.q-droite .figure { display: block; margin: 0 auto; }
.q-droite .figure.disque { max-width: 230px; }
.q-droite .part { fill: #fff; stroke: var(--ms-navy); stroke-width: 3; transition: fill .15s; }
.q-droite .part.coloree { fill: #85b7eb; }
.q-droite.cliquable .part { cursor: pointer; }
.q-droite.cliquable .part:hover:not(.coloree) { fill: #e3eefa; }
.q-droite.correct .part.coloree { fill: #8bc34a; }
.q-droite.wrong .part.coloree { fill: #e57373; }
.serie-correction .frac { font-size: .9em; }
.q-consigne { margin: 0 0 6px; color: var(--ms-violet); font-weight: bold; font-size: 1rem; min-height: 1.2em; }
.quiz-box .q-enonce .frac .q-champ.q-frac { width: 56px; }
.q-enonce .frac > span { display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
/* Correction des exercices à étapes : la réponse de l'élève passe sous la bonne réponse */
.serie-correction li.ko { flex-wrap: wrap; }
.serie-correction li .calc { flex: 1 1 auto; }
.serie-correction li.ko .etat { flex-basis: 100%; white-space: normal; }
