/* =====================================================================
   MATALO - Maquette : page de démonstration (lot 079) - demo.html
   1) les règles du moteur d'exercices de la PROD (copiées de
      prod/app/css/matalo.css, partie « moteur d'exercices ») ;
   2) la mise en page de la démo : barre de navigation entre les 5 univers,
      une section par niveau (chaque section porte la classe de son thème :
      theme-ferme, theme-chevaliers, theme-jungle, (pirates), theme-espace).
   ===================================================================== */

/* ---------- 1. moteur d'exercices (copie de la PROD) ---------- */
/* moteur d'exercices */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; }
.frac .num { border-bottom: 3px solid currentColor; padding: 0 .15em .06em; }
.frac .den { padding-top: .06em; }
.frac .fracbar { display: none; }
.math { white-space: nowrap; }
.trous { color: var(--bois-300); letter-spacing: 2px; }
.aide-exo { text-align: center; color: var(--encre-2); margin: 0 0 18px; }
.note-essai { text-align: center; color: #e8f6f8; margin: 18px 0 0; }
.tuile.mec-choisi, .tuile.mec-encours { background: var(--or-300); box-shadow: 0 6px 0 var(--or-700); color: var(--bois-900); }
.tuile.mec-bon { background: var(--succes); color: #fff; box-shadow: 0 6px 0 var(--succes-fonce); }
.tuile.mec-faux { background: var(--erreur); color: #fff; box-shadow: 0 6px 0 var(--erreur-fonce); animation: secoue .4s; }
.mec-zone[data-mecanique="tri"] .tuile.mec-choisi, .mec-zone[data-mecanique="assemblage"] .tuile.mec-choisi { opacity: .35; }
.tuile[disabled] { cursor: default; }
.colonnes .tuile { display: block; }
/* placement : graduations cliquables */
.placement { position: relative; display: flex; justify-content: space-between; margin: 10px 4px 6px; padding-top: 6px; }
.placement::before { content: ""; position: absolute; left: 14px; right: 14px; top: 22px; height: 6px; border-radius: 3px; background: var(--ocean-900); }
.placement .graduation { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 32px; }
.placement .point { width: 34px; height: 34px; border-radius: 50%; border: 5px solid var(--ocean-900); background: #fff; cursor: pointer; transition: transform .1s, background .15s; padding: 0; }
.placement .point:hover { transform: scale(1.15); background: var(--ocean-100); }
.placement .point.mec-choisi { background: var(--or-500); border-color: var(--or-700); }
.placement .graduation b { font-size: 1.15rem; color: var(--encre); white-space: nowrap; }
/* support "droite graduee" */
.droite-support { display: flex; justify-content: space-between; align-items: flex-end; margin: 22px auto 0; max-width: 560px; height: 120px; position: relative; padding: 0 6px; }
.droite-support::before { content: ""; position: absolute; left: 0; right: 0; bottom: 48px; height: 5px; border-radius: 3px; background: var(--ocean-900); }
.droite-support .trait { position: relative; width: 3px; height: 24px; margin-bottom: 38px; background: var(--ocean-900); border-radius: 2px; }
.droite-support .trait.grand { height: 40px; margin-bottom: 30px; width: 4px; }
.droite-support .trait b { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); font-size: 1.1rem; white-space: nowrap; }
.droite-support .trait.cible { background: var(--corail); }
.droite-support .question { position: absolute; bottom: 58px; left: 50%; transform: translateX(-50%); font-weight: 700; color: var(--corail); white-space: nowrap; }
.droite-support .fleche { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); color: var(--corail); }
/* assemblage : cases de lettres */
.cases-lettres { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 24px; padding: 14px; background: #fff; border-radius: 14px; box-shadow: inset 0 2px 6px rgba(0,0,0,.12); }
.case-lettre { width: 46px; height: 56px; border-radius: 10px; border: 3px dashed rgba(154,91,46,.45); background: #fffaf0; font-size: 1.5rem; font-weight: 700; color: var(--ocean-900); cursor: pointer; font-family: var(--police); }
.case-lettre:not(:empty) { border-style: solid; border-color: var(--or-500); }
.mec-support .math { font-size: inherit; }
.bandeau-reponse .piece { vertical-align: middle; }

/* ---------- Fractions dessinees dans les consignes et supports (lot 009) ---------- */
.mec-consigne .frac, .consigne .frac { font-size: .92em; margin: 0 .18em; vertical-align: middle; }
.mec-consigne .frac .num { border-bottom-width: 2px; }
.support-comparaison { display: inline-flex; align-items: center; justify-content: center; gap: .9em; }
.support-comparaison .terme { display: inline-flex; align-items: center; }
.support-comparaison .frac { margin: 0; }

/* ---------- 2. page de démonstration ---------- */
html { scroll-behavior: smooth; scroll-padding-top: 78px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body.page-demo { background: #0d2230; min-height: 100vh; }

/* couleur propre a chaque univers (nav, onglets, pastilles) */
[data-u="cp"]  { --u: #c2452d; --u2: #6e8024; --u-clair: #fde7d8; }
[data-u="ce1"] { --u: #8a2a3b; --u2: #3a5aa8; --u-clair: #f6e1e5; }
[data-u="ce2"] { --u: #2f7d3b; --u2: #b7791f; --u-clair: #e1f3e0; }
[data-u="cm1"] { --u: #0f6f8f; --u2: #d99a1c; --u-clair: #dff3f7; }
[data-u="cm2"] { --u: #4b3bc4; --u2: #ff5d8f; --u-clair: #e6e3ff; }

/* --- barre de navigation (toujours visible) --- */
.demo-nav {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  padding: 10px clamp(12px, 3vw, 28px);
  background: rgba(10, 22, 34, .92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px -10px rgba(0,0,0,.7);
  color: #fff;
}
.demo-nav .marque { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; flex: none; }
.demo-nav .marque b { font-family: "Montserrat", "Fredoka", sans-serif; font-weight: 800; font-size: 1.35rem; letter-spacing: .5px; }
.demo-nav .marque small { display: block; font-size: .72rem; opacity: .7; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.demo-nav ol { position: relative; list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex: 1; justify-content: center; overflow-x: auto; scrollbar-width: none; }
.demo-nav ol::-webkit-scrollbar { display: none; }
.demo-nav a.univers-lien {
  display: flex; align-items: center; gap: 9px; text-decoration: none; color: #fff;
  padding: 5px 14px 5px 5px; border-radius: 999px; white-space: nowrap;
  background: rgba(255,255,255,.08); border: 2px solid transparent;
  transition: background .2s, border-color .2s, transform .15s;
}
.demo-nav a.univers-lien:hover { background: rgba(255,255,255,.16); transform: translateY(-1px); }
.demo-nav a.univers-lien img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 0 0 2px var(--u); }
.demo-nav a.univers-lien .niv { font-weight: 800; font-size: .95rem; }
.demo-nav a.univers-lien .nom { font-size: .82rem; opacity: .85; }
.demo-nav a.univers-lien .score { font-size: .72rem; font-weight: 700; background: rgba(255,255,255,.15); border-radius: 999px; padding: 1px 7px; }
.demo-nav a.univers-lien .score:empty { display: none; }
.demo-nav a.univers-lien.actif { background: var(--u); border-color: #fff; box-shadow: 0 4px 14px -4px var(--u); }
.demo-nav .fleches { display: flex; gap: 6px; flex: none; }
.demo-nav .fleches button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; font-size: 1rem; }
.demo-nav .fleches button:hover { background: rgba(255,255,255,.25); }
.demo-nav .fleches button:disabled { opacity: .3; cursor: default; }
/* le nom de l'univers : seulement sur l'univers courant (tous sur les grands ecrans) */
.demo-nav a.univers-lien .nom { display: none; }
.demo-nav a.univers-lien.actif .nom { display: inline; }
@media (min-width: 1560px) { .demo-nav a.univers-lien .nom { display: inline; } }
@media (max-width: 640px) {
  .demo-nav { gap: 8px; padding: 8px 10px; }
  .demo-nav .marque small, .demo-nav .fleches { display: none; }
  .demo-nav ol { justify-content: flex-start; }
  .demo-nav a.univers-lien { padding: 3px 10px 3px 3px; }
  .demo-nav a.univers-lien img { width: 28px; height: 28px; }
}

/* --- accueil : les 5 univers d'un coup d'oeil --- */
.demo-accueil { padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 40px) clamp(30px, 5vw, 60px); color: #fff; text-align: center;
  background: radial-gradient(900px 420px at 50% -10%, rgba(31,163,184,.35), transparent 70%), linear-gradient(180deg, #123448, #0d2230); }
.demo-accueil h1 { font-family: "Montserrat", "Fredoka", sans-serif; font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 0 0 10px; line-height: 1.15; }
.demo-accueil p.intro { max-width: 760px; margin: 0 auto 28px; font-size: 1.1rem; color: #cfe6ee; }
.demo-accueil p.intro b { color: #fff; }
.vignettes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; max-width: 1240px; margin: 0 auto; }
@media (max-width: 1000px) { .vignettes { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .vignettes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.vignette { position: relative; display: block; text-decoration: none; color: #fff; border-radius: 22px; overflow: hidden; background: var(--u);
  box-shadow: 0 10px 26px -12px rgba(0,0,0,.8); transition: transform .2s, box-shadow .2s; }
.vignette:hover, .vignette:focus-visible { transform: translateY(-4px) rotate(-.5deg); box-shadow: 0 18px 34px -12px rgba(0,0,0,.9); outline: none; }
.vignette:focus-visible { box-shadow: 0 0 0 4px #fff, 0 18px 34px -12px rgba(0,0,0,.9); }
.vignette .decor { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.vignette .perso { position: absolute; bottom: 64px; width: 42%; filter: drop-shadow(0 6px 6px rgba(0,0,0,.4)); }
.vignette .perso.g { left: 2%; } .vignette .perso.f { right: 2%; }
.vignette .texte { display: block; padding: 10px 12px 14px; text-align: left; min-height: 64px; }
.vignette .texte b { display: inline-block; background: #fff; color: var(--u); font-weight: 800; border-radius: 8px; padding: 0 8px; font-size: .9rem; margin-bottom: 3px; }
.vignette .texte span { display: block; font-weight: 700; line-height: 1.2; }
.demo-accueil .astuces { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin: 26px auto 0; font-size: .95rem; color: #cfe6ee; }
.demo-accueil .astuces i { color: #ffd76a; margin-right: 6px; }
@media (hover: none) { .demo-accueil .astuces .clavier { display: none; } }
.demo-accueil kbd { background: rgba(255,255,255,.15); border-radius: 6px; padding: 1px 7px; font-family: inherit; font-weight: 700; color: #fff; }

/* --- une section par niveau, dans son theme --- */
.niveau.ocean { min-height: auto; padding: clamp(20px, 3vw, 36px) 0 clamp(36px, 5vw, 60px); overflow: hidden; isolation: isolate; }
/* le decor anime du theme reste dans sa section (en PROD il couvre toute la page) */
.niveau.ocean::before { position: absolute; z-index: -1; }
.niveau + .niveau { border-top: 6px solid rgba(0,0,0,.25); }
.niveau .entete-univers { max-width: 980px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 32px); display: flex; align-items: center; gap: 18px; }
.niveau .entete-univers .mascotte { width: 92px; height: 92px; flex: none; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); animation: flotte 4s ease-in-out infinite; }
@keyframes flotte { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .niveau .entete-univers .mascotte { animation: none; } }
.niveau .entete-univers .titres { flex: 1; min-width: 0; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.35); }
.niveau .entete-univers .titres .niv { display: inline-block; background: #fff; color: var(--u); text-shadow: none; font-weight: 800; border-radius: 10px; padding: 1px 10px; margin-right: 8px; font-size: 1rem; vertical-align: 6px; }
.niveau .entete-univers h2 { margin: 0; font-family: var(--police-titre); font-weight: 400; font-size: clamp(1.7rem, 3.4vw, 2.5rem); line-height: 1.1; }
.niveau .entete-univers p { margin: 4px 0 0; font-weight: 500; opacity: .95; }
.niveau .entete-univers .bulle-u { position: relative; background: #fff; color: var(--encre); border-radius: 16px; padding: 10px 14px; font-weight: 600; font-size: .92rem; max-width: 300px; box-shadow: var(--ombre-s); }
.niveau .entete-univers .bulle-u::before { content: ""; position: absolute; left: -9px; top: 50%; margin-top: -9px; border: 9px solid transparent; border-left: 0; border-right-color: #fff; }
@media (max-width: 760px) { .niveau .entete-univers .bulle-u { display: none; } .niveau .entete-univers .mascotte { width: 70px; height: 70px; } }

/* onglets : les 5 exercices du niveau */
.onglets-exos { max-width: 980px; margin: 18px auto 0; padding: 0 clamp(16px, 3vw, 32px); display: flex; gap: 8px; flex-wrap: wrap; }
.onglet-exo { display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: .92rem;
  padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(255,255,255,.85); color: var(--encre); box-shadow: 0 3px 0 rgba(0,0,0,.18); transition: transform .12s, background .2s; }
.onglet-exo:hover { transform: translateY(-1px); background: #fff; }
.onglet-exo .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--u-clair); color: var(--u); font-weight: 800; font-size: .85rem; }
.onglet-exo.actif { background: #fff; box-shadow: 0 0 0 3px var(--u), 0 3px 0 rgba(0,0,0,.18); }
.onglet-exo.actif .n { background: var(--u); color: #fff; }
.onglet-exo.ok .n { background: var(--succes); color: #fff; }
.onglet-exo.ko .n { background: var(--erreur); color: #fff; }
.onglet-exo.ok .n::after { content: "\2713"; } .onglet-exo.ko .n::after { content: "\2717"; }
.onglet-exo.ok .n span, .onglet-exo.ko .n span { display: none; }

/* la scene : barre du haut + carte de l'exercice (comme dans l'application) */
.niveau .scene-exo { padding-top: 14px; padding-bottom: 0; }
.niveau .barre-exo { position: static; border-radius: 18px 18px 0 0; }
.niveau .carte-exo { border-top-left-radius: 0; border-top-right-radius: 0; }
.niveau .barre-exo .ile-mini span small { display: block; font-weight: 600; font-size: .72rem; opacity: .75; text-transform: uppercase; letter-spacing: .5px; }
.niveau .compteur img { width: 24px; height: 24px; vertical-align: -5px; display: inline-block; }
.mec-ecouter { display: inline-flex; align-items: center; justify-content: center; width: 2.1em; height: 2.1em; margin: 0 .45em .15em 0; border: 0; border-radius: 50%;
  background: #2f7d5b; color: #fff; font-size: .8em; vertical-align: middle; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.25); transition: transform .1s; }
.mec-ecouter:hover { transform: scale(1.08); }
.mec-ecouter.lit { background: #d9822b; animation: mecEcoute 1s ease-in-out infinite; }
@keyframes mecEcoute { 50% { box-shadow: 0 0 0 .35em rgba(217,130,43,.35); } }
.etiquette-exo { display: inline-flex; gap: 6px; align-items: center; font-size: .78rem; font-weight: 700; color: var(--encre-3); text-transform: uppercase; letter-spacing: .6px; margin: 0 0 8px 8px; }
.tuile.mec-solution { box-shadow: 0 0 0 4px var(--succes), 0 6px 0 var(--succes-fonce); }

/* retour apres la reponse (dans la carte, pas en bas de l'ecran) */
.retour-exo { display: none; align-items: center; gap: 16px; margin: 0 clamp(16px, 3vw, 34px) 26px; padding: 14px 18px; border-radius: 18px; color: #fff; }
.retour-exo.visible { display: flex; animation: monte .25s ease; }
.retour-exo.bon { background: var(--succes); box-shadow: 0 6px 0 var(--succes-fonce); }
.retour-exo.faux { background: var(--erreur); box-shadow: 0 6px 0 var(--erreur-fonce); }
.retour-exo img { width: 64px; height: 64px; object-fit: contain; flex: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.3)); }
.retour-exo .texte { flex: 1; min-width: 0; }
.retour-exo h3 { margin: 0; font-size: 1.3rem; }
.retour-exo p { margin: 2px 0 0; opacity: .95; }
.retour-exo .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.retour-exo .btn { white-space: nowrap; }
@media (max-width: 640px) { .retour-exo { flex-wrap: wrap; } .retour-exo img { width: 48px; height: 48px; } .retour-exo .actions { width: 100%; justify-content: center; } }

/* bilan du niveau */
.bilan-niveau { display: none; max-width: 980px; margin: 18px auto 0; padding: 0 clamp(16px, 3vw, 32px); }
.bilan-niveau.visible { display: block; }
.bilan-niveau .parchemin { display: flex; align-items: center; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
.bilan-niveau .etoiles { font-size: 1.6rem; color: var(--or-500); letter-spacing: 2px; }
.bilan-niveau .texte { flex: 1; min-width: 200px; font-weight: 600; }

/* pied de page */
.demo-pied { text-align: center; color: #cfe6ee; padding: 36px 16px 46px; background: #0d2230; }
.demo-pied h2 { color: #fff; font-family: "Montserrat", "Fredoka", sans-serif; font-weight: 800; margin: 0 0 8px; }
.demo-pied .boutons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.ligne-reponse.mec-bon-texte { color: var(--succes-fonce); box-shadow: inset 0 0 0 3px var(--succes); }
.ligne-reponse.mec-faux-texte { color: var(--erreur-fonce); box-shadow: inset 0 0 0 3px var(--erreur); }
.demo-nav .marque .ile-logo { width: 40px; height: 40px; object-fit: contain; }

/* Lot 117 : titre du CE1 (« Le Royaume des chevaliers ») : la Cinzel Decorative en graisse normale
   dessinait des lettres fantaisie peu lisibles (E, H) ; on passe en Cinzel grasse, plus lisible. */
.niveau.theme-chevaliers .entete-univers h2 { font-family: "Cinzel", "Cinzel Decorative", Georgia, serif; font-weight: 900; letter-spacing: .5px; }
