/* ============================================================
   JYOTISH - ADVANCED ANIMATIONS & TRANSITIONS
   ============================================================ */

/* ==================== 1. PAGE TRANSITIONS ==================== */

/* Fade in animation for page load */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Page content animation */
.page-content {
    animation: fadeIn 0.5s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.animate-fade-up {
    animation: fadeInUp 0.5s ease-out forwards;
}

.animate-scale {
    animation: scaleIn 0.3s ease-out forwards;
}

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.45s; }

/* ==================== CARD ANIMATIONS ==================== */

/* Card flip animation */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
}

.card-flip:hover .card-flip-inner,
.card-flip.flipped .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    backface-visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* Card hover effects */
.card-hover {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
}

/* Card glow effect */
.card-glow {
    transition: box-shadow 0.3s ease;
}

.card-glow:hover {
    box-shadow: 0 0 30px rgba(255, 107, 0, 0.3);
}

/* ==================== LOADING SKELETONS ==================== */

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    width: 80%;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 60%; }
.skeleton-text.full { width: 100%; }

.skeleton-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    width: 100%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ==================== PROGRESS ANIMATIONS ==================== */

@keyframes progressFill {
    from { width: 0; }
}

.progress-animated .progress-fill {
    animation: progressFill 1s ease-out forwards;
}

/* Circular progress */
@keyframes rotate {
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

.circular-progress {
    animation: rotate 2s linear infinite;
}

.circular-progress circle {
    animation: dash 1.5s ease-in-out infinite;
}

/* ==================== PULSE & GLOW EFFECTS ==================== */

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

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 107, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 107, 0, 0.8); }
}

@keyframes breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

.pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

.breathe {
    animation: breathe 3s ease-in-out infinite;
}

/* Live indicator */
@keyframes livePulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

.live-indicator {
    position: relative;
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #4CAF50;
    border-radius: 50%;
}

.live-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #4CAF50;
    border-radius: 50%;
    animation: livePulse 2s ease-out infinite;
}

/* ==================== BUTTON ANIMATIONS ==================== */

.btn-animated {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-animated::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s;
}

.btn-animated:hover::after {
    width: 300px;
    height: 300px;
}

.btn-animated:active {
    transform: scale(0.95);
}

/* Ripple effect */
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* ==================== NOTIFICATION ANIMATIONS ==================== */

@keyframes slideInRight {
    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; }
}

.notification-enter {
    animation: slideInRight 0.3s ease-out forwards;
}

.notification-exit {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
}

.toast.success { border-left: 4px solid #4CAF50; }
.toast.warning { border-left: 4px solid #FF9800; }
.toast.error { border-left: 4px solid #F44336; }
.toast.info { border-left: 4px solid #2196F3; }

/* ==================== COUNTDOWN TIMER ==================== */

.countdown-container {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.countdown-item {
    text-align: center;
    min-width: 70px;
}

.countdown-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--maroon);
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.countdown-value.flip {
    animation: flipNumber 0.3s ease-out;
}

@keyframes flipNumber {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0deg); }
}

.countdown-label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

/* ==================== MODAL ANIMATIONS ==================== */

.modal-animated {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.modal-animated.active {
    opacity: 1;
    visibility: visible;
}

.modal-animated .modal-content {
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease-out;
}

.modal-animated.active .modal-content {
    transform: scale(1) translateY(0);
}

/* ==================== TAB ANIMATIONS ==================== */

.tab-content-animated {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.3s, transform 0.3s;
    display: none;
}

.tab-content-animated.active {
    opacity: 1;
    transform: translateX(0);
    display: block;
}

/* Tab indicator */
.tabs-animated {
    position: relative;
}

.tab-indicator {
    position: absolute;
    bottom: 0;
    height: 3px;
    background: var(--saffron);
    transition: left 0.3s ease, width 0.3s ease;
}

/* ==================== HOVER REVEALS ==================== */

.hover-reveal {
    position: relative;
    overflow: hidden;
}

.hover-reveal .reveal-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.hover-reveal:hover .reveal-content {
    transform: translateY(0);
}

/* ==================== FLOATING ELEMENTS ==================== */

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.float {
    animation: float 3s ease-in-out infinite;
}

.float-rotate {
    animation: floatRotate 4s ease-in-out infinite;
}

/* ==================== TYPEWRITER EFFECT ==================== */

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    50% { border-color: transparent; }
}

.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--maroon);
    white-space: nowrap;
    animation: typing 3s steps(30, end), blink 0.75s step-end infinite;
}

/* ==================== SCORE REVEAL ==================== */

@keyframes countUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.score-reveal {
    animation: countUp 0.5s ease-out forwards;
}

/* Score meter fill */
.score-meter {
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.score-meter-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1s ease-out;
}

.score-meter-fill.excellent { background: linear-gradient(90deg, #4CAF50, #8BC34A); }
.score-meter-fill.good { background: linear-gradient(90deg, #8BC34A, #CDDC39); }
.score-meter-fill.moderate { background: linear-gradient(90deg, #FFC107, #FF9800); }
.score-meter-fill.poor { background: linear-gradient(90deg, #FF9800, #F44336); }

/* ==================== VOICE WAVE ANIMATION ==================== */

@keyframes soundWave {
    0%, 100% { height: 5px; }
    50% { height: 20px; }
}

.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 30px;
}

.voice-wave span {
    width: 4px;
    background: var(--saffron);
    border-radius: 2px;
    animation: soundWave 0.5s ease-in-out infinite;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }

/* ==================== CONFETTI ==================== */

@keyframes confetti {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confetti 3s linear forwards;
    z-index: 9999;
}

/* ==================== DARK MODE TRANSITION ==================== */

body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #e0e0e0;
}

body.dark-mode .card,
body.dark-mode .account-card {
    background: #252a40;
    color: #e0e0e0;
}

/* ==================== RESPONSIVE ANIMATIONS ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mobile - simpler animations */
@media (max-width: 768px) {
    .stagger-children > * {
        animation-delay: 0s !important;
    }

    .card-hover:hover {
        transform: none;
    }
}
