/* ============================================================
 * ANIMATIONS & TRANSITIONS
 * Version: 1.0.0
 * Description: Smooth animations for better UX
 * ============================================================ */

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

.page-content {
    animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ====================
 * 2. CARD ANIMATIONS
 * ==================== */

.story-item {
    animation: cardFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

/* Stagger animation for cards */
.story-item:nth-child(1) { animation-delay: 0.05s; }
.story-item:nth-child(2) { animation-delay: 0.1s; }
.story-item:nth-child(3) { animation-delay: 0.15s; }
.story-item:nth-child(4) { animation-delay: 0.2s; }
.story-item:nth-child(5) { animation-delay: 0.25s; }
.story-item:nth-child(6) { animation-delay: 0.3s; }
.story-item:nth-child(n+7) { animation-delay: 0.35s; }

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

/* ====================
 * 3. SMOOTH SCROLL
 * ==================== */

html {
    scroll-behavior: smooth;
}

/* Disable for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ====================
 * 4. LOADING SPINNER
 * ==================== */

.loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    text-align: center;
}

.loading-content .loading-spinner {
    margin-bottom: 15px;
}

.loading-content p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* ====================
 * 5. INFINITE SCROLL LOADER
 * ==================== */

.infinite-scroll-loader {
    text-align: center;
    padding: 40px 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.infinite-scroll-loader.visible {
    opacity: 1;
    transform: translateY(0);
}

.infinite-scroll-loader .spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 15px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.infinite-scroll-loader p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

/* ====================
 * 6. BUTTON RIPPLE EFFECT
 * ==================== */

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

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

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

/* ====================
 * 7. TOOLTIP ANIMATIONS
 * ==================== */

[data-tooltip] {
    position: relative;
    cursor: pointer;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1000;
}

[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.85);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ====================
 * 8. MODAL ANIMATIONS
 * ==================== */

.modal.fade .modal-dialog {
    transform: scale(0.9) translateY(-50px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.fade.in .modal-dialog,
.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ====================
 * 9. NOTIFICATION TOAST
 * ==================== */

.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    min-width: 300px;
    max-width: 400px;
    padding: 16px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    transform: translateX(calc(100% + 40px));
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-notification.success {
    border-left: 4px solid #43e97b;
}

.toast-notification.error {
    border-left: 4px solid #f5576c;
}

.toast-notification.info {
    border-left: 4px solid #4facfe;
}

.toast-notification .icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-notification.success .icon {
    color: #43e97b;
}

.toast-notification.error .icon {
    color: #f5576c;
}

.toast-notification.info .icon {
    color: #4facfe;
}

.toast-notification .message {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.toast-notification .close {
    cursor: pointer;
    font-size: 18px;
    color: #999;
    flex-shrink: 0;
}

/* ====================
 * 10. BREADCRUMB ANIMATION
 * ==================== */

.page-breadcrumb li {
    animation: breadcrumbSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.page-breadcrumb li:nth-child(1) { animation-delay: 0.1s; }
.page-breadcrumb li:nth-child(2) { animation-delay: 0.15s; }
.page-breadcrumb li:nth-child(3) { animation-delay: 0.2s; }
.page-breadcrumb li:nth-child(4) { animation-delay: 0.25s; }

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

/* ====================
 * 11. PAGINATION ANIMATION
 * ==================== */

.pagination li {
    animation: paginationFade 0.3s ease backwards;
}

.pagination li:nth-child(1) { animation-delay: 0.05s; }
.pagination li:nth-child(2) { animation-delay: 0.1s; }
.pagination li:nth-child(3) { animation-delay: 0.15s; }
.pagination li:nth-child(4) { animation-delay: 0.2s; }
.pagination li:nth-child(5) { animation-delay: 0.25s; }

@keyframes paginationFade {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ====================
 * 12. SEARCH BAR FOCUS ANIMATION
 * ==================== */

.search-input-wrapper input:focus {
    animation: searchPulse 0.6s ease;
}

@keyframes searchPulse {
    0% {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 6px 30px rgba(102, 126, 234, 0.3);
    }
    100% {
        box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
    }
}

/* ====================
 * 13. MICRO-INTERACTIONS
 * ==================== */

/* Button press effect */
.btn:active {
    transform: scale(0.98);
}

/* Link hover effect */
a {
    transition: color 0.2s ease;
}

/* Icon bounce on hover */
.icon-bounce:hover {
    animation: iconBounce 0.6s ease;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-5px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-2px); }
}

/* ====================
 * 14. SKELETON PULSE ANIMATION
 * ==================== */

@keyframes skeletonPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.skeleton-loading {
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

/* ====================
 * 15. ACCESSIBILITY - REDUCE MOTION
 * ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .toast-notification,
    .loading-overlay,
    .modal {
        transition: none !important;
    }
}
