/**
 * Matching Pairs Activity Styles
 * Click-based matching game (MFL lesson style)
 */

/* ===== Header Layout ===== */
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 200px;
}

/* ===== Language Flag ===== */
.language-flag {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    background: var(--bg-cream);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    flex-shrink: 0;
    overflow: hidden;
}

.language-flag-img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* ===== Header Score ===== */
.header-score {
    margin-right: 0;
}

/* ===== Phonetics ===== */
.item-phonetic {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 0.85em;
    font-weight: 600;
    opacity: 0.8;
    font-style: italic;
    margin-top: 0.15rem;
}

.source-item .item-phonetic {
    color: rgba(255, 255, 255, 0.9);
}

.target-item .item-phonetic {
    color: var(--text-muted);
}

/* ===== Start Overlay ===== */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(250, 251, 252, 0.98) 0%, rgba(245, 247, 250, 0.98) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
}

.start-overlay.hidden {
    display: none;
}

.start-content {
    text-align: center;
    padding: 1.25rem 1.5rem;
    background: var(--bg-section);
    border-radius: var(--radius-large);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 340px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.start-icon {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
}

.start-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.start-text {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.start-btn {
    font-size: 1rem;
    padding: 0.75rem 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Game Area ===== */
.game-area {
    margin-top: 0.25rem;
}

/* ===== Source and Target Zones ===== */
.takezone,
.dropzone-area {
    min-height: 200px;
    padding: 0.5rem;
}

.takezone {
    background: linear-gradient(180deg, #e3f2fd 0%, #fff 100%);
    border-color: var(--primary-blue);
}

.dropzone-area {
    background: linear-gradient(180deg, #f3e5f5 0%, #fff 100%);
    border-color: var(--primary-purple);
}

/* ===== Match Items (Clickable) ===== */
.match-item {
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Source Items ===== */
.source-item {
    width: 100%;
    max-width: 300px;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-medium);
    box-shadow: var(--shadow-button), 0 4px 12px rgba(91, 155, 213, 0.15);
    text-align: center;
    font-family: 'Baloo 2', cursive;
    font-size: 1.1em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.source-item:hover:not(.matched) {
    box-shadow: var(--shadow-button-hover), 0 8px 20px rgba(91, 155, 213, 0.2);
    transform: translateY(-3px);
}

.source-item.selected {
    box-shadow: 0 0 0 3px var(--primary-purple), var(--shadow-button), 0 6px 16px rgba(91, 155, 213, 0.2);
    transform: translateY(-2px) scale(1.02);
    background: linear-gradient(145deg, var(--primary-purple) 0%, var(--primary-pink) 100%);
}

.source-item.matched {
    background: linear-gradient(145deg, var(--correct-green) 0%, #6BC5C5 100%);
    cursor: default;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 2px 0 rgba(0,0,0,0.08);
}

.source-item.wrong {
    background: var(--incorrect-red);
    animation: shake 0.5s ease-out;
}

.source-item img {
    max-width: 60px;
    max-height: 60px;
    border-radius: var(--radius-small);
    object-fit: contain;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    border: 2px solid rgba(255,255,255,0.3);
}

.source-item .item-audio-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-round);
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.source-item .item-audio-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

/* ===== Target Items ===== */
.target-item {
    width: 100%;
    max-width: 300px;
    padding: 0.5rem 0.75rem;
    min-height: 50px;
    background: var(--bg-section);
    border: solid 3px #bbb;
    border-radius: var(--radius-medium);
    text-align: center;
    font-family: 'Baloo 2', cursive;
    font-size: 1.05em;
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    box-shadow: var(--shadow-soft);
}

.target-item:hover:not(.matched) {
    border-color: var(--primary-purple);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.target-item.selected {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 4px var(--primary-purple), 0 6px 20px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px) scale(1.02);
    background: #f3e5f5;
}

.target-item.matched {
    background-color: var(--correct-bg);
    border: solid 3px var(--correct-green);
    cursor: default;
    pointer-events: none;
}

.target-item.wrong {
    background-color: var(--incorrect-bg);
    border: solid 3px var(--incorrect-red);
    animation: shake 0.5s ease-out;
}

.target-item img {
    max-width: 75px;
    max-height: 75px;
    border-radius: var(--radius-small);
    object-fit: contain;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

.target-item .target-label {
    color: var(--primary-purple);
    font-weight: 700;
}

.target-item.matched .target-label {
    color: var(--correct-green);
}

.target-item .target-audio-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: linear-gradient(180deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 2px solid #ddd;
    color: var(--text-dark);
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-round);
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.target-item .target-audio-btn:hover {
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
    transform: translateY(-1px);
}

/* ===== Color Swatch (for hex colors) ===== */
.color-swatch {
    width: 70px;
    height: 70px;
    border-radius: var(--radius-medium);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.source-item .color-swatch {
    width: 50px;
    height: 50px;
}

.target-item .color-swatch {
    width: 70px;
    height: 70px;
}

/* ===== Shake Animation ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ===== Swipe Hint ===== */
.swipe-hint {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-section);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-round);
    display: inline-block;
    box-shadow: var(--shadow-soft);
}

/* ===== Completion Icon ===== */
.completion-icon {
    font-size: 5rem;
}

.completion-icon.success {
    color: var(--warning-yellow);
    animation: trophyBounce 0.7s ease-out;
}

.completion-icon.timeout {
    color: var(--text-muted);
}

@keyframes trophyBounce {
    0% { transform: scale(0) rotate(-20deg); }
    50% { transform: scale(1.2) rotate(10deg); }
    70% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0); }
}

/* ===== Responsive Styles ===== */

/* Tablets */
@media (min-width: 768px) {
    .takezone,
    .dropzone-area {
        min-height: 280px;
        padding: 0.75rem;
    }

    .source-item,
    .target-item {
        max-width: 320px;
        font-size: 1.15em;
        padding: 0.6rem 0.9rem;
    }

    .target-item {
        min-height: 60px;
    }

    .source-item img {
        max-width: 70px;
        max-height: 70px;
    }

    .target-item img {
        max-width: 90px;
        max-height: 90px;
    }

    .color-swatch {
        width: 80px;
        height: 80px;
    }

    .source-item .color-swatch {
        width: 60px;
        height: 60px;
    }

    .target-item .color-swatch {
        width: 80px;
        height: 80px;
    }
}

/* Desktops */
@media (min-width: 992px) {
    .source-item,
    .target-item {
        max-width: 340px;
        font-size: 1.2em;
    }

    .target-item {
        min-height: 65px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .game-area {
        flex-direction: column;
    }

    .takezone,
    .dropzone-area {
        min-height: 180px;
        padding: 0.5rem;
    }

    .source-item,
    .target-item {
        font-size: 1em;
        padding: 0.5rem 0.75rem;
    }

    .source-item img,
    .target-item img {
        max-width: 45px;
        max-height: 45px;
    }

    .color-swatch {
        width: 50px;
        height: 50px;
    }

    .source-item .color-swatch {
        width: 40px;
        height: 40px;
    }

    .target-item .color-swatch {
        width: 50px;
        height: 50px;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .source-item,
    .target-item {
        font-size: 0.95em;
        padding: 0.4rem 0.6rem;
    }

    .source-item img,
    .target-item img {
        max-width: 35px;
        max-height: 35px;
    }

    .color-swatch {
        width: 40px;
        height: 40px;
    }

    .source-item .color-swatch {
        width: 35px;
        height: 35px;
    }

    .target-item .color-swatch {
        width: 40px;
        height: 40px;
    }

    .takezone,
    .dropzone-area {
        min-height: 150px;
        padding: 0.4rem;
        gap: 8px;
    }
}

/* ===== Fullscreen Mode ===== */
:fullscreen .takezone,
:fullscreen .dropzone-area {
    min-height: 50vh;
}

:fullscreen .source-item,
:fullscreen .target-item {
    max-width: 360px;
    font-size: 1.25em;
}

:fullscreen .color-swatch {
    width: 90px;
    height: 90px;
}

/* ===== Accessibility ===== */
.source-item:focus-visible,
.target-item:focus-visible {
    outline: 3px solid var(--primary-purple);
    outline-offset: 3px;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .source-item,
    .target-item,
    .match-item {
        transition: none;
    }

    @keyframes shake {
        0%, 100% { transform: none; }
    }

    @keyframes trophyBounce {
        0%, 100% { transform: none; }
    }
}

/* ===== Match celebration ===== */
.match-item.just-matched {
    animation: matchCelebrate 0.5s ease-out;
}

@keyframes matchCelebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
