/* Plateau Wordle commun au solo et au multi : grille, clavier, messages. */

/* L'attribut hidden doit gagner sur les display des composants (.btn est en
   inline-flex dans le CSS partagé, .clavier en flex…). */
[hidden] {
  display: none !important;
}

#app {
  max-width: 580px;
  padding: 16px 16px 20px;
}
/* Le bandeau partagé compense le padding de #app par des marges négatives :
   elles doivent suivre le padding ci-dessus, sinon il déborde de la page. */
#app > .jeu-banner {
  margin: -16px -16px 10px;
}
/* Sur un écran peu haut, les pastilles du bandeau cèdent leur place au plateau. */
@media (max-height: 820px) {
  body.wordle-plateau .banner-deco { display: none; }
}

.wordle-zone {
  touch-action: manipulation;
}

/* --- Bandeau d'infos de partie (badges + indice) --- */
.infos-partie {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 10px;
  margin: 10px 0 8px;
  font-size: 0.82rem;
  color: var(--texte-doux);
}
.badge-partie {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--texte);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 9px;
}
.score-session b {
  color: var(--texte);
}

.zone-indice {
  min-height: 1.4em;
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--texte-doux);
}
.zone-indice .texte-indice {
  font-style: italic;
}
.btn-indice {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--texte);
  background: var(--surface-2);
  border: 1px dashed var(--line-forte);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}
.btn-indice:hover {
  border-color: var(--color-mid);
}

/* --- Grille ---
   --lettres est posé par le JS. La taille d'une case est la plus petite de trois
   limites : 58 px, la largeur disponible divisée par le nombre de lettres, et la
   hauteur d'écran, pour que grille + clavier tiennent sans défiler. */
.grille-wordle {
  --lettres: 5;
  --gap: 6px;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  margin: 0 auto 12px;
  width: 100%;
}
.grille-ligne {
  display: flex;
  gap: var(--gap);
}
.grille-case {
  --case: min(58px, calc((100vw - 64px - (var(--lettres) - 1) * var(--gap)) / var(--lettres)), max(30px, calc((100svh - 460px) / 6)));
  --case: min(58px, calc((100cqw - (var(--lettres) - 1) * var(--gap)) / var(--lettres)), max(30px, calc((100svh - 460px) / 6)));
  width: var(--case);
  height: var(--case);
  border: 2px solid var(--line-forte);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--case) * 0.5);
  font-weight: 800;
  color: #f1f5f9;
  background: var(--surface-2);
  text-transform: uppercase;
  transition: border-color 0.15s;
}
.grille-case.active { border-color: color-mix(in srgb, var(--color-mid) 55%, var(--line-forte)); }
.grille-case.remplie { border-color: #8a94a3; }
.grille-case.correct { background: #22c55e; border-color: #22c55e; color: #fff; }
.grille-case.present { background: #eab308; border-color: #eab308; color: #fff; }
.grille-case.absent { background: #5b6472; border-color: #5b6472; color: #fff; }

/* Ligne sacrifiée par l'indice */
.ligne-bloquee .grille-case {
  border-style: dashed;
  opacity: 0.35;
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255, 255, 255, 0.06) 6px 12px);
}

@keyframes flip {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}
.grille-case.flip { animation: flip 0.5s ease forwards; }
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.grille-case.pop { animation: pop 0.1s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
.shake { animation: shake 0.5s ease; }

.essais-restants {
  font-size: 0.85rem;
  color: var(--texte-doux);
  margin-bottom: 10px;
  min-height: 1.2em;
}

/* --- Clavier : pleine largeur, touches d'au moins 44 px de haut --- */
.clavier {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 520px;
  margin: 0 auto 8px;
  user-select: none;
  -webkit-user-select: none;
}
.clavier[hidden] {
  display: none;
}
.clavier-ligne {
  display: flex;
  gap: 5px;
}
.touche {
  flex: 1 1 0;
  min-width: 0;
  height: clamp(44px, 6.5svh, 54px);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #3a4250;
  color: #eef1f5;
  text-transform: uppercase;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.touche:hover { background: #475061; }
.touche.large {
  flex: 1.6 1 0;
  font-size: 0.78rem;
}
.touche.correct { background: #22c55e; color: #fff; }
.touche.present { background: #eab308; color: #fff; }
.touche.absent { background: #232833; color: #6b7280; }

/* --- Fin de partie : affichée à la place du clavier, donc toujours à l'écran --- */
.resultat-partie {
  display: none;
  margin: 4px auto 10px;
  max-width: 460px;
  padding: 14px 14px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
}
.resultat-partie.visible { display: block; }
.resultat-message {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.resultat-message.victoire { color: #4ade80; }
.resultat-message.defaite { color: #f87171; }
.resultat-detail {
  font-size: 0.88rem;
  color: var(--texte-doux);
  margin-bottom: 10px;
}
.resultat-detail strong {
  color: var(--texte);
  letter-spacing: 0.08em;
}
.resultat-boutons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* --- Message éphémère : sous la barre réseau fixe --- */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: #0b0d11;
  border: 1px solid var(--line-forte);
  color: #f1f5f9;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.visible { opacity: 1; }

/* --- Confettis --- */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}
.confetti {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  top: -10px;
  animation: confetti-fall 1.8s ease-out forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

@media (max-width: 480px) {
  #app { padding: 12px 10px 16px; }
  #app > .jeu-banner { margin: -12px -10px 8px; }
  .grille-wordle { --gap: 5px; }
  .clavier-ligne { gap: 4px; }
  .touche { font-size: 0.92rem; }
  .touche.large { font-size: 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .grille-case.flip, .grille-case.pop, .shake { animation-duration: 0.01s; }
  .confetti-container { display: none; }
}
