/* Flashcard Container - Scene */
.flashcard-scene {
    perspective: 1000px;
    margin: 10px;
    width: 300px;
    height: 200px;
    position: relative;
    display: inline-block;
    grid-area: 1 / 1;
    touch-action: pan-y pinch-zoom;
}

/* Cards Container */
.deck-content {
    display: grid;
    place-items: center;
    width: 100%;
}

/* Deck Container */
.flashcard-deck {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
    overflow: hidden;
}

/* Hide all scenes in a deck by default except active */
.flashcard-deck .flashcard-scene {
    display: none;
    margin: 0;
}

.flashcard-deck .flashcard-scene.active {
    display: block;
}

/* Fullscreen Mode */
.flashcard-deck.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    z-index: 9999;
    max-width: none;
    margin: 0;
    border-radius: 0;
    justify-content: center;
}

.flashcard-deck.fullscreen .flashcard-scene {
    width: 90vw !important;
    height: 70vh !important;
    max-width: 600px;
    max-height: 500px;
    margin: auto;
}

/* Modal Mode */
.flashcard-deck.modal-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flashcard-deck.modal-mode .deck-content {
    background: transparent;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    position: relative;
}

.flashcard-deck.modal-mode .flashcard-scene {
    width: 80vw !important;
    height: 60vh !important;
    max-width: 500px;
}

/* Close Button (for fullscreen/modal) */
.deck-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 20px;
    display: none;
    z-index: 100;
    color: #333;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.deck-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.flashcard-deck.fullscreen .deck-close-btn,
.flashcard-deck.modal-mode .deck-close-btn {
    display: flex;
}

/* Controls */
.deck-controls {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    z-index: 10;
}

.deck-btn {
    background: white;
    border: 1px solid #ddd;
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 8px;
}

.deck-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    background: #f8f9fa;
}

.deck-btn:active {
    transform: translateY(0);
}

.deck-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* The Card itself */
.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    cursor: pointer;
}

/* Flip State */
.flashcard.is-flipped {
    transform: rotateY(180deg);
}

/* Common Face Styles */
.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    background: white;
    /* Default fallback */
    transition: background 0.3s ease;
}

/* Front Face */
.flashcard-front {
    z-index: 2;
    transform: rotateY(0deg);
}

/* Back Face */
.flashcard-back {
    transform: rotateY(180deg);
}

/* Color Themes based on Card Type */

/* Default */
.card-type-default .flashcard-front {
    background: white;
    border-top: 4px solid #0d6efd;
}

.card-type-default .flashcard-back {
    background: #f0f4f8;
    border-top: 4px solid #0d6efd;
}

/* Vocabulary */
.card-type-vocabulary .flashcard-front {
    background: #fffcf5;
    border-top: 4px solid #fd7e14;
}

.card-type-vocabulary .flashcard-back {
    background: #fff2e3;
    border-top: 4px solid #fd7e14;
}

.card-type-vocabulary .card-header {
    color: #fd7e14;
}

/* Sentence */
.card-type-sentence .flashcard-front {
    background: #f5f9ff;
    border-top: 4px solid #0dcaf0;
}

.card-type-sentence .flashcard-back {
    background: #e3f2fd;
    border-top: 4px solid #0dcaf0;
}

.card-type-sentence .card-header {
    color: #0dcaf0;
}

/* Grammar */
.card-type-grammar .flashcard-front {
    background: #fdf5ff;
    border-top: 4px solid #6f42c1;
}

.card-type-grammar .flashcard-back {
    background: #f5e3ff;
    border-top: 4px solid #6f42c1;
}

.card-type-grammar .card-header {
    color: #6f42c1;
}

/* Task */
.card-type-task .flashcard-front {
    background: #f5fff8;
    border-top: 4px solid #198754;
}

.card-type-task .flashcard-back {
    background: #e3f8ec;
    border-top: 4px solid #198754;
}

.card-type-task .card-header {
    color: #198754;
}

/* Header inside card */
.flashcard .card-header {
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    background: transparent;
}

/* Audio container */
.flashcard .card-audio {
    z-index: 10;
}

/* Slide Animations — horizontal only (translateX) */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.anim-next-in {
    animation: slideInRight 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.anim-next-out {
    animation: slideOutLeft 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.anim-prev-in {
    animation: slideInLeft 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.anim-prev-out {
    animation: slideOutRight 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Swipe Hints */
.swipe-hint {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    color: rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.swipe-hint-left {
    left: 20px;
}

.swipe-hint-right {
    right: 20px;
}

/* Mobile-specific */
@media (max-width: 576px) {
    .flashcard-deck.fullscreen .flashcard-scene {
        width: 95vw !important;
        height: 60vh !important;
    }

    .flashcard-deck.fullscreen .deck-controls {
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(255, 255, 255, 0.95);
        padding: 10px 20px;
        border-radius: 50px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .deck-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}