/* Memory Reconstruction Puzzle Styles */

.puzzle-section {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 10, 15, 0.95), rgba(10, 4, 8, 1));
  opacity: 0;
  transition: opacity 1s ease;
  overflow: hidden;
  padding: 20px;
}

.puzzle-section.active {
  display: flex;
  opacity: 1;
}

.puzzle-intro-text {
  font-family: 'Tajawal', sans-serif;
  color: #fff;
  text-align: center;
  margin-bottom: 20px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 1s ease 0.5s;
}

@media (min-height: 700px) {
  .puzzle-intro-text {
    margin-bottom: 40px;
  }
}

.puzzle-container {
  position: relative;
  /* Size is now dynamically set by JS */
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

/* The grid where pieces snap (Visual Reference) */
.puzzle-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  pointer-events: none;
}

.grid-cell {
  border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Individual Puzzle Pieces */
.puzzle-piece {
  position: absolute;
  /* width/height/backgroundSize set by JS */
  background-image: url('../../yara.png');
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  will-change: transform, left, top;
}

.puzzle-piece:active {
  cursor: grabbing;
  z-index: 100;
  transform: scale(1.05) rotate(0deg) !important;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6), 0 0 0 1px var(--gold);
}

.puzzle-piece.snapped {
  cursor: default;
  pointer-events: none;
  z-index: 5;
  box-shadow: none;
  border-radius: 0;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Completion Sequence */
.puzzle-container.completed {
  border: 2px solid var(--gold);
  box-shadow: 0 0 40px rgba(201, 151, 58, 0.3);
  transition: all 1s ease;
  animation: finalZoom 2s forwards ease-out;
}

@keyframes finalZoom {
  to { transform: scale(1.05); }
}

.final-reveal-area {
  margin-top: 30px;
  width: 100%;
  max-width: 400px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 1s ease 1s;
  display: none;
  flex-direction: column;
  align-items: center;
}

.final-reveal-area.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.final-message-box {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 32px;
  padding: 32px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.final-instr {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.7;
  margin-bottom: 20px;
}

.input-zone {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

#puzzleReplyInput {
  width: 100%;
  min-height: 100px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  outline: none;
  transition: all 0.3s ease;
  text-align: center;
}

#puzzleReplyInput:focus {
  background: rgba(0,0,0,0.4);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201, 151, 58, 0.2);
}

.confirm-reveal-btn {
  background: linear-gradient(135deg, var(--gold), #8A651E);
  color: #120408;
  border: none;
  padding: 14px 45px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(201, 151, 58, 0.3);
  transition: all 0.3s cubic-bezier(.34, 1.56, .64, 1);
}

.confirm-reveal-btn:hover {
  transform: scale(1.05) translateY(-2px);
}

.confirm-reveal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.digital-signature {
  margin-top: 25px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.5s ease, transform 1.5s ease;
}

.digital-signature.reveal {
  opacity: 1;
  transform: translateY(0);
}

@keyframes puzzlePop {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.puzzle-piece-glow {
  position: absolute;
  inset: 0;
  background: var(--gold);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.puzzle-piece.snapped .puzzle-piece-glow {
  animation: snapPulse 0.6s ease-out;
}

@keyframes snapPulse {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Mobile Adjustments */
@media (max-height: 700px) {
  .puzzle-container {
    width: 240px;
    height: 320px;
  }
  .puzzle-piece {
    width: 80px;
    height: 106.66px;
    background-size: 240px 320px;
  }
}
