/**
 * Responsive grid layout for Word Pair Matching Game
 * Mobile-first approach with square cells using aspect-ratio
 */

/* ===== Game Board Container ===== */
.game-board {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
}

/* ===== Grid Layout (Mobile-First) ===== */
.word-grid {
  display: grid;
  gap: var(--spacing-md);
  width: 100%;

  /* Mobile: 2 columns */
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: auto;
}

/* ===== Word Buttons ===== */
.word-button {
  /* Square cells using modern aspect-ratio */
  aspect-ratio: 1 / 1;
  min-height: 80px; /* Minimum touch target for mobile */
  width: 100%;

  /* Visual styling */
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-button-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  /* Typography */
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--color-text);

  /* Interaction */
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;

  /* Layout */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);

  /* Text overflow handling */
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
}

/* ===== Button States ===== */
.word-button:hover:not(:disabled):not(.merged) {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.word-button:focus-visible {
  outline: 2px solid var(--color-selected);
  outline-offset: 2px;
}

.word-button.selected {
  border-color: var(--color-selected);
  background: var(--color-selected-bg);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
  transform: scale(1.05);
}

/* Merged button styles moved to components.css to avoid conflicts */

.word-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Tablet (600px+): 4 columns ===== */
@media (min-width: 600px) {
  .word-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-lg);
  }

  .word-button {
    min-height: 100px;
    font-size: 1rem;
    padding: var(--spacing-md);
  }
}

/* ===== Desktop (900px+): Constrained width ===== */
@media (min-width: 900px) {
  .game-board {
    max-width: 800px;
  }

  .word-grid {
    gap: 1.25rem;
  }

  .word-button {
    min-height: 120px;
    font-size: 1.125rem;
    padding: var(--spacing-lg);
  }
}

/* ===== Landscape mobile optimization ===== */
@media (max-height: 600px) and (orientation: landscape) {
  .word-button {
    min-height: 60px;
    font-size: 0.75rem;
    padding: var(--spacing-xs);
  }

  .word-grid {
    gap: var(--spacing-sm);
  }
}

/* ===== Category Color Borders ===== */
.word-button[data-category-color] {
  border-width: 2px;
}

/* These will be applied dynamically via inline styles or category classes */
.category-fruits { border-color: var(--color-category-1); }
.category-colors { border-color: var(--color-category-2); }
.category-animals { border-color: var(--color-category-3); }
.category-numbers { border-color: var(--color-category-4); }
.category-vegetables { border-color: var(--color-category-5); }
.category-countries { border-color: var(--color-category-6); }
