/* ============================================================
   ELEVE.CSS — Feuille de style de l'application « Calcul Mental »
   ------------------------------------------------------------
   Sommaire (rechercher les titres ci-dessous pour naviguer) :
     1. Variables & réinitialisation
     2. Header
     3. Contenu / mise en page générale
     4. Boutons
     5. Écran d'accueil
     6. Écran d'impression (formulaire de configuration des fiches)
     7. Chemin des niveaux (sélection du niveau)
     8. Popup de réglages d'un niveau
     9. Popup d'information « Voir le programme »
    10. Jeu (question / réponse / timer)
    11. Résultats
    12. Footer
    13. Responsive (petits écrans)
   ============================================================ */

/* ── 1. Variables & réinitialisation ── */
:root {
  --amber:   #FFB627;
  --amber-d: #E89A0C;
  --amber-l: #FFF1D0;
  --ink:     #2C2A4A;
  --ink-2:   #4A4768;
  --ink-3:   #837FA0;
  --surface: #FFFFFF;
  --bg:      #FFFBF2;
  --border:  #EAE0CB;
  --green:   #22B8A0;
  --blue:    #3D8BEB;
  --red:     #FF5D73;
  --purple:  #6C63FF;
  --radius:  18px;
  /* Chemin des niveaux : dégradé du plus simple (vert) au plus expert (corail) */
  --n1: #57C785;
  --n2: #2FBF9E;
  --n3: #22ABC7;
  --n4: #3D8BEB;
  --n5: #6C63FF;
  --n6: #9B5DE5;
  --n7: #E0479E;
  --n8: #FF5D73;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Nunito', sans-serif; background: var(--bg); color: var(--ink); min-height: 100vh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }

/* ── 2. Header ── */
header {
  background: var(--ink);
  position: sticky; top: 0; z-index: 50;
}
.header-inner {
  max-width: 560px; margin: 0 auto; padding: 14px 24px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-mascot {
  width: 34px; height: 34px; border-radius: 50%; background: var(--amber);
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
  box-shadow: 2px 2px 0 rgba(0,0,0,.22); flex-shrink: 0;
}
.header-word { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1rem; color: #fff; }
.header-accent { color: var(--amber); }
.header-badge {
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .66rem;
  background: rgba(255,255,255,.12); color: #fff; border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 999px; padding: 5px 12px; letter-spacing: .04em; text-transform: uppercase;
}
.header-wave { display: block; width: 100%; height: 20px; }
.header-wave path { fill: var(--bg); }

/* ── 3. Contenu / mise en page générale ── */
.content { max-width: 560px; margin: 0 auto; padding: 22px 22px 48px; }
.page-eyebrow { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .68rem; color: var(--amber-d); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.page-title { font-family: 'Fredoka', sans-serif; font-size: 1.5rem; font-weight: 600; color: var(--ink); margin-bottom: 22px; line-height: 1.25; }
.page-sub { font-size: .88rem; color: var(--ink-3); margin-top: -14px; margin-bottom: 22px; font-weight: 600; }

/* ── 4. Boutons ── */
.btn {
  display: block; width: 100%; padding: 14px 18px; font-family: 'Fredoka', sans-serif; font-size: .95rem; font-weight: 600;
  border: 2.5px solid var(--ink); border-radius: 999px; cursor: pointer; color: #fff; text-align: center;
  box-shadow: 4px 4px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover  { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { background: var(--amber-d); }
.btn-ghost { background: var(--surface); color: var(--ink-3); border: 1.5px solid var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--bg); border-color: var(--ink-3); color: var(--ink); transform: none; box-shadow: none; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #1a9c86; }
.mt { margin-top: 12px; }
.mt2 { margin-top: 22px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.btn-linklike { background: none; border: none; box-shadow: none; color: var(--amber-d); font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .7rem; cursor: pointer; text-decoration: underline; padding: 0; }

/* ── 5. Écran d'accueil ── */
.action-card {
  background: var(--surface); border: 2.5px solid var(--ink); border-radius: var(--radius);
  padding: 20px; cursor: pointer; display: flex; align-items: flex-start; gap: 14px;
  transition: transform .15s ease, box-shadow .15s ease; position: relative; width: 100%; text-align: left;
  box-shadow: 5px 5px 0 var(--card-shadow-color, var(--amber));
}
.action-card:hover  { transform: translate(-2px, -2px) rotate(-1deg); box-shadow: 7px 7px 0 var(--card-shadow-color, var(--amber)); }
.action-card:active { transform: translate(1px, 1px); box-shadow: 3px 3px 0 var(--card-shadow-color, var(--amber)); }
.card-amber  { --card-shadow-color: var(--amber); }
.card-purple { --card-shadow-color: var(--purple); }
.card-icon { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }
.card-amber  .card-icon { background: var(--amber); }
.card-purple .card-icon { background: var(--purple); }
.card-body  { flex: 1; }
.card-title { font-family: 'Fredoka', sans-serif; font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.card-desc  { font-size: .8rem; color: var(--ink-3); line-height: 1.5; }

/* ── 6. Écran d'impression (formulaire de configuration des fiches) ── */
.field-group { margin-bottom: 18px; }
.field-label { display: block; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 7px; }
select { width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: var(--radius); font-family: 'Nunito', sans-serif; font-size: .95rem; color: var(--ink); background: var(--surface); outline: none; transition: border-color .2s; }
select:focus { border-color: var(--amber); }
input[type=number].field-input { width: 100%; padding: 11px 14px; border: 2px solid var(--border); border-radius: var(--radius); font-family: 'Nunito', sans-serif; font-size: .95rem; color: var(--ink); background: var(--surface); outline: none; transition: border-color .2s; }
input[type=number].field-input:focus { border-color: var(--amber); }
.variant-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.variant-btn { padding: 14px 10px; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; transition: border-color .2s, background .2s; font-family: 'Nunito', sans-serif; font-weight: 600; font-size: .82rem; color: var(--ink-2); line-height: 1.4; }
.variant-btn .vicon { font-size: 1.5em; display: block; margin-bottom: 5px; }
.variant-btn:hover { border-color: var(--amber); background: var(--amber-l); }
.variant-btn.selected { border-color: var(--amber); background: var(--amber-l); color: var(--amber-d); font-weight: 800; }
.info-banner { background: var(--bg); border-left: 4px solid var(--amber); border-radius: 0 10px 10px 0; padding: 10px 13px; font-family: 'Nunito', sans-serif; font-size: .74rem; font-weight: 600; color: var(--ink-3); margin-top: 8px; }
.checkbox-group { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.checkbox-group input[type=checkbox] { width: 19px; height: 19px; cursor: pointer; accent-color: var(--amber); }
.checkbox-group label { font-size: .85rem; color: var(--ink-2); cursor: pointer; }

/* ── 7. Chemin des niveaux (sélection du niveau) ──
   Remplace l'ancienne liste verticale de boutons par un "chemin de jeu"
   en zigzag : chaque niveau est un jeton rond relié au suivant par une
   ligne en pointillés, coloré selon un dégradé du vert (facile) au corail
   (expert) qui suit la vraie progression CP → 6e. L'icône et le sous-texte
   de chaque jeton reflètent le contenu réel du niveau (voir types_exos.md). */
.level-path { position: relative; padding: 6px 0 4px; margin-bottom: 4px; }
.level-track { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; overflow: visible; }
.level-stop { position: relative; z-index: 1; display: flex; margin-bottom: 2px; }
.level-stop.left  { justify-content: flex-start; }
.level-stop.right { justify-content: flex-end; }
.level-token-group { display: flex; align-items: center; gap: 12px; width: 60%; }
.level-stop.right .level-token-group { flex-direction: row-reverse; text-align: right; }
.level-stop.right .level-name { justify-content: flex-end; }

.level-token-wrap { position: relative; flex-shrink: 0; }
.level-token {
  width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--ink);
  background: var(--lvl-color); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif; font-weight: 600; cursor: pointer;
  box-shadow: 3px 3px 0 rgba(44,42,74,.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.level-token .lvl-icon { font-size: .95rem; line-height: 1; margin-bottom: 1px; }
.level-token .lvl-num  { font-size: 1.05rem; line-height: 1; }
.level-token:hover { transform: translateY(-3px) scale(1.05); box-shadow: 4px 5px 0 rgba(44,42,74,.3); }
.level-token.active { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px var(--lvl-color); }

.level-gear {
  position: absolute; bottom: -4px; right: -4px; width: 25px; height: 25px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink); display: flex; align-items: center; justify-content: center;
  font-size: .7rem; cursor: pointer;
}
.level-stop.right .level-gear { right: auto; left: -4px; }

.level-info { flex: 1; min-width: 0; }
.level-name { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: .85rem; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.level-info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; padding: 0; line-height: 1;
  background: var(--surface); border: 1.5px solid var(--ink-3); color: var(--ink-3);
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .62rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.level-info-icon:hover { border-color: var(--amber); color: var(--amber-d); }
.modal-title-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-grade-badge {
  display: inline-block; font-family: 'Nunito', sans-serif; font-size: .62rem; font-weight: 800; letter-spacing: .03em;
  text-transform: uppercase; color: #fff; background: var(--ink-3);
  border-radius: 999px; padding: 3px 9px;
}

/* ── 8. Popup de réglages d'un niveau ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(44,42,74,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 20px;
}
.modal-box {
  background: var(--surface); border: 3px solid var(--ink); border-radius: var(--radius);
  max-width: 480px; width: 100%; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 6px 6px 0 var(--ink);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 2px solid var(--border); flex-shrink: 0;
}
.modal-title { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.modal-close { background: none; border: none; font-size: 1.2rem; color: var(--ink-3); cursor: pointer; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 6px 18px; overflow-y: auto; flex: 1; }
.modal-sound-check { padding: 10px 0; border-bottom: 2px solid var(--border); margin-bottom: 4px; }
.modal-master-row { padding: 12px 0; border-bottom: 2px solid var(--amber-l); margin-bottom: 4px; }
.modal-master-label { display: block; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .68rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.modal-cat-time input[type=range]:disabled { opacity: .35; cursor: not-allowed; }
.modal-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-top: 2px solid var(--border); flex-shrink: 0;
}
.modal-footer .btn { width: auto; padding: 10px 20px; margin: 0; }
.modal-cat-row { padding: 12px 0; border-bottom: 1.5px solid var(--border); }
.modal-cat-row:last-child { border-bottom: none; }
.modal-cat-check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.modal-cat-check input { width: 19px; height: 19px; accent-color: var(--amber); cursor: pointer; flex-shrink: 0; }
.modal-cat-check span { font-size: .85rem; color: var(--ink-2); }
.modal-cat-time { display: flex; align-items: center; gap: 8px; padding-left: 29px; }
.modal-cat-time input[type=range] { flex: 1; accent-color: var(--amber); }
.modal-cat-time-val { font-family: 'Nunito', sans-serif; font-weight: 700; font-size: .72rem; color: var(--ink-3); min-width: 42px; text-align: right; }
.btn-reset-time {
  background: none; border: 2px solid var(--border); border-radius: 8px;
  width: 26px; height: 26px; font-size: .8rem; color: var(--ink-3); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.btn-reset-time:hover:not(:disabled) { border-color: var(--amber); color: var(--amber-d); }
.btn-reset-time:disabled { opacity: .3; cursor: default; }

/* ── 9. Popup d'information « Voir le programme » (lecture seule) ── */
.info-list { list-style: none; display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.info-item {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 4px;
  border-bottom: 1.5px solid var(--border); font-size: .85rem; color: var(--ink-2);
}
.info-item:last-child { border-bottom: none; }
.info-bullet { color: var(--amber-d); font-size: .8rem; flex-shrink: 0; }
.info-note { font-size: .74rem; color: var(--ink-3); font-weight: 600; padding: 10px 4px 4px; line-height: 1.5; }

/* ── 10. Jeu (question / réponse / timer) ── */
.bar-wrap { background: var(--border); border-radius: 999px; height: 8px; margin-bottom: 8px; }
.bar { background: linear-gradient(90deg, var(--amber), var(--green)); height: 8px; border-radius: 999px; transition: width .35s ease; }
.q-counter { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .7rem; color: var(--ink-3); text-align: center; margin-bottom: 14px; letter-spacing: .03em; text-transform: uppercase; }

.game-panel { border-radius: var(--radius); padding: 22px 16px 10px; background: var(--surface); border: 2.5px solid var(--border); transition: background-color .3s linear; }
.btn-audio { background: none; border: 2px solid var(--border); border-radius: 999px; color: var(--ink-3); font-family: 'Nunito', sans-serif; font-weight: 700; font-size: .7rem; padding: 5px 12px; cursor: pointer; transition: border-color .2s, color .2s, background .2s; }
.btn-audio:hover { border-color: var(--amber); color: var(--amber-d); }
.btn-audio.on { background: var(--amber-l); border-color: var(--amber); color: var(--amber-d); }

.q-box { font-family: 'Fredoka', sans-serif; font-size: 2.1rem; font-weight: 600; color: var(--ink); text-align: center; margin: 26px 0; min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; line-height: 1.3; }
.q-box .q-sub { display: block; font-size: .48em; color: var(--ink-3); font-weight: 700; font-family: 'Nunito', sans-serif; }
.frac { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; vertical-align: middle; line-height: 1.15; margin: 0 3px; }
.frac-expr { display: inline-flex; flex-direction: row; align-items: center; justify-content: center; flex-wrap: nowrap; }
.frac .frac-num, .frac .frac-den { display: block; padding: 0 3px; }
.frac .frac-num { border-bottom: 2.5px solid currentColor; padding-bottom: 2px; }
.frac .frac-den { padding-top: 2px; }
#answer { display: block; width: 160px; margin: 0 auto 16px; padding: 12px 10px; font-family: 'Fredoka', sans-serif; font-size: 1.6rem; font-weight: 600; text-align: center; border: 2.5px solid var(--border); border-radius: var(--radius); outline: none; transition: border-color .2s; background: var(--surface); color: var(--ink); }
#answer:focus { border-color: var(--amber); }
#answer::-webkit-inner-spin-button, #answer::-webkit-outer-spin-button { -webkit-appearance: none; }
#answer[type=number] { -moz-appearance: textfield; }

.btn-stop { background: none; border: 2px solid var(--border); border-radius: 999px; color: var(--ink-3); font-family: 'Nunito', sans-serif; font-weight: 700; font-size: .7rem; padding: 5px 12px; cursor: pointer; transition: border-color .2s, color .2s; }
.btn-stop:hover { border-color: var(--red); color: var(--red); }

/* ── 11. Résultats ── */
.score-ring { width: 104px; height: 104px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Fredoka', sans-serif; font-size: 1.7rem; font-weight: 600; color: #fff; margin: 0 auto 10px; border: 3px solid var(--ink); box-shadow: 4px 4px 0 rgba(44,42,74,.2); }
.score-msg { text-align: center; font-size: .9rem; color: var(--ink-3); margin-bottom: 22px; font-weight: 700; }

.review-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: 20px; }
.review-table th { background: var(--bg); color: var(--ink-2); font-weight: 800; padding: 8px 10px; text-align: left; border-bottom: 2px solid var(--border); font-family: 'Nunito', sans-serif; font-size: .66rem; letter-spacing: .03em; text-transform: uppercase; }
.review-table td { padding: 7px 10px; border-bottom: 1.5px solid var(--border); vertical-align: middle; }
.review-table tr:last-child td { border-bottom: none; }
.ans-ok   { color: var(--green); font-weight: 800; }
.ans-ko   { color: var(--red);   font-weight: 800; }
.ans-skip { color: var(--amber-d); font-style: italic; font-size: .82rem; }
.btn-reveal { display: inline-block; padding: 3px 9px; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: .72rem; border: 2px solid var(--red); border-radius: 999px; cursor: pointer; color: var(--red); background: transparent; transition: background .15s, color .15s; white-space: nowrap; }
.btn-reveal:hover { background: var(--red); color: #fff; }
.corr-badge { display: inline-block; margin-left: 6px; background: var(--green); color: #fff; border-radius: 999px; padding: 3px 9px; font-family: 'Nunito', sans-serif; font-size: .7rem; font-weight: 800; }

.btn-replay {
  display: block; width: 100%; padding: 14px 18px; margin-bottom: 10px; font-family: 'Fredoka', sans-serif;
  font-size: .95rem; font-weight: 600; color: var(--ink); background: var(--amber);
  border: 2.5px solid var(--ink); border-radius: 999px; cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease; text-align: center;
}
.btn-replay:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }

/* ── 12. Footer ── */
footer { text-align: center; font-size: .74rem; color: var(--ink-3); padding: 18px 24px 26px; font-family: 'Nunito', sans-serif; font-weight: 600; }

/* ── 13. Responsive (petits écrans) ── */
@media (max-width: 520px) {
  .header-inner { padding: 12px 18px 10px; }
  .content { padding: 18px 16px 32px; }
  .q-box { font-size: 1.7rem; }
  .g2, .variant-group { grid-template-columns: 1fr; }
  .level-token-group { width: 82%; }
  .level-token { width: 52px; height: 52px; }
}
