/* ============================================= */
/* TRAINING.CSS — Immersive Combat Arena          */
/* ============================================= */

/* ── CRT SCANLINE OVERLAY ── */
.scanline-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 100;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 240, 255, 0.012) 2px,
        rgba(0, 240, 255, 0.012) 4px
    );
    animation: scanlineScroll 8s linear infinite;
    mix-blend-mode: screen;
}

@keyframes scanlineScroll {
    0%   { background-position: 0 0; }
    100% { background-position: 0 200px; }
}

/* ── TRAINING HUD — Glassmorphism ── */
.training-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(5, 8, 30, 0.85);
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: relative;
    z-index: 10;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), inset 0 -1px 0 rgba(0, 240, 255, 0.1);
}

.training-hud::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.03) 0%, transparent 50%, rgba(255, 0, 170, 0.02) 100%);
    pointer-events: none;
}

.training-hud-left {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

.training-hud-right {
    display: flex;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.lesson-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lesson-chapter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0.8;
}

.lesson-name {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.training-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 12px;
    background: rgba(0, 240, 255, 0.03);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.training-stat:hover {
    border-color: rgba(0, 240, 255, 0.25);
    background: rgba(0, 240, 255, 0.06);
}

.training-stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.training-stat-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
    transition: all 0.15s ease;
}

/* ── PROGRESS BAR — Neon Trail ── */
.training-progress-bar-container {
    width: 100%;
    height: 3px;
    background: rgba(0, 240, 255, 0.06);
    position: relative;
    z-index: 10;
    overflow: hidden;
}

.training-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-green), var(--neon-cyan));
    background-size: 200% 100%;
    animation: progressShimmer 2s linear infinite;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.6), 0 0 30px rgba(0, 240, 255, 0.3);
    transition: width 0.3s ease;
    position: relative;
}

.training-progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 6px;
    height: 9px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
}

@keyframes progressShimmer {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* ── ARENA CANVAS — Expanded ── */
.training-arena-container {
    position: relative;
    flex: 1;
    min-height: 250px;
    max-height: 55vh;
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 240, 255, 0.08);
}

.training-arena-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── BOTTOM PANEL — Glass Panel ── */
.training-bottom-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 24px 10px;
    gap: 8px;
    flex-shrink: 0;
    background: rgba(5, 8, 28, 0.95);
    border-top: 1px solid rgba(0, 240, 255, 0.08);
    position: relative;
    z-index: 10;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
}

.training-bottom-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.3), transparent);
}

/* ── WORD PROMPT — Neon Glow ── */
.training-prompt {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 14px;
    padding: 10px 24px;
    max-width: 800px;
    line-height: 1.9;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 500;
    position: relative;
}

.training-prompt .word {
    display: inline-flex;
    padding: 3px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    position: relative;
    border: 1px solid transparent;
}

.training-prompt .word.active {
    background: rgba(0, 240, 255, 0.06);
    border-color: rgba(0, 240, 255, 0.2);
    border-radius: 8px;
    box-shadow:
        0 0 20px rgba(0, 240, 255, 0.1),
        inset 0 0 25px rgba(0, 240, 255, 0.03);
    animation: activePulse 1.5s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(0, 240, 255, 0.08), inset 0 0 20px rgba(0, 240, 255, 0.02);
        border-color: rgba(0, 240, 255, 0.15);
    }
    50% {
        box-shadow: 0 0 30px rgba(0, 240, 255, 0.2), inset 0 0 35px rgba(0, 240, 255, 0.05);
        border-color: rgba(0, 240, 255, 0.35);
    }
}

.training-prompt .word.completed {
    opacity: 0.25;
    transform: scale(0.97);
    transition: all 0.5s ease;
}

.training-prompt .word.error {
    animation: wordShake 0.35s ease;
    border-color: rgba(255, 34, 85, 0.7) !important;
    box-shadow: 0 0 25px rgba(255, 34, 85, 0.35), inset 0 0 15px rgba(255, 34, 85, 0.08) !important;
    background: rgba(255, 34, 85, 0.08) !important;
}

@keyframes wordShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-5px) rotate(-0.5deg); }
    30% { transform: translateX(5px) rotate(0.5deg); }
    45% { transform: translateX(-4px) rotate(-0.3deg); }
    60% { transform: translateX(4px) rotate(0.3deg); }
    75% { transform: translateX(-2px); }
}

.training-prompt .char {
    color: var(--text-muted);
    transition: color 0.12s, text-shadow 0.12s, transform 0.12s;
    display: inline-block;
}

.training-prompt .char.correct {
    color: var(--neon-green);
    text-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
    transform: scale(1.02);
}

.training-prompt .char.incorrect {
    color: var(--neon-red);
    text-shadow: 0 0 12px rgba(255, 34, 85, 0.7);
    text-decoration: underline wavy var(--neon-red);
    animation: charShake 0.3s ease;
}

@keyframes charShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.training-prompt .char.cursor {
    color: #ffffff;
    position: relative;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    transform: scale(1.08);
}

.training-prompt .char.cursor::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 2.5px;
    background: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
    animation: cursorBlink 0.7s ease-in-out infinite;
    border-radius: 2px;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan); }
    50% { opacity: 0.25; box-shadow: 0 0 5px var(--neon-cyan); }
}

/* ── HINT ── */
.training-hint {
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--neon-cyan);
    text-align: center;
    min-height: 1.3em;
    text-shadow: 0 0 8px rgba(0, 240, 255, 0.3);
    transition: color 0.3s, text-shadow 0.3s;
    letter-spacing: 0.5px;
}

/* ── KEYBOARD — Enhanced ── */
.keyboard-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 3px;
}

.key {
    width: 44px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(10, 14, 42, 0.8);
    color: var(--text-muted);
    transition: all 0.1s ease;
    position: relative;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
    overflow: hidden;
}

/* Glass reflection on keys */
.key::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.04), transparent);
    border-radius: 6px 6px 0 0;
    pointer-events: none;
}

.key.in-zone {
    border-color: rgba(0, 240, 255, 0.12);
    background: rgba(10, 18, 50, 0.85);
    color: rgba(255, 255, 255, 0.5);
}

.key.active-key {
    border-color: rgba(0, 240, 255, 0.4);
    background: rgba(0, 240, 255, 0.08);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.2), inset 0 0 10px rgba(0, 240, 255, 0.05);
    animation: keyPulse 0.6s ease-in-out infinite alternate;
}

@keyframes keyPulse {
    from {
        box-shadow: 0 0 12px rgba(0, 240, 255, 0.2), inset 0 0 8px rgba(0, 240, 255, 0.05);
    }
    to {
        box-shadow: 0 0 22px rgba(0, 240, 255, 0.4), inset 0 0 15px rgba(0, 240, 255, 0.1);
        border-color: rgba(0, 240, 255, 0.6);
    }
}

.key.pressed {
    background: rgba(0, 255, 136, 0.25) !important;
    border-color: var(--neon-green) !important;
    color: #ffffff !important;
    box-shadow: 0 0 18px rgba(0, 255, 136, 0.4), inset 0 0 8px rgba(0, 255, 136, 0.1);
    transform: scale(0.93) translateY(1px);
}

.key.wrong {
    background: rgba(255, 34, 85, 0.25) !important;
    border-color: var(--neon-red) !important;
    color: #ffffff !important;
    box-shadow: 0 0 18px rgba(255, 34, 85, 0.4);
    transform: scale(0.93);
    animation: keyShake 0.3s ease;
}

@keyframes keyShake {
    0%, 100% { transform: translateX(0) scale(0.93); }
    25% { transform: translateX(-3px) scale(0.93); }
    75% { transform: translateX(3px) scale(0.93); }
}

.key.home-key::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 2px;
    background: rgba(0, 240, 255, 0.3);
    border-radius: 1px;
}

.key-backspace { width: 80px; font-size: 0.55rem; }
.key-tab { width: 60px; font-size: 0.55rem; }
.key-caps { width: 70px; font-size: 0.55rem; }
.key-enter { width: 85px; font-size: 0.55rem; }
.key-shift { width: 95px; font-size: 0.55rem; }
.key-space { width: 280px; font-size: 0.6rem; letter-spacing: 3px; }

/* Finger color coding — Neon */
.key.show-fingers.finger-pinky-l  { border-bottom: 2px solid #ff6b9d; }
.key.show-fingers.finger-ring-l   { border-bottom: 2px solid #c084fc; }
.key.show-fingers.finger-middle-l { border-bottom: 2px solid #60a5fa; }
.key.show-fingers.finger-index-l  { border-bottom: 2px solid #34d399; }
.key.show-fingers.finger-index-r  { border-bottom: 2px solid #fbbf24; }
.key.show-fingers.finger-middle-r { border-bottom: 2px solid #f97316; }
.key.show-fingers.finger-ring-r   { border-bottom: 2px solid #f472b6; }
.key.show-fingers.finger-pinky-r  { border-bottom: 2px solid #a78bfa; }

/* ── Finger Guide ── */
.keyboard-finger-guide {
    display: flex;
    justify-content: center;
    gap: 14px;
    padding: 4px 0;
    flex-wrap: wrap;
}

.finger-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.5rem;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.5px;
}

.finger-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* ── INPUT DISPLAY ── */
.training-input-display {
    min-height: 0;
}

/* ── SCREEN LAYOUT ── */
#screen-training {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

#screen-training.active {
    display: flex;
}

/* ── Combo indicator overlay ── */
.training-combo-tier {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 900;
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    animation: comboFlashIn 0.6s ease-out forwards;
    text-shadow: 0 0 30px currentColor, 0 0 60px currentColor;
}

@keyframes comboFlashIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(3); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    50% { transform: translate(-50%, -50%) scale(0.95); }
    70% { transform: translate(-50%, -50%) scale(1.02); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}
