/* =============================================================================
   GAME.CSS - Game-Specific Styles
   Canvas container, HUD elements, game controls, and game-specific UI
   ============================================================================= */

@import './base.css';
@import './components.css';

/* =============================================================================
   GAME CONTAINER & LAYOUT
   ============================================================================= */

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--spacing-md);
  min-height: 100vh;
  background: linear-gradient(180deg, #0A0A0A 0%, #1A1A1A 100%);
  position: relative;
}

.game-header {
  width: 100%;
  max-width: 1024px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-sm) 0;
}

.game-title {
  font-size: var(--size-h2);
  margin: 0;
}

.game-status {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--size-small);
  font-family: var(--font-mono);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-accent-success);
}

.status-dot.paused {
  background-color: var(--color-accent-warning);
}

.status-dot.error {
  background-color: var(--color-accent-warning);
}

/* =============================================================================
   CANVAS WRAPPER & GAME VIEWPORT
   ============================================================================= */

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 1024px;
  aspect-ratio: 4/3;
  background-color: #000;
  border: 2px solid var(--color-primary-yellow);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 
    0 8px 32px rgba(255, 215, 0, 0.2),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
  margin-bottom: var(--spacing-md);
}

.canvas-wrapper::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, var(--color-primary-yellow), transparent, var(--color-primary-yellow));
  border-radius: var(--radius-md);
  z-index: -1;
  animation: borderGlow 3s ease-in-out infinite alternate;
}

@keyframes borderGlow {
  0% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.8;
  }
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: none; /* Hide cursor during gameplay */
}

/* Loading State */
.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.9);
  color: var(--color-primary-white);
  z-index: 20;
}

.canvas-loading.hidden {
  display: none;
}

.loading-spinner {
  margin-bottom: var(--spacing-sm);
}

.loading-text {
  font-family: var(--font-display);
  font-size: var(--size-h3);
  text-transform: uppercase;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

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

/* =============================================================================
   GAME HUD (HEADS UP DISPLAY)
   ============================================================================= */

.game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

.hud-left,
.hud-right,
.hud-center {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hud-center {
  align-items: center;
}

.hud-item {
  background-color: rgba(10, 10, 10, 0.9);
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: var(--size-small);
  color: var(--color-primary-yellow);
  backdrop-filter: blur(5px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  animation: hudSlideIn 0.5s ease-out;
}

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

.hud-label {
  font-size: var(--size-tiny);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(245, 245, 245, 0.7);
  margin-bottom: 0.2rem;
}

.hud-value {
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
  color: var(--color-primary-yellow);
}

.hud-value.large {
  font-size: var(--size-body);
}

.hud-value.success {
  color: var(--color-accent-success);
}

.hud-value.warning {
  color: var(--color-accent-warning);
}

/* Score Animation */
.hud-value.score-increase {
  animation: scoreIncrease 0.3s ease-out;
}

@keyframes scoreIncrease {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    color: var(--color-accent-success);
  }
  100% {
    transform: scale(1);
  }
}

.hud-value.score-decrease {
  animation: scoreDecrease 0.3s ease-out;
}

@keyframes scoreDecrease {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
    color: var(--color-accent-warning);
  }
  100% {
    transform: scale(1);
  }
}

/* =============================================================================
   PERSPECTIVE SELECTOR (IN-GAME)
   ============================================================================= */

.perspective-selector {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  background-color: rgba(10, 10, 10, 0.95);
  padding: 0.75rem;
  border-radius: var(--radius-xl);
  border: 2px solid rgba(255, 215, 0, 0.3);
  backdrop-filter: blur(10px);
  pointer-events: all;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: perspectiveSelectorSlideIn 0.5s ease-out;
}

@keyframes perspectiveSelectorSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(50px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.perspective-btn-small {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--color-primary-white);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.perspective-btn-small::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 40%, rgba(255, 215, 0, 0.1) 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.perspective-btn-small:hover {
  border-color: var(--color-primary-yellow);
  background-color: rgba(255, 215, 0, 0.2);
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

.perspective-btn-small:hover::before {
  opacity: 1;
}

.perspective-btn-small.active {
  border-color: var(--color-primary-yellow);
  background-color: var(--color-primary-yellow);
  color: var(--color-primary-black);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
  animation: perspectiveActive 0.3s ease-out;
}

@keyframes perspectiveActive {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

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

/* Perspective Tooltips */
.perspective-btn-small[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-primary-black);
  color: var(--color-primary-white);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: var(--size-tiny);
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  margin-bottom: 0.5rem;
  z-index: 100;
}

.perspective-btn-small:hover[data-tooltip]::after {
  opacity: 1;
}

/* =============================================================================
   GAME CONTROLS INTERFACE
   ============================================================================= */

.game-controls {
  width: 100%;
  max-width: 1024px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.game-controls h3 {
  font-size: var(--size-h3);
  margin-bottom: var(--spacing-sm);
  text-align: center;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
}

.control-section {
  text-align: center;
}

.control-section h4 {
  font-size: var(--size-body);
  margin-bottom: var(--spacing-sm);
  color: var(--color-primary-yellow);
}

.control-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.control-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2rem;
  padding: 0 0.5rem;
  background-color: var(--color-primary-black);
  border: 2px solid var(--color-primary-gray);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
  color: var(--color-primary-white);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.control-key.highlighted {
  border-color: var(--color-primary-yellow);
  background-color: rgba(255, 215, 0, 0.1);
  color: var(--color-primary-yellow);
}

.control-action {
  font-size: var(--size-small);
  color: rgba(245, 245, 245, 0.9);
}

/* Mobile Touch Controls */
.touch-controls {
  display: none;
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: all;
  z-index: 15;
}

.touch-btn {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--color-primary-white);
  cursor: pointer;
  transition: all var(--transition-fast);
  backdrop-filter: blur(5px);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
  background-color: rgba(255, 215, 0, 0.3);
  border-color: var(--color-primary-yellow);
  transform: scale(0.95);
}

.touch-btn.jump {
  font-size: 2rem;
}

/* =============================================================================
   GAME STATE OVERLAYS
   ============================================================================= */

/* Pause Overlay */
.pause-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--spacing-md);
  z-index: 30;
  animation: overlayFadeIn 0.3s ease-out;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.pause-overlay.active {
  display: flex;
}

.pause-overlay h2 {
  font-size: var(--size-h1);
  color: var(--color-primary-yellow);
  text-align: center;
  margin-bottom: var(--spacing-sm);
}

.pause-overlay p {
  text-align: center;
  font-size: var(--size-body);
  color: rgba(245, 245, 245, 0.8);
  margin-bottom: var(--spacing-md);
}

.pause-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

/* Game Over Screen */
.game-over {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.95) 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  z-index: 40;
  padding: var(--spacing-md);
  text-align: center;
  animation: gameOverSlideIn 0.5s ease-out;
}

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

.game-over.active {
  display: flex;
}

.game-over h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--color-primary-yellow);
  margin-bottom: var(--spacing-sm);
}

.game-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
  width: 100%;
  max-width: 400px;
  margin-bottom: var(--spacing-lg);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: var(--spacing-sm);
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-label {
  font-size: var(--size-small);
  color: var(--color-primary-gray);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: var(--size-h2);
  color: var(--color-primary-yellow);
  font-family: var(--font-display);
  font-weight: var(--weight-black);
  line-height: 1;
}

.game-over-actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

/* =============================================================================
   NOTIFICATION SYSTEM (GAME-SPECIFIC)
   ============================================================================= */

.game-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(10, 10, 10, 0.95);
  border: 2px solid var(--color-primary-yellow);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  text-align: center;
  z-index: 25;
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  animation: notificationSlideIn 0.3s ease-out;
}

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

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

.game-notification h3 {
  color: var(--color-primary-yellow);
  margin-bottom: var(--spacing-sm);
}

.game-notification p {
  color: rgba(245, 245, 245, 0.9);
  margin-bottom: var(--spacing-md);
}

/* =============================================================================
   MOBILE RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 768px) {
  .canvas-wrapper {
    aspect-ratio: 3/4; /* Portrait aspect ratio on mobile */
    max-width: 100vw;
    margin: 0 -1rem var(--spacing-md) -1rem;
    border-radius: 0;
  }
  
  .canvas-wrapper::before {
    border-radius: 0;
  }
  
  .game-container {
    padding: var(--spacing-sm);
  }
  
  .game-header {
    flex-direction: column;
    gap: var(--spacing-sm);
    text-align: center;
  }
  
  .game-hud {
    padding: 0.5rem;
    font-size: var(--size-tiny);
  }
  
  .hud-item {
    padding: 0.25rem 0.75rem;
  }
  
  .perspective-selector {
    bottom: 0.5rem;
    gap: 0.25rem;
    padding: 0.5rem;
  }
  
  .perspective-btn-small {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .touch-controls {
    display: flex;
  }
  
  .game-controls {
    margin-bottom: var(--spacing-sm);
  }
  
  .controls-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }
  
  .control-key {
    min-width: 2rem;
    height: 1.75rem;
  }
  
  .game-stats {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }
  
  .stat-value {
    font-size: var(--size-h3);
  }
  
  .game-over-actions,
  .pause-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .game-notification {
    min-width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
  }
  
  /* Hide keyboard controls on mobile */
  .control-section:first-child {
    display: none;
  }
}

/* =============================================================================
   PERFORMANCE & ACCESSIBILITY
   ============================================================================= */

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .canvas-wrapper::before,
  .hud-item,
  .perspective-selector,
  .perspective-btn-small.active,
  .game-over,
  .pause-overlay,
  .game-notification {
    animation: none;
  }
  
  .perspective-btn-small:hover,
  .perspective-btn-small:active,
  .touch-btn:active {
    transform: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .canvas-wrapper {
    border-width: 3px;
  }
  
  .hud-item {
    border-width: 2px;
    background-color: rgba(0, 0, 0, 0.95);
  }
  
  .perspective-btn-small {
    border-width: 3px;
  }
  
  .control-key {
    border-width: 3px;
  }
}

/* Print styles (hide game elements) */
@media print {
  .game-container,
  .canvas-wrapper,
  .game-hud,
  .perspective-selector,
  .touch-controls,
  .game-controls {
    display: none !important;
  }
}
