/* Flashcard App Styles */

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* Study screen specific styles */
.study-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
}

#root {
    width: 100%;
    min-width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
}

.watercolor-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    touch-action: manipulation;
}

.card-scene {
    width: min(340px, 85vw);
    height: min(480px, 65vh);
    margin: 0 auto;
    perspective: 2000px;
    -webkit-perspective: 2000px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

.card-animation-container {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    perspective: 1200px;
    -webkit-perspective: 1200px;
    isolation: isolate;
}

/* Stack cards */
.card-animation-container .card-3d {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
    transform-origin: center center;
}

/* Next card styling - hidden by default */
.card-animation-container .next-card {
    z-index: 1;
    pointer-events: none;
    transform: scale(0.92);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.3s ease-out;
    visibility: hidden;
}

/* Show next card only during swipe - fully visible with smooth scale */
.card-animation-container .next-card.show-during-swipe {
    opacity: 1;
    visibility: visible;
    transform: scale(0.98);
}

/* Current card styling */
.card-animation-container .current-card {
    z-index: 2;
    transform-origin: center;
    transition: none;
}

/* Only animate current card during flip */
.card-animation-container .current-card.flipped {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Only animate current card during swipe */
.card-animation-container .current-card.swipe-left,
.card-animation-container .current-card.swipe-right {
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.8s ease-out !important;
}

/* Ensure no transitions when becoming current card */
.card-animation-container .next-card.current-card {
    transform: none;
    opacity: 1;
    transition: none !important;
}

.card-3d {
    position: relative;
    width: 100%;
    height: 100%;
    cursor: pointer;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    will-change: transform, opacity;
}

.card-3d.flipped {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
}

/* Maintain smooth swipe animation when flipped */
.card-animation-container .current-card.flipped.swipe-left {
    transform: translate3d(-120vw, 40vh, 0) rotate(-60deg) scale(0.5) rotateY(180deg) !important;
    -webkit-transform: translate3d(-120vw, 40vh, 0) rotate(-60deg) scale(0.5) rotateY(180deg) !important;
}

.card-animation-container .current-card.flipped.swipe-right {
    transform: translate3d(120vw, 40vh, 0) rotate(60deg) scale(0.5) rotateY(180deg) !important;
    -webkit-transform: translate3d(120vw, 40vh, 0) rotate(60deg) scale(0.5) rotateY(180deg) !important;
}

/* Maintain smooth drag animation when flipped */
.card-animation-container .current-card.flipped[style*="transform"] {
    transform: translate3d(var(--drag-x, 0), calc(var(--drag-y, 0) * 0.15), 0) rotate(calc(var(--drag-rotate, 0) * 0.08deg)) rotateY(180deg) !important;
    -webkit-transform: translate3d(var(--drag-x, 0), calc(var(--drag-y, 0) * 0.15), 0) rotate(calc(var(--drag-rotate, 0) * 0.08deg)) rotateY(180deg) !important;
}

/* Preview animations during drag - no transition */
.card-animation-container .card-3d.swiping-left,
.card-animation-container .card-3d.swiping-right {
    transition: none !important;
}

/* Swipe out animations - only applied to current card */
.card-animation-container .current-card.swipe-left {
    transform: translate3d(-120vw, 40vh, 0) rotate(-60deg) scale(0.5) !important;
    opacity: 0 !important;
    pointer-events: none;
}

.card-animation-container .current-card.swipe-right {
    transform: translate3d(120vw, 40vh, 0) rotate(60deg) scale(0.5) !important;
    opacity: 0 !important;
    pointer-events: none;
}

/* Touch action for mobile */
.touch-action-manipulation {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure background elements don't move with card animations */
.mobile-center, .parallax-layer, .floating-elements {
    transform: none !important;
    will-change: auto !important;
}

.mobile-center > div {
    transform: none !important;
}

/* Prevent any transform propagation beyond card container */
.card-scene > *:not(.card-animation-container) {
    transform: none !important;
}

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
    touch-action: manipulation;
}

.card-front {
    z-index: 2;
    transform: rotateY(0deg);
    -webkit-transform: rotateY(0deg);
}

.card-back {
    z-index: 1;
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    position: absolute;
    top: 0;
    left: 0;
}

.card-content {
    position: relative;
    z-index: 2;
    height: 100%;
    padding: clamp(16px, 4vw, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.chinese-character {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 300;
    color: #1f2937;
    margin-bottom: 8px;
    line-height: 1;
}

.pinyin {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: #6b7280;
    font-weight: 400;
    margin-bottom: 16px;
}

.translation-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.emoji-display {
    font-size: clamp(2rem, 5vw, 2.8rem);
    margin-bottom: 8px;
}

.english-translation {
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.thai-translation {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: #6b7280;
    font-weight: 400;
}

.mobile-button {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    padding: 8px;
    backdrop-filter: blur(10px);
}

.mobile-button:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.floating-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: float 20s infinite linear;
}

.floating-shape:nth-child(1) { 
    width: 80px; 
    height: 80px; 
    top: 10%; 
    left: 10%; 
    animation-delay: 0s; 
    animation-duration: 25s; 
}

.floating-shape:nth-child(2) { 
    width: 120px; 
    height: 120px; 
    top: 20%; 
    right: 15%; 
    animation-delay: -5s; 
    animation-duration: 30s; 
}

.floating-shape:nth-child(3) { 
    width: 60px; 
    height: 60px; 
    bottom: 30%; 
    left: 20%; 
    animation-delay: -10s; 
    animation-duration: 20s; 
}

.floating-shape:nth-child(4) { 
    width: 100px; 
    height: 100px; 
    bottom: 20%; 
    right: 25%; 
    animation-delay: -15s; 
    animation-duration: 35s; 
}

.floating-shape:nth-child(5) { 
    width: 40px; 
    height: 40px; 
    top: 50%; 
    left: 5%; 
    animation-delay: -20s; 
    animation-duration: 15s; 
}

.floating-shape:nth-child(6) { 
    width: 90px; 
    height: 90px; 
    top: 70%; 
    right: 10%; 
    animation-delay: -8s; 
    animation-duration: 28s; 
}

@keyframes float {
    0% { 
        transform: translateY(0px) translateX(0px) rotate(0deg) scale(1); 
        opacity: 0.3; 
    }
    25% { 
        transform: translateY(-20px) translateX(10px) rotate(90deg) scale(1.1); 
        opacity: 0.5; 
    }
    50% { 
        transform: translateY(-40px) translateX(-5px) rotate(180deg) scale(0.9); 
        opacity: 0.3; 
    }
    75% { 
        transform: translateY(-20px) translateX(-15px) rotate(270deg) scale(1.05); 
        opacity: 0.4; 
    }
    100% { 
        transform: translateY(0px) translateX(0px) rotate(360deg) scale(1); 
        opacity: 0.3; 
    }
}

.animated-bg {
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #f5576c, #4facfe, #00f2fe);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.parallax-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 120%;
    height: 120%;
    pointer-events: none;
    z-index: -1;
}

.parallax-1 {
    background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3), transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3), transparent 50%);
    animation: parallaxMove1 30s ease-in-out infinite;
}

.parallax-2 {
    background: radial-gradient(circle at 60% 20%, rgba(120, 219, 255, 0.2), transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(255, 159, 119, 0.2), transparent 50%);
    animation: parallaxMove2 25s ease-in-out infinite reverse;
}

@keyframes parallaxMove1 {
    0%, 100% { transform: translateX(-10px) translateY(-5px) rotate(0deg); }
    50% { transform: translateX(10px) translateY(5px) rotate(1deg); }
}

@keyframes parallaxMove2 {
    0%, 100% { transform: translateX(5px) translateY(-10px) rotate(0deg); }
    50% { transform: translateX(-5px) translateY(10px) rotate(-1deg); }
}

.mobile-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    box-sizing: border-box;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Fixed positioning only for study mode */
.study-mode.mobile-center {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    touch-action: none;
}

@media (max-width: 480px) {
    .card-scene {
        width: min(300px, 90vw);
        height: min(400px, 55vh);
    }
    .mobile-center {
        padding: 12px;
    }
}
