/**
 * Flashcards Activity Styles
 * MFL-style playful design with 3D flip animation
 */

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

/* ===== Phonetics ===== */
.card-phonetic {
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.85;
    margin-top: 0.25rem;
    font-style: italic;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .card-phonetic {
        font-size: 1.25rem;
    }
}

@media (min-width: 992px) {
    .card-phonetic {
        font-size: 1.4rem;
    }
}

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

/* ===== Flashcard Wrapper ===== */
.flashcard-wrapper {
    padding: 0.5rem 0.5rem;
}

/* ===== Flashcard Container ===== */
.flashcard-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 240px;
    perspective: 1200px;
}

/* ===== The Flashcard ===== */
.flashcard {
    width: 300px;
    height: 200px;
    cursor: pointer;
    position: relative;
    border-radius: var(--radius-large);
    outline: none;
}

.flashcard:focus-visible {
    box-shadow: 0 0 0 4px rgba(142, 36, 170, 0.4);
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

/* ===== Card Faces ===== */
.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius-large);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.25rem;
    box-shadow: 0 6px 0 rgba(0,0,0,0.12), 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.3);
}

.flashcard-front {
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    color: white;
}

.flashcard-back {
    background: linear-gradient(145deg, var(--primary-purple) 0%, var(--primary-pink) 100%);
    color: white;
    transform: rotateY(180deg);
}

/* ===== Card Content ===== */
.card-content {
    font-family: 'Baloo 2', cursive;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    word-wrap: break-word;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
}

.card-content img {
    max-width: 120px;
    max-height: 90px;
    border-radius: var(--radius-medium);
    object-fit: contain;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
    border: 2px solid rgba(255,255,255,0.3);
}

.card-content .card-text {
    margin-top: 0.5rem;
}

/* ===== Audio Buttons on Card ===== */
.flashcard .audio-btn {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    opacity: 0.9;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius-round);
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.flashcard .audio-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}

.flashcard .audio-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

.flashcard .audio-btn.playing {
    animation: audioPlaying 0.5s ease-in-out infinite;
}

/* ===== Flip Hint ===== */
.flashcard::after {
    content: '';
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s;
}

.flashcard:not(.flipped):hover::after {
    content: 'Click to flip';
    opacity: 1;
}

/* ===== Navigation ===== */
.navigation-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.nav-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-button), 0 4px 12px rgba(91, 155, 213, 0.2);
}

.nav-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: var(--shadow-button-hover), 0 8px 20px rgba(91, 155, 213, 0.25);
}

.nav-btn:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #ccc;
    box-shadow: none;
}

.card-counter {
    font-family: 'Baloo 2', cursive;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary-purple);
    min-width: 110px;
    background: var(--bg-section);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-round);
    box-shadow: var(--shadow-soft);
}

/* ===== Mark Known Button ===== */
#markKnownBtn {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
}

#markKnownBtn.marked {
    background: #9e9e9e;
    pointer-events: none;
    opacity: 0.7;
}

/* ===== Swipe Hint ===== */
.swipe-hint {
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

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

/* Tablets */
@media (min-width: 768px) {
    .flashcard {
        width: 380px;
        height: 250px;
    }

    .card-content {
        font-size: 2rem;
    }

    .card-content img {
        max-width: 160px;
        max-height: 120px;
    }

    .flashcard-container {
        min-height: 280px;
    }

    .nav-btn {
        width: 60px;
        height: 60px;
        font-size: 1.3rem;
    }
}

/* Desktops */
@media (min-width: 992px) {
    .flashcard {
        width: 450px;
        height: 280px;
    }

    .card-content {
        font-size: 2.2rem;
    }

    .card-content img {
        max-width: 180px;
        max-height: 140px;
    }

    .flashcard-container {
        min-height: 320px;
    }

    .nav-btn {
        width: 65px;
        height: 65px;
        font-size: 1.4rem;
    }

    .card-counter {
        font-size: 1.6rem;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .flashcard {
        width: 500px;
        height: 320px;
    }

    .card-content {
        font-size: 2.5rem;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .flashcard {
        width: 260px;
        height: 180px;
    }

    .card-content {
        font-size: 1.4rem;
    }

    .card-content img {
        max-width: 90px;
        max-height: 70px;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 1rem;
    }

    .nav-btn {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }

    .card-counter {
        font-size: 1.2rem;
        padding: 0.3rem 0.6rem;
    }
}

/* ===== Fullscreen Mode ===== */
:fullscreen .flashcard-container {
    min-height: 45vh;
}

:fullscreen .flashcard {
    width: 50vw;
    max-width: 550px;
    height: 38vh;
    max-height: 350px;
}

/* ===== Card Animations ===== */
.flashcard.card-enter {
    animation: cardEnter 0.35s ease-out;
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.flashcard.card-exit {
    animation: cardExit 0.3s ease-out;
}

@keyframes cardExit {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-40px) scale(0.95);
    }
}

/* ===== Correct/Mastered State ===== */
.flashcard.mastered .flashcard-front,
.flashcard.mastered .flashcard-back {
    background: var(--correct-green);
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    .flashcard-inner {
        transition: none;
    }

    .flashcard.flipped .flashcard-inner {
        transform: none;
    }

    .flashcard.flipped .flashcard-front {
        display: none;
    }

    .flashcard.flipped .flashcard-back {
        transform: none;
    }

    .nav-btn,
    #markKnownBtn,
    .audio-btn {
        transition: none;
    }

    @keyframes cardEnter {
        from, to { opacity: 1; transform: none; }
    }

    @keyframes cardExit {
        from, to { opacity: 1; transform: none; }
    }

    @keyframes fadeInOut {
        from, to { opacity: 0.7; }
    }
}

/* ===== Multilingual Mode ===== */

/* Hide standard flashcard in multilingual mode */
.activity-container.multilingual-mode .flashcard-container,
.activity-container.multilingual-mode .swipe-hint,
.activity-container.multilingual-mode #markKnownBtn {
    display: none;
}

/* Multilingual Card Container */
.multilingual-card {
    background: var(--bg-section);
    border-radius: var(--radius-large);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
    animation: cardEnter 0.35s ease-out;
}

/* Concept Header */
.concept-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
}

.concept-text {
    font-family: 'Baloo 2', cursive;
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
}

.concept-image {
    max-width: 120px;
    max-height: 100px;
    border-radius: var(--radius-medium);
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.concept-subtitle {
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Translations Grid */
.translations-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 576px) {
    .translations-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 992px) {
    .translations-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Language Tile */
.language-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.75rem;
    background: linear-gradient(145deg, var(--primary-blue) 0%, var(--primary-teal) 100%);
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 6px 16px rgba(91, 155, 213, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
}

.language-tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12), 0 10px 24px rgba(91, 155, 213, 0.3);
}

.language-tile:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12), 0 4px 12px rgba(91, 155, 213, 0.2);
}

/* Played state - green gradient */
.language-tile.played {
    background: linear-gradient(145deg, var(--correct-green) 0%, #66bb6a 100%);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12), 0 6px 16px rgba(76, 175, 80, 0.2);
}

.language-tile.played:hover {
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12), 0 10px 24px rgba(76, 175, 80, 0.3);
}

/* Playing animation */
.language-tile.playing {
    animation: tilePulse 0.5s ease-in-out infinite;
}

@keyframes tilePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* Flag in tile */
.tile-flag {
    width: 48px;
    height: 36px;
    border-radius: 4px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-bottom: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Tile text */
.tile-text {
    font-family: 'Baloo 2', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    text-align: center;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
    word-break: break-word;
    line-height: 1.2;
}

/* Tile phonetic */
.tile-phonetic {
    font-family: 'Nunito', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    font-style: italic;
    text-align: center;
    margin-top: 0.25rem;
}

/* Audio icon indicator */
.tile-audio-icon {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.language-tile:hover .tile-audio-icon {
    opacity: 1;
}

.language-tile.played .tile-audio-icon {
    opacity: 1;
    color: rgba(255, 255, 255, 0.9);
}

.language-tile.played .tile-audio-icon::before {
    content: '\f00c'; /* checkmark */
}

/* Progress indicator for multilingual */
.multilingual-progress {
    text-align: center;
    margin-top: 1rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.multilingual-progress strong {
    color: var(--primary-purple);
}

/* Responsive adjustments */
@media (min-width: 768px) {
    .multilingual-card {
        padding: 2rem;
    }

    .concept-text {
        font-size: 2.5rem;
    }

    .concept-image {
        max-width: 150px;
        max-height: 120px;
    }

    .tile-flag {
        width: 56px;
        height: 42px;
    }

    .tile-text {
        font-size: 1.2rem;
    }

    .tile-phonetic {
        font-size: 0.85rem;
    }
}

@media (min-width: 992px) {
    .multilingual-card {
        max-width: 700px;
    }

    .concept-text {
        font-size: 2.75rem;
    }

    .tile-text {
        font-size: 1.3rem;
    }
}

/* Fullscreen adjustments for multilingual */
:fullscreen .multilingual-card {
    max-width: 800px;
}

:fullscreen .translations-grid {
    gap: 1.25rem;
}

:fullscreen .language-tile {
    padding: 1.25rem 1rem;
}

:fullscreen .tile-flag {
    width: 64px;
    height: 48px;
}

:fullscreen .tile-text {
    font-size: 1.4rem;
}
