/* solo.php — règles propres à cette page.
   L'habillage commun vient de fichiers-partages-des-jeux/css/jeu.css. */

/* Habillage commun (body, #app, top-bar, boutons, info-bar, overlay,
   classement) : fichiers-partages-des-jeux/css/jeu.css.
   Ici, uniquement ce qui est propre a ce jeu. */

/* Carte commune aux pages de jeu. Grille + panneau de définitions côte à
   côte : ce jeu a besoin de plus que le plancher de 800 px. */
#app {
  padding: 32px 28px 28px;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin-bottom: 4px;
  text-align: center;
}

.info-bar {
  margin: 12px 0 16px;
}

.info-item {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  padding: 8px 14px;
}

.info-item span {
  color: var(--texte);
  font-weight: 700;
}

.game-layout {
  display: flex;
  gap: 24px;
  width: 100%;
  align-items: flex-start;
}

/* Grille */
.grille-container {
  flex-shrink: 0;
  /* Allégé depuis que #app porte la carte : deux couches de
     rgba(20,20,35,0.55) superposées ne feraient aucun contraste */
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
}

.grille-table {
  border-collapse: collapse;
  user-select: none;
  margin: 0 auto;
}

.grille-table td {
  width: 36px;
  height: 36px;
  position: relative;
  border: 1px solid var(--line-forte);
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  transition: background 0.15s;
}

/* Etats de case : fonds opaques et non translucides. Sur un fond sombre, deux
   voiles rgba() differents finissent par composer presque la meme couleur et
   les etats deviennent indistinguables. */
.grille-table td.noire {
  background: #0a0f11;
  cursor: default;
  border-color: #0a0f11;
}

.grille-table td.lettre {
  background: var(--surface-2);
}

.grille-table td.lettre:hover {
  background: #24343b;
}

/* Le mot en cours de saisie : tout le mot s'eclaircit legerement. */
.grille-table td.mot-actif {
  background: #1f3b40 !important;
}

/* La case sous le curseur : declaree apres .mot-actif pour gagner la cascade,
   les deux classes etant posees ensemble sur cette case. */
.grille-table td.active {
  background: #2a5a58 !important;
  border-color: var(--color-light);
  box-shadow: inset 0 0 0 2px var(--color-light);
}

/* Verte franche plutot que teal : sur un theme teal, un vert translucide se
   confondrait avec la surbrillance du mot actif. */
.grille-table td.correct {
  background: #14432a !important;
}

.grille-table td.erreur {
  background: #4d1f24 !important;
}

/* La lettre est dans un span qui porte sa propre couleur : colorer le <td>
   seul reste sans effet, il faut viser .lettre-case. */
.grille-table td.correct .lettre-case {
  color: #7ee29b;
}

.grille-table td.erreur .lettre-case {
  color: #ff9a9a;
}

.grille-table td.indice .lettre-case {
  color: #e0a33c;
}

.numero-case {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--color-light);
  line-height: 1;
  pointer-events: none;
}

.lettre-case {
  font-size: 1rem;
  font-weight: 700;
  color: var(--texte);
  text-transform: uppercase;
  pointer-events: none;
}

.direction-indicator {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 0.5rem;
  color: var(--texte-doux);
  pointer-events: none;
}

/* Barre de définition active (mobile uniquement) : toujours visible
   juste au-dessus du clavier, évite d'aller chercher la définition
   dans le panneau situé sous le clavier. */
.clue-bar {
  display: none;
}

@media (max-width: 768px) {

  .clue-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 9px 10px;
    background: var(--surface-2);
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.3;
    color: var(--texte);
  }

  .clue-bar-txt {
    flex: 1;
    min-width: 0;
  }

  .clue-bar-len {
    font-size: 0.7rem;
    color: var(--texte-doux);
  }

  .clue-bar-nav {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--texte);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .clue-bar-nav:active {
    background: rgba(99, 102, 241, 0.4);
  }
}

/* Panneau définitions */
.definitions-panel {
  flex: 1;
  min-width: 280px;
  max-height: 80vh;
  overflow-y: auto;
  /* Allégé depuis que #app porte la carte */
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 16px;
}

.definitions-panel h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--texte);
  margin-bottom: 8px;
  margin-top: 12px;
}

.definitions-panel h3:first-child {
  margin-top: 0;
}

.def-item {
  font-size: 0.82rem;
  color: var(--texte-doux);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.4;
}

.def-item:hover {
  background: var(--surface-1);
  color: var(--texte);
}

/* Definition en cours de saisie : le panneau est deja en --surface-2, un fond
   --surface-2 ne s'y verrait pas. Teinte d'accent + repere a gauche. */
.def-item.active {
  background: color-mix(in srgb, var(--color-light) 16%, var(--surface-2));
  color: var(--texte);
  box-shadow: inset 3px 0 0 var(--color-light);
}

.def-item.found {
  color: #34d399;
  text-decoration: line-through;
  opacity: 0.7;
}

.def-numero {
  font-weight: 700;
  color: var(--color-light);
  margin-right: 4px;
}

/* Boutons */
.actions-bar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-warning {
  background: #a3742c;
}

.btn-success {
  background: #3f7a55;
}

/* Modal victoire */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 40px 32px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.modal h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 16px;
  font-family: var(--font-display);
  color: #34d399;
}

.modal p {
  font-size: 0.95rem;
  color: var(--texte-doux);
  margin-bottom: 8px;
}

.modal .score-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--texte);
}

.modal .btn {
  margin-top: 20px;
}

/* Confettis */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  z-index: 1001;
  pointer-events: none;
}

/* Responsive */

@media (max-width: 768px) {

  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  .grille-container, .definitions-panel {
    width: 100%;
  }

  .grille-table td {
    width: 28px;
    height: 28px;
  }

  .numero-case {
    font-size: 0.45rem;
  }

  .lettre-case {
    font-size: 0.8rem;
  }

  .definitions-panel {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {

  #app {
    padding: 24px 12px 20px;
  }

  .info-bar {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .info-bar::-webkit-scrollbar {
    display: none;
  }

  .info-item {
    padding: 6px 10px;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* Clavier AZERTY */
#clavier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 16px 0 8px;
}

.clavier-ligne {
  display: flex;
  gap: 4px;
}

.touche {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px 0;
  min-width: 34px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--texte);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.touche:hover {
  background: rgba(255,255,255,0.22);
}

.touche:active {
  transform: translateY(0);
  background: rgba(99,102,241,0.3);
}

.touche.large {
  min-width: 60px;
  font-size: 0.75rem;
  padding: 12px 8px;
}

@media (max-width: 480px) {

  .touche {
    min-width: 28px;
    font-size: 0.8rem;
    padding: 10px 0;
    border-radius: 6px;
  }

  .touche.large {
    min-width: 48px;
    font-size: 0.7rem;
  }
}

@media (max-width: 360px) {

  .touche {
    min-width: 24px;
    font-size: 0.72rem;
    padding: 9px 0;
  }

  .touche.large {
    min-width: 42px;
  }
}

/* --- Utilitaires (remplacent d'anciens attributs style=) ---------------- */
.u-mini {
  font-size: 0.72rem;
}

.u-petit {
  font-size: 0.82rem;
}

.u-texte-faible {
  color: var(--texte-faible);
}
