/* ==========================================================================
   Mon Studio Vidéo - Animations CSS Améliorées
   Animations ludiques et engageantes pour les enfants
   ========================================================================== */

/* --------------------------------------------------------------------------
   Animations de base
   -------------------------------------------------------------------------- */

/* Pulse - pulsation douce */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

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

/* Bounce - rebond */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-8px);
    }
}

.bounce {
    animation: bounce 1.5s ease infinite;
}

/* Wiggle - tremblement */
@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-3deg);
    }
    75% {
        transform: rotate(3deg);
    }
}

.wiggle {
    animation: wiggle 0.5s ease-in-out infinite;
}

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

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

/* Glow - lueur */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-primary),
                    0 0 10px var(--color-primary);
    }
    50% {
        box-shadow: 0 0 20px var(--color-primary),
                    0 0 30px var(--color-primary),
                    0 0 40px var(--color-secondary);
    }
}

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

/* Rainbow - arc-en-ciel (bordure) */
@keyframes rainbow {
    0% { border-color: #ff0000; }
    14% { border-color: #ff7f00; }
    28% { border-color: #ffff00; }
    42% { border-color: #00ff00; }
    57% { border-color: #0000ff; }
    71% { border-color: #4b0082; }
    85% { border-color: #8f00ff; }
    100% { border-color: #ff0000; }
}

.rainbow-border {
    animation: rainbow 3s linear infinite;
    border-width: 3px;
    border-style: solid;
}

/* --------------------------------------------------------------------------
   Animations d'entrée
   -------------------------------------------------------------------------- */

/* Slide In from Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.4s ease-out;
}

/* Slide In from Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* Slide In from Bottom */
@keyframes slideInBottom {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-bottom {
    animation: slideInBottom 0.4s ease-out;
}

/* Zoom In with Bounce */
@keyframes zoomInBounce {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    60% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.zoom-in-bounce {
    animation: zoomInBounce 0.5s ease-out;
}

/* Pop In */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    70% {
        transform: scale(1.15);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.pop-in {
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Flip In */
@keyframes flipIn {
    0% {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    100% {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

.flip-in {
    animation: flipIn 0.5s ease-out;
}

/* --------------------------------------------------------------------------
   Animations de sortie
   -------------------------------------------------------------------------- */

/* Fade Out */
@keyframes fadeOutAnim {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.fade-out {
    animation: fadeOutAnim 0.3s ease-out forwards;
}

/* Zoom Out */
@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.zoom-out {
    animation: zoomOut 0.3s ease-out forwards;
}

/* --------------------------------------------------------------------------
   Animations d'attention
   -------------------------------------------------------------------------- */

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.6s ease-in-out;
}

/* Tada */
@keyframes tada {
    0%, 100% {
        transform: scale(1) rotate(0);
    }
    10%, 20% {
        transform: scale(0.9) rotate(-3deg);
    }
    30%, 50%, 70%, 90% {
        transform: scale(1.1) rotate(3deg);
    }
    40%, 60%, 80% {
        transform: scale(1.1) rotate(-3deg);
    }
}

.tada {
    animation: tada 1s ease-in-out;
}

/* Heartbeat */
@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

.heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* Jello */
@keyframes jello {
    0%, 100% {
        transform: skewX(0) skewY(0);
    }
    11% {
        transform: skewX(-12.5deg) skewY(-12.5deg);
    }
    22% {
        transform: skewX(6.25deg) skewY(6.25deg);
    }
    33% {
        transform: skewX(-3.125deg) skewY(-3.125deg);
    }
    44% {
        transform: skewX(1.5625deg) skewY(1.5625deg);
    }
    55% {
        transform: skewX(-0.78125deg) skewY(-0.78125deg);
    }
    66% {
        transform: skewX(0.390625deg) skewY(0.390625deg);
    }
    77% {
        transform: skewX(-0.1953125deg) skewY(-0.1953125deg);
    }
}

.jello {
    animation: jello 0.9s ease-in-out;
}

/* --------------------------------------------------------------------------
   Animations de chargement
   -------------------------------------------------------------------------- */

/* Spinner simple */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Dots loading */
@keyframes dotsLoading {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 4px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: dotsLoading 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* Progress shimmer */
@keyframes progressShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.progress-shimmer {
    background: linear-gradient(
        90deg,
        var(--color-primary) 0%,
        var(--color-secondary) 25%,
        var(--color-accent) 50%,
        var(--color-secondary) 75%,
        var(--color-primary) 100%
    );
    background-size: 200% 100%;
    animation: progressShimmer 2s linear infinite;
}

/* --------------------------------------------------------------------------
   Animations de fond
   -------------------------------------------------------------------------- */

/* Gradient shift */
@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.gradient-animated {
    background: linear-gradient(
        -45deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-accent),
        var(--color-success)
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* Stars twinkling */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

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

.star:nth-child(2n) {
    animation-delay: 0.5s;
}

.star:nth-child(3n) {
    animation-delay: 1s;
}

/* --------------------------------------------------------------------------
   Animations spécifiques aux éléments de l'app
   -------------------------------------------------------------------------- */

/* Bouton ajouter média - invite à cliquer */
.btn-add-media {
    animation: pulse 2s ease-in-out infinite;
}

.btn-add-media:hover {
    animation: none;
}

/* Clip ajouté avec succès */
.clip.just-added {
    animation: zoomInBounce 0.4s ease-out;
}

/* Clip supprimé */
.clip.removing {
    animation: zoomOut 0.3s ease-out forwards;
}

/* Média dans la bibliothèque - apparition */
.media-item {
    animation: popIn 0.3s ease-out;
}

/* Toast notification */
.toast {
    animation: slideInBottom 0.3s ease-out;
}

/* Modal apparition */
.modal.visible .modal-content {
    animation: zoomInBounce 0.3s ease-out;
}

/* Placeholder vidéo */
.preview-placeholder .placeholder-icon {
    animation: float 3s ease-in-out infinite;
}

/* Playhead */
.playhead-handle {
    transition: transform 0.1s ease;
}

.playhead-handle:hover {
    animation: pulse 0.5s ease-in-out infinite;
}

/* Bouton export - attire l'attention quand prêt */
.ready-to-export #btnExport {
    animation: glow 2s ease-in-out infinite, pulse 2s ease-in-out infinite;
}

/* Processing spinner */
.processing-animation {
    animation: spin 2s linear infinite;
}

/* --------------------------------------------------------------------------
   Effets hover avancés
   -------------------------------------------------------------------------- */

/* Effet 3D sur hover */
.btn-tool {
    transition: all 0.2s ease;
}

.btn-tool:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-tool:active {
    transform: translateY(0) scale(0.98);
}

/* Effet ripple au clic */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
}

.ripple:active::after {
    animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
    0% {
        width: 0;
        height: 0;
        opacity: 0.5;
    }
    100% {
        width: 200px;
        height: 200px;
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   Transitions fluides globales
   -------------------------------------------------------------------------- */

/* Transitions douces pour tous les éléments interactifs */
button,
.btn,
.media-item,
.clip,
.effect-item,
.template-item,
.sticker-item,
.project-item {
    transition: all var(--transition-fast);
}

/* Amélioration de la fluidité des modales */
.modal {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-content {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --------------------------------------------------------------------------
   Réduction des animations (accessibilité)
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .btn-add-media,
    .preview-placeholder .placeholder-icon,
    .playhead-handle:hover {
        animation: none !important;
    }
}
