/* Typing Engine UI - GlyphPulse V6 */

#glyph-typing-container {
    width: 100%;
    max-width: 1100px;
    margin: 40px auto;
    padding: 30px;
    background: rgba(10, 15, 30, 0.8);
    border: 1px solid rgba(0, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.05), inset 0 0 20px rgba(0, 0, 0, 0.5);
    font-family: 'Fira Code', 'Courier New', Courier, monospace; /* Monospace for typing */
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    backdrop-filter: blur(10px);
}

.gp-typing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.gp-typing-title {
    font-size: 1.2rem;
    color: #fff;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gp-typing-title .pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #00ffff;
    border-radius: 50%;
    box-shadow: 0 0 10px #00ffff;
    animation: typing-pulse 1.5s infinite alternate;
}

@keyframes typing-pulse {
    0% { opacity: 0.5; box-shadow: 0 0 5px #00ffff; }
    100% { opacity: 1; box-shadow: 0 0 15px #00ffff; }
}

.gp-typing-metrics {
    display: flex;
    gap: 20px;
}

.gp-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.gp-metric-label {
    font-size: 0.7rem;
    color: #8892b0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gp-metric-val {
    font-size: 1.2rem;
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
}

.gp-typing-board {
    font-size: 2.8rem; /* Much larger for visibility */
    font-weight: 700; /* Thicker */
    text-transform: uppercase; /* Enforce uppercase */
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.6;
    color: #64748b; /* Brighter inactive color */
    word-break: normal;
    white-space: normal;
    text-align: center; /* PERFECTLY CENTERED TEXT */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    align-content: center;
    position: relative;
    outline: none; /* Remove focus ring */
    cursor: text;
    user-select: none;
    min-height: 120px;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.3s;
}

.gp-typing-board:focus {
    background: rgba(255, 255, 255, 0.02);
}

.gp-word {
    display: inline-block;
    white-space: nowrap;
}

/* Character states */
.gp-char {
    position: relative;
    transition: color 0.1s;
}

.gp-char.correct {
    color: #e2e8f0; /* White/Bright */
}

.gp-char.active {
    color: #e2e8f0;
}

.gp-char.active::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 100%;
    height: 2px;
    background-color: #00ffff;
    box-shadow: 0 0 8px #00ffff;
    animation: cursor-blink 1s infinite;
}

.gp-char.error {
    color: #ff3366; /* Neon Red */
    background: rgba(255, 51, 102, 0.1);
    border-radius: 2px;
}

.gp-char.active.error::before {
    background-color: #ff3366;
    box-shadow: 0 0 8px #ff3366;
}

.gp-char.space-char {
    opacity: 0.4;
    padding: 0 2px;
}

.gp-char.space-char.correct {
    opacity: 0;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.gp-typing-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.gp-typing-btn {
    background: transparent;
    border: 1px solid rgba(0, 255, 255, 0.3);
    color: #00ffff;
    padding: 8px 16px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.gp-typing-btn:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.gp-level-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.gp-level-btn {
    background: transparent;
    border: 1px solid #4a5568;
    color: #4a5568;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.gp-level-btn.active {
    border-color: #00ffff;
    color: #00ffff;
    background: rgba(0, 255, 255, 0.05);
}



/* Virtual Keyboard */
.gp-virtual-keyboard {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px auto 20px auto;
    width: max-content;
    align-items: flex-start;
    /* Mathematical visual centering: 
       Container width = 667px (Center = 333.5px)
       Visual content spans from 58px to 667px (Center = 362.5px)
       Offset = 362.5 - 333.5 = +29px. Translate left by 29px to center on screen. */
    transform: translateX(-29px);
}

/* Perfect Microsoft US Staggering (1U = 58px) */
.vk-row-0 { padding-left: 58px; }   /* Tilde is 1U = 58px */
.vk-row-1 { padding-left: 87px; }   /* Tab is 1.5U = 87px */
.vk-row-2 { padding-left: 101.5px; } /* CapsLock is 1.75U = 101.5px */
.vk-row-3 { padding-left: 130.5px; } /* LShift is 2.25U = 130.5px */
.vk-row-4 { 
    align-self: flex-start;
    padding-left: 237.5px; /* Mathematical center (362.5px) minus half of spacebar (125px) */
}

.vk-row {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

.vk-key {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    border-radius: 8px;
    min-width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    text-transform: uppercase;
    transition: all 0.15s ease;
}

.vk-key.space-key {
    width: 250px;
    font-size: 0.8rem;
    letter-spacing: 2px;
}

.vk-key.vk-active {
    background: rgba(0, 255, 255, 0.15); /* Neon Cyan highlight */
    border-color: #00ffff;
    color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
    transform: scale(1.1);
}

.vk-key.vk-pressed {
    background: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: scale(0.95);
    transition: all 0.05s;
}

.vk-key.vk-error {
    background: rgba(255, 51, 102, 0.4);
    border-color: #ff3366;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.4);
}

/* ========================================
   PEDAGOGICAL MODE (Finger Color Zones)
   ======================================== */
.pedagogical-mode .vk-key {
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s, transform 0.1s;
}

.pedagogical-mode .finger-lp { border-bottom: 3px solid #ff00ff; color: #ff80ff; }
.pedagogical-mode .finger-lr { border-bottom: 3px solid #ff7f00; color: #ffbf80; }
.pedagogical-mode .finger-lm { border-bottom: 3px solid #ffff00; color: #ffff80; }
.pedagogical-mode .finger-li { border-bottom: 3px solid #00ff00; color: #80ff80; }

.pedagogical-mode .finger-ri { border-bottom: 3px solid #00ffff; color: #80ffff; }
.pedagogical-mode .finger-rm { border-bottom: 3px solid #007fff; color: #80bfff; }
.pedagogical-mode .finger-rr { border-bottom: 3px solid #7f00ff; color: #bf80ff; }
.pedagogical-mode .finger-rp { border-bottom: 3px solid #ff007f; color: #ff80bf; }

/* Active States for Pedagogical Mode */
.pedagogical-mode .finger-lp.vk-active { background: rgba(255,0,255,0.2); border-color: #ff00ff; box-shadow: 0 0 15px rgba(255,0,255,0.5); }
.pedagogical-mode .finger-lr.vk-active { background: rgba(255,127,0,0.2); border-color: #ff7f00; box-shadow: 0 0 15px rgba(255,127,0,0.5); }
.pedagogical-mode .finger-lm.vk-active { background: rgba(255,255,0,0.2); border-color: #ffff00; box-shadow: 0 0 15px rgba(255,255,0,0.5); }
.pedagogical-mode .finger-li.vk-active { background: rgba(0,255,0,0.2); border-color: #00ff00; box-shadow: 0 0 15px rgba(0,255,0,0.5); }

.pedagogical-mode .finger-ri.vk-active { background: rgba(0,255,255,0.2); border-color: #00ffff; box-shadow: 0 0 15px rgba(0,255,255,0.5); }
.pedagogical-mode .finger-rm.vk-active { background: rgba(0,127,255,0.2); border-color: #007fff; box-shadow: 0 0 15px rgba(0,127,255,0.5); }
.pedagogical-mode .finger-rr.vk-active { background: rgba(127,0,255,0.2); border-color: #7f00ff; box-shadow: 0 0 15px rgba(127,0,255,0.5); }
.pedagogical-mode .finger-rp.vk-active { background: rgba(255,0,127,0.2); border-color: #ff007f; box-shadow: 0 0 15px rgba(255,0,127,0.5); }

/* Next Key Highlight (Glowing before press) - Intense Neon */
@keyframes ghost-pulse {
    from { 
        box-shadow: inset 0 0 10px currentColor, 0 0 15px currentColor; 
        filter: brightness(1.2); 
        transform: translateY(0) scale(1); 
    }
    to { 
        box-shadow: inset 0 0 20px currentColor, 0 0 35px currentColor, 0 0 50px currentColor; 
        filter: brightness(2); 
        transform: translateY(-3px) scale(1.05); 
    }
}

.pedagogical-mode .vk-next-key {
    animation: ghost-pulse 0.6s infinite alternate cubic-bezier(0.4, 0, 0.2, 1) !important;
    color: #fff !important;
    text-shadow: 0 0 10px #fff, 0 0 20px currentColor !important;
    z-index: 10;
}
.pedagogical-mode .finger-lp.vk-next-key { background: rgba(255,0,255,0.4); border-color: #ff00ff; }
.pedagogical-mode .finger-lr.vk-next-key { background: rgba(255,127,0,0.4); border-color: #ff7f00; }
.pedagogical-mode .finger-lm.vk-next-key { background: rgba(255,255,0,0.4); border-color: #ffff00; }
.pedagogical-mode .finger-li.vk-next-key { background: rgba(0,255,0,0.4); border-color: #00ff00; }

.pedagogical-mode .finger-ri.vk-next-key { background: rgba(0,255,255,0.4); border-color: #00ffff; }
.pedagogical-mode .finger-rm.vk-next-key { background: rgba(0,127,255,0.4); border-color: #007fff; }
.pedagogical-mode .finger-rr.vk-next-key { background: rgba(127,0,255,0.4); border-color: #7f00ff; }
.pedagogical-mode .finger-rp.vk-next-key { background: rgba(255,0,127,0.4); border-color: #ff007f; }

/* Default for Space or unmapped keys */
.pedagogical-mode .vk-key:not([class*="finger-"]).vk-next-key {
    background: rgba(255,255,255,0.4); border-color: #ffffff; color: #ffffff !important;
}

/* Ghost Hands */
#ghost-hands-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: none;
}
.pedagogical-mode #ghost-hands-layer {
    display: block;
}

.ghost-finger-beam {
    position: absolute;
    width: 30px;
    height: 300px;
    background: linear-gradient(to top, rgba(0,255,255,0.4), transparent);
    border-radius: 15px 15px 0 0;
    bottom: -150px;
    transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
    opacity: 0.2;
    transform-origin: bottom center;
}
.ghost-finger-beam.active {
    opacity: 0.8;
    box-shadow: 0 -10px 20px rgba(0,255,255,0.4);
    animation: ghost-pulse 1s infinite alternate;
}

@keyframes ghost-pulse {
    from { opacity: 0.5; filter: brightness(1); }
    to { opacity: 0.9; filter: brightness(1.3); }
}
