/* ========================================
   Animations & Micro-interactions
   By: Whimsy Injector Agent
   ======================================== */

/* ========================================
   Keyframe Animations
   ======================================== */

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

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

@keyframes wobble {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
    100% { transform: rotate(0deg); }
}

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

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

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

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

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

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

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(0, 240, 255, 0.8), 0 0 30px rgba(0, 240, 255, 0.4);
    }
}

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

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

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

@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(20deg);
    }
    75% {
        transform: rotate(-20deg);
    }
}

/* ========================================
   Loading States
   ======================================== */

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 240, 255, 0.3);
    border-top-color: var(--color-secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--color-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

.loading-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, var(--color-secondary), var(--color-accent));
    border-radius: var(--radius-full);
    animation: shimmer 1.5s infinite;
}

/* ========================================
   Button Hover Effects
   ======================================== */

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

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

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

/* ========================================
   Card Hover Effects
   ======================================== */

.card-hover {
    transition: all var(--transition-base);
}

.card-hover:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.card-3d {
    perspective: 1000px;
}

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

.card-3d:hover .card-3d-inner {
    transform: rotateY(10deg) rotateX(5deg);
}

/* ========================================
   Text Effects
   ======================================== */

.text-gradient-animate {
    background: linear-gradient(90deg, var(--color-secondary), var(--color-accent), var(--color-secondary));
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

.text-shimmer {
    position: relative;
    overflow: hidden;
}

.text-shimmer::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    color: rgba(255, 255, 255, 0.3);
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 50% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s infinite;
}

/* ========================================
   Scroll Animations
   ======================================== */

.animate-on-scroll {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s ease;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

.animate-on-scroll.from-left {
    transform: translateX(-50px);
}

.animate-on-scroll.from-left.visible {
    transform: translateX(0);
}

.animate-on-scroll.from-right {
    transform: translateX(50px);
}

.animate-on-scroll.from-right.visible {
    transform: translateX(0);
}

.animate-on-scroll.scale {
    transform: scale(0.9);
}

.animate-on-scroll.scale.visible {
    transform: scale(1);
}

/* ========================================
   Input Animations
   ======================================== */

.input-group {
    position: relative;
}

.input-animate {
    padding: var(--space-md) 0;
    border: none;
    border-bottom: 2px solid rgba(138, 143, 153, 0.3);
    background: transparent;
    color: #ffffff;
    font-size: var(--text-base);
    transition: border-color var(--transition-base);
}

.input-animate:focus {
    outline: none;
    border-bottom-color: var(--color-secondary);
}

.input-label {
    position: absolute;
    top: var(--space-md);
    left: 0;
    color: var(--color-neutral);
    pointer-events: none;
    transition: all 0.3s ease;
}

.input-animate:focus + .input-label,
.input-animate:not(:placeholder-shown) + .input-label {
    top: -12px;
    font-size: var(--text-xs);
    color: var(--color-secondary);
}

/* ========================================
   Notification/Toast Animations
   ======================================== */

.toast {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    background: var(--bg-card);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-tooltip);
    animation: slideInRight 0.4s ease, fadeIn 0.4s ease;
}

.toast.toast-success {
    border-color: var(--color-success);
}

.toast.toast-error {
    border-color: var(--color-error);
}

.toast.toast-warning {
    border-color: var(--color-warning);
}

.toast.hiding {
    animation: fadeOut 0.3s ease;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ========================================
   Success Celebrations
   ======================================== */

.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: var(--z-modal);
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--color-secondary);
    animation: confetti 3s ease-out forwards;
}

.confetti:nth-child(2n) {
    background: var(--color-accent);
    animation-delay: 0.1s;
}

.confetti:nth-child(3n) {
    background: var(--color-success);
    animation-delay: 0.2s;
}

.confetti:nth-child(4n) {
    background: #F39C12;
    animation-delay: 0.3s;
}

.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    position: relative;
}

.success-checkmark::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--color-success);
    animation: scaleIn 0.5s ease;
}

.success-checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    color: #ffffff;
    animation: fadeIn 0.5s ease 0.2s both;
}

/* ========================================
   Progress Animations
   ======================================== */

.progress-circle {
    width: 120px;
    height: 120px;
    position: relative;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle-bg {
    fill: none;
    stroke: var(--bg-input);
    stroke-width: 8;
}

.progress-circle-bar {
    fill: none;
    stroke: var(--color-secondary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1s ease;
}

.progress-circle-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: #ffffff;
}

/* ========================================
   Tooltip Animations
   ======================================== */

.tooltip {
    position: relative;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: var(--z-tooltip);
}

.tooltip::before {
    content: attr(data-tooltip);
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--bg-card);
    color: #ffffff;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    white-space: nowrap;
    margin-bottom: var(--space-sm);
}

.tooltip::after {
    content: '';
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border: 6px solid transparent;
    border-top-color: var(--bg-card);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* ========================================
   Counter Animation
   ======================================== */

.counter {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--color-secondary);
}

/* ========================================
   Typing Animation for Chat
   ======================================== */

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-md);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--color-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator span:nth-child(3) { animation-delay: 0s; }

/* ========================================
   Stagger Animation for Lists
   ======================================== */

.stagger-in > * {
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   Morphing Shapes
   ======================================== */

.morph {
    animation: morph 8s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

/* ========================================
   Attention Grabbers
   ======================================== */

.attention-grab {
    animation: pulse 2s infinite;
}

.shake-on-error {
    animation: shake 0.5s;
}

.wobble-on-hover:hover {
    animation: wobble 0.5s;
}

.bounce-on-hover:hover {
    animation: bounce 0.5s;
}

/* ========================================
   Magnetic Button Effect
   ======================================== */

.magnetic {
    transition: transform 0.3s ease;
}

/* ========================================
   Glow Effects
   ======================================== */

.glow-pulse {
    animation: glow 2s infinite;
}

.glow-hover:hover {
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.6);
}

/* ========================================
   Reveal Animations
   ======================================== */

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

.reveal::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(0, 240, 255, 0.1),
        transparent
    );
    transition: left 0.5s ease;
}

.reveal:hover::after {
    left: 100%;
}

/* ========================================
   Interactive Elements
   ======================================== */

.clickable {
    cursor: pointer;
    user-select: none;
}

.clickable:active {
    transform: scale(0.95);
}

.draggable {
    cursor: move;
    user-select: none;
}

/* ========================================
   Special Effects
   ======================================== */

.sparkle {
    position: relative;
}

.sparkle::before {
    content: '✨';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 20px;
    animation: spin 3s linear infinite;
}

.wave-emoji {
    display: inline-block;
    animation: wave 2.5s infinite;
    transform-origin: 70% 70%;
}

/* ========================================
   Reduced Motion
   ======================================== */

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