/* ==========================================================================
   Jeu Puzzle tactile
   ========================================================================== */

.puzzle-play {
  height: 530px;
  overflow: hidden;
  background: radial-gradient(circle at 16% 16%, rgba(255, 255, 255, 0.74) 0 42px, transparent 43px),
    radial-gradient(circle at 86% 84%, rgba(143, 201, 196, 0.24) 0 70px, transparent 71px),
    linear-gradient(160deg, #e8f3e6 0%, #f4e8cf 100%);
  touch-action: none;
}

.puzzle-board {
  position: absolute;
  top: 18px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: min(100%, 300px);
  aspect-ratio: 1 / 1;
  border: 3px dashed #14251e;
  border-radius: 8px;
  background: linear-gradient(rgba(255, 250, 240, 0.5), rgba(255, 250, 240, 0.5));
  background-color: rgba(255, 255, 255, 0.58);
  opacity: 0.44;
  transform: translateX(-50%);
}

.puzzle-board span {
  border: 1px dashed rgba(36, 58, 52, 0.16);
}

.puzzle-layer {
  position: absolute;
  inset: 0;
}

.puzzle-piece {
  position: absolute;
  border: 2px solid rgba(255, 250, 240, 0.95);
  border-radius: 12px;
  background-repeat: no-repeat;
  box-shadow: 0 10px 22px rgba(28, 62, 53, 0.2);
  touch-action: none;
  cursor: grab;
}

.puzzle-card.assets-ready .puzzle-board {
  background: linear-gradient(rgba(255, 250, 240, 0.5), rgba(255, 250, 240, 0.5)),
    url("../assets/images/puzzle-libellule.png") center / 100% 100% no-repeat;
}

.puzzle-card.assets-ready .puzzle-piece {
  background-image: url("../assets/images/puzzle-libellule.png");
}

.puzzle-piece.dragging {
  z-index: 5;
  border-color: #ffd449;
  outline: 4px solid rgba(255, 212, 73, 0.92);
  outline-offset: 2px;
  box-shadow: 0 14px 28px rgba(36, 58, 52, 0.22), 0 0 0 7px rgba(255, 212, 73, 0.2);
  transform: scale(1.04);
  cursor: grabbing;
}

.puzzle-piece.locked {
  z-index: 2;
  /* Laisse saisir une pièce incorrecte éventuellement recouverte. */
  pointer-events: none;
  border-color: rgba(111, 159, 120, 0.52);
  animation: pieceLocked 0.28s ease-out;
  cursor: default;
}

.puzzle-card .eyebrow {
  justify-content: center;
}

.puzzle-card::after {
  color: #fff;
}

.restart-puzzle {
  display: grid;
  place-items: center;
  width: fit-content;
  min-width: 235px;
  max-width: calc(100% - 28px);
  min-height: 47px;
  margin: 12px auto 0;
  padding: 10px 22px;
  border: 2px solid rgba(28, 55, 48, 0.14);
  border-radius: 999px;
  color: #fff;
  -webkit-text-fill-color: #fff;
  background: #2f7ecb;
  box-shadow: 0 4px 7px rgba(29, 59, 61, 0.18);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.restart-puzzle:hover,
.restart-puzzle:active {
  background: #2f7ecb;
}

.puzzle-bravo {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 7;
  width: min(94%, 330px);
  height: auto;
  opacity: 0;
  filter: drop-shadow(0 7px 10px rgba(20, 45, 40, 0.24));
  transform: translate(-50%, -230%) scaleX(0.82) scaleY(1.14);
  transform-origin: 50% 78%;
  pointer-events: none;
}

.puzzle-bravo.show {
  animation: metamorphBravoDrop 2.35s cubic-bezier(0.2, 0.9, 0.18, 1) forwards;
}

.puzzle-fun-fact {
  position: absolute;
  top: 392px;
  left: 50%;
  z-index: 6;
  width: min(86%, 306px);
  margin: 0;
  padding: 12px 14px;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
}

.puzzle-fun-fact[hidden] {
  display: none;
}

@keyframes pieceLocked {
  50% {
    transform: scale(1.04);
  }
}
