/* Jeu : les mots dessinés */

/* Repli pour les navigateurs sans color-mix() (Safari avant 16.2, vieux iPad) : sous chaque règle qui mélange
   des couleurs, un petit bloc @supports not redonne une couleur simple de base.css (la plus présente du mélange).
   Une ligne de repli écrite juste avant ne suffirait pas : une valeur qui contient var() est jugée trop tard,
   elle devient « unset » (le noir d'un SVG, un fond transparent). */

.mots-dessines__carte {
  scroll-margin-top: 5rem;
  display: grid;
  gap: var(--espace-3);
  width: 100%;
  max-width: 46rem;
  padding: var(--espace-4);
  border-radius: var(--rayon-grand);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--trait);
}

.mots-dessines__tete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--espace-3);
}

.mots-dessines__image {
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--trait);
  font-size: 1.8rem;
}

.mots-dessines__image > .icone {
  width: 2.2rem;
  height: 2.2rem;
}

.mots-dessines__titre {
  flex: 0 1 auto;
  min-width: 0;
  font-size: var(--t-titre-3);
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

.mots-dessines__devant {
  color: var(--encre-2);
  font-weight: 400;
  margin-right: 0.38em;
}

.mots-dessines__devant--elision {
  margin-right: 0.05em;
}

.mots-dessines__invite {
  font-size: 1rem;
  text-align: center;
}

/* ---------- La planche ---------- */

.mots-dessines__cadre {
  display: grid;
  place-items: center;
}

.mots-dessines__planche {
  display: block;
  width: 100%;
  height: auto;
  max-height: 21rem;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 18px;
  overflow: hidden;
}

.mots-dessines__planche.est-gomme {
  cursor: cell;
}

.mots-dessines__papier {
  fill: var(--surface);
}

.mots-dessines__reglure {
  fill: none;
  stroke: var(--trait);
  stroke-width: 2;
  stroke-dasharray: 2 8;
  stroke-linecap: round;
}

/* Le code des couleurs (22/10/2026) : le piège est surligné en jaune, sans rouge */
.mots-dessines__fond-piege {
  fill: var(--fn-piege);
  stroke: var(--fn-piege-texte);
  stroke-opacity: 0.35;
  stroke-width: 2;
}

.mots-dessines__lettre {
  font-family: var(--police-texte);
  font-weight: 700;
  font-size: 100px;
  fill: var(--encre);
}

.mots-dessines__lettre--piege {
  fill: var(--fn-piege-texte);
}

.mots-dessines__trait,
.mots-dessines__forme {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mots-dessines__traits {
  pointer-events: none;
}

.mots-dessines__c--rouge { stroke: var(--rouge); }
.mots-dessines__c--jaune { stroke: var(--jaune); }
.mots-dessines__c--vert { stroke: var(--vert); }
.mots-dessines__c--bleu { stroke: var(--bleu); }
.mots-dessines__c--violet { stroke: var(--violet); }
.mots-dessines__c--encre { stroke: var(--encre); }

.mots-dessines__p--rouge { fill: color-mix(in srgb, var(--rouge) 30%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--rouge { fill: var(--rouge); } }
.mots-dessines__p--jaune { fill: color-mix(in srgb, var(--jaune) 75%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--jaune { fill: var(--jaune); } }
.mots-dessines__p--vert { fill: color-mix(in srgb, var(--vert) 55%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--vert { fill: var(--vert); } }
.mots-dessines__p--bleu { fill: color-mix(in srgb, var(--bleu) 25%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--bleu { fill: var(--bleu); } }
.mots-dessines__p--violet { fill: color-mix(in srgb, var(--violet) 30%, transparent); }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--violet { fill: var(--violet); } }
.mots-dessines__p--encre { fill: var(--encre); }
.mots-dessines__p--verre { fill: color-mix(in srgb, var(--bleu) 14%, var(--surface)); fill-opacity: 0.85; }
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__p--verre { fill: var(--surface); } }

.mots-dessines__exemple {
  animation: mots-dessines-apparait 380ms ease-out;
}

@keyframes mots-dessines-apparait {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* le crayon du clavier */
.mots-dessines__curseur {
  display: none;
  fill: none;
  stroke-width: 3;
  stroke-dasharray: 4 4;
}

.mots-dessines__curseur.est-pose {
  stroke-dasharray: none;
  stroke-width: 5;
}

.mots-dessines__planche:focus-visible .mots-dessines__curseur {
  display: inline;
}

.mots-dessines__planche:focus-visible {
  outline: 3px solid var(--bleu);
  outline-offset: 3px;
}

/* ---------- La palette ---------- */

.mots-dessines__palette {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--espace-2) var(--espace-5);
}

.mots-dessines__rang {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--espace-2);
}

.mots-dessines__couleur,
.mots-dessines__outil {
  display: grid;
  place-items: center;
  min-width: 3rem;
  height: 3rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--encre);
  box-shadow: inset 0 0 0 2px var(--trait);
  transition: transform var(--duree), box-shadow var(--duree);
}

.mots-dessines__couleur {
  width: 3rem;
}

.mots-dessines__couleur--rouge { background: var(--rouge); }
.mots-dessines__couleur--jaune { background: var(--jaune); }
.mots-dessines__couleur--vert { background: var(--vert); }
.mots-dessines__couleur--bleu { background: var(--bleu); }
.mots-dessines__couleur--encre { background: var(--encre); }

.mots-dessines__couleur[aria-pressed="true"],
.mots-dessines__outil[aria-pressed="true"] {
  transform: translateY(-3px);
  box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 6px var(--encre);
}

.mots-dessines__outil--texte {
  min-width: 0;
  padding: 0 0.9rem;
  border-radius: var(--rayon);
  font-weight: 700;
  font-size: 0.95rem;
}

.mots-dessines__outil[disabled] {
  opacity: 0.45;
  cursor: default;
}

.mots-dessines__point {
  display: block;
  border-radius: 50%;
  background: currentColor;
}

.mots-dessines__point--fin {
  width: 0.45rem;
  height: 0.45rem;
}

.mots-dessines__point--gros {
  width: 1.1rem;
  height: 1.1rem;
}

/* la gomme : un petit pavé rose et bleu */
.mots-dessines__gomme {
  display: block;
  width: 1.5rem;
  height: 0.95rem;
  border-radius: 4px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rouge) 45%, var(--surface)) 0 55%, var(--bleu) 55% 100%);
  transform: rotate(-25deg);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__gomme { background: linear-gradient(90deg, var(--surface) 0 55%, var(--bleu) 55% 100%); } }

/* ---------- Les pièges, l'exemple, le mot à soi ---------- */

.mots-dessines__legende {
  display: grid;
  gap: var(--espace-3);
  width: 100%;
  max-width: 40rem;
}

.mots-dessines__piege {
  display: flex;
  align-items: flex-start;
  gap: var(--espace-3);
}

.mots-dessines__puce {
  flex: none;
  min-width: 2.6rem;
  padding: 0.1rem 0.55rem;
  border-radius: 10px;
  background: var(--fn-piege);
  box-shadow: inset 0 0 0 2px var(--fn-piege-texte);
  color: var(--fn-piege-texte);
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.4;
  text-align: center;
}

.mots-dessines__raison {
  font-size: 1.05rem;
}

.mots-dessines__sens {
  font-size: 1rem;
}

.mots-dessines__idee {
  max-width: 34rem;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
}

.mots-dessines__idee:empty,
.mots-dessines__message:empty {
  display: none;
}

.mots-dessines__marquer {
  display: grid;
  justify-items: center;
  gap: var(--espace-2);
}

.mots-dessines__marquer-titre {
  font-weight: 700;
}

.mots-dessines__marque {
  --taille: 2.9rem;
}

.mots-dessines__message {
  max-width: 34rem;
  text-align: center;
}

.mots-dessines__truc {
  display: grid;
  justify-items: center;
  width: 100%;
}

.mots-dessines__perso {
  display: grid;
  gap: var(--espace-2);
  width: 100%;
  max-width: 34rem;
  padding: var(--espace-4);
  border-radius: var(--rayon-grand);
  background: var(--surface-2);
}

.mots-dessines__perso-titre {
  font-family: var(--police-titre);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.mots-dessines__perso-ligne {
  display: flex;
  flex-wrap: wrap;
  gap: var(--espace-2);
}

.mots-dessines__champ {
  flex: 1 1 10rem;
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: var(--rayon);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--trait);
  font-size: 1.3rem;
  font-weight: 700;
}

.mots-dessines__champ:focus-visible {
  outline: 3px solid var(--bleu);
}

/* ---------- Le carnet ---------- */

.mots-dessines__carnet {
  display: grid;
  gap: var(--espace-2);
  width: 100%;
  max-width: 46rem;
}

.mots-dessines__carnet-titre {
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: var(--t-titre-3);
}

.mots-dessines__pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: var(--espace-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.mots-dessines__page {
  display: grid;
  gap: var(--espace-1);
  padding: var(--espace-2);
  border-radius: var(--rayon);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 2px var(--trait);
}

.mots-dessines__page--nouvelle {
  /* la page qui vient d'arriver dans le carnet : le contour bleu de « ce qui vient de changer » */
  box-shadow: inset 0 0 0 3px var(--fn-change);
}

.mots-dessines__ouvrir {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
}

.mots-dessines__planche--mini {
  max-height: 6rem;
  touch-action: auto;
  cursor: pointer;
  pointer-events: none;
}

.mots-dessines__page-pied {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--espace-2);
  padding-left: var(--espace-1);
}

.mots-dessines__page-mot {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.mots-dessines__enlever {
  flex: none;
  width: 3rem;
  height: 3rem;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--encre-2);
  font-size: 1.6rem;
  line-height: 1;
}

.mots-dessines__enlever:hover {
  background: var(--surface);
  color: var(--encre);
}

/* L'affiche de l'accueil : les deux m entourés, comme deux pommes */
.mots-dessines__glyphe {
  background: color-mix(in srgb, var(--rouge) 22%, var(--bois));
  box-shadow: inset 0 -6px 0 var(--bois-flanc), 0 0 0 3px var(--rouge);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .mots-dessines__glyphe { background: var(--bois); } }

@media (prefers-reduced-motion: reduce) {
  .mots-dessines__exemple {
    animation: none;
  }
}

@media (max-width: 520px) {
  .mots-dessines__carte {
    padding: var(--espace-3);
  }

  .mots-dessines__palette {
    gap: var(--espace-2);
  }
}

/* Les lettres que l'enfant marque comme son piège : jaune surligné (le code des couleurs, 22/10/2026) */
.mots-dessines__marque.tuile--allumee {
  background: var(--fn-piege);
  color: var(--fn-piege-texte);
  box-shadow: inset 0 -5px 0 var(--bois-flanc), 0 0 0 4px var(--fn-piege), 0 0 0 6px var(--fn-piege-texte);
}
