/* ==========================================================================
   CSS DÉDIÉ : MOTS_CROISES.PHP - Grille de Mots Mêlés
   École de l'Enfant-Jésus - Morlanwelz
   ========================================================================== */

:root {
  --mc-primary: #3b82f6;
  --mc-primary-dark: #1d4ed8;
  --mc-accent: #f59e0b;
  --mc-success: #10b981;
  --mc-grid-bg: #f8fafc;
  --mc-border: #cbd5e1;
}

/* Barre de statut du jeu */
.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background-color: #ffffff;
  border: 2px solid #ffde59;
  border-radius: 18px;
  padding: 12px 18px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.back-link {
  color: #1e3a8a;
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #eff6ff;
  border-radius: 20px;
  border: 1.5px solid #bfdbfe;
  transition: all 0.2s;
}

.back-link:hover {
  background: #dbeafe;
  transform: translateX(-2px);
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-badge {
  background-color: #f8fafc;
  border: 2px solid #e2e8f0;
  padding: 5px 12px;
  border-radius: 15px;
  font-weight: 800;
  font-size: 13px;
  color: #334155;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  background-color: white;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: #f1f5f9;
  transform: scale(1.08);
}

/* Barre de sélection des thèmes */
.theme-selector-box {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.theme-selector-title {
  font-size: 13px;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-buttons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-tab-btn {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  color: #334155;
  padding: 8px 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: 'Fredoka', 'Nunito', sans-serif;
}

.theme-tab-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.theme-tab-btn.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #1d4ed8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Zone d'actions et options (Difficulté, Nouvelle grille, Indice) */
.options-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: 14px;
}

.options-group-left, .options-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.opt-btn {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  padding: 7px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.opt-btn:hover {
  background: #f8fafc;
  transform: translateY(-1px);
}

.opt-btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border-color: #059669;
}
.opt-btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.opt-btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border-color: #d97706;
}

/* --------------------------------------------------------------------------
   Mise en page principale du jeu (Grille à gauche, Mots à droite)
   -------------------------------------------------------------------------- */
.mots-game-container {
  display: flex;
  gap: 25px;
  align-items: flex-start;
  margin-bottom: 30px;
}

@media (max-width: 900px) {
  .mots-game-container {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Conteneur de la grille */
.grid-panel {
  flex: 1;
  background: #ffffff;
  border: 3px solid #ffde59;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

/* La grille de lettres */
.word-search-grid {
  display: grid;
  gap: 4px;
  background-color: #e2e8f0;
  padding: 8px;
  border-radius: 16px;
  touch-action: none; /* Crucial pour le drag fluide sur tablette/mobile */
  max-width: 100%;
}

.grid-cell {
  background-color: #ffffff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 800;
  color: #1e293b;
  cursor: pointer;
  aspect-ratio: 1;
  width: clamp(28px, 4.5vw, 44px);
  height: clamp(28px, 4.5vw, 44px);
  transition: background-color 0.12s, color 0.12s, transform 0.1s;
  box-shadow: 0 2px 0 #cbd5e1;
}

.grid-cell:hover {
  background-color: #fef08a;
  transform: scale(1.05);
  z-index: 2;
}

/* Cellule en cours de sélection */
.grid-cell.selecting {
  background-color: #60a5fa !important;
  color: #ffffff !important;
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
  z-index: 3;
}

/* Cellule d'un mot déjà trouvé (couleurs pastel) */
.grid-cell.found {
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

/* Palette de couleurs variées pour les mots trouvés */
.color-0 { background-color: #a7f3d0 !important; color: #065f46 !important; } /* Vert émeraude */
.color-1 { background-color: #fed7aa !important; color: #9a3412 !important; } /* Orange pêche */
.color-2 { background-color: #bae6fd !important; color: #075985 !important; } /* Bleu ciel */
.color-3 { background-color: #fbcfe8 !important; color: #9d174d !important; } /* Rose */
.color-4 { background-color: #ddd6fe !important; color: #5b21b6 !important; } /* Violet doux */
.color-5 { background-color: #fef08a !important; color: #854d0e !important; } /* Jaune citron */
.color-6 { background-color: #99f6e4 !important; color: #115e59 !important; } /* Turquoise */
.color-7 { background-color: #fecdd3 !important; color: #9f1239 !important; } /* Corail */
.color-8 { background-color: #c7d2fe !important; color: #3730a3 !important; } /* Indigo */
.color-9 { background-color: #e2e8f0 !important; color: #334155 !important; } /* Gris ardoise */

/* Indice visuel rebondissant */
.grid-cell.hint {
  animation: hintPulse 0.8s infinite alternate ease-in-out;
  background-color: #fbbf24 !important;
  color: #78350f !important;
  z-index: 5;
}

@keyframes hintPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(251, 191, 36, 0.7); }
  100% { transform: scale(1.18); box-shadow: 0 0 14px rgba(251, 191, 36, 0.9); }
}

/* --------------------------------------------------------------------------
   Panneau latéral : Liste des mots à trouver
   -------------------------------------------------------------------------- */
.words-panel {
  width: 320px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

@media (max-width: 900px) {
  .words-panel {
    width: 100%;
  }
}

.words-panel-header {
  margin-bottom: 15px;
  border-bottom: 2px dashed #e2e8f0;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.words-panel-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: #1e3a8a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.words-count-badge {
  background: #eff6ff;
  color: #2563eb;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid #bfdbfe;
}

.words-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

@media (max-width: 900px) {
  .words-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    max-height: none;
  }
}

.word-card-item {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 12px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  letter-spacing: 0.5px;
}

.word-card-item .word-meta-length {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 700;
}

/* Mot trouvé : barré, coché et coloré */
.word-card-item.found {
  text-decoration: line-through;
  opacity: 0.85;
  transform: translateX(4px);
  border-color: currentColor;
}

.word-card-item.found .word-meta-length {
  display: none;
}

.word-card-item .check-icon {
  display: none;
  font-weight: 900;
}

.word-card-item.found .check-icon {
  display: inline;
}

/* --------------------------------------------------------------------------
   Modale de Victoire / Félicitations
   -------------------------------------------------------------------------- */
.mots-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.mots-modal-overlay.show {
  display: flex;
}

.mots-modal {
  background: white;
  border-radius: 26px;
  max-width: 520px;
  width: 90%;
  padding: 35px 25px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
  border: 4px solid #ffde59;
  position: relative;
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-trophy {
  font-size: 58px;
  margin-bottom: 10px;
  animation: bounceTrophy 1.2s infinite alternate ease-in-out;
}

@keyframes bounceTrophy {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

.mots-modal h2 {
  margin: 0 0 10px 0;
  font-size: 26px;
  color: #1e3a8a;
  font-weight: 900;
}

.mots-modal p {
  color: #475569;
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-stats-summary {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 25px;
}

.modal-stat-box {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  padding: 10px 18px;
  border-radius: 14px;
}

.modal-stat-box strong {
  display: block;
  font-size: 20px;
  color: #1d4ed8;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-primary-action {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary-action {
  background: #f1f5f9;
  color: #475569;
  border: 2px solid #cbd5e1;
  padding: 12px 20px;
  border-radius: 25px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-secondary-action:hover {
  background: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Styles d'impression pour l'école (@media print)
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: white !important;
    color: black !important;
  }

  #menu, #haut, #filrouge, .game-top-bar, .theme-selector-box, .options-bar, #bas, .btn-icon, .mots-modal-overlay {
    display: none !important;
  }

  #corps {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }

  .mots-game-container {
    flex-direction: row !important;
    gap: 20px !important;
  }

  .grid-panel {
    border: 2px solid #000 !important;
    box-shadow: none !important;
    padding: 10px !important;
  }

  .word-search-grid {
    background: #000 !important;
    gap: 1px !important;
    padding: 1px !important;
  }

  .grid-cell {
    border-radius: 0 !important;
    box-shadow: none !important;
    color: black !important;
    background: white !important;
    font-size: 16px !important;
    width: 32px !important;
    height: 32px !important;
  }

  .words-panel {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    width: 250px !important;
  }

  .word-card-item {
    border: 1px solid #ccc !important;
    background: white !important;
    color: black !important;
    font-size: 13px !important;
    padding: 4px 8px !important;
  }
}

.print-header {
  display: none;
}
