/**
 * Gender Sorting Activity Styles
 * Drag-and-drop game for sorting nouns by grammatical gender
 */

/* ===== 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: 340px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.start-icon {
    font-size: 2.5rem;
    color: var(--primary-purple);
    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 Zone (Draggable Words) ===== */
.takezone {
    min-height: 200px;
    padding: 0.75rem;
    background: linear-gradient(180deg, #e3f2fd 0%, #fff 100%);
    border: dashed 4px var(--primary-blue);
    border-radius: var(--radius-large);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-soft);
}

/* ===== Draggable Word Items ===== */
.word-item {
    width: 100%;
    max-width: 280px;
    padding: 0.6rem 0.9rem;
    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);
    font-family: 'Baloo 2', cursive;
    font-size: 1.1em;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

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

.word-item.dragging {
    opacity: 0.8;
    cursor: grabbing;
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 12px 35px rgba(0,0,0,0.25);
    z-index: 1000;
}

.word-item.correct {
    background: linear-gradient(145deg, var(--correct-green) 0%, #6BC5C5 100%);
    cursor: default;
}

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

.word-item.sorted-out {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

/* ===== Word Item Image ===== */
.word-image {
    width: 45px;
    height: 45px;
    object-fit: contain;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.9);
    padding: 3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.word-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    text-align: left;
}

.word-text {
    font-size: 1.05em;
}

.word-phonetic {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 0.8em;
    font-weight: 600;
    opacity: 0.85;
    font-style: italic;
    margin-top: 0.1rem;
    color: rgba(255, 255, 255, 0.9);
}

.word-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;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
    flex-shrink: 0;
}

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

/* ===== Touch Drag Clone ===== */
.touch-drag-clone {
    opacity: 0.9;
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(0,0,0,0.3);
}

/* ===== Gender Buckets Container ===== */
.gender-buckets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.gender-bucket-wrapper {
    padding: 0;
}

/* ===== Gender Bucket Drop Zones ===== */
.gender-bucket {
    --bucket-color: #5B9BD5;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bucket-color) 15%, white) 0%, #fff 100%);
    border: dashed 4px var(--bucket-color);
    border-radius: var(--radius-large);
    padding: 0.75rem;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s;
}

.gender-bucket.drop-hint {
    border-style: dashed;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bucket-color) 20%, white) 0%, #fff 100%);
}

.gender-bucket.drop-active {
    border-style: solid;
    border-width: 4px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bucket-color) 25%, white) 0%, #fff 100%);
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* ===== Bucket Header ===== */
.bucket-header {
    text-align: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 2px solid color-mix(in srgb, var(--bucket-color) 30%, white);
}

.bucket-label {
    display: block;
    font-family: 'Baloo 2', cursive;
    font-size: 1.15em;
    font-weight: 700;
    color: var(--bucket-color);
}

.bucket-article {
    display: block;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* ===== Bucket Drop Area ===== */
.bucket-drop-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0.5rem;
    min-height: 150px;
    border-radius: var(--radius-medium);
    background: rgba(255, 255, 255, 0.5);
}

/* ===== Sorted Items in Bucket ===== */
.sorted-item {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(145deg, var(--correct-green) 0%, #6BC5C5 100%);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-medium);
    text-align: center;
    font-family: 'Baloo 2', cursive;
    font-size: 1em;
    font-weight: 600;
    box-shadow: 0 2px 0 rgba(0,0,0,0.08), var(--shadow-soft);
    animation: dropIn 0.3s ease-out;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sorted-item-image {
    width: 30px;
    height: 30px;
    object-fit: contain;
    border-radius: var(--radius-small);
    background: rgba(255, 255, 255, 0.9);
    padding: 2px;
}

@keyframes dropIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== Keyboard Gender Picker ===== */
.keyboard-gender-picker {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-section);
    border-radius: var(--radius-large);
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    min-width: 280px;
    text-align: center;
}

.picker-title {
    font-family: 'Baloo 2', cursive;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.picker-option {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(180deg, #f5f5f5 0%, #e8e8e8 100%);
    border: 2px solid var(--bucket-color);
    border-radius: var(--radius-medium);
    font-family: 'Nunito', sans-serif;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.picker-option:hover,
.picker-option:focus {
    background: linear-gradient(180deg, #fff 0%, #f0f0f0 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.picker-close {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    font-family: 'Nunito', sans-serif;
    font-size: 0.9em;
    color: var(--text-muted);
    cursor: pointer;
}

.picker-close:hover {
    color: var(--text-dark);
}

/* ===== 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;
}

@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 {
        min-height: 280px;
    }

    .word-item {
        max-width: 300px;
        font-size: 1.15em;
    }

    .word-image {
        width: 50px;
        height: 50px;
    }

    .gender-bucket {
        min-height: 320px;
    }

    .bucket-label {
        font-size: 1.25em;
    }

    .sorted-item {
        font-size: 1.05em;
    }

    .sorted-item-image {
        width: 35px;
        height: 35px;
    }
}

/* Desktops */
@media (min-width: 992px) {
    .word-item {
        max-width: 320px;
        font-size: 1.2em;
    }

    .word-image {
        width: 55px;
        height: 55px;
    }

    .gender-bucket {
        min-height: 380px;
    }

    .bucket-label {
        font-size: 1.3em;
    }

    .sorted-item-image {
        width: 40px;
        height: 40px;
    }
}

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

    .takezone {
        min-height: 150px;
        margin-bottom: 0.5rem;
    }

    .word-item {
        font-size: 1em;
        padding: 0.5rem 0.75rem;
    }

    .word-image {
        width: 38px;
        height: 38px;
    }

    .gender-buckets {
        gap: 0.5rem;
    }

    .gender-bucket-wrapper {
        flex: 1 1 calc(50% - 0.25rem);
        max-width: calc(50% - 0.25rem);
    }

    .gender-bucket {
        min-height: 180px;
        padding: 0.5rem;
    }

    .bucket-label {
        font-size: 1em;
    }

    .bucket-article {
        font-size: 0.8em;
    }

    .sorted-item {
        font-size: 0.9em;
        padding: 0.4rem 0.6rem;
    }

    .sorted-item-image {
        width: 24px;
        height: 24px;
    }
}

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

    .word-image {
        width: 32px;
        height: 32px;
    }

    .gender-bucket {
        min-height: 150px;
        padding: 0.4rem;
    }

    .bucket-label {
        font-size: 0.9em;
    }

    .sorted-item {
        font-size: 0.85em;
    }

    .sorted-item-image {
        width: 20px;
        height: 20px;
    }

    .takezone {
        min-height: 120px;
        padding: 0.5rem;
        gap: 8px;
    }
}

/* ===== Fullscreen Mode ===== */
:fullscreen .takezone {
    min-height: 40vh;
}

:fullscreen .gender-bucket {
    min-height: 50vh;
}

:fullscreen .word-item {
    max-width: 340px;
    font-size: 1.25em;
}

:fullscreen .word-image {
    width: 60px;
    height: 60px;
}

:fullscreen .sorted-item {
    font-size: 1.1em;
}

:fullscreen .sorted-item-image {
    width: 45px;
    height: 45px;
}

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

.gender-bucket:focus-within {
    outline: 2px solid var(--bucket-color);
    outline-offset: 2px;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .word-item,
    .gender-bucket,
    .sorted-item {
        transition: none;
    }

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

    @keyframes dropIn {
        0%, 100% { transform: none; opacity: 1; }
    }

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