/**
 * Robinhood-Style Animations
 * Phase 4: Polish & Interaction
 */

/* ===== Keyframe Animations ===== */
@keyframes robinhood-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes robinhood-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes robinhood-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes robinhood-scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

/* ===== Skeleton Loader ===== */
.robinhood-skeleton {
    background: linear-gradient(
        90deg,
        var(--robinhood-bg-secondary) 0px,
        var(--robinhood-bg-tertiary) 40px,
        var(--robinhood-bg-secondary) 80px
    );
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--robinhood-radius-sm);
    min-height: 20px;
}

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

.robinhood-skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--robinhood-space-3);
}

.robinhood-skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--robinhood-radius-full);
}

.robinhood-skeleton-card {
    padding: var(--robinhood-space-4);
    border-radius: var(--robinhood-radius-md);
    background: var(--robinhood-bg-primary);
    border: 1px solid var(--robinhood-border-light);
}

/* ===== Loading Spinner ===== */
.robinhood-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid var(--robinhood-border-light);
    border-top-color: var(--robinhood-success);
    border-radius: 50%;
    animation: robinhood-spin 1s linear infinite;
}

.robinhood-spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.robinhood-spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* ===== Pulse Animation ===== */
.robinhood-pulse {
    animation: robinhood-pulse 2s ease-in-out infinite;
}

/* ===== Fade In Animation ===== */
.robinhood-fade-in {
    animation: robinhood-fade-in 0.3s ease-out;
}

.robinhood-slide-up {
    animation: robinhood-slide-up 0.4s ease-out;
}

.robinhood-scale-in {
    animation: robinhood-scale-in 0.3s ease-out;
}

/* ===== Enhanced Hover Effects ===== */
.robinhood-card,
.robinhood-metric-card,
.summary-card,
.status-card {
    transition: all var(--robinhood-transition-base);
}

.robinhood-card:hover,
.robinhood-metric-card:hover,
.summary-card:hover,
.status-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--robinhood-shadow-hover);
}

/* ===== Button Click Animation ===== */
.robinhood-btn,
button:not([disabled]) {
    transition: all var(--robinhood-transition-base);
    position: relative;
    overflow: hidden;
}

.robinhood-btn:active:not(:disabled),
button:active:not([disabled]) {
    transform: scale(0.98);
}

/* ===== Ripple Effect (Optional) ===== */
.robinhood-btn-ripple {
    position: relative;
    overflow: hidden;
}

.robinhood-btn-ripple::after {
    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;
}

.robinhood-btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* ===== Toast Notifications ===== */
.robinhood-toast {
    position: fixed;
    top: 80px;
    right: 24px;
    padding: var(--robinhood-space-4) var(--robinhood-space-6);
    border-radius: var(--robinhood-radius-pill);
    box-shadow: var(--robinhood-shadow-lg);
    z-index: var(--robinhood-z-toast);
    font-size: var(--robinhood-font-body);
    font-weight: var(--robinhood-weight-semibold);
    color: white;
    max-width: 400px;
    word-wrap: break-word;
    animation: robinhood-slide-up 0.3s ease-out;
}

.robinhood-toast-success {
    background: var(--robinhood-success);
}

.robinhood-toast-danger {
    background: var(--robinhood-danger);
}

.robinhood-toast-info {
    background: var(--robinhood-text-secondary);
}

/* ===== Smooth Scroll ===== */
html {
    scroll-behavior: smooth;
}

/* ===== Focus Visible Enhancement ===== */
*:focus-visible {
    outline: 2px solid var(--robinhood-success);
    outline-offset: 2px;
    border-radius: var(--robinhood-radius-sm);
}

/* ===== Loading Overlay ===== */
.robinhood-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--robinhood-z-modal);
    animation: robinhood-fade-in 0.3s ease-out;
}

/* ===== Success Checkmark Animation ===== */
@keyframes robinhood-checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.robinhood-checkmark {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: robinhood-checkmark 0.6s ease-out forwards;
}

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