/* ============================================================
 *  NuMat — style.css v8
 *  Styles + animations ludiques (victoire, défaite, cascade, particules, confettis)
 * ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body.numat-app,
body.vita-app {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
  background: #0d3b1e !important;
  background: linear-gradient(180deg, #0d3b1e 0%, #0a2a16 100%) !important;
  color: #fff !important;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}

#numat-root,
#vita-root {
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.logo-svg { height: 28px; width: auto; }

/* ============================================================
 *  Status bar
 * ============================================================ */
.status {
  background: rgba(0, 0, 0, 0.25) !important;
  border-radius: 8px !important;
  padding: 6px 10px !important;
}

/* ============================================================
 *  Tray (zone du haut pour cartes sélectionnées)
 * ============================================================ */
.tray {
  width: 100% !important;
  height: 90px !important;
  min-height: 90px !important;
  background: #111111 !important;
  background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%) !important;
  border: 3px solid #ffeb3b !important;
  border-radius: 12px !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 4px 0 8px 0 !important;
  padding: 0 8px !important;
  z-index: 9999 !important;
  position: relative !important;
  overflow: visible !important;
  box-shadow: 0 0 24px rgba(255, 235, 59, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

/* Animation : tray qui tremble (défaite) */
.tray.tray-shake {
  animation: tray-shake 0.5s cubic-bezier(.36,.07,.19,.97) !important;
}
@keyframes tray-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

/* ============================================================
 *  Board
 * ============================================================ */
#board {
  position: relative !important;
  width: 100% !important;
  height: 340px !important;
  margin-top: 4px !important;
  overflow: visible !important;
}

/* ============================================================
 *  Tuiles
 * ============================================================ */
.tile {
  position: absolute !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 900 !important;
  font-size: 1.8rem !important;
  color: #fff !important;
  box-shadow: 0 3px 0 rgba(0,0,0,0.55), inset 0 0 0 2px rgba(255,255,255,0.22), 0 0 0 1px rgba(0,0,0,0.25) !important;
  border: 2px solid rgba(255,255,255,0.35) !important;
  opacity: 1 !important;
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out, opacity 0.18s ease-out;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.tile:active {
  transform: scale(0.94);
}

/* Couleurs (fallback CSS — l'inline dans app.js reste prioritaire) */
.tile.c1 { background: #e53935 !important; color: #ffffff !important; }
.tile.c2 { background: #fb8c00 !important; color: #ffffff !important; }
.tile.c3 { background: #fdd835 !important; color: #1a1a1a !important; }
.tile.c4 { background: #43a047 !important; color: #ffffff !important; }
.tile.c5 { background: #00acc1 !important; color: #ffffff !important; }
.tile.c6 { background: #1e88e5 !important; color: #ffffff !important; }
.tile.c7 { background: #5e35b1 !important; color: #ffffff !important; }
.tile.c8 { background: #d81b60 !important; color: #ffffff !important; }
.tile.c9 { background: #6d4c41 !important; color: #ffffff !important; }

.tile.blocked {
  opacity: 0.45 !important;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.12) !important;
}

/* Tuiles dans le tray */
.tray-tile {
  position: relative !important;
  width: 48px !important;
  height: 60px !important;
  font-size: 1.7rem !important;
  flex: 0 0 auto !important;
  animation: tray-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
@keyframes tray-enter {
  0%   { transform: scale(0.3) translateY(-12px); opacity: 0; }
  60%  { transform: scale(1.08) translateY(0);    opacity: 1; }
  100% { transform: scale(1)    translateY(0);    opacity: 1; }
}

/* ============================================================
 *  Animations de tuiles
 * ============================================================ */

/* Entrée en cascade au chargement du niveau */
.tile.entering {
  animation-name: tile-fall-in;
  animation-duration: 0.45s;
  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  animation-fill-mode: both;
}
@keyframes tile-fall-in {
  0%   { transform: translateY(-110px) scale(0.4) rotate(-8deg); opacity: 0; }
  60%  { transform: translateY(8px)    scale(1.05) rotate(2deg); opacity: 1; }
  100% { transform: translateY(0)      scale(1)    rotate(0);     opacity: 1; }
}

/* Tuile qui quitte le plateau (vers le tray) */
.tile.leaving {
  animation: tile-leave 0.22s ease-out forwards !important;
}
@keyframes tile-leave {
  0%   { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(0.3) translateY(-26px); opacity: 0; }
}

/* Match : pulse doré puis disparition */
.tile.matching {
  animation: tile-match 0.45s ease-in forwards !important;
  z-index: 100 !important;
}
@keyframes tile-match {
  0%   { transform: scale(1);   box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); }
  35%  { transform: scale(1.18); box-shadow: 0 0 28px 6px rgba(255, 235, 59, 0.85), 0 0 0 4px rgba(255, 255, 255, 0.6); }
  100% { transform: scale(0);   box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); opacity: 0; }
}

/* Shake (tuile bloquante cliquée) */
.tile.shake {
  animation: tile-shake 0.32s ease-in-out !important;
}
@keyframes tile-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20%      { transform: translateX(-6px) rotate(-4deg); }
  40%      { transform: translateX(6px)  rotate(4deg); }
  60%      { transform: translateX(-4px) rotate(-2deg); }
  80%      { transform: translateX(4px)  rotate(2deg); }
}

/* Indice */
.tile.hint {
  outline: 3px solid #ffeb3b !important;
  outline-offset: 2px !important;
  animation: numat-pulse 0.55s ease-in-out infinite alternate !important;
}
@keyframes numat-pulse {
  from { transform: scale(1);    filter: brightness(1); }
  to   { transform: scale(1.1); filter: brightness(1.3); }
}

/* ============================================================
 *  Particules (match)
 * ============================================================ */
.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 200;
  transform: translate(-50%, -50%);
  animation: particle-fly 0.65s ease-out forwards !important;
}
@keyframes particle-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0)), calc(-50% + var(--dy, 0))) scale(0.2); opacity: 0; }
}

/* ============================================================
 *  Confettis (victoire)
 * ============================================================ */
.confetti {
  position: absolute !important;
  top: -20px !important;
  border-radius: 1px !important;
  pointer-events: none !important;
  animation-name: confetti-fall !important;
  animation-timing-function: linear !important;
  animation-fill-mode: forwards !important;
  /* animation-duration et animation-delay sont réglés inline (JS) sans !important
     pour que le thème WP ne puisse pas les écraser (ils ne sont pas définis ici). */
}
@keyframes confetti-fall {
  0%   { transform: translateY(0)    rotate(0deg);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ============================================================
 *  Flash rouge (défaite)
 * ============================================================ */
#flash.show {
  opacity: 1 !important;
  animation: flash-fade 0.6s ease-out forwards !important;
}
@keyframes flash-fade {
  0%   { opacity: 0; }
  30%  { opacity: 0.7; }
  100% { opacity: 0; }
}

/* ============================================================
 *  Modale (remplace alert)
 * ============================================================ */
#modal.show {
  display: flex !important;
  animation: modal-backdrop-in 0.25s ease-out !important;
}
@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: linear-gradient(180deg, #1e3a2a 0%, #163020 100%);
  border: 2px solid #ffeb3b;
  border-radius: 18px;
  padding: 28px 24px 22px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55), 0 0 30px rgba(255, 235, 59, 0.25);
  animation: modal-card-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}
@keyframes modal-card-in {
  from { transform: scale(0.6) translateY(20px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}

.modal-card-lose {
  border-color: #ef5350;
  background: linear-gradient(180deg, #3a1a1a 0%, #2a1010 100%);
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55), 0 0 30px rgba(239, 83, 80, 0.35);
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  margin-bottom: 12px;
}
.modal-icon-win  { background: linear-gradient(135deg, #ffd54f, #ffb300); color: #4a2a00; box-shadow: 0 0 22px rgba(255, 211, 79, 0.7); }
.modal-icon-lose { background: linear-gradient(135deg, #ef5350, #c62828); color: #fff; }
.modal-icon-info { background: linear-gradient(135deg, #4fc3f7, #0288d1); color: #fff; }

.modal-title {
  margin: 4px 0 8px 0;
  font-size: 1.25rem;
  color: #ffeb3b;
  font-weight: 800;
}
.modal-card-lose .modal-title { color: #ef5350; }

.modal-body {
  margin: 0 0 18px 0;
  color: #e8f5e9;
  font-size: 0.95rem;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.modal-actions button {
  flex: 1;
  padding: 11px 8px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.12s ease-out;
}
.modal-actions button:active { transform: scale(0.95); }
.btn-primary {
  background: linear-gradient(180deg, #66bb6a, #43a047);
  color: #fff;
  box-shadow: 0 4px 0 #2e7d32;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* ============================================================
 *  Boutons de contrôle
 * ============================================================ */
.controls {
  display: flex !important;
  gap: 6px !important;
  width: 100% !important;
  margin-top: 8px !important;
}
.numat-btn,
.controls button,
button {
  flex: 1 !important;
  padding: 11px 6px !important;
  background: linear-gradient(180deg, #43a047 0%, #2e7d32 100%) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 9px !important;
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  cursor: pointer !important;
  box-shadow: 0 3px 0 #1b5e20 !important;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out !important;
}
.numat-btn:active,
.controls button:active,
button:active {
  transform: translateY(2px) !important;
  box-shadow: 0 1px 0 #1b5e20 !important;
}
