/* =========================================================================
   Moteur « Aventure » de l'Atelier (v1) — complète assets/css/sandbox.css (chargée avant).
   Préfixe .av-. Style « autocollants » : traits épais, ombres franches, palette courte.
   ========================================================================= */
.av { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; padding-bottom: 30px; }
.av-chargement { text-align: center; opacity: .6; }
.av .icone { width: 1.2em; height: 1.2em; flex: none; }

/* En-tête : retour · titre · son */
.av-entete { display: flex; align-items: center; gap: 10px; }
.av-titre { flex: 1; font-size: clamp(1.15rem, 3.6vw, 1.6rem); text-align: center; }
.av-entete .btn-mini, .av .btn-mini { padding: 6px 12px; font-size: .92rem; border-radius: 12px; box-shadow: 3px 3px 0 var(--encre); }
.av-btn-carte span { display: inline; }
.av-son { padding: 6px 9px !important; }

/* Décor en bandeau */
.av-decor { border: var(--trait) solid var(--encre); border-radius: 22px; overflow: hidden; box-shadow: 5px 5px 0 var(--encre); height: clamp(90px, 22vw, 150px); background: var(--papier); }
.av-decor svg { width: 100%; height: 100%; }

/* Cartes */
.av-carte { background: var(--papier); border: var(--trait) solid var(--encre); border-radius: 24px; box-shadow: 6px 6px 0 var(--encre); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.av-centre { align-items: center; text-align: center; }
.av-petit { margin: 0; font-size: .95rem; opacity: .75; }
.av-apercu { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--ciel); border: 2px solid var(--encre); font-size: .92rem; text-align: center; }
.av-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* Guide */
.av-guide { width: 64px; height: 64px; flex: none; }
.av-guide-mini { width: 46px; height: 46px; }
.av-guide-grand { width: 130px; height: 130px; animation: av-flotte 3s ease-in-out infinite; }
@keyframes av-flotte { 50% { transform: translateY(-6px) rotate(-2deg); } }
.av-bulle { display: flex; gap: 10px; align-items: flex-start; }
.av-bulle-texte { position: relative; flex: 1; background: var(--creme); border: 2px solid var(--encre); border-radius: 16px; padding: 10px 14px; text-align: left; }
.av-bulle-texte::before { content: ""; position: absolute; left: -9px; top: 16px; width: 14px; height: 14px; background: var(--creme); border-left: 2px solid var(--encre); border-bottom: 2px solid var(--encre); transform: rotate(45deg); }
.av-bulle-texte b { display: block; font-family: var(--police-titre); font-size: .95rem; color: var(--encre); opacity: .7; }
.av-bulle-texte span { display: block; }

/* Accueil */
.av-accueil { flex-direction: row; align-items: center; gap: 18px; }
.av-accueil-texte { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.av-guide-nom { margin: 0; font-family: var(--police-titre); font-size: 1.3rem; }
.av-intro { margin: 0; font-size: 1.08rem; white-space: pre-line; }

/* Carte des chapitres : un chemin de pastilles */
.av-chemin { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; position: relative; }
.av-chemin::before { content: ""; position: absolute; left: 33px; top: 20px; bottom: 20px; border-left: 4px dashed var(--encre); opacity: .35; }
.av-etape { position: relative; }
.av-etape:nth-child(even) { margin-left: 22px; }
.av-etape-bouton { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 14px; text-align: left; background: var(--papier); border: var(--trait) solid var(--encre); border-radius: 20px; box-shadow: 4px 4px 0 var(--encre); cursor: pointer; font: inherit; color: inherit; transition: transform .08s, box-shadow .08s; }
.av-etape-bouton:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--encre); }
.av-etape-bouton:disabled { cursor: default; opacity: .6; box-shadow: none; background: #F3F1EC; }
.av-etape-num { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: var(--trait) solid var(--encre); background: var(--pc); font-family: var(--police-titre); font-size: 1.3rem; }
.av-etape-num .icone { width: 24px; height: 24px; }
.av-etape-texte { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.av-etape-texte b { font-family: var(--police-titre); font-size: 1.08rem; }
.av-etape-texte small { opacity: .75; }
.av-etape-texte em { font-style: normal; font-size: .85rem; font-weight: 800; opacity: .7; display: inline-flex; align-items: center; gap: 4px; }
.av-etape-ok .av-etape-num { background: var(--vert); }
.av-etape-franchie .av-etape-num { background: var(--menthe); }
.av-etape-ouverte:not(.av-etape-ok):not(.av-etape-franchie) .av-etape-num { animation: av-pulse 1.8s ease-in-out infinite; }
.av-etape-fermee .av-etape-num { background: var(--gris); }
.av-etape-final .av-etape-bouton { background: #FFF1C2; }
.av-etape-final.av-etape-fermee .av-etape-bouton { background: #F3F1EC; }
.av-etoile-defi { color: #F2B705; width: 1em !important; height: 1em !important; }
@keyframes av-pulse { 50% { transform: scale(1.1); } }

/* Fiche de leçon */
.av-fiche { background: #FFFDF6; }
.av-fiche-titre { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; }
.av-fiche-titre .icone { color: #F2B705; width: 28px; height: 28px; }
.av-fiche p { margin: 0; }
.av-exemples { margin: 0; padding: 10px 14px 10px 30px; background: var(--creme); border: 2px dashed var(--encre); border-radius: 14px; display: flex; flex-direction: column; gap: 4px; }
.av-astuce { margin: 0; padding: 10px 14px; background: var(--ciel); border-radius: 14px; border: 2px solid var(--encre); }
.av-sous-titre { font-size: 1.2rem; }
.av-chemins-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.av-chemins-grille .btn { flex-direction: column; gap: 2px; padding: 14px; }
.av-chemins-grille .btn b { font-family: var(--police-titre); font-size: 1.2rem; }
.av-chemins-grille .btn small { font-weight: 700; opacity: .75; }
.av-chemin-1 { background: var(--menthe); }
.av-chemin-2 { background: var(--jaune); }
.av-chemin-3 { background: var(--corail); }

/* Progression d'une série */
.av-progression { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.av-progression i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--encre); background: var(--papier); }
.av-progression i.fait { background: var(--pc); }
.av-progression i.actuel { background: var(--encre); transform: scale(1.2); }
.av-revision { margin: 0; text-align: center; font-weight: 800; }
.av-revision::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; background: var(--corail); border: 2px solid var(--encre); }

/* Exercice */
.av-exercice { align-items: stretch; }
.av-zone { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.av-question { margin: 0; font-family: var(--police-titre); font-size: clamp(1.25rem, 4.6vw, 1.9rem); line-height: 1.25; }
.av-consigne { margin: 0; opacity: .75; }
.av-phrase { font-family: var(--police); font-weight: 700; font-size: clamp(1.15rem, 4.2vw, 1.5rem); }
.av-zone .choix { max-width: 520px; }
.choix-ligne { display: flex !important; flex-wrap: wrap; justify-content: center; }
.choix-ligne .btn { width: auto !important; }
.av-saisie { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.av-saisie .champ { width: min(240px, 60vw); }
.av-unite { font-weight: 800; font-size: 1.2rem; }
.av-signe { min-width: 52px; padding-left: 12px !important; padding-right: 12px !important; font-size: 1.3rem; font-weight: 800; }
.av-saisie:has(.av-signe) .champ { width: min(240px, 40vw); }
.av-champ-ok { background: #DDF5E3 !important; }
.av-champ-ko { background: #FFE0E6 !important; }
.av-vf { display: flex; gap: 12px; justify-content: center; }
.av-vf .btn { min-width: 120px; font-size: 1.2rem; font-family: var(--police-titre); }
.av-vf .btn.bonne { background: var(--vert); } .av-vf .btn.mauvaise { background: var(--rose); } .av-vf .btn.eteint { opacity: .55; }

/* Paires */
.av-paires { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.av-colonne { display: flex; flex-direction: column; gap: 8px; }
.av-colonne .jeton { width: 100%; cursor: pointer; }
.av .jeton { font: inherit; font-weight: 800; color: var(--encre); }
.av .jeton.ok { background: var(--vert); box-shadow: none; opacity: .85; }
.av-colonne + .av-colonne .jeton:not(.ok) { background: var(--ciel); }
.av .btn:disabled.bonne, .av .btn:disabled.mauvaise { opacity: 1; }

/* Classer */
.av-zone .categories, .av-zone .glisser-elements { width: 100%; }
.av-categorie { font: inherit; color: inherit; cursor: pointer; }
.av-categorie:hover { background: var(--ciel); }

/* Ordre */
.av-ordre-ligne { list-style: none; margin: 0; padding: 10px; min-height: 58px; width: 100%; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; border: var(--trait) solid var(--encre); border-radius: 14px; background: var(--creme); counter-reset: ordre; }
.av-ordre-ligne li { counter-increment: ordre; display: flex; align-items: center; gap: 4px; }
.av-ordre-ligne li::before { content: counter(ordre); font-family: var(--police-titre); font-size: .85rem; opacity: .6; }

/* Droite graduée */
.av-droite { position: relative; width: calc(100% - 40px); height: 84px; margin: 6px 20px 0; }
.av-droite-ligne { position: absolute; left: 0; right: 0; top: 30px; border-top: 4px solid var(--encre); }
.av-droite-ligne::after { content: ""; position: absolute; right: -14px; top: -10px; border: 8px solid transparent; border-left: 12px solid var(--encre); }
.av-graduation { position: absolute; top: 0; height: 84px; transform: translateX(-50%); background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; font: inherit; color: inherit; }
.av-graduation i { display: block; width: 4px; height: 26px; margin-top: 19px; background: var(--encre); border-radius: 2px; transition: transform .1s; }
.av-graduation span { margin-top: 6px; font-size: .9rem; font-weight: 800; white-space: nowrap; }
.av-graduation:hover i { transform: scaleY(1.3); background: var(--corail); }
.av-graduation.bonne i { width: 14px; height: 14px; margin-top: 25px; border-radius: 50%; background: var(--vert); border: 3px solid var(--encre); }
.av-graduation.mauvaise i { width: 14px; height: 14px; margin-top: 25px; border-radius: 50%; background: var(--corail); border: 3px solid var(--encre); }

/* Image à légender */
.av-image { position: relative; width: 100%; max-width: 520px; border: var(--trait) solid var(--encre); border-radius: 16px; overflow: hidden; background: var(--papier); }
.av-image img { display: block; width: 100%; height: auto; }
.av-repere { position: absolute; transform: translate(-50%, -50%); min-width: 34px; height: 34px; padding: 0 8px; border-radius: 17px; border: var(--trait) solid var(--encre); background: var(--jaune); font-family: var(--police-titre); font-size: 1rem; cursor: pointer; color: var(--encre); box-shadow: 2px 2px 0 var(--encre); white-space: nowrap; }
.av-repere.ok { background: var(--vert); cursor: default; font-size: .85rem; }

/* Retour après une réponse */
.av-retour { display: flex; gap: 10px; align-items: flex-start; text-align: left; min-height: 0; }
.av-retour:empty { display: none; }
.av-retour > div { flex: 1; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--encre); }
.av-retour b { font-family: var(--police-titre); font-size: 1.15rem; }
.av-retour p { margin: 4px 0 0; }
.av-retour p:empty { display: none; }
.av-retour-bravo > div { background: #DDF5E3; }
.av-retour-oups > div { background: #FFF1C2; }
.av-bonne { font-weight: 800; }
.av-explication { opacity: .9; }

/* Bilan et diplôme */
.av-bilan .jeu-score { margin: 0; }
.av .etoile-gagnee .icone { width: 100%; height: 100%; }
.av-gain { margin: 0; min-height: 1.4em; font-family: var(--police-titre); font-size: 1.2rem; }
.av-diplome { background: #FFFDF6; border-style: double; border-width: 7px; }
.av-diplome-ruban { display: inline-flex; align-items: center; gap: 8px; padding: 6px 18px; background: var(--corail); border: var(--trait) solid var(--encre); border-radius: 999px; font-family: var(--police-titre); font-size: 1.2rem; transform: rotate(-3deg); }
.av-diplome-ruban .icone { width: 26px; height: 26px; }
.av-diplome-titre { font-size: clamp(1.5rem, 5vw, 2.2rem); }
.av-diplome-nom { margin: 0; font-family: var(--police-titre); font-size: 1.3rem; color: #C2410C; }

/* Petites animations */
.av-secoue { animation: av-secoue .35s; }
@keyframes av-secoue { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.av .btn .icone { width: 1.1em; height: 1.1em; }

@media (max-width: 600px) {
  .av-carte { padding: 16px 14px; border-radius: 20px; box-shadow: 4px 4px 0 var(--encre); }
  .av-accueil { flex-direction: column; text-align: center; }
  .av-accueil-texte { align-items: center; }
  .av-guide-grand { width: 110px; height: 110px; }

  .av-btn-carte span { display: none; }
  .av-chemin::before { left: 29px; }
  .av-etape:nth-child(even) { margin-left: 12px; }
  .av-etape-bouton { padding: 10px; gap: 10px; }
  .av-paires { gap: 8px; }
  .av-colonne .jeton { padding: 8px 8px; font-size: .95rem; }
  .av-graduation span { font-size: .78rem; }
}
