/*
 * keyboard.css - สไตล์สำหรับคีย์บอร์ดเสมือนจริงและระบบแนะนำนิ้วสัมผัส
 */

.keyboard-section {
    position: relative;
    background: #392110;
    border: 6px solid #573319;
    border-radius: 16px;
    padding: 12px 16px 14px 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 6px;
}

/* Side Hand Guides */
.hand-guide {
    position: absolute;
    bottom: 8px;
    width: 60px;
    height: 70px;
    opacity: 0.85;
    pointer-events: none;
    transition: all 0.2s ease;
}

.hand-guide.left {
    left: 8px;
}

.hand-guide.right {
    right: 8px;
}

.hand-svg {
    width: 100%;
    height: 100%;
    fill: #d39e6a;
    stroke: #5d3618;
    stroke-width: 1.5;
}

/* Highlight specific active finger on hand */
.hand-guide.active-pinky .finger-pinky,
.hand-guide.active-ring .finger-ring,
.hand-guide.active-middle .finger-middle,
.hand-guide.active-index .finger-index,
.hand-guide.active-thumb .finger-thumb {
    fill: #43d43b !important;
    filter: drop-shadow(0 0 5px #43d43b);
}

/* Keyboard Container */
.virtual-keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

/* Individual Key Cap */
.kb-key {
    flex: 1;
    height: 44px;
    background: linear-gradient(180deg, #444b54 0%, #2b313a 100%);
    border: 2px solid #1c2026;
    border-radius: 6px;
    color: #f1f5f9;
    font-family: var(--font-code);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 0 #15181c, 0 5px 6px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: background 0.1s, transform 0.08s, box-shadow 0.08s;
}

.kb-key .key-main {
    line-height: 1;
}

.kb-key .key-sub {
    font-size: 10px;
    color: #94a3b8;
    margin-bottom: 2px;
    line-height: 1;
}

/* Home Row Touch Indicators (F and J bumps) */
.kb-key.home-key::after {
    content: '';
    position: absolute;
    bottom: 5px;
    width: 10px;
    height: 2px;
    background: #94a3b8;
    border-radius: 2px;
}

/* Key Widths */
.kb-key.kb-wide {
    flex: 1.5;
}

.kb-key.kb-wide-caps {
    flex: 1.75;
}

.kb-key.kb-wide-enter {
    flex: 2.2;
}

.kb-key.kb-extra-wide {
    flex: 2.4;
}

.kb-key.kb-spacebar {
    flex: 6.5;
}

/* Pressed State */
.kb-key.kb-pressed,
.kb-key.kb-active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #15181c, 0 2px 3px rgba(0,0,0,0.3);
    background: linear-gradient(180deg, #2b313a 0%, #1f242b 100%);
}

/* Next Expected Key Glow (Green Highlight matching image) */
.kb-key.kb-target {
    background: linear-gradient(180deg, #6ee755 0%, #34b321 100%) !important;
    color: #0c3305 !important;
    border-color: #1a630e !important;
    box-shadow: 0 4px 0 #114209, 0 0 16px rgba(78, 222, 57, 0.9) !important;
    transform: translateY(-2px);
    animation: targetKeyPulse 0.8s infinite alternate ease-in-out;
    z-index: 2;
}

.kb-key.kb-target .key-sub {
    color: #0c3305 !important;
    font-weight: 700;
}

@keyframes targetKeyPulse {
    0% {
        box-shadow: 0 4px 0 #114209, 0 0 10px rgba(78, 222, 57, 0.6);
    }
    100% {
        box-shadow: 0 4px 0 #114209, 0 0 22px rgba(78, 222, 57, 1);
        transform: translateY(-3px);
    }
}

/* Floating Hand/Finger Indicator above target key */
.kb-key.kb-target::before {
    content: '👇';
    position: absolute;
    top: -26px;
    font-size: 20px;
    animation: targetFingerBounce 0.5s infinite alternate ease-in-out;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

@keyframes targetFingerBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

/* Shift Key Required Indicator (Amber/Orange Glow) */
.kb-key.kb-shift-target {
    background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%) !important;
    color: #381c03 !important;
    border-color: #78350f !important;
    box-shadow: 0 4px 0 #451a03, 0 0 14px rgba(251, 191, 36, 0.8) !important;
    animation: targetKeyPulse 0.8s infinite alternate ease-in-out;
    z-index: 2;
}

/* Error Shake on Key */
.kb-key.kb-error {
    background: linear-gradient(180deg, #f87171 0%, #dc2626 100%) !important;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.9) !important;
}

@media (max-height: 760px) {
    .keyboard-section {
        padding: 6px 8px;
        margin-top: 4px;
    }
    .virtual-keyboard {
        gap: 3px;
    }
    .kb-row {
        gap: 3px;
    }
    .kb-key {
        height: 35px;
        font-size: 12px;
    }
    .kb-key .key-sub {
        font-size: 9px;
    }
    .hand-guide {
        width: 44px;
        height: 52px;
    }
}
