/**
 * Animation & Transition Styles
 * Optimized for performance and native feel
 */

:root {
    --transition-speed: 0.3s;
    --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --bounce-timing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   SMOOTH TRANSITIONS
   ============================================ */
* {
    -webkit-tap-highlight-color: transparent;
}

a, button, [role="button"] {
    transition: all var(--transition-speed) var(--transition-timing);
}

/* ============================================
   TOUCH FEEDBACK
   ============================================ */
.touch-active {
    transform: scale(0.98);
    opacity: 0.8;
}

/* ============================================
   IMAGE LOADING
   ============================================ */
img {
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

img.loaded {
    opacity: 1;
}

img[data-src] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ============================================
   SCROLL ANIMATIONS
   ============================================ */
[data-animate] {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s var(--transition-timing),
                transform 0.8s var(--transition-timing);
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger animations */
[data-animate]:nth-child(1) { transition-delay: 0ms; }
[data-animate]:nth-child(2) { transition-delay: 100ms; }
[data-animate]:nth-child(3) { transition-delay: 200ms; }
[data-animate]:nth-child(4) { transition-delay: 300ms; }
[data-animate]:nth-child(5) { transition-delay: 400ms; }

/* ============================================
   FLOATING ANIMATION
   ============================================ */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

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

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

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   BOUNCE ON HOVER
   ============================================ */
.hover-bounce {
    transition: transform 0.3s var(--bounce-timing);
}

.hover-bounce:hover {
    transform: translateY(-5px);
}

/* ============================================
   SCALE ON HOVER
   ============================================ */
.hover-scale {
    transition: transform 0.3s var(--transition-timing);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ============================================
   SMOOTH SCROLL
   ============================================ */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
body.loading {
    cursor: wait;
}

body.loading * {
    pointer-events: none;
}

/* ============================================
   PAGE READY
   ============================================ */
body:not(.app-ready) [data-animate] {
    opacity: 0;
}

body.app-ready {
    animation: pageIn 0.5s ease-out;
}

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

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    [data-animate] {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: 20px;
}

/* ============================================
   PROGRESSIVE ENHANCEMENT
   ============================================ */
.no-js [data-animate] {
    opacity: 1;
    transform: none;
}

.no-js img[data-src] {
    opacity: 1;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
    [data-animate] {
        transform: translateY(20px);
    }
    
    .hover-bounce:active,
    .hover-scale:active {
        transform: scale(0.95);
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Remove will-change after animation */
[data-animate].animate-in {
    will-change: auto;
}

/* ============================================
   FOCUS VISIBLE (Keyboard navigation)
   ============================================ */
:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

/* ============================================
   BACKDROP BLUR SUPPORT
   ============================================ */
@supports (backdrop-filter: blur(10px)) {
    .backdrop-blur {
        backdrop-filter: blur(10px);
    }
}

/* ============================================
   DARK MODE TRANSITIONS
   ============================================ */
.dark-mode-transition * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
}

/* ============================================
   CUSTOM SCROLLBAR (Webkit)
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #1e293b;
}

.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* ============================================
   MOBILE VIEWPORT FIX
   ============================================ */
.mobile-vh {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

/* ============================================
   RESIZE PROTECTION
   ============================================ */
body.resizing * {
    transition: none !important;
}

/* ============================================
   CARD HOVER EFFECTS
   ============================================ */
.card-hover {
    transition: transform 0.3s var(--transition-timing),
                box-shadow 0.3s var(--transition-timing);
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 
                0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ============================================
   BUTTON PRESS EFFECT
   ============================================ */
button:active:not(:disabled),
.btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

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

/* ============================================
   FADE ANIMATIONS
   ============================================ */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

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

/* ============================================
   SLIDE ANIMATIONS
   ============================================ */
.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

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

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

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

/* ============================================
   MOBILE BOTTOM NAV SPACING
   ============================================ */
/* Add bottom padding on mobile to prevent content from being hidden behind fixed bottom nav */
@media (max-width: 1023px) {
    main {
        padding-bottom: 80px !important;
    }
    
    /* Ensure footer is visible above bottom nav */
    footer {
        margin-bottom: 0;
    }
}
