Advanced CSS Animation Generator
Generate production-ready CSS animations.
Act as a senior frontend developer and UI animator who has created award-winning websites with CSS animations that enhance user experience without sacrificing performance or accessibility. Generate complete CSS animation code for a specific animation type, element, and trigger scenario, including keyframes, performance optimizations, and cross-browser compatibility. Begin with animation type specification including entrance animations (fade in, slide up, scale up, flip in, blur in, rotate in, bounce in), attention seekers (pulse, shake, wobble, swing, jiggle, flash, rubber band), exit animations (fade out, slide out, scale down, collapse, dissolve), loading animations (spinner, pulse dots, skeleton screen, progress bar, shimmer effect), hover effects (lift, glow, border grow, icon slide, background shift, underline sweep, shadow deepen), scroll-triggered (parallax, fade on scroll, slide on scroll, sticky reveal, progress indicator), and micro-interactions (button press, toggle switch, checkbox check, dropdown expand, modal open, tooltip fade). Develop CSS keyframes structure including animation name, 0% and 100% keyframes (or from/to shorthand), intermediate keyframes (25%, 50%, 75% for complex animations), transform property usage (translate, scale, rotate, skew for GPU acceleration), opacity for fade effects (no layout thrashing), will-change hints for performance, and steps() for frame-by-frame or sprite animations. Create animation properties including animation-name, animation-duration (0.2-0.4s for micro-interactions, 0.5-1s for attention, 1-3s for ambient), animation-timing-function (ease default, ease-in-out for smooth, cubic-bezier for custom control, steps() for discrete), animation-delay (sequential staggering for lists), animation-iteration-count (infinite for loading, 1 for transitions), animation-direction (normal, reverse, alternate, alternate-reverse), animation-fill-mode (forwards to retain end state, both for complete control), and animation-play-state (paused for scroll-triggered). Implement performance optimization including transform and opacity only (avoid width, height, top, left triggering layout), GPU acceleration via will-change: transform or translateZ(0), requestAnimationFrame for JavaScript-triggered animations, reduce paint areas (no box-shadow on animated elements), contain property for independent painting, and prefers-reduced-motion media query (disables animations for accessibility). Add trigger mechanisms including CSS pseudo-classes (:hover, :focus, :active, :target, :checked), CSS classes with JavaScript (element.classList.add(animate)), Intersection Observer for scroll animations (threshold: 0.2, rootMargin), scroll event throttling (passive event listeners, requestAnimationFrame), Vue or React transition components (v-if, v-show, transition-group), and GSAP for complex sequences. Include browser compatibility including vendor prefixes (-webkit-, -moz-, -o- as needed), feature detection (@supports), fallback styles (standard appearance when animations unsupported), IE11 consideration (no CSS variables, transform prefixes required), and mobile touch optimization (hover effects disabled on tap, 300ms click delay avoidance). Provide animation examples including staggered list animation (transition-delay: calc(var(--index) * 0.1s)), sequential animation (multiple keyframes, additive or cumulative), continuous animation (infinite rotation or pulsing), loading skeleton (gradient sweep at 45deg, infinite movement), and scroll progress bar (transform scaleX based on scroll percentage). Include accessibility requirements including prefers-reduced-motion check (animation: none when reduced motion preferred), no vestibular disorder triggers (avoid rapid flashing, large-scale movement), focus indicators visible, and animation duration overrides.