/* Jeu : le d qui marche à reculons */

.reculons__series {
  justify-content: center;
}

.reculons__tete {
  display: flex;
  align-items: center;
  gap: var(--espace-3);
  width: 100%;
  max-width: 34rem;
}

.reculons__consigne {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: var(--t-grand);
  line-height: 1.35;
  text-align: center;
  min-height: 2.7em;
  display: grid;
  place-items: center;
}

.reculons__plateau {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--espace-4);
  width: 100%;
  max-width: 34rem;
  padding: var(--espace-5) var(--espace-2);
  border-radius: var(--rayon-grand);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 3px var(--trait);
  overflow: hidden;
}

/* ---------- Le coup de vent ---------- */

.reculons__troupe {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.35rem, 1.5vw, 0.7rem);
  padding-bottom: var(--espace-3);
  border-bottom: 4px solid var(--trait);
  max-width: 100%;
}

.reculons__car {
  --taille: clamp(2.8rem, 2.2rem + 3vw, 3.8rem);
  cursor: pointer;
  perspective: 300px;
  animation: reculons-marche 2.4s ease-in-out infinite;
}

.reculons__car:nth-child(2n) { animation-delay: -0.6s; }
.reculons__car:nth-child(3n) { animation-delay: -1.2s; }

.reculons__car.tuile--secoue {
  animation: secouer 360ms ease;
}

/* Ils marchent sur place : rien ne défile */
@keyframes reculons-marche {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.reculons__face {
  display: inline-block;
  transition: transform 620ms cubic-bezier(0.3, 0.7, 0.3, 1.3);
}

.reculons__car.est-retourne .reculons__face {
  transform: scaleX(-1);
}

/* Un caractère retourné garde la même tuile : c'est sa forme qu'il faut regarder, pas sa couleur */

.reculons__car.fait-la-roue .reculons__face {
  animation: reculons-roue 720ms ease;
}

@keyframes reculons-roue {
  0% { transform: scaleX(-1) rotate(0); }
  60% { transform: scaleX(1) rotate(360deg) translateY(-10px); }
  100% { transform: scaleX(1) rotate(360deg); }
}

.reculons__car--tetu {
  box-shadow: inset 0 -6px 0 var(--bois-flanc), 0 0 0 3px var(--violet);
}

.reculons__car.est-fier .reculons__face {
  animation: reculons-fier 700ms ease;
}

@keyframes reculons-fier {
  0%, 100% { transform: none; }
  30% { transform: scale(1.18) rotate(-6deg); }
  60% { transform: scale(1.18) rotate(6deg); }
}

.reculons__vent {
  position: absolute;
  top: 0.4rem;
  left: -4rem;
  width: 3rem;
  height: 3rem;
  opacity: 0;
  pointer-events: none;
}

.reculons__vent .icone {
  width: 100%;
  height: 100%;
}

.reculons__vent.est-en-train {
  animation: reculons-vent 900ms ease-in forwards;
}

@keyframes reculons-vent {
  0% { left: -4rem; opacity: 0; }
  20% { opacity: 1; }
  100% { left: calc(100% + 1rem); opacity: 0; }
}

/* ---------- Une paire : b ou d, p ou q ---------- */

.reculons__carte {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--espace-3);
}

.reculons__image {
  flex: none;
  width: 2.8rem;
  height: 2.8rem;
}

.reculons__image .icone {
  width: 100%;
  height: 100%;
}

.reculons__mot {
  display: inline-flex;
  align-items: flex-end;
  font-family: var(--police-texte);
  font-weight: 700;
  font-size: clamp(2.2rem, 1.6rem + 3vw, 3.2rem);
  line-height: 1.2;
  letter-spacing: 0.05em;
  max-width: 100%;
}

.reculons__trou {
  display: inline-block;
  min-width: 0.75em;
  margin: 0 0.05em;
  border-bottom: 4px dashed var(--violet);
  text-align: center;
}

.reculons__trou.est-rempli {
  /* le code des couleurs : la lettre trouvée, c'est juste : vert pâle, et le trait plein (le signe de forme) */
  border-bottom-style: solid;
  background: var(--fn-juste);
  color: var(--fn-juste-texte);
  animation: reculons-tombe 560ms ease;
}

@keyframes reculons-tombe {
  0% { transform: translateY(-24px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}

.reculons__choix {
  display: flex;
  gap: var(--espace-5);
}

.reculons__lettre {
  --taille: clamp(3.4rem, 2.8rem + 3vw, 4.4rem);
  cursor: pointer;
}

.reculons__repere-bar {
  display: flex;
  justify-content: center;
  gap: var(--espace-3);
  width: 100%;
  max-width: 32rem;
  margin-bottom: var(--espace-2);
}

.reculons__repere-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--espace-2);
  padding: var(--espace-2) var(--espace-3);
  border-radius: var(--rayon);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--trait);
  font-size: 0.95rem;
  line-height: 1.25;
  transition: box-shadow 180ms ease, background-color 180ms ease;
}

.reculons__repere-item.est-cible {
  box-shadow: 0 0 0 3px var(--violet);
  background: var(--surface-2);
}

.reculons__repere-item .reculons__repere {
  width: 2.4rem;
}

.reculons__aide {
  min-height: 1rem;
  width: 100%;
}

.reculons__aide-ligne {
  display: flex;
  align-items: center;
  gap: var(--espace-3);
  padding: var(--espace-3);
  border-radius: var(--rayon);
  background: var(--surface);
  font-size: 1.05rem;
}

.reculons__repere {
  flex: none;
  width: 3.2rem;
}

.reculons__repere svg {
  width: 100%;
  height: auto;
}

.reculons__repere-ligne { stroke: var(--trait); stroke-width: 2; }
.reculons__repere-baton { fill: var(--violet); }
.reculons__repere-ballon { fill: none; stroke: var(--violet); stroke-width: 5; }

.reculons__truc {
  display: grid;
  gap: var(--espace-4);
  width: 100%;
  max-width: 34rem;
}

/* ---------- L'affiche ---------- */

.reculons__glyphe {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-family: var(--police-texte);
  font-weight: 700;
}

.reculons__glyphe i {
  display: inline-block;
  width: 3px;
  height: 1em;
  background: currentColor;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .reculons__car,
  .reculons__car.fait-la-roue .reculons__face,
  .reculons__car.est-fier .reculons__face,
  .reculons__trou.est-rempli {
    animation: none;
  }
}

/* La réplique d'une lettre, dans une bulle près de la rangée (la consigne reste en place) */
.reculons__bulle {
  margin: 0;
  max-width: 100%;
  text-align: center;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--trait);
}

/* La zone à toucher : la phrase d'étape, les lettres et les boutons (essai du 22/10/2026) */
.reculons__jeu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--espace-3);
  width: 100%;
}
