/* 
 * Game UI Styles
 * Game-specific interface elements
 */

/* ===== Phaser Integration ===== */
.phaser-element {
  position: absolute;
}

/* ===== Turn Indicator ===== */
#turn-indicator {
  position: absolute;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: var(--z-fixed);
  box-shadow: var(--glass-shadow);
  animation: turnIndicatorPulse 2.4s ease-in-out infinite;
  transition: all var(--transition-normal);
}

/* Turn indicator color variants */
#turn-indicator.player-turn {
  border-color: var(--accent-green);
  color: var(--accent-green);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(80, 250, 123, 0.4);
}

#turn-indicator.enemy-turn {
  border-color: var(--accent-red);
  color: var(--accent-red);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(255, 85, 85, 0.4);
}

#turn-text {
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

/* ===== Next Turn Button ===== */
#next-turn-btn {
  pointer-events: auto;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-family: inherit;
  border: 2px solid currentColor;
  border-radius: var(--radius-lg);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#next-turn-btn:hover {
  transform: translateY(-2px) scale(1.05);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#next-turn-btn:active {
  transform: translateY(0) scale(1);
}

/* ===== Status Toast Container ===== */
#status-toast-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  pointer-events: none;
  max-width: 400px;
}

.status-toast {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  text-align: center;
  box-shadow: var(--glass-shadow);
  opacity: 0;
  animation: statusToastSlide 2.5s forwards;
  max-width: 100%;
  word-wrap: break-word;
}

.status-toast.info {
  border-color: var(--primary-400);
  color: var(--primary-300);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(14, 165, 233, 0.3);
}

.status-toast.success {
  border-color: var(--accent-green);
  color: var(--accent-green);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(80, 250, 123, 0.3);
}

.status-toast.error {
  border-color: var(--accent-red);
  color: var(--accent-red);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(255, 85, 85, 0.3);
}

.status-toast.warning {
  border-color: var(--accent-yellow);
  color: var(--accent-yellow);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(241, 250, 140, 0.3);
}

/* ===== Chat Toggle Button ===== */
#chat-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: all var(--transition-fast);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

#chat-toggle:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.1);
}

/* ===== Cards ===== */
.card-info-container {
    pointer-events: auto;
}

.card-info-container h1 {
  font-size: var(--font-size-base);
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  font-weight: bold;
}

.card-info-container h2 {
  font-size: var(--font-size-sm);
  margin: 0;
  color: var(--text-secondary);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

.card-info-container h3 {
  font-size: var(--font-size-sm);
  margin: 0;
  color: var(--text-secondary);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

.card-info-container p {
  font-size: var(--font-size-xs);
  margin: 0;
  color: var(--text-muted);
  opacity: 0.8;
}

.card-container {
  display: flex;
  width: var(--card-width);
  height: var(--card-height);
  transition: transform 0.1s ease-out;
}

.card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: absolute;
  background: var(--surface-elevated);
  backdrop-filter: var(--glass-blur);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);

  --scale: 1;
  --hover-offset: 0px;
  --rotation: 0deg;
  transform: translateY(var(--hover-offset)) scale(calc(var(--scale) * var(--mobile-scale-factor))) rotate(var(--rotation));
  transition: transform 0.1s ease-out;

  /* Make text smaller than usual on cards */
  --font-size-base: var(--font-size-xs);
  --font-size-sm: var(--font-size-2xs);
}

@keyframes card-wiggle {
  0%   { --rotation: 0deg; }
  10%  { --rotation: 1.18deg; }   /* sin(36°) ≈ 0.59 */
  20%  { --rotation: 1.90deg; }   /* sin(72°) ≈ 0.95 */
  30%  { --rotation: 1.90deg; }   /* sin(108°) ≈ 0.95 */
  40%  { --rotation: 1.18deg; }   /* sin(144°) ≈ 0.59 */
  50%  { --rotation: 0deg; }      /* sin(180°) = 0 */
  60%  { --rotation: -1.18deg; }  /* sin(216°) ≈ -0.59 */
  70%  { --rotation: -1.90deg; }  /* sin(252°) ≈ -0.95 */
  80%  { --rotation: -1.90deg; }  /* sin(288°) ≈ -0.95 */
  90%  { --rotation: -1.18deg; }  /* sin(324°) ≈ -0.59 */
  100% { --rotation: 0deg; }      /* sin(360°) = 0 */
}

.card-container.selected .card {
  --hover-offset: -150px;
  --scale: 1.2;
  animation: card-wiggle 0.5s infinite;
}

.card:hover {
  --hover-offset: -50px;
  box-shadow: 
    var(--glass-shadow),
    0 0 30px rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}

.card-header {
  background: var(--surface-elevated);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.elemental-types-container {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-end;
  gap: var(--space-1);
}

/* ===== Card Image ===== */
.card-image-container {
  position: relative;
  height: 120px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* ===== Stats Display ===== */
.stats-container {
  flex: 1;
  display: flex;
  flex-wrap: nowrap;
  min-width: 0;
  padding: 0 var(--space-3);
  gap: var(--space-1);
  justify-content: center;
}

.stat-item {
  flex: 1 0 33.3333%;
  overflow: hidden;
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);

  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
}

.stat-label {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

.stat-value {
  color: var(--text-primary);
  font-size: var(--font-size-2xs);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  font-weight: bold;
}

/* ===== Type Frame ===== */
.type-frame {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  z-index: 10;
  position: relative;
  width: max-content;
  padding: 2px 6px;
  font-size: var(--font-size-xs);
  line-height: 1.2;
  min-height: auto;
}

/* ===== Actions ===== */
.actions-container {
  padding: var(--space-1) var(--space-3)
}

#action-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.action-item {
  display: block;
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
  /* PERFORMANCE: Only animate hardware-accelerated properties */
  transition: background var(--transition-normal), transform var(--transition-normal), box-shadow var(--transition-normal);
  cursor: pointer;
}

.action-item.selected {
  background: var(--surface-elevated);
  border-color: var(--primary-400);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.action-title {
  padding-left: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--accent-yellow);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

.action-description {
  margin: 0;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== Entity Popup ===== */
.entity-popup {
  position: fixed;
  bottom: var(--space-5);
  left: var(--space-5);
  width: 320px;
  max-height: 500px;
  background: var(--surface-elevated);
  backdrop-filter: var(--glass-blur);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  z-index: var(--z-popover);
  overflow: hidden;
  opacity: 0.95;
  transition: all var(--transition-normal);
  display: none;
  flex-direction: column;
}

.entity-popup.active {
  display: flex;
}

.entity-header {
  background: var(--surface-elevated);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.entity-stats {
  display: flex;
  flex-wrap: wrap;
  padding: var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.entity-actions {
  padding: var(--space-3);
  background: var(--surface-elevated);
}

/* ===== Game Overlays ===== */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal-backdrop);
}

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

.overlay-content {
  background: var(--surface-elevated);
  backdrop-filter: var(--glass-blur);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  box-shadow: var(--glass-shadow);
  animation: scaleIn 0.3s ease-out;
}

/* ===== Loading States ===== */
.game-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-8);
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary-400);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
}

/* ===== Game Notifications ===== */
.game-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 2px solid var(--primary-400);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  font-size: var(--font-size-xl);
  color: var(--primary-300);
  text-align: center;
  box-shadow: 
    var(--glass-shadow),
    0 0 30px rgba(14, 165, 233, 0.4);
  z-index: var(--z-toast);
  animation: scaleIn 0.5s ease-out;
}

/* ===== Game Controls ===== */
.game-controls {
  position: absolute;
  bottom: var(--space-4);
  right: var(--space-4);
  display: flex;
  gap: var(--space-2);
  z-index: var(--z-fixed);
}

.control-button {
  width: 48px;
  height: 48px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-lg);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glass-shadow);
}

.control-button:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 
    var(--glass-shadow),
    0 0 20px rgba(255, 255, 255, 0.1);
}

.control-button:active {
  transform: translateY(0);
}

/* ===== Game-specific Animations ===== */
@keyframes turnIndicatorPulse {
  0%, 100% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 10px currentColor; 
  }
  50% { 
    box-shadow: 
      var(--glass-shadow),
      0 0 25px currentColor,
      0 0 40px currentColor; 
  }
}

@keyframes statusToastSlide {
  0% { 
    opacity: 0; 
    transform: translateY(-20px) scale(0.9); 
  }
  10% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
  90% { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
  }
  100% { 
    opacity: 0; 
    transform: translateY(-20px) scale(0.9); 
  }
}
