/* ================================================
   OPTIMIZED ANIMATIONS
   GPU-accelerated (transform, opacity only)
   ProductiveApp v4.0
   ================================================ */

/* === PERFORMANCE HINTS === */
.sidebar,
.sidebar-item,
.sidebar-label,
.sidebar-brand,
.sidebar-profile-info,
.sidebar-toggle,
.stat-card,
.quick-action,
.project-card,
.note-item {
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* === BASE TRANSITIONS === */
.transition-fast {
    transition: transform 150ms ease, opacity 150ms ease;
}

.transition-normal {
    transition: transform 200ms ease-out, opacity 200ms ease-out;
}

.transition-slow {
    transition: transform 300ms ease-out, opacity 300ms ease-out;
}

/* === HOVER EFFECTS (GPU-accelerated) === */

/* Scale on hover */
.hover-scale {
    transition: transform 150ms ease;
}
.hover-scale:hover {
    transform: scale(1.02);
}

/* Lift on hover */
.hover-lift {
    transition: transform 200ms ease, box-shadow 200ms ease;
}
.hover-lift:hover {
    transform: translateY(-2px);
}

/* Glow on hover */
.hover-glow {
    transition: box-shadow 200ms ease;
}
.hover-glow:hover {
    box-shadow: 0 0 20px var(--accent-glow, rgba(99, 102, 241, 0.3));
}

/* === KEYFRAME ANIMATIONS === */

/* Fade in */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Fade in up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade in scale */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Pulse (subtle) */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

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

/* Bounce (subtle) */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

/* === ANIMATION CLASSES === */
.animate-fadeIn {
    animation: fadeIn 200ms ease-out forwards;
}

.animate-fadeInUp {
    animation: fadeInUp 250ms ease-out forwards;
}

.animate-fadeInScale {
    animation: fadeInScale 200ms ease-out forwards;
}

.animate-slideInLeft {
    animation: slideInLeft 250ms ease-out forwards;
}

.animate-slideInRight {
    animation: slideInRight 250ms ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

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

.animate-bounce {
    animation: bounce 500ms ease infinite;
}

/* === STAGGER ANIMATIONS === */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp 200ms ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

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

/* === LOADING STATES === */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--skeleton-base, rgba(255, 255, 255, 0.05)) 25%,
        var(--skeleton-shine, rgba(255, 255, 255, 0.1)) 50%,
        var(--skeleton-base, rgba(255, 255, 255, 0.05)) 75%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
}

/* Light theme skeleton overrides */
[data-theme="ivory"] .skeleton,
[data-theme="sakura"] .skeleton,
[data-theme="pastel"] .skeleton,
[data-theme="mint"] .skeleton,
[data-theme="paper"] .skeleton,
[data-theme="porcelain"] .skeleton,
[data-theme="zen"] .skeleton,
[data-theme="watercolor"] .skeleton,
[data-theme="nordic"] .skeleton {
    --skeleton-base: rgba(0, 0, 0, 0.05);
    --skeleton-shine: rgba(0, 0, 0, 0.1);
}

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

/* === PROGRESS INDICATOR === */
.progress-line {
    position: relative;
    overflow: hidden;
}

.progress-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--progress-shine, rgba(255, 255, 255, 0.2)),
        transparent
    );
    animation: progressSlide 1.5s ease-in-out infinite;
}

/* Light theme progress overrides */
[data-theme="ivory"] .progress-line::after,
[data-theme="sakura"] .progress-line::after,
[data-theme="pastel"] .progress-line::after,
[data-theme="mint"] .progress-line::after,
[data-theme="paper"] .progress-line::after,
[data-theme="porcelain"] .progress-line::after,
[data-theme="zen"] .progress-line::after,
[data-theme="watercolor"] .progress-line::after,
[data-theme="nordic"] .progress-line::after {
    --progress-shine: rgba(0, 0, 0, 0.15);
}

@keyframes progressSlide {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(200%);
    }
}

/* ================================================
   ENHANCED MICRO-ANIMATIONS v4.1
   Intensity-aware via --anim-intensity (0.0 - 1.0)
   Controlled by AnimationControls panel
   ================================================ */

/* === INTENSITY CSS VARIABLE (default: Elegant preset) === */
:root {
    --anim-intensity: 0.45;
}

/* === VIEW TRANSITIONS === */
@keyframes viewSlideIn {
    from {
        opacity: 0;
        transform: translateY(calc(20px * var(--anim-intensity))) scale(calc(1 - 0.03 * var(--anim-intensity)));
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.view-container.active {
    animation: viewSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* === CARD 3D TILT ON HOVER === */
.stat-card,
.project-card {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.25s ease;
    transform-style: preserve-3d;
}

.stat-card:hover {
    transform: perspective(800px)
               rotateX(calc(-1.5deg * var(--anim-intensity)))
               rotateY(calc(2deg * var(--anim-intensity)))
               translateY(calc(-3px * var(--anim-intensity)));
    box-shadow: 0 calc(8px * var(--anim-intensity)) calc(24px * var(--anim-intensity)) rgba(0,0,0,0.15);
}

.project-card:hover {
    transform: perspective(800px)
               rotateX(calc(-1deg * var(--anim-intensity)))
               rotateY(calc(1.5deg * var(--anim-intensity)))
               translateY(calc(-2px * var(--anim-intensity)));
    box-shadow: 0 calc(6px * var(--anim-intensity)) calc(20px * var(--anim-intensity)) rgba(0,0,0,0.12);
}

/* === STAGGERED LIST REVEAL WITH SPRING FEEL === */
@keyframes springReveal {
    0% {
        opacity: 0;
        transform: translateY(calc(15px * var(--anim-intensity))) scale(calc(1 - 0.04 * var(--anim-intensity)));
    }
    60% {
        opacity: 1;
        transform: translateY(calc(-2px * var(--anim-intensity))) scale(calc(1 + 0.005 * var(--anim-intensity)));
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.spring-stagger > * {
    opacity: 0;
    animation: springReveal 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.spring-stagger > *:nth-child(1) { animation-delay: 0ms; }
.spring-stagger > *:nth-child(2) { animation-delay: 50ms; }
.spring-stagger > *:nth-child(3) { animation-delay: 100ms; }
.spring-stagger > *:nth-child(4) { animation-delay: 150ms; }
.spring-stagger > *:nth-child(5) { animation-delay: 200ms; }
.spring-stagger > *:nth-child(6) { animation-delay: 250ms; }
.spring-stagger > *:nth-child(7) { animation-delay: 300ms; }
.spring-stagger > *:nth-child(8) { animation-delay: 350ms; }

/* === BUTTON RIPPLE EFFECT === */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: width 0s, height 0s, opacity 0s;
    opacity: 0;
}

.btn-ripple:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
    transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
}

/* === SIDEBAR ITEM HOVER ACCENT BAR === */
.sidebar-item {
    position: relative;
}

.sidebar-item::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center;
}

.sidebar-item:hover::after {
    transform: translateY(-50%) scaleY(var(--anim-intensity, 0.45));
}

.sidebar-item.active::after {
    transform: translateY(-50%) scaleY(1);
    box-shadow: 0 0 8px var(--accent-glow, rgba(99,102,241,0.3));
}

/* === TOAST NOTIFICATION ENTRANCE === */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px) scale(0.9);
    }
    70% {
        transform: translateX(calc(-5px * var(--anim-intensity))) scale(1.02);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

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

/* === SMOOTH NUMBER COUNTER === */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(calc(8px * var(--anim-intensity)));
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-count {
    animation: countUp 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* === SUBTLE FLOAT (decorative) === */
@keyframes subtleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(calc(-4px * var(--anim-intensity))); }
}

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

/* === MODAL ENHANCED ENTRANCE === */
@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(calc(1 - 0.08 * var(--anim-intensity))) translateY(calc(10px * var(--anim-intensity)));
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* === SHIMMER LOADING (enhanced) === */
@keyframes shimmerWave {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer-loading {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--bg-card) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmerWave 1.5s ease-in-out infinite;
}

/* === FOCUS RING ANIMATION === */
@keyframes focusRingPulse {
    0% { box-shadow: 0 0 0 0 var(--accent-glow, rgba(99,102,241,0.4)); }
    70% { box-shadow: 0 0 0 calc(4px * var(--anim-intensity)) transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

input:focus-visible,
button:focus-visible {
    animation: focusRingPulse 0.6s ease-out;
}

/* === REDUCED MOTION — OVERRIDE ALL NEW ANIMATIONS === */
@media (prefers-reduced-motion: reduce) {
    .view-container.active {
        animation: none !important;
        opacity: 1 !important;
    }
    .spring-stagger > * {
        animation: none !important;
        opacity: 1 !important;
    }
    .stat-card:hover,
    .project-card:hover {
        transform: none !important;
    }
    .animate-count,
    .animate-float {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .sidebar-item::after {
        transition: none !important;
    }
    .shimmer-loading {
        animation: none !important;
    }
    input:focus-visible,
    button:focus-visible {
        animation: none !important;
    }
}
