/* styles/main.css - Core styles and layout */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: Arial, sans-serif;
  background: linear-gradient(135deg, #1e3a5f 0%, #2d1b3d 100%);
  background-attachment: fixed;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

/* Landscape warning */
#landscape-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  text-align: center;
  padding: 20px;
}

#landscape-warning-icon {
  font-size: 72px;
  margin-bottom: 20px;
}

#landscape-warning-text {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 10px;
}

#landscape-warning-subtext {
  font-size: 16px;
  color: #a8c5e8;
}

@media (orientation: landscape) and (max-width: 900px) {
  #landscape-warning {
    display: flex;
  }
}

/* Level selector - reduced padding */
#level-selector {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px 15px;
  background: rgba(0, 0, 0, 0.2);
}

.level-btn {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  border: 3px solid #4a7ba7;
  background: #2c3e50;
  color: white;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.level-btn:hover {
  background: #34495e;
  transform: scale(1.05);
}

.level-btn.active {
  background: #4a7ba7;
  border-color: #6fa8dc;
  box-shadow: 0 0 15px rgba(74, 123, 167, 0.5);
}

.level-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.level-btn.complete::after {
  content: '✓';
  position: absolute;
  top: -5px;
  right: -5px;
  background: #4ade80;
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Challenge display - reduced height and padding */
#challenge-display {
  background: white;
  padding: 15px 20px;
  text-align: center;
  font-size: 38px;
  font-family: Times New Roman, serif;
  font-style: italic;
  font-weight: bold;
  color: #1a1a1a;
  border-bottom: 3px solid #4a7ba7;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.3s ease;
}

#challenge-display.has-correct-tiles {
  background: #fbbf24;
}

#challenge-display.complete {
  background: #4ade80;
}

#next-puzzle-btn {
  position: absolute;
  right: 20px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  color: white;
  border: 3px solid white;
  border-radius: 12px;
  font-size: 18px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-style: normal;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  display: none;
  transition: all 0.2s;
}

#next-puzzle-btn:hover {
  transform: scale(1.05);
}

#next-puzzle-btn:active {
  transform: scale(0.95);
}

/* Number line container - reduced padding */
#number-line-container {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 20px;
  border-bottom: 2px solid #4a7ba7;
}

#number-line {
  position: relative;
  height: 45px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 22.5px;
  border: 2px solid #4a7ba7;
}

.tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 2px;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tick-mark {
  width: 2px;
  height: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.tick-label {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: bold;
  transition: color 0.2s, transform 0.2s;
}

.tick-label.active {
  color: white;
  transform: translateX(-50%) scale(1.2);
}

#slider {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  border-radius: 50%;
  cursor: grab;
  border: 3px solid white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

#slider:active {
  cursor: grabbing;
}

#x-label {
  color: white;
  font-size: 28px;
  font-style: italic;
  font-family: Times New Roman, serif;
  font-weight: bold;
  line-height: 1;
}

/* Arena container - reduced padding */
#arena-container {
  flex: 1;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* Changed from hidden to visible */
  position: relative;
}

#arena {
  width: 100%;
  height: 100%;
  max-width: 800px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  border: 3px solid #4a7ba7;
  position: relative;
  overflow: hidden;
}

/* Puzzle counter positioned on top edge of arena */
#puzzle-counter {
  background: linear-gradient(135deg, rgba(74, 123, 167, 0.95) 0%, rgba(111, 168, 220, 0.95) 100%);
  color: white;
  padding: 5px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  min-width: 50px;
  text-align: center;
}

/* Progress restored message */
.progress-restored-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, rgba(74, 123, 167, 0.98) 0%, rgba(111, 168, 220, 0.98) 100%);
  color: white;
  padding: 20px 40px;
  border-radius: 16px;
  font-size: 20px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  text-align: center;
  border: 3px solid #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  animation: fadeInScale 0.4s ease-out;
  pointer-events: none;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes fadeOutScale {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

.progress-restored-message.fade-out {
  animation: fadeOutScale 0.3s ease-in forwards;
}

/* Group highlights */
.group-highlight {
  position: absolute;
  border: 2px solid #4ade80;
  border-radius: 12px;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.3);
  box-sizing: border-box;
}

/* Tile spawner - reduced padding */
#tile-spawner {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 2px solid #4a7ba7;
  position: relative;
}

.spawn-btn {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: 3px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-style: italic;
  font-family: Times New Roman, serif;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.spawn-btn:hover {
  transform: scale(1.05);
}

.spawn-btn:active {
  transform: scale(0.95);
}

.spawn-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.spawn-btn.highlighted {
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

/* Reset button - now positioned where trash was */
#reset-btn {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: 3px solid #fff;
  background: linear-gradient(135deg, #ff6b6b 0%, #ff4444 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  color: white;
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
}

/* Reset button - hover state */
#reset-btn:hover {
  transform: translateY(-50%) scale(1.05) rotate(180deg);
  background: linear-gradient(135deg, #ff8888 0%, #ff5555 100%);
}

#reset-btn:active {
  transform: translateY(-50%) scale(0.95) rotate(180deg);
}

#reset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Media queries */
@media (max-width: 600px) {
  #challenge-display {
    font-size: 28px;
    padding: 12px 15px;
    min-height: 60px;
  }
  
  #next-puzzle-btn {
    padding: 6px 12px;
    font-size: 16px;
    right: 10px;
  }
  
  #tile-spawner {
    padding: 12px 80px 12px 12px; /* Reduced right padding since only one button now */
  }
  
  .spawn-btn {
    width: 50px;
    height: 50px;
    font-size: 24px;
  }
  
  #reset-btn {
    width: 50px;
    height: 50px;
    font-size: 28px;
    right: 10px;
  }
  
  /* Puzzle counter responsive */
  #puzzle-counter {
    font-size: 13px;
    padding: 4px 14px;
  }
  
  /* Reduce level selector size on mobile */
  #level-selector {
    padding: 10px;
  }
  
  .level-btn {
    width: 45px;
    height: 45px;
    font-size: 18px;
  }
  
  /* Reduce number line padding */
  #number-line-container {
    padding: 10px 15px;
  }
  
  /* Arena container reduced padding on mobile */
  #arena-container {
    padding: 10px;
  }
}

/* Add this to animations.css or main.css */

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

/* Optional: Style for the help message if you want it in CSS instead of inline */
.puzzle-help-message {
  position: absolute;
  bottom: 10px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  font-style: normal;
  font-family: Arial, sans-serif;
  animation: fadeIn 0.3s ease-in-out;
  z-index: 100;
}

/* Arena success animation - smooth exhale effect */
@keyframes pulse-success {
  0% { 
    transform: scale(1);
    opacity: 0.8;
  }
  50% { 
    transform: scale(1.015);
    opacity: 1;
  }
  100% { 
    transform: scale(1);
    opacity: 0.8;
  }
}

/* Arena success state with smooth transition */
#arena.solve-success {
  border-color: #4ade80 !important;
  box-shadow: 0 0 40px rgba(74, 222, 128, 0.6);
  animation: pulse-success 1s ease-in-out;
}