/* Word Match game specific styles */

/* ---------- Layout ---------- */
.word_match-section {
  padding: 2rem 0 1rem;
}

.word_match-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 2rem;
  align-items: start;
  margin-top: 1rem;
}

/* ---------- Sidebar ---------- */
.word_match-sidebar {
  position: sticky;
  top: 100px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.word_match-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.word_match-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-primary);
  padding: 0.6rem 0.4rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.word_match-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.word_match-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Stars */
.word_match-stars {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.8rem;
  line-height: 1;
}

.word_match-stars .star {
  color: var(--border-color);
  transition: color 0.3s ease, transform 0.3s ease, text-shadow 0.3s ease;
}

.word_match-stars .star.earned {
  color: #fbbf24;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
  animation: starPop 0.5s ease;
}

@keyframes starPop {
  0% {
    transform: scale(0.4) rotate(-30deg);
  }

  60% {
    transform: scale(1.25) rotate(10deg);
  }

  100% {
    transform: scale(1) rotate(0);
  }
}

/* Progress */
.word_match-progress {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.word_match-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.word_match-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.word_match-progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* Category */
.word_match-category {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.word_match-category .category-value {
  font-weight: 600;
  color: var(--primary-color);
}

/* Feedback */
.word_match-feedback {
  min-height: 1.4rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
}

.word_match-feedback.success {
  color: var(--success-color);
}

.word_match-feedback.error {
  color: var(--error-color);
}

.word_match-feedback.info {
  color: var(--primary-color);
}

/* Actions */
.word_match-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.word_match-actions .btn {
  justify-content: center;
  width: 100%;
}

.btn-danger {
  color: var(--error-color);
  border-color: var(--error-color);
}

.btn-danger:hover {
  background: var(--error-color);
  color: #fff;
}

/* Legend */
.word_match-legend {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.9rem;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.legend-dot--word {
  background: var(--primary-color);
}

.legend-dot--pair {
  background: var(--secondary-color);
}

/* ---------- Board ---------- */
.word_match-board-wrap {
  position: relative;
  min-height: 420px;
}

.word_match-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

/* Card */
.word_match-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, opacity 0.35s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.word_match-card:hover:not(.matched):not(.disabled) {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.word_match-card:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.word_match-card .card-face {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Type colors */
.word_match-card[data-type="word"] {
  background: linear-gradient(160deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.02));
  border-color: rgba(37, 99, 235, 0.35);
}

.word_match-card[data-type="pair"] {
  background: linear-gradient(160deg, rgba(124, 58, 237, 0.08), rgba(124, 58, 237, 0.02));
  border-color: rgba(124, 58, 237, 0.35);
}

.card-word {
  font-size: clamp(0.85rem, 2.4vw, 1.15rem);
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: 0.02em;
  word-break: break-word;
  line-height: 1.15;
}

.card-translation {
  font-size: clamp(0.8rem, 2.2vw, 1.05rem);
  font-weight: 700;
  color: var(--secondary-color);
  word-break: break-word;
  line-height: 1.15;
}

.card-emoji {
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  line-height: 1;
}

/* States */
.word_match-card.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25), var(--shadow-md);
  transform: translateY(-4px) scale(1.03);
}

.word_match-card.wrong {
  animation: cardShake 0.4s ease;
  border-color: var(--error-color);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
}

@keyframes cardShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

.word_match-card.matched {
  animation: cardMatched 0.5s ease forwards;
  pointer-events: none;
  border-color: var(--success-color);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
}

@keyframes cardMatched {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  40% {
    transform: scale(1.12) rotate(2deg);
    background: rgba(16, 185, 129, 0.2);
  }

  100% {
    transform: scale(0.85);
    opacity: 0;
  }
}

.word_match-card.hinted {
  animation: cardHint 1s ease 2;
}

@keyframes cardHint {

  0%,
  100% {
    box-shadow: var(--shadow-sm);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.6), var(--shadow-md);
  }
}

.word_match-card.disabled {
  pointer-events: none;
}

/* ---------- Overlay ---------- */
.word_match-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-xl);
  z-index: 10;
  animation: overlayFade 0.3s ease;
}

@keyframes overlayFade {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.word_match-overlay[hidden] {
  display: none;
}

.word_match-overlay-card {
  background: var(--bg-primary);
  padding: 2rem 2.25rem;
  border-radius: var(--radius-xl);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  width: calc(100% - 2rem);
  animation: overlayCardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes overlayCardIn {
  from {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.word_match-overlay-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.word_match-overlay-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.word_match-overlay-text {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* ---------- Info section ---------- */
.word_match-info {
  padding: 3rem 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .word_match-layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .word_match-sidebar {
    position: static;
  }

  .word_match-board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
  }
}

@media (max-width: 600px) {
  .word_match-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .word_match-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .word_match-stat-value {
    font-size: 1.05rem;
  }

  .word_match-overlay-card {
    padding: 1.5rem;
  }
}

@media (max-width: 380px) {
  .word_match-board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .card-word {
    font-size: 0.78rem;
  }

  .card-translation {
    font-size: 0.72rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

  .word_match-card,
  .word_match-progress-fill,
  .word_match-overlay,
  .word_match-overlay-card,
  .word_match-stars .star {
    animation: none !important;
    transition: none !important;
  }
}