/**
 * Continents & Oceans - Styles
 * Professional geography learning game
 * Ages 7-11
 */

/* ===== CSS VARIABLES ===== */
:root {
  /* Colors */
  --primary: #19547b;
  --primary-light: #2a6a99;
  --primary-dark: #0f3d5a;
  --secondary: #ffd89b;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Ocean colors */
  --ocean-blue: #4a90e2;
  --ocean-light: #7db3f5;
  --ocean-dark: #2563eb;

  /* Continent colors */
  --land-green: #48bb78;
  --land-light: #68d391;
  --land-dark: #2f855a;

  /* Neutral colors */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.6);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 1000;
  --z-loading: 2000;
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  z-index: var(--z-loading);
  animation: fadeIn 0.3s ease;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.loading-text {
  color: white;
  font-size: 1.25rem;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  animation: slideUp 0.4s ease;
}

.game-container.hidden {
  display: none;
}

/* ===== HEADER ===== */
.game-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.game-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 900;
  color: white;
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-md);
}

.title-icon {
  font-size: 1.2em;
  animation: rotate 10s linear infinite;
}

.game-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: rgba(255, 255, 255, 0.95);
  font-weight: 500;
}

/* ===== GAME STATS ===== */
.game-stats {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-xl);
}

.stat-item {
  background: white;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 150px;
  transition: transform var(--transition-fast);
}

.stat-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-label {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
}

.stat-value {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.125rem;
  margin-left: auto;
}

/* ===== GAME BOARD ===== */
.game-board {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-xl);
}

@media (max-width: 1024px) {
  .game-board {
    grid-template-columns: 1fr;
  }
}

/* ===== MAP CONTAINER ===== */
.map-container {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-xl);
  position: relative;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.world-map {
  width: 100%;
  max-width: 800px;
  position: relative;
}

.world-map svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Map zones */
.map-zone {
  fill: var(--land-light);
  stroke: var(--primary-dark);
  stroke-width: 2;
  cursor: pointer;
  transition: all var(--transition-normal);
  opacity: 0.7;
}

.map-zone.ocean {
  fill: var(--ocean-light);
}

.map-zone:hover {
  opacity: 1;
  filter: brightness(1.1);
  stroke-width: 3;
}

.map-zone.highlight {
  animation: pulse-glow 1s ease-in-out infinite;
}

.map-zone.filled {
  opacity: 1;
  cursor: default;
}

.map-zone.filled.continent {
  fill: var(--land-green);
}

.map-zone.filled.ocean {
  fill: var(--ocean-blue);
}

/* Zone labels */
.zone-label {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  fill: white;
  text-anchor: middle;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.map-zone.filled + .zone-label,
.map-zone:hover + .zone-label {
  opacity: 1;
}

/* ===== FEEDBACK OVERLAY ===== */
.feedback-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  border-radius: var(--radius-xl);
  z-index: var(--z-dropdown);
  animation: fadeIn 0.2s ease;
}

.feedback-overlay.hidden {
  display: none;
}

.feedback-content {
  background: white;
  padding: var(--spacing-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  animation: bounceIn 0.4s ease;
}

.feedback-icon {
  font-size: 3rem;
}

.feedback-message {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.feedback-overlay.correct .feedback-icon {
  content: '✅';
}

.feedback-overlay.incorrect .feedback-icon {
  content: '❌';
}

/* ===== ITEMS PANEL ===== */
.items-panel {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  max-height: 650px;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--spacing-sm);
}

.panel-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-lg);
}

.items-container {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding-right: var(--spacing-sm);
}

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

.items-container::-webkit-scrollbar-track {
  background: var(--bg-body);
  border-radius: var(--radius-full);
}

.items-container::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: var(--radius-full);
}

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

/* ===== ITEM CARD ===== */
.item-card {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  color: white;
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  cursor: grab;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  position: relative;
}

.item-card:hover {
  transform: translateX(4px) scale(1.02);
  box-shadow: var(--shadow-md);
}

.item-card:active {
  cursor: grabbing;
}

.item-card.dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.item-card.placed {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.item-card.continent {
  background: linear-gradient(135deg, var(--land-light) 0%, var(--land-green) 100%);
}

.item-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.item-name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.item-type {
  font-size: 0.75rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Keyboard focus state */
.item-card:focus {
  outline: 3px solid var(--warning);
  outline-offset: 2px;
}

.item-card.selected {
  box-shadow: 0 0 0 3px var(--warning);
  animation: pulse-selected 1s ease-in-out infinite;
}

/* ===== KEYBOARD HELP ===== */
.keyboard-help {
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 2px solid var(--border-color);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.keyboard-help strong {
  color: var(--primary);
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.help-btn,
.restart-btn {
  position: fixed;
  bottom: var(--spacing-xl);
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-sticky);
}

.help-btn {
  right: var(--spacing-xl);
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.help-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.1);
}

.restart-btn {
  left: var(--spacing-xl);
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.restart-btn:hover {
  background: var(--primary);
  color: white;
}

/* ===== RESULTS SCREEN ===== */
.results-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 0.4s ease;
  padding: var(--spacing-lg);
}

.results-screen.hidden {
  display: none;
}

.results-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  text-align: center;
  animation: scaleIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.rank-display {
  margin-bottom: var(--spacing-xl);
}

.rank-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-md);
  animation: bounceIn 0.6s ease 0.2s both;
}

.rank-letter {
  font-size: 6rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: var(--spacing-sm);
  animation: scaleIn 0.5s ease 0.3s both;
}

.rank-letter.S {
  color: #ffd700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.rank-letter.A {
  color: #10b981;
}

.rank-letter.B {
  color: #3b82f6;
}

.rank-letter.C {
  color: #f59e0b;
}

.rank-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  animation: fadeIn 0.4s ease 0.4s both;
}

.results-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg);
  background: var(--bg-body);
  border-radius: var(--radius-lg);
}

.result-stat {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.result-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.result-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.results-message {
  margin-bottom: var(--spacing-xl);
}

.results-text {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.best-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-md);
  background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
  border-radius: var(--radius-md);
  color: white;
  font-weight: 600;
}

.best-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.results-actions {
  display: flex;
  justify-content: center;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  animation: fadeIn 0.3s ease;
}

.modal-content {
  position: relative;
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-xl);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-close {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 1.5rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--error);
  color: white;
  transform: rotate(90deg);
}

.modal-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--spacing-xl);
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

.help-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--spacing-md);
}

.help-section p,
.help-section ul {
  color: var(--text-secondary);
  line-height: 1.8;
}

.help-section ul {
  list-style: none;
  padding-left: 0;
}

.help-section li {
  padding-left: var(--spacing-lg);
  position: relative;
  margin-bottom: var(--spacing-sm);
}

.help-section li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.scoring-formula {
  font-family: 'Courier New', monospace;
  background: var(--bg-body);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-sm);
  font-size: 0.875rem;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes pulse-glow {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.3);
  }
}

@keyframes pulse-selected {
  0%, 100% {
    box-shadow: 0 0 0 3px var(--warning);
  }
  50% {
    box-shadow: 0 0 0 6px var(--warning);
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .game-container {
    padding: var(--spacing-md);
  }

  .game-stats {
    gap: var(--spacing-sm);
  }

  .stat-item {
    min-width: 120px;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .help-btn,
  .restart-btn {
    bottom: var(--spacing-md);
  }

  .help-btn {
    right: var(--spacing-md);
    width: 45px;
    height: 45px;
    font-size: 1.25rem;
  }

  .restart-btn {
    left: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .btn-text {
    display: none;
  }

  .modal-content {
    padding: var(--spacing-lg);
  }
}

/* ===== ACCESSIBILITY ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 3px solid var(--warning);
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .item-card {
    border: 2px solid currentColor;
  }

  .map-zone {
    stroke-width: 3;
  }
}
