/* ================================================================
   Word Practice — Styles
   ================================================================ */

.wp-wrapper {
    min-height: 100vh;
    background: var(--surface-dark, #0f1923);
    color: #fff;
    display: flex;
    flex-direction: column;
}

/* ── Grid View ── */
.wp-grid-view {
    flex: 1;
    padding: 16px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.wp-grid-header {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.wp-grid-controls {
    display: flex;
    gap: 10px;
}

.wp-control-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #b0bec5;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.wp-control-btn:hover {
    background: rgba(29,154,138,0.15);
    border-color: rgba(29,154,138,0.3);
    color: #5ef5d8;
}

.wp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.wp-grid-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.wp-grid-card:hover {
    background: rgba(29,154,138,0.12);
    border-color: rgba(29,154,138,0.35);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(29,154,138,0.15);
}

.wp-grid-card:active {
    transform: translateY(0);
}

.wp-grid-card--completed {
    border-color: rgba(76,175,80,0.4);
}

.wp-grid-card--completed::after {
    content: '\2713';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.75rem;
    color: #4CAF50;
    background: rgba(76,175,80,0.15);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-grid-card__emoji {
    font-size: 2.4rem;
    margin-bottom: 8px;
    display: block;
}

.wp-grid-card__img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 8px;
}

.wp-grid-card__text {
    font-size: 0.92rem;
    font-weight: 600;
    color: #e0e8ef;
    transition: opacity 0.3s;
}

.wp-grid-card__text--hidden {
    opacity: 0;
}

.wp-grid-loading {
    text-align: center;
    padding: 60px 0;
    color: #7c8a96;
}

/* ── Typing View ── */
.wp-typing-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px 16px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.wp-back-grid {
    align-self: flex-start;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    color: #b0bec5;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.wp-back-grid:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Word display */
.wp-word-display {
    text-align: center;
    margin-bottom: 16px;
}

.wp-word-image {
    margin-bottom: 10px;
}

.wp-word-emoji {
    font-size: 4rem;
    display: block;
}

.wp-word-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.wp-word-text {
    font-size: 1.6rem;
    font-weight: 700;
    color: #e0e8ef;
    margin: 0;
    transition: opacity 0.3s;
}

.wp-word-text--hidden {
    opacity: 0;
    height: 0;
    overflow: hidden;
    margin: 0;
}

/* Letter slots */
.wp-letter-slots {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 16px 0;
    min-height: 56px;
}

.wp-slot {
    width: 44px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    border: 2px solid rgba(255,255,255,0.15);
    color: #5ef5d8;
    transition: all 0.2s;
}

.wp-slot--empty {
    color: rgba(255,255,255,0.2);
    border-style: dashed;
}

.wp-slot--active {
    border-color: #5ef5d8;
    box-shadow: 0 0 12px rgba(94,245,216,0.2);
    animation: slotPulse 1.5s ease-in-out infinite;
}

.wp-slot--filled {
    animation: slotPop 0.3s ease-out;
    background: rgba(29,154,138,0.15);
    border-color: rgba(29,154,138,0.4);
}

@keyframes slotPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(94,245,216,0.15); }
    50% { box-shadow: 0 0 16px rgba(94,245,216,0.35); }
}

@keyframes slotPop {
    0% { transform: scale(0.7); opacity: 0.5; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

/* Actions */
.wp-actions-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 8px 0;
}

.wp-replay-btn {
    background: rgba(29,154,138,0.15);
    border: 1px solid rgba(29,154,138,0.3);
    color: #5ef5d8;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wp-replay-btn:hover {
    background: rgba(29,154,138,0.25);
}

.wp-encouragement {
    text-align: center;
    font-size: 0.92rem;
    color: #5ef5d8;
    min-height: 1.4em;
    margin: 6px 0;
    font-weight: 500;
}

.wp-feedback {
    text-align: center;
    font-size: 0.85rem;
    color: #ff9800;
    min-height: 1.2em;
    margin: 4px 0;
    transition: opacity 0.3s;
}

/* ── On-Screen Keyboard ── */
.wp-keyboard {
    margin: 12px 0 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
}

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

.wp-key {
    --key-size: 38px;
    width: var(--key-size);
    height: var(--key-size);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: #e0e8ef;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-key:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
}

.wp-key:active {
    transform: scale(0.92);
}

.wp-key--highlight {
    background: rgba(29,154,138,0.35) !important;
    border-color: #1d9a8a !important;
    color: #fff !important;
    box-shadow: 0 0 12px rgba(29,154,138,0.4);
    animation: keyGlow 1.2s ease-in-out infinite;
}

.wp-key--highlight-row {
    background: rgba(29,154,138,0.12) !important;
    border-color: rgba(29,154,138,0.25) !important;
}

.wp-key--correct {
    background: rgba(76,175,80,0.35) !important;
    border-color: #4CAF50 !important;
    color: #fff !important;
    animation: keyFlashCorrect 0.4s ease-out;
}

.wp-key--wrong {
    background: rgba(255,152,0,0.2) !important;
    border-color: rgba(255,152,0,0.4) !important;
    animation: keyShake 0.35s ease-out;
}

@keyframes keyGlow {
    0%, 100% { box-shadow: 0 0 8px rgba(29,154,138,0.3); }
    50% { box-shadow: 0 0 18px rgba(29,154,138,0.55); }
}

@keyframes keyFlashCorrect {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

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

.wp-desktop-hint {
    text-align: center;
    font-size: 0.78rem;
    color: #5f6f7a;
    margin: 4px 0;
}

.wp-keyboard-toggle {
    display: none;
    margin: 8px auto;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    color: #7c8a96;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
}

.wp-keyboard-toggle:hover {
    color: #b0bec5;
    border-color: rgba(255,255,255,0.2);
}

/* Complete actions */
.wp-complete-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

.wp-btn {
    padding: 10px 22px;
    border-radius: 25px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.wp-btn--next {
    background: linear-gradient(135deg, #1d9a8a, #5ef5d8);
    color: #0f1923;
}

.wp-btn--next:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(29,154,138,0.3);
}

.wp-btn--grid {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #b0bec5;
}

.wp-btn--grid:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* ── Word complete celebration ── */
@keyframes celebrateBounce {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.wp-celebrate {
    animation: celebrateBounce 0.5s ease-out;
}

/* ── Interactive badge in module select ── */
.speech-module-badge--interactive {
    background: rgba(29,154,138,0.15);
    color: #5ef5d8;
    border: 1px solid rgba(29,154,138,0.3);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .wp-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .wp-grid-card {
        padding: 14px 8px;
    }

    .wp-grid-card__emoji {
        font-size: 1.8rem;
    }

    .wp-grid-card__text {
        font-size: 0.8rem;
    }

    .wp-word-emoji {
        font-size: 3rem;
    }

    .wp-word-text {
        font-size: 1.3rem;
    }

    .wp-slot {
        width: 38px;
        height: 46px;
        font-size: 1.4rem;
    }

    .wp-key {
        --key-size: 34px;
        font-size: 0.88rem;
    }

    .wp-keyboard-toggle {
        display: none !important;
    }

    .wp-desktop-hint {
        display: none;
    }
}

@media (max-width: 480px) {
    .wp-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .wp-key {
        --key-size: 30px;
        font-size: 0.82rem;
        border-radius: 6px;
    }

    .wp-slot {
        width: 34px;
        height: 42px;
        font-size: 1.2rem;
    }
}

@media (min-width: 769px) {
    .wp-keyboard {
        display: none;
    }

    .wp-keyboard.wp-keyboard--visible {
        display: flex;
    }

    .wp-keyboard-toggle {
        display: block;
    }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .wp-slot--active {
        animation: none;
    }
    .wp-key--highlight {
        animation: none;
    }
    .wp-slot--filled {
        animation: none;
    }
}
