/**
 * Word Search Activity Styles
 * Find hidden vocabulary words in a letter grid
 */

/* ===== 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;
}

/* ===== 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: 380px;
    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.5rem;
}

/* ===== Grid Container ===== */
.grid-container {
    background: linear-gradient(180deg, #e3f2fd 0%, #fff 100%);
    border: 2px solid var(--primary-blue);
    border-radius: var(--radius-medium);
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ===== Word Search Grid ===== */
.word-search-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-size, 10), 1fr);
    gap: 2px;
    background: #ddd;
    padding: 2px;
    border-radius: var(--radius-small);
    user-select: none;
    touch-action: none;
}

/* ===== Grid Cells ===== */
.grid-cell {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-family: 'Baloo 2', cursive;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 2px;
}

.grid-cell:hover:not(.found) {
    background: #f0f7ff;
    transform: scale(1.05);
}

.grid-cell.selecting {
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(91, 155, 213, 0.4);
}

.grid-cell.found {
    background: linear-gradient(145deg, var(--correct-green) 0%, #6BC5C5 100%);
    color: #fff;
    cursor: default;
}

.grid-cell.invalid {
    background: var(--incorrect-red);
    color: #fff;
    animation: shake 0.3s ease-out;
}

/* ===== Word List Container ===== */
.word-list-container {
    background: linear-gradient(180deg, #f3e5f5 0%, #fff 100%);
    border: 2px solid var(--primary-purple);
    border-radius: var(--radius-medium);
    padding: 0.75rem;
    height: 100%;
    min-height: 300px;
}

.word-list-header {
    font-family: 'Baloo 2', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-purple);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.word-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: calc(100% - 50px);
    overflow-y: auto;
}

/* ===== Word Items ===== */
.word-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-section);
    border: 2px solid #ddd;
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
}

.word-item:hover:not(.found) {
    border-color: var(--primary-purple);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.word-item.found {
    background: var(--correct-bg);
    border-color: var(--correct-green);
}

.word-item.found .word-target {
    text-decoration: line-through;
    opacity: 0.7;
}

.word-target {
    font-family: 'Baloo 2', cursive;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.word-source {
    font-family: 'Nunito', sans-serif;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.word-audio-btn {
    margin-left: auto;
    background: linear-gradient(180deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 2px solid #ddd;
    color: var(--text-dark);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-round);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.word-audio-btn:hover {
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
    transform: translateY(-1px);
}

/* ===== Shake Animation ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px); }
    40%, 80% { transform: translateX(3px); }
}

/* ===== 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;
}

@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 and larger */
@media (min-width: 768px) {
    .grid-cell {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }

    .word-list-container {
        min-height: 400px;
    }

    .word-item {
        padding: 0.6rem 0.9rem;
    }

    .word-target {
        font-size: 1.05rem;
    }
}

/* Desktops */
@media (min-width: 992px) {
    .grid-cell {
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
    }

    .word-list-container {
        min-height: 450px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .game-area {
        flex-direction: column;
    }

    .grid-container {
        padding: 0.5rem;
    }

    .grid-cell {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .word-list-container {
        min-height: 200px;
        margin-top: 0.5rem;
    }

    .word-item {
        padding: 0.4rem 0.6rem;
    }

    .word-target {
        font-size: 0.95rem;
    }

    .word-source {
        font-size: 0.8rem;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .grid-cell {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }

    .word-list-header {
        font-size: 1rem;
    }

    .word-target {
        font-size: 0.9rem;
    }
}

/* ===== Fullscreen Mode ===== */
:fullscreen .grid-container {
    min-height: 60vh;
}

:fullscreen .grid-cell {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
}

:fullscreen .word-list-container {
    min-height: 60vh;
}

/* ===== Accessibility ===== */
.grid-cell:focus-visible {
    outline: 3px solid var(--primary-purple);
    outline-offset: 2px;
}

.word-item:focus-visible {
    outline: 3px solid var(--primary-purple);
    outline-offset: 2px;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .grid-cell,
    .word-item {
        transition: none;
    }

    @keyframes shake {
        0%, 100% { transform: none; }
    }

    @keyframes trophyBounce {
        0%, 100% { transform: none; }
    }
}

/* ===== Found Word Animation ===== */
.grid-cell.just-found {
    animation: cellFound 0.5s ease-out;
}

@keyframes cellFound {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ===== Selection Line Indicator ===== */
.grid-cell.selecting::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}
