/* ============================================
   TrikAi Avatar - Animations
   Breathing, Transitions, Micro-interactions
   ============================================ */

/* === Page Transitions === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

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

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

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

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Avatar Breathing === */
@keyframes avatarBreathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

@keyframes avatarGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(123, 104, 238, 0.3);
        filter: brightness(1);
    }
    50% {
        box-shadow: 0 0 35px rgba(123, 104, 238, 0.6);
        filter: brightness(1.05);
    }
}

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

/* === Typing Indicator === */
@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-text-muted);
    animation: typingDot 1.4s infinite;
}

.typing-indicator__dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator__dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* === Pulse === */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* === Ripple Effect === */
@keyframes ripple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(4); opacity: 0; }
}

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

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    animation: ripple 0.6s ease-out forwards;
    pointer-events: none;
}

/* === Waveform (Voice Call) === */
@keyframes waveform {
    0%, 100% { height: 4px; }
    50% { height: var(--wave-height, 20px); }
}

.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 40px;
}

.waveform__bar {
    width: 3px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    animation: waveform 1.2s ease-in-out infinite;
}

.waveform__bar:nth-child(1) { --wave-height: 16px; animation-delay: 0s; }
.waveform__bar:nth-child(2) { --wave-height: 28px; animation-delay: 0.1s; }
.waveform__bar:nth-child(3) { --wave-height: 36px; animation-delay: 0.2s; }
.waveform__bar:nth-child(4) { --wave-height: 24px; animation-delay: 0.3s; }
.waveform__bar:nth-child(5) { --wave-height: 32px; animation-delay: 0.15s; }
.waveform__bar:nth-child(6) { --wave-height: 20px; animation-delay: 0.25s; }
.waveform__bar:nth-child(7) { --wave-height: 28px; animation-delay: 0.35s; }
.waveform__bar:nth-child(8) { --wave-height: 14px; animation-delay: 0.05s; }
.waveform__bar:nth-child(9) { --wave-height: 24px; animation-delay: 0.2s; }
.waveform__bar:nth-child(10) { --wave-height: 18px; animation-delay: 0.3s; }

.waveform--paused .waveform__bar {
    animation-play-state: paused;
    height: 4px;
}

/* === Skeleton Loading === */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-surface-2) 25%,
        var(--color-surface-3) 50%,
        var(--color-surface-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s linear infinite;
    border-radius: var(--radius-md);
}

.skeleton--text {
    height: 16px;
    width: 80%;
    margin-bottom: var(--space-2);
}

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

.skeleton--card {
    height: 120px;
    border-radius: var(--radius-lg);
}

/* === Confetti / Celebration === */
@keyframes confettiFall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: confettiFall 3s ease-in forwards;
    z-index: var(--z-toast);
    pointer-events: none;
}

/* === Progress Bar Fill === */
@keyframes progressFill {
    from { width: 0; }
    to { width: var(--progress, 0%); }
}

/* === Shake (Error) === */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    50% { transform: translateX(8px); }
    75% { transform: translateX(-4px); }
}

.shake {
    animation: shake 0.3s ease;
}

/* === Bounce In === */
@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

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

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner--sm {
    width: 16px;
    height: 16px;
}

.spinner--lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* === Stagger Children === */
.stagger-children > * {
    animation: slideUp 0.4s ease backwards;
}

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

/* === Button Press === */
.press-scale {
    transition: transform var(--transition-fast);
}

.press-scale:active {
    transform: scale(0.97);
}

/* === Notification Badge Pulse === */
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.badge-pulse {
    animation: badgePulse 2s ease infinite;
}

/* === Counter Animation === */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Mood Color Transition === */
.mood-transition {
    transition: background-color 0.5s ease, box-shadow 0.5s ease;
}

/* === Screen Transition Classes === */
.screen-enter {
    animation: fadeIn 0.3s ease;
}

.screen-exit {
    animation: fadeOut 0.2s ease;
}

.screen-slide-enter {
    animation: slideInRight 0.3s ease;
}

.screen-slide-exit {
    animation: slideInLeft 0.3s ease reverse;
}

/* === Audio Orb === */
@keyframes orbBreathe {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
}

@keyframes orbRingPulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes orbGlow {
    0%, 100% { box-shadow: 0 0 40px rgba(123, 104, 238, 0.2), 0 0 80px rgba(6, 182, 212, 0.1); }
    50% { box-shadow: 0 0 60px rgba(123, 104, 238, 0.4), 0 0 100px rgba(6, 182, 212, 0.2); }
}

.audio-orb {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: var(--gradient-voice);
    animation: orbBreathe 3s ease-in-out infinite, orbGlow 3s ease-in-out infinite;
    position: relative;
}

.audio-orb::before,
.audio-orb::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1px solid rgba(123, 104, 238, 0.3);
    animation: orbRingPulse 2.5s ease-out infinite;
}

.audio-orb::after {
    inset: -16px;
    animation-delay: 0.8s;
}

.audio-orb--listening {
    animation: orbBreathe 1.5s ease-in-out infinite, orbGlow 1.5s ease-in-out infinite;
}

.audio-orb--speaking {
    animation: orbBreathe 0.8s ease-in-out infinite, orbGlow 0.8s ease-in-out infinite;
}

/* === Scroll Fade-In === */
.fade-in {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s var(--easing-default), transform 0.6s var(--easing-default);
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.fade-in-left {
    opacity: 0;
    transform: translateX(-24px);
    transition: opacity 0.6s var(--easing-default), transform 0.6s var(--easing-default);
}

.fade-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-in-right {
    opacity: 0;
    transform: translateX(24px);
    transition: opacity 0.6s var(--easing-default), transform 0.6s var(--easing-default);
}

.fade-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.fade-in-scale {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.6s var(--easing-default), transform 0.6s var(--easing-default);
}

.fade-in-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* === Gradient Shimmer === */
@keyframes gradientShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.gradient-shimmer {
    background-size: 200% auto;
    animation: gradientShimmer 3s linear infinite;
}

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

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

/* === Voice Ring Expand (Bento) === */
@keyframes voiceRingExpand {
    0% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* === Memory Node Glow (Bento) === */
@keyframes nodeGlow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.3); }
}
