/* Jeu : le plateau de Kim */

/* 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). */

.kim__niveaux,
.kim__choix-son {
  justify-content: center;
  flex-wrap: wrap;
}

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

.kim__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;
  transition: background var(--duree), color var(--duree), transform var(--duree);
}

.kim__consigne--bravo {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: #e6f9ed;
  color: #146c38;
  box-shadow: inset 0 0 0 2px #1f9d55;
  animation: entrer 380ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

/* ---------- Le plateau de bois et son torchon ---------- */

.kim__cadre {
  position: relative;
  width: 100%;
  max-width: 26rem;
  max-width: min(26rem, max(16rem, calc(100vh - 23rem)));
  max-width: min(26rem, max(16rem, calc(100dvh - 23rem)));
  padding: clamp(0.6rem, 2.2vw, 1rem);
  border-radius: 26px;
  background: var(--bois-flanc);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.2), 0 6px 0 var(--ombre);
  overflow: hidden;
}

.kim__plateau {
  --colonnes: 3;
  display: grid;
  grid-template-columns: repeat(var(--colonnes), minmax(0, 1fr));
  gap: clamp(0.45rem, 2vw, 0.9rem);
  padding: clamp(0.6rem, 2.5vw, 1rem);
  border-radius: 18px;
  background:
    repeating-linear-gradient(0deg,
      var(--bois) 0 18px,
      color-mix(in srgb, var(--bois-flanc) 22%, var(--bois)) 18px 20px);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.18);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .kim__plateau { background: repeating-linear-gradient(0deg, var(--bois) 0 18px, var(--bois) 18px 20px); } }

.kim__plateau--quatre {
  max-width: 26rem;
  margin: 0 auto;
}

.kim__place {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 18px;
}

.kim__place--vide {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--bois-encre) 22%, transparent);
  background: color-mix(in srgb, var(--bois-encre) 6%, transparent);
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .kim__place--vide { background: transparent; } }

.kim__objet {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 0.35rem;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.42);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
  font-size: 4.5rem;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.kim__objet > .icone {
  width: clamp(4.2rem, 74%, 5.4rem);
  height: clamp(4.2rem, 74%, 5.4rem);
}

.kim__plateau--quatre .kim__objet > .icone {
  width: clamp(5rem, 76%, 6.5rem);
  height: clamp(5rem, 76%, 6.5rem);
}

.kim__plateau--neuf .kim__objet > .icone {
  width: clamp(3.5rem, 72%, 4.4rem);
  height: clamp(3.5rem, 72%, 4.4rem);
}

.kim__objet .icone {
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.16));
  transition: transform var(--duree);
}

.kim__objet:hover .icone {
  transform: scale(1.08) rotate(-3deg);
}

.kim__objet.est-touche .icone {
  animation: kim-saute 360ms ease;
}

@keyframes kim-saute {
  0%, 100% { translate: 0 0; }
  35% { translate: 0 -8px; }
}

/* Le code des couleurs : trouvé = halo vert/or très visible avec pastille ✓ et rebond joyeux ; montré (« Montre-moi ») = contour bleu */
.kim__cadre.est-bravo {
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.2), 0 0 0 4px #1f9d55, 0 8px 24px rgba(31, 157, 85, 0.28);
}

.kim__objet.est-trouve {
  position: relative;
  background: #e6f9ed;
  color: #146c38;
  box-shadow: inset 0 0 0 4px #1f9d55, 0 0 0 5px rgba(250, 204, 21, 0.7), 0 8px 18px rgba(31, 157, 85, 0.35);
  animation: kim-victoire 620ms cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

.kim__objet.est-trouve::after {
  content: '\2713';
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 999px;
  background: #146c38;
  color: #ffffff;
  font-family: var(--police-texte);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

@keyframes kim-victoire {
  0% { transform: scale(0.75); }
  45% { transform: scale(1.14) rotate(-4deg); }
  75% { transform: scale(1.05) rotate(3deg); }
  100% { transform: scale(1); }
}

.kim__objet.est-montre {
  box-shadow: inset 0 0 0 3px var(--fn-change);
}

.kim__objet--revient {
  animation: entrer 480ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.kim__objet--retourne {
  animation: kim-retourne 520ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

@keyframes kim-retourne {
  from { transform: rotateY(90deg) scale(0.8); }
  to { transform: none; }
}

/* Le torchon à carreaux, qui tombe du haut */
.kim__torchon {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 22px;
  background:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--rouge) 55%, transparent) 0 22px, transparent 22px 44px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--rouge) 55%, transparent) 0 22px, transparent 22px 44px),
    var(--sur-rouge);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12), 0 8px 18px var(--ombre);
  transform: translateY(-108%) rotate(-2deg);
  transition: transform 520ms cubic-bezier(0.5, 0, 0.3, 1);
  pointer-events: none;
}
@supports not (color: color-mix(in srgb, red 50%, blue)) { .kim__torchon { background: repeating-linear-gradient(90deg, var(--rouge) 0 22px, transparent 22px 44px), repeating-linear-gradient(0deg, var(--rouge) 0 22px, transparent 22px 44px), var(--sur-rouge); } }

.kim__torchon.est-pose {
  transform: none;
  pointer-events: auto;
}

/* ---------- Les objets à choisir, quand un objet a disparu ---------- */

.kim__reserve {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--espace-3);
  animation: entrer 360ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.kim__choix {
  display: grid;
  place-items: center;
  width: 5.5rem;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 3px var(--trait), inset 0 -5px 0 var(--trait);
  font-size: 3.8rem;
  transition: transform var(--duree), opacity var(--duree);
}

.kim__choix > .icone {
  width: 3.8rem;
  height: 3.8rem;
}

.kim__choix:hover {
  transform: translateY(-3px);
}

.kim__choix.est-ecarte {
  opacity: 0.35;
  cursor: default;
}

.kim__choix.est-ecarte:hover {
  transform: none;
}

/* ---------- La carte de vérification et de réussite ---------- */

.kim__phrase {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem 1rem;
  width: 100%;
  max-width: 36rem;
  padding: 0.85rem 1.1rem;
  border-radius: 22px;
  background: var(--surface-2);
  box-shadow: inset 6px 0 0 var(--accent), inset 0 0 0 2px var(--trait);
  animation: entrer 420ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.kim__phrase--bravo {
  background: #ecfdf3;
  color: #0f3d23;
  box-shadow: inset 0 0 0 3px #1f9d55, 0 6px 0 rgba(31, 157, 85, 0.22);
}

.kim__phrase--bravo .kim__phrase-texte {
  color: #0f3d23;
}

.kim__phrase--bravo .bouton-voix {
  background: #d1fae5;
  color: #0f3d23;
  box-shadow: inset 0 0 0 2px #146c38;
}

.kim__phrase-visuels {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.kim__phrase-medaillon {
  display: grid;
  place-items: center;
  width: 4.3rem;
  height: 4.3rem;
  border-radius: 18px;
  background: #fbf6ec;
  color: #0f3d23;
  box-shadow: inset 0 0 0 2px rgba(31, 157, 85, 0.35), 0 3px 8px rgba(0, 0, 0, 0.08);
}

.kim__phrase-medaillon > .icone {
  width: 3.2rem;
  height: 3.2rem;
}

.kim__phrase-fleche {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--vert);
}

.kim__phrase--bravo .kim__phrase-fleche {
  color: #146c38;
}

.kim__phrase-corps {
  flex: 1 1 13rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
}

.kim__phrase-bravo {
  margin: 0;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--vert);
}

.kim__phrase--bravo .kim__phrase-bravo {
  color: #146c38;
}

.kim__phrase-texte {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.35;
  color: var(--encre);
}

.kim__phrase-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.kim__cacher {
  min-width: 12rem;
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
}

.kim__truc {
  display: grid;
  justify-items: center;
  gap: var(--espace-4);
  width: 100%;
}

.kim__truc .petit-savoir {
  max-width: 36rem;
}

/* La zone du jeu : la ligne d'étape, le plateau et ses boutons, resserrés d'un seul regard */
.kim__jeu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}

.kim__jeu > [hidden] {
  display: none !important;
}
