/* ============================================================
   LES MURS — la feuille
   ------------------------------------------------------------
   ⚠️ UN SEUL DESIGN, SIX TEINTES. Chaque outil pose `--mu-t` sur
      `<html>` : six portes se distinguent sans six feuilles a tenir.

   ⚠️ TOUT CE QUI SE PROJETTE EST EN `em`, JAMAIS EN `px` NI EN `vw`.
      Un vidéoprojecteur de classe fait 1024×768 ou 1280×720, parfois
      des proportions presque carrees. Une taille en `vw` seule
      s'effondre sur un ecran peu large mais haut : la racine mele
      donc les DEUX dimensions (§7.70).
   ============================================================ */

:root {
  --mu-t:      #7c3aed;   /* la teinte de l'outil, posee par la page */
  --mu-t-pale: #f5f3ff;
  --mu-encre:  #1a1430;
  --mu-gris:   #64748b;
  --mu-bord:   #e2e8f0;
  --mu-fond:   #fbfaff;
  --mu-carte:  #ffffff;
  --mu-vert:   #16a34a;
  --mu-ambre:  #d97706;
  --mu-rouge:  #dc2626;
  --mu-ombre:  0 1px 2px rgba(26,20,48,.06), 0 8px 24px rgba(26,20,48,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--mu-fond);
  color: var(--mu-encre);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--mu-t); }

/* ------------------------------------------------------------
   Les boutons
   ------------------------------------------------------------
   ⚠️ `.mu-b-plein` NE PORTE PAS `width:100%`. Dans OQuiz, cette
   seule ligne a casse trois ecrans : dans un conteneur flex, le
   bouton reclame toute la largeur, le `flex-shrink` le ramene a une
   fraction, et ce qui est a cote se retrouve ecrase — un titre
   affiche un mot par ligne (§7.121). Quand il doit faire toute la
   largeur, on l'ecrit sur place avec `.mu-b-large`.
   ------------------------------------------------------------ */
.mu-b {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .45em;
  padding: .7rem 1.2rem; border-radius: 12px;
  border: 1px solid var(--mu-bord); background: #fff;
  color: var(--mu-encre); font: inherit; font-weight: 600;
  font-size: 1rem; line-height: 1.2;
  cursor: pointer;
  /* 44 px : la cible minimale qu'un doigt atteint sans viser. */
  min-height: 44px;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.mu-b:hover  { box-shadow: var(--mu-ombre); }
.mu-b:active { transform: translateY(1px); }
.mu-b:focus-visible { outline: 3px solid var(--mu-t); outline-offset: 2px; }
.mu-b[disabled] { opacity: .5; cursor: not-allowed; }

.mu-b-plein  { background: var(--mu-t); border-color: var(--mu-t); color: #fff; }
.mu-b-large  { width: 100%; }
.mu-b-danger { border-color: #fecaca; color: var(--mu-rouge); }

/* ------------------------------------------------------------
   Les pages ordinaires (hors projection)
   ------------------------------------------------------------ */
.mu-page { max-width: 62rem; margin: 0 auto; padding: 1.2rem 1rem 4rem; }
.mu-etroit { max-width: 32rem; }

.mu-haut {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .9rem 1rem; margin-bottom: 1.4rem;
  background: #fff; border-bottom: 1px solid var(--mu-bord);
}
.mu-marque { display: flex; align-items: center; gap: .6rem;
             font-weight: 800; font-size: 1.05rem; text-decoration: none;
             color: var(--mu-encre); }
.mu-marque span.e { font-size: 1.5rem; line-height: 1; }

.mu-carte {
  background: var(--mu-carte); border: 1px solid var(--mu-bord);
  border-radius: 18px; padding: 1.3rem; box-shadow: var(--mu-ombre);
}

h1 { font-size: 1.6rem; margin: 0 0 .4rem; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .7rem; }
.mu-sous { color: var(--mu-gris); margin: 0 0 1.2rem; line-height: 1.5; }

label { display: block; font-weight: 600; margin: 1rem 0 .35rem; }
input[type=text], input[type=password], input[type=number],
textarea, select {
  width: 100%; padding: .75rem .9rem; font: inherit;
  border: 1px solid var(--mu-bord); border-radius: 12px;
  background: #fff; color: var(--mu-encre);
  /* ⚠️ `min-width:0` : un `<select>` prend la largeur de sa plus
     longue option et deborde de sa colonne sans cela (§7.69). */
  min-width: 0;
}
input:focus, textarea:focus, select:focus {
  outline: 3px solid var(--mu-t); outline-offset: 1px; border-color: var(--mu-t);
}
textarea { min-height: 6rem; resize: vertical; }

.mu-aide { color: var(--mu-gris); font-size: .9rem; margin: .35rem 0 0; }
.mu-err {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: 12px; padding: .8rem 1rem; margin: 1rem 0; font-weight: 600;
}
.mu-ok {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
  border-radius: 12px; padding: .8rem 1rem; margin: 1rem 0; font-weight: 600;
}

/* ------------------------------------------------------------
   L'accueil : les six portes
   ------------------------------------------------------------ */
.mu-portes {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  margin: 1.5rem 0;
}
.mu-porte {
  display: block; text-decoration: none; color: inherit;
  background: #fff; border: 1px solid var(--mu-bord); border-radius: 18px;
  padding: 1.2rem; box-shadow: var(--mu-ombre);
  border-top: 4px solid var(--p, var(--mu-t));
  transition: transform .14s ease, box-shadow .14s ease;
}
.mu-porte:hover { transform: translateY(-2px);
                  box-shadow: 0 10px 30px rgba(26,20,48,.12); }
.mu-porte .e  { font-size: 2rem; line-height: 1; display: block; margin-bottom: .5rem; }
.mu-porte .n  { font-weight: 800; font-size: 1.1rem; display: block; }
.mu-porte .q  { color: var(--mu-gris); font-size: .92rem; margin-top: .3rem;
                line-height: 1.45; }
.mu-porte .a  { color: var(--p, var(--mu-t)); font-size: .85rem; font-weight: 700;
                margin-top: .7rem; display: block; }

/* ------------------------------------------------------------
   Le code — saisi, et projete
   ------------------------------------------------------------ */
.mu-code-champ {
  font-size: 2rem; font-weight: 800; letter-spacing: .35em;
  text-align: center; text-transform: uppercase;
  padding: .9rem .5rem .9rem .85em;   /* le letter-spacing decale a droite */
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   LA PROJECTION
   ============================================================ */

/* ⚠️ LA RACINE MELE LARGEUR ET HAUTEUR (§7.70), et `--mu-auto` est
   CHERCHE par dichotomie a chaque ecran (§7.41, §7.121) : la formule
   directe se mord la queue, puisque agrandir change le nombre de
   lignes d'un titre, donc la hauteur. `--mu-z` est le zoom que le
   professeur regle — lui seul voit le fond de la salle. */
.mu-ecran {
  --mu-auto: 1;
  --mu-z: 1;
  font-size: calc(clamp(10.5px, .62vw + .62vh, 20px) * var(--mu-auto) * var(--mu-z));
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--mu-fond);
  overflow: hidden;
}
.mu-ecran-tete {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1em; padding: .9em 1.4em;
  border-bottom: 1px solid var(--mu-bord); background: #fff;
}
.mu-ecran-titre { font-size: 1.5em; font-weight: 800; margin: 0; line-height: 1.2; }
.mu-ecran-q     { font-size: 1.15em; color: var(--mu-gris); margin: .2em 0 0; }

.mu-ecran-corps {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  /* ⚠️ `safe center` : avec `center`, un contenu plus grand que la
     boite deborde DES DEUX COTES et le haut devient inatteignable
     (§7.42, §7.121). */
  justify-content: safe center;
  align-items: center;
  padding: 1em 1.4em;
  overflow: hidden;
}
.mu-ecran-pied {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1em; padding: .7em 1.4em;
  border-top: 1px solid var(--mu-bord); background: #fff;
  font-size: .95em;
}

/* Le code au tableau : c'est le seul chiffre que toute la classe doit
   lire du fond de la salle. */
.mu-gros-code {
  font-size: 2.1em; font-weight: 800; letter-spacing: .14em;
  color: var(--mu-t); font-variant-numeric: tabular-nums;
}
.mu-gens { font-size: 1.1em; font-weight: 700; color: var(--mu-gris); }

/* ------------------------------------------------------------
   Le nuage de mots
   ------------------------------------------------------------ */
.mu-nuage { width: 100%; height: 100%; display: block; }
.mu-nuage text {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 800;
  /* ⚠️ `transition` sur la TAILLE, pas sur la position : un mot qui
     grossit quand son compte monte est la seule animation que la
     reference montre vraiment, et celle qui dit quelque chose. */
  transition: font-size .5s cubic-bezier(.2,.8,.2,1), opacity .4s ease;
}
.mu-nuage text.neuf { animation: mu-pop .5s cubic-bezier(.2,.9,.3,1.3); }
@keyframes mu-pop {
  from { opacity: 0; transform: scale(.4); }
  to   { opacity: 1; transform: scale(1); }
}

/* ------------------------------------------------------------
   Le sondage
   ------------------------------------------------------------ */
.mu-barres { width: 100%; max-width: 48em; display: flex;
             flex-direction: column; gap: .75em; }
.mu-barre-l { display: grid; grid-template-columns: 1fr auto; gap: .5em .9em; }
.mu-barre-t { font-size: 1.15em; font-weight: 700; }
.mu-barre-n { font-size: 1.15em; font-weight: 800; color: var(--mu-t);
              font-variant-numeric: tabular-nums; }
.mu-barre-p { grid-column: 1 / -1; height: 1.5em; border-radius: 999px;
              background: #fff; border: 1px solid var(--mu-bord); overflow: hidden; }
.mu-barre-f { height: 100%; border-radius: 999px; background: var(--mu-t);
              transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* ------------------------------------------------------------
   Les cartes : post-it, questions, brainstorming
   ------------------------------------------------------------ */
.mu-cartes {
  width: 100%; height: 100%;
  display: grid; gap: .8em; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(16em, 1fr));
  overflow: hidden;
}
.mu-c {
  background: #fff; border: 1px solid var(--mu-bord);
  border-left: .35em solid var(--c, var(--mu-t));
  border-radius: 14px; padding: .85em 1em;
  box-shadow: var(--mu-ombre);
  animation: mu-entre .45s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes mu-entre {
  from { opacity: 0; transform: translateY(1em) scale(.96); }
  to   { opacity: 1; transform: none; }
}
.mu-c-txt  { font-size: 1.05em; line-height: 1.45; }
.mu-c-bas  { display: flex; align-items: center; justify-content: space-between;
             gap: .6em; margin-top: .6em; font-size: .85em; color: var(--mu-gris); }
.mu-c-aime { font-weight: 800; color: var(--mu-t); }
.mu-c.epinglee { border-color: var(--mu-ambre); background: #fffbeb; }
.mu-c.traitee  { opacity: .55; }
.mu-c.traitee .mu-c-txt { text-decoration: line-through;
                          text-decoration-color: rgba(26,20,48,.3); }

/* ------------------------------------------------------------
   Le pendu
   ------------------------------------------------------------ */
.mu-pendu { display: flex; flex-direction: column; align-items: center;
            gap: .8em; width: 100%; height: 100%;
            justify-content: safe center; }
.mu-scene { flex: 0 1 auto; max-height: 52%; }
.mu-mot   { display: flex; flex-wrap: wrap; gap: .3em; justify-content: center; }
.mu-l {
  width: 1.3em; height: 1.7em;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2em; font-weight: 800;
  border-bottom: .12em solid var(--mu-encre);
}
.mu-l.sep { border-bottom: none; width: .7em; }
.mu-l.pleine { animation: mu-pop .4s cubic-bezier(.2,.9,.3,1.3); }
.mu-ratees { display: flex; gap: .35em; flex-wrap: wrap; justify-content: center;
             font-size: 1.3em; font-weight: 800; color: var(--mu-rouge); }
.mu-ratees span { text-decoration: line-through; }
.mu-indice { font-size: 1.1em; color: var(--mu-gris); font-style: italic; }

/* ------------------------------------------------------------
   Le téléphone de l'élève
   ------------------------------------------------------------ */
.mu-tel { min-height: 100svh; display: flex; flex-direction: column; }
/* ⚠️ `svh` ET NON `vh` : sur un telephone, `vh` compte une barre de
   navigateur qui n'est pas la, et le bouton d'envoi tombe sous le
   bord de l'ecran (§7.121). */
.mu-tel-corps { flex: 1 1 auto; padding: 1.1rem 1rem 2rem; }

.mu-choix { display: grid; gap: .7rem; margin: 1.2rem 0; }
.mu-choix button {
  text-align: left; padding: 1rem 1.1rem; font-size: 1.05rem;
  border-radius: 14px; border: 2px solid var(--mu-bord); background: #fff;
  font: inherit; font-weight: 600; cursor: pointer; min-height: 56px;
}
.mu-choix button.pris {
  border-color: var(--mu-t); background: var(--mu-t-pale); color: var(--mu-t);
}

.mu-clavier { display: grid; grid-template-columns: repeat(7, 1fr);
              gap: .4rem; margin: 1rem 0; }
.mu-clavier button {
  aspect-ratio: 1; font-size: 1.1rem; font-weight: 800;
  border-radius: 10px; border: 1px solid var(--mu-bord); background: #fff;
  font-family: inherit; cursor: pointer; min-height: 0;
}
.mu-clavier button.jouee  { opacity: .3; cursor: not-allowed; }
.mu-clavier button.juste  { background: #f0fdf4; border-color: #86efac; color: #166534; }
.mu-clavier button.ratee  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ------------------------------------------------------------
   La liste du professeur
   ------------------------------------------------------------ */
.mu-liste { display: grid; gap: .8rem; }
.mu-m {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--mu-bord); border-radius: 14px;
  padding: .9rem 1rem; border-left: 4px solid var(--c, var(--mu-t));
}
.mu-m-e { font-size: 1.6rem; line-height: 1; }
.mu-m-t { flex: 1 1 12rem; min-width: 0; }
.mu-m-t b { display: block; font-size: 1.02rem; }
.mu-m-t span { color: var(--mu-gris); font-size: .85rem; }
.mu-m-c { font-weight: 800; letter-spacing: .1em; color: var(--mu-t); }
.mu-badge { font-size: .72rem; font-weight: 800; text-transform: uppercase;
            letter-spacing: .04em; padding: .25em .6em; border-radius: 999px;
            background: var(--mu-t-pale); color: var(--mu-t); }
.mu-badge.ouvert { background: #f0fdf4; color: #166534; }
.mu-badge.ferme  { background: #f1f5f9; color: var(--mu-gris); }

/* ------------------------------------------------------------
   Le QR
   ------------------------------------------------------------ */
.mu-qr { background: #fff; padding: .8rem; border-radius: 14px;
         border: 1px solid var(--mu-bord); display: inline-block; }
.mu-qr svg { display: block; width: 100%; height: auto; }

/* ------------------------------------------------------------
   Sous 760 px
   ------------------------------------------------------------ */
@media (max-width: 760px) {
  .mu-page { padding: 1rem .8rem 3rem; }
  .mu-cartes { grid-template-columns: 1fr; }
  .mu-haut { padding: .7rem .8rem; }
}

/* ============================================================
   ⚠️ CE BLOC DOIT RESTER LE DERNIER DE LA FEUILLE.
      Toute animation ecrite APRES lui LUI ECHAPPE, et rien ne le
      signale — c'est §7.121, ou un `*/` orphelin avait avale le bloc
      entier : 45 regles s'animaient sans contre-ordre et la mesure
      rendait `blocs_media: 0`.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
