/* ============================================
   Memory Game Styles
   ============================================ */

/* Memory Board */
.memory-game__board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 0;
}

/* Memory Card */
.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  cursor: pointer;
  perspective: 1000px;
}

.memory-card.flipped .memory-card__inner {
  transform: rotateY(180deg);
}

.memory-card.matched {
  pointer-events: none;
}

.memory-card.wrong {
  animation: shake 0.5s ease-in-out;
}

/* Card Inner Container for 3D flip */
.memory-card__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

/* Card Face (Front and Back) */
.memory-card__face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Back Face (Image) */
.memory-card__back {
  background: #fff;
}

.memory-card__back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Front Face (Text) */
.memory-card__front {
  background: #fff;
  transform: rotateY(180deg);
  padding: 1rem;
  border: 3px solid #000;
}

/* German words with light gray background */
.memory-card__front--german {
  background: lightgrey;
}

.memory-card__text {
  font-family: var(--font-heading);
  font-size: clamp(0.8rem, 3vw, 1.4rem);
  font-weight: 700;
  color: #000;
  text-align: center;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.2;
  text-transform: lowercase;
  width: 100%;
}

/* Matched Cards Animation */
.memory-card.matched .memory-card__inner {
  animation: fadeOut 0.6s ease-out forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: rotateY(180deg) scale(1);
  }
  50% {
    opacity: 0.5;
    transform: rotateY(180deg) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: rotateY(180deg) scale(0.8);
  }
}

/* Shake Animation for Wrong Match */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Success Overlay */
.memory-success {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.memory-success--show {
  opacity: 1;
}

.memory-success__content {
  background: #fff;
  padding: 3rem 4rem;
  border-radius: 8px;
  text-align: center;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.memory-success__title {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 1rem;
}

.memory-success__text {
  color: #666;
  margin-bottom: 2rem;
}

.memory-success__restart {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: #000;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.memory-success__restart:hover {
  background: #333;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.memory-success__restart svg {
  width: 24px;
  height: 24px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .memory-game__board {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem 0;
  }
  
  .memory-card__text {
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .memory-game__board {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 1rem 0;
  }
  
  .memory-card__text {
    font-size: 1rem;
    padding: 1rem;
  }
}
