/* ============================================
   MAP PUZZLES - GAME-SPECIFIC STYLES
   ============================================
   
   This stylesheet contains ONLY game-specific styles.
   Common components (buttons, modals, screens, etc.) 
   are inherited from game-framework.css
   
   Sections:
   1. Game Layout
   2. Map Panel & SVG
   3. Pieces Panel
   4. Drag & Drop States
   5. Results & Achievements
   6. Responsive
   ============================================ */

/* ============================================
   1. GAME LAYOUT
   ============================================ */

.game-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-xl);
  height: calc(100vh - 140px);
  padding: var(--space-lg);
  max-width: 1600px;
  margin: 0 auto;
}

/* ============================================
   2. MAP PANEL & SVG
   ============================================ */

.map-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
}

.map-container {
  position: relative;
  flex: 1;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 3px solid var(--primary-color);
}

#map-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  transition: transform 0.3s ease;
}

#map-svg.dragging {
  cursor: grabbing;
}

#map-svg.zoomed {
  transform: scale(1.2);
}

/* Target zones (country outlines on map) */
.target-zone {
  cursor: pointer;
  transition: all 0.2s ease;
}

.target-zone path {
  fill: rgba(240, 240, 240, 0.5);
  stroke: #ccc;
  stroke-width: 2;
  transition: all 0.3s ease;
}

.target-zone:hover path {
  fill: rgba(78, 205, 196, 0.2);
  stroke: var(--secondary-color);
  stroke-width: 3;
}

.target-zone.highlight path {
  fill: rgba(255, 235, 59, 0.4);
  stroke: var(--warning-color);
  stroke-width: 4;
  animation: pulse 1.5s infinite;
}

.target-zone.filled path {
  fill: rgba(76, 175, 80, 0.6);
  stroke: var(--success-color);
  stroke-width: 3;
  pointer-events: none;
}

.target-zone.filled .country-label {
  fill: white;
  font-weight: bold;
}

/* Country labels on map */
.country-label {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  fill: #666;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.country-label.hidden {
  display: none;
}

/* Drop feedback overlay */
.drop-feedback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}

.drop-feedback.valid {
  display: block;
  background: rgba(76, 175, 80, 0.1);
  border: 3px solid var(--success-color);
  animation: fadeIn 0.2s;
}

.drop-feedback.invalid {
  display: block;
  background: rgba(255, 82, 82, 0.1);
  border: 3px solid var(--error-color);
  animation: shake 0.3s;
}

/* Map controls */
.map-controls {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  padding-top: var(--space-md);
  border-top: 2px solid var(--border-color);
}

.map-controls .btn-icon {
  font-size: 1.2rem;
}

/* ============================================
   3. PIECES PANEL
   ============================================ */

.pieces-panel {
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.pieces-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--border-color);
}

.pieces-header h3 {
  font-family: var(--font-headings);
  color: var(--primary-color);
  margin: 0 0 var(--space-xs) 0;
}

#remaining-count {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

.pieces-container {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-md);
  padding: var(--space-sm);
  align-content: start;
}

/* Custom scrollbar for pieces */
.pieces-container::-webkit-scrollbar {
  width: 8px;
}

.pieces-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.pieces-container::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

.pieces-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* Country pieces */
.country-piece {
  cursor: grab;
  background: white;
  border: 3px solid var(--primary-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.country-piece:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-lg);
  border-color: var(--secondary-color);
}

.country-piece.dragging {
  opacity: 0.5;
  cursor: grabbing;
  transform: rotate(5deg);
}

.country-piece.placed {
  opacity: 0.3;
  pointer-events: none;
  border-style: dashed;
  background: #f5f5f5;
}

.country-piece svg {
  width: 80px;
  height: 60px;
  fill: var(--secondary-color);
  transition: fill 0.2s ease;
}

.country-piece:hover svg {
  fill: var(--primary-color);
}

.piece-label {
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  word-break: break-word;
}

.pieces-footer {
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 2px solid var(--border-color);
  margin-top: var(--space-md);
}

.pieces-footer .btn-secondary {
  flex: 1;
  font-size: var(--font-size-sm);
}

/* ============================================
   4. DRAG & DROP STATES
   ============================================ */

/* Ghost image while dragging */
.dragging-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.8;
  transform: rotate(5deg);
}

/* Snap animation */
@keyframes snapToPlace {
  0% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  50% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.snapping {
  animation: snapToPlace 0.4s ease-out;
}

/* Incorrect placement shake */
@keyframes wrongPlace {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}

.wrong-placement {
  animation: wrongPlace 0.3s ease-in-out;
}

/* ============================================
   5. RESULTS & ACHIEVEMENTS
   ============================================ */

.map-preview {
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.map-preview svg {
  width: 100%;
  max-width: 600px;
  display: block;
  margin: 0 auto;
}

.achievements {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.achievement {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: #f5f5f5;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  opacity: 0.5;
  transition: all 0.3s ease;
}

.achievement.unlocked {
  opacity: 1;
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  border-color: #ff8c00;
  animation: celebrate 0.6s ease-out;
}

.achievement-icon {
  font-size: 2rem;
}

.achievement-name {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text-primary);
}

.achievement.unlocked .achievement-name {
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   6. RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .game-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: auto;
    min-height: calc(100vh - 140px);
  }

  .map-panel {
    height: 500px;
  }

  .pieces-panel {
    height: 300px;
  }

  .pieces-container {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (max-width: 768px) {
  .game-container {
    padding: var(--space-md);
    gap: var(--space-md);
  }

  .map-panel,
  .pieces-panel {
    padding: var(--space-md);
  }

  .map-panel {
    height: 400px;
  }

  .pieces-container {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: var(--space-sm);
  }

  .country-piece svg {
    width: 60px;
    height: 45px;
  }

  .piece-label {
    font-size: 0.7rem;
  }

  .map-controls {
    flex-wrap: wrap;
  }

  .achievements {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .game-header {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: stretch;
  }

  .game-stats {
    justify-content: space-around;
  }

  .map-panel {
    height: 300px;
  }

  .pieces-panel {
    height: 250px;
  }

  .country-label {
    font-size: 10px;
  }
}

/* ============================================
   7. ACCESSIBILITY
   ============================================ */

/* Keyboard focus states */
.country-piece:focus {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

.target-zone:focus path {
  stroke: var(--primary-color);
  stroke-width: 4;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .country-piece,
  .target-zone,
  #map-svg {
    transition: none;
  }

  .snapping,
  .wrong-placement,
  .achievement.unlocked {
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .target-zone path {
    stroke-width: 3;
  }

  .country-piece {
    border-width: 4px;
  }

  .map-container {
    border-width: 4px;
  }
}
