/* ============================================================================
   TYPING-COMBAT.CSS - Typing-Triggered Combat Animation System
   High-Contrast Cyberpunk Stick-Figure Combat Engine
   ============================================================================ */

:root {
  --tc-bg-dark: #07090e;
  --tc-bg-panel: rgba(15, 23, 42, 0.75);
  --tc-border: rgba(255, 255, 255, 0.12);
  --tc-cyan: #00f3ff;
  --tc-magenta: #ff0055;
  --tc-yellow: #ffe600;
  --tc-green: #10b981;
  --tc-red: #ef4444;
  --tc-purple: #9d4edd;
  --tc-glow-cyan: 0 0 15px rgba(0, 243, 255, 0.5);
  --tc-glow-magenta: 0 0 15px rgba(255, 0, 85, 0.5);
  --tc-font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --tc-font-sans: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

/* Base Container & Shell */
.tc-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  background: var(--tc-bg-dark);
  border: 1px solid var(--tc-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 243, 255, 0.1);
  font-family: var(--tc-font-sans);
  color: #f8fafc;
  user-select: none;
}

/* Battle Screen / Arena Box */
.tc-arena-box {
  position: relative;
  width: 100%;
  height: 480px;
  background: radial-gradient(circle at 50% 30%, #111827 0%, #07090e 85%);
  overflow: hidden;
  perspective: 800px;
}

/* Grid & Stars Background Layer */
.tc-bg-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(0, 243, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 243, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  transform: perspective(500px) rotateX(60deg) translateY(-50px) scale(2);
  transform-origin: top center;
  opacity: 0.6;
  pointer-events: none;
}

/* Screen Shake Wrapper */
.tc-shake-target {
  position: relative;
  width: 100%;
  height: 100%;
  will-change: transform;
}

/* Camera Flash Overlay */
.tc-camera-flash {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 80ms ease-out;
}
.tc-camera-flash.active {
  opacity: 0.85;
}

/* HUD Header: Top Bar Stats & Health */
.tc-hud-bar {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 30;
  pointer-events: none;
}

.tc-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tc-stat-val {
  color: var(--tc-cyan);
  font-family: var(--tc-font-mono);
  font-size: 1.1rem;
}

/* Combo Badge Escalation */
.tc-combo-badge {
  background: linear-gradient(135deg, rgba(255, 0, 85, 0.2), rgba(0, 243, 255, 0.2));
  border-color: var(--tc-cyan);
  box-shadow: var(--tc-glow-cyan);
  transition: transform 120ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.tc-combo-badge.pop {
  transform: scale(1.35) rotate(-3deg);
}

/* Health Bar */
.tc-hp-container {
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tc-hp-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.1em;
  display: flex;
  justify-content: space-between;
}
.tc-hp-track {
  width: 100%;
  height: 10px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  overflow: hidden;
}
.tc-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff0055, #ff6600);
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
  transition: width 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================================
   TARGET WORD & LETTER DISPLAY
   ============================================================================ */

.tc-target-wrapper {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 40;
  width: 90%;
  max-width: 700px;
}

.tc-target-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

/* Character Box */
.tc-char-box {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 38px;
  height: 48px;
  padding: 0 8px;
  background: rgba(30, 41, 59, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-family: var(--tc-font-mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: #94a3b8;
  transition: all 120ms ease;
}

/* Space character box */
.tc-char-box.is-space {
  min-width: 24px;
  background: rgba(255, 255, 255, 0.05);
  border-style: dashed;
}

/* Typed Character State */
.tc-char-box.typed {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
  text-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  transform: scale(0.95);
}

/* Active (Required) Character State */
.tc-char-box.active {
  background: rgba(0, 243, 255, 0.2);
  border-color: var(--tc-cyan);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(0, 243, 255, 0.6), inset 0 0 10px rgba(0, 243, 255, 0.3);
  transform: translateY(-4px) scale(1.1);
  animation: tcPulseBorder 1.2s infinite ease-in-out;
}

@keyframes tcPulseBorder {
  0%, 100% { border-color: var(--tc-cyan); box-shadow: 0 0 16px rgba(0, 243, 255, 0.6); }
  50% { border-color: #ffffff; box-shadow: 0 0 24px rgba(0, 243, 255, 0.9); }
}

/* Miss Shake State on Target Box */
.tc-target-box.miss-shake {
  animation: tcHorizShake 200ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  border-color: var(--tc-red);
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.7);
}

.tc-char-box.active.miss-flash {
  background: rgba(239, 68, 68, 0.35);
  border-color: var(--tc-red);
  color: var(--tc-red);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
}

@keyframes tcHorizShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-12px); }
  40% { transform: translateX(12px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* ============================================================================
   FLOATING ARENA PLATFORM & FIGHTERS RIG
   ============================================================================ */

.tc-stage {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 680px;
  height: 220px;
}

/* Cyber Floating Platform */
.tc-platform {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 580px;
  height: 36px;
  background: linear-gradient(90deg, rgba(0,243,255,0.2) 0%, rgba(15,23,42,0.9) 20%, rgba(15,23,42,0.9) 80%, rgba(255,0,85,0.2) 100%);
  border-top: 3px solid var(--tc-cyan);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.2);
  border-radius: 8px 8px 30px 30px;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1), opacity 300ms ease;
}

.tc-platform.transitioning {
  transform: translateX(-150%) scale(0.9);
  opacity: 0;
}

/* Fighter Anchors */
.tc-fighter {
  position: absolute;
  bottom: 30px;
  width: 140px;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  transition: transform 100ms ease-out;
}

.tc-player-wrap {
  left: 140px;
}

.tc-enemy-wrap {
  right: 140px;
}

/* SVG Character Rig Styles */
.tc-rig-svg {
  width: 120px;
  height: 150px;
  overflow: visible;
}

.tc-bone {
  transform-origin: center center;
  transition: transform 80ms ease-out;
}

/* Default Idle Breathing Motion */
.tc-player-wrap.state-idle .tc-player-body {
  animation: tcIdleBreathing 2.4s infinite ease-in-out;
}
.tc-enemy-wrap.state-idle .tc-enemy-body {
  animation: tcIdleBreathing 2.2s infinite ease-in-out 0.2s;
}

@keyframes tcIdleBreathing {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(1.5deg); }
}

/* Player Pose States */
.tc-player-wrap.state-windup {
  transform: translateX(-15px) rotate(-6deg);
}
.tc-player-wrap.state-strike {
  transform: translateX(185px) scaleX(1.08) rotate(4deg);
}
.tc-player-wrap.state-recoil {
  transform: translateX(-25px) rotate(-12deg);
}
.tc-player-wrap.state-victory {
  transform: translateY(-15px) scale(1.1);
}

/* Enemy Pose States */
.tc-enemy-wrap.state-attack {
  transform: translateX(-185px) scaleX(1.08) rotate(-4deg);
}
.tc-enemy-wrap.state-hit {
  transform: translateX(18px) rotate(10deg);
}
.tc-enemy-wrap.state-block {
  transform: translateX(-10px) scale(0.95);
}
.tc-enemy-wrap.state-defeat {
  transform: translateX(50px) rotate(45deg);
  opacity: 0.3;
  filter: blur(2px);
}

/* Flash Filters on Hit */
.tc-hit-flash {
  filter: brightness(2.5) drop-shadow(0 0 12px #ff0055);
}
.tc-block-flash {
  filter: brightness(2.0) drop-shadow(0 0 12px #00f3ff);
}

/* ============================================================================
   EFFECT CANVASES & VISUAL OVERLAYS
   ============================================================================ */

.tc-effects-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

/* Parry / Block Red X Overlay */
.tc-block-overlay {
  position: absolute;
  top: 40%;
  right: 210px;
  transform: translate(50%, -50%) scale(0);
  width: 60px;
  height: 60px;
  color: var(--tc-red);
  font-size: 3.5rem;
  font-weight: 900;
  font-family: var(--tc-font-mono);
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 15px rgba(239, 68, 68, 0.9);
  pointer-events: none;
  z-index: 50;
  transition: transform 120ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.tc-block-overlay.active {
  transform: translate(50%, -50%) scale(1.2);
}

/* ============================================================================
   KEY-PRESS HUD & BOTTOM CONTROLS
   ============================================================================ */

.tc-bottom-hud {
  position: relative;
  width: 100%;
  padding: 16px 24px;
  background: rgba(10, 14, 23, 0.95);
  border-top: 1px solid var(--tc-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

/* Centered Keycap HUD Box */
.tc-keycap-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tc-keycap-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.1em;
}

.tc-keycap-box {
  width: 58px;
  height: 58px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 5px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--tc-font-mono);
  font-size: 1.8rem;
  font-weight: 900;
  color: #f8fafc;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
  transition: transform 150ms cubic-bezier(0.175, 0.885, 0.32, 1.275), background 150ms ease, border-color 150ms ease;
  will-change: transform;
}

.tc-keycap-box.correct {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.3), #0f172a);
  border-color: var(--tc-green);
  color: #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
}

.tc-keycap-box.incorrect {
  background: linear-gradient(145deg, rgba(239, 68, 68, 0.3), #0f172a);
  border-color: var(--tc-red);
  color: var(--tc-red);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
}

.tc-keycap-box.pop {
  transform: scale(1.15) rotate(4deg);
}
.tc-keycap-box.pop-neg {
  transform: scale(1.15) rotate(-4deg);
}

/* WPM / Rank Info */
.tc-rank-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tc-tier-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Story Caption Log (Running Narrative) */
.tc-story-log {
  width: 100%;
  padding: 12px 24px;
  background: #030712;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-family: var(--tc-font-mono);
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
}
.tc-story-title {
  color: var(--tc-cyan);
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.tc-story-text {
  color: #cbd5e1;
}

/* Mobile Input Hidden Capture */
.tc-mobile-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
