/**
 * ========================================================
 * ANIMATIONS.CSS - Keyframes, Transitions & Effects
 * ========================================================
 *
 * This file contains all animation definitions for the
 * Spirit Skin Slim Bloom website.
 *
 * Contents:
 * 1. Base Animation Classes
 * 2. Fade Animations
 * 3. Slide Animations
 * 4. Scale Animations
 * 5. Rotate Animations
 * 6. Special Effects
 * 7. Hover Effects
 * 8. Loading Animations
 * 9. Scroll-Triggered Animations
 * 10. Reduced Motion Support
 *
 * Dependencies: variables.css
 *
 * ========================================================
 */


/* ========================================================
   1. BASE ANIMATION CLASSES
   ========================================================
   Shared animation properties
   ======================================================== */

/* Base class for all animated elements */
.animate {
    animation-duration: var(--transition-normal);
    animation-timing-function: var(--ease-smooth);
    animation-fill-mode: both;
}

/* Animation delay utilities */
.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-400 { animation-delay: 400ms; }
.animate-delay-500 { animation-delay: 500ms; }
.animate-delay-700 { animation-delay: 700ms; }
.animate-delay-1000 { animation-delay: 1000ms; }

/* Animation duration utilities */
.animate-fast { animation-duration: var(--transition-fast); }
.animate-normal { animation-duration: var(--transition-normal); }
.animate-slow { animation-duration: var(--transition-slow); }
.animate-slower { animation-duration: var(--transition-slower); }

/* Animation iteration */
.animate-once { animation-iteration-count: 1; }
.animate-infinite { animation-iteration-count: infinite; }

/* Animation direction */
.animate-reverse { animation-direction: reverse; }
.animate-alternate { animation-direction: alternate; }


/* ========================================================
   2. FADE ANIMATIONS
   ========================================================
   Opacity-based animations
   ======================================================== */

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

.animate-fade-in {
    animation-name: fadeIn;
    animation-duration: var(--transition-slow);
}

/* Fade Out */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.animate-fade-out {
    animation-name: fadeOut;
    animation-duration: var(--transition-normal);
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation-name: fadeInUp;
    animation-duration: var(--transition-slow);
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-down {
    animation-name: fadeInDown;
    animation-duration: var(--transition-slow);
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-left {
    animation-name: fadeInLeft;
    animation-duration: var(--transition-slow);
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-right {
    animation-name: fadeInRight;
    animation-duration: var(--transition-slow);
}


/* ========================================================
   3. SLIDE ANIMATIONS
   ========================================================
   Translation-based animations
   ======================================================== */

/* Slide In Up */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.animate-slide-in-up {
    animation-name: slideInUp;
    animation-duration: var(--transition-slow);
    animation-timing-function: var(--ease-spring);
}

/* Slide In Down */
@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

.animate-slide-in-down {
    animation-name: slideInDown;
    animation-duration: var(--transition-slow);
    animation-timing-function: var(--ease-spring);
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.animate-slide-in-left {
    animation-name: slideInLeft;
    animation-duration: var(--transition-slow);
}

/* Slide In Right */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.animate-slide-in-right {
    animation-name: slideInRight;
    animation-duration: var(--transition-slow);
}


/* ========================================================
   4. SCALE ANIMATIONS
   ========================================================
   Size-based animations
   ======================================================== */

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation-name: scaleIn;
    animation-duration: var(--transition-normal);
    animation-timing-function: var(--ease-spring);
}

/* Scale Out */
@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

.animate-scale-out {
    animation-name: scaleOut;
    animation-duration: var(--transition-normal);
}

/* Pop In */
@keyframes popIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-pop-in {
    animation-name: popIn;
    animation-duration: var(--transition-slow);
    animation-timing-function: var(--ease-spring);
}

/* Zoom In */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-zoom-in {
    animation-name: zoomIn;
    animation-duration: var(--transition-slow);
}


/* ========================================================
   5. ROTATE ANIMATIONS
   ========================================================
   Rotation-based animations
   ======================================================== */

/* Rotate In */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: rotate(0);
    }
}

.animate-rotate-in {
    animation-name: rotateIn;
    animation-duration: var(--transition-slow);
}

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

.animate-spin {
    animation-name: spin;
    animation-duration: 1s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}


/* ========================================================
   6. SPECIAL EFFECTS
   ========================================================
   Unique and branded animations
   ======================================================== */

/* Pulse */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation-name: pulse;
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.animate-bounce {
    animation-name: bounce;
    animation-duration: 1s;
    animation-iteration-count: infinite;
}

/* Float */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-float {
    animation-name: float;
    animation-duration: 3s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

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

.animate-shimmer {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation-name: shimmer;
    animation-duration: 2s;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

/* Glow */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(139, 168, 136, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(139, 168, 136, 0.8),
                    0 0 30px rgba(139, 168, 136, 0.6);
    }
}

.animate-glow {
    animation-name: glow;
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.animate-shake {
    animation-name: shake;
    animation-duration: 0.8s;
}

/* Wiggle */
@keyframes wiggle {
    0%, 100% {
        transform: rotate(-3deg);
    }
    50% {
        transform: rotate(3deg);
    }
}

.animate-wiggle {
    animation-name: wiggle;
    animation-duration: 0.3s;
    animation-iteration-count: 3;
}


/* ========================================================
   7. HOVER EFFECTS
   ========================================================
   Interactive hover animations
   ======================================================== */

/* Lift on hover */
.hover-lift {
    transition: transform var(--transition-normal) var(--ease-smooth),
                box-shadow var(--transition-normal) var(--ease-smooth);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Grow on hover */
.hover-grow {
    transition: transform var(--transition-normal) var(--ease-smooth);
}

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

/* Shrink on hover */
.hover-shrink {
    transition: transform var(--transition-normal) var(--ease-smooth);
}

.hover-shrink:hover {
    transform: scale(0.95);
}

/* Rotate on hover */
.hover-rotate {
    transition: transform var(--transition-normal) var(--ease-smooth);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* Underline animation */
.hover-underline {
    position: relative;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform var(--transition-normal) var(--ease-smooth);
}

.hover-underline:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Color shift on hover */
.hover-primary {
    transition: color var(--transition-fast) var(--ease-smooth);
}

.hover-primary:hover {
    color: var(--color-primary);
}

/* Background fill on hover */
.hover-fill {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.hover-fill::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: var(--color-primary);
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform var(--transition-normal) var(--ease-smooth);
    z-index: -1;
}

.hover-fill:hover::before {
    transform: scaleY(1);
}


/* ========================================================
   8. LOADING ANIMATIONS
   ========================================================
   Loading states and spinners
   ======================================================== */

/* Spinner */
@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-light-gray);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spinner 0.8s linear infinite;
}

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

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

/* Dots loading */
@keyframes dotsLoading {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.dots-loading {
    display: inline-flex;
    gap: 4px;
}

.dots-loading span {
    width: 8px;
    height: 8px;
    background-color: var(--color-primary);
    border-radius: 50%;
    animation: dotsLoading 1.4s ease-in-out infinite both;
}

.dots-loading span:nth-child(1) { animation-delay: -0.32s; }
.dots-loading span:nth-child(2) { animation-delay: -0.16s; }
.dots-loading span:nth-child(3) { animation-delay: 0s; }

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

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-light-gray) 0%,
        var(--color-cream) 50%,
        var(--color-light-gray) 100%
    );
    background-size: 200px 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}


/* ========================================================
   9. SCROLL-TRIGGERED ANIMATIONS
   ========================================================
   Animations triggered by Intersection Observer
   ======================================================== */

/* Initial state for scroll animations */
.animate-on-scroll {
    opacity: 0;
    transition: opacity var(--transition-slow) var(--ease-smooth),
                transform var(--transition-slow) var(--ease-smooth);
}

/* Fade up variant */
.animate-on-scroll[data-animation="fade-up"] {
    transform: translateY(40px);
}

/* Fade down variant */
.animate-on-scroll[data-animation="fade-down"] {
    transform: translateY(-40px);
}

/* Fade left variant */
.animate-on-scroll[data-animation="fade-left"] {
    transform: translateX(-40px);
}

/* Fade right variant */
.animate-on-scroll[data-animation="fade-right"] {
    transform: translateX(40px);
}

/* Scale variant */
.animate-on-scroll[data-animation="scale"] {
    transform: scale(0.9);
}

/* Animated state */
.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* Staggered children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--transition-normal) var(--ease-smooth),
                transform var(--transition-normal) var(--ease-smooth);
}

.stagger-children.is-visible > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children.is-visible > *:nth-child(2) { transition-delay: 100ms; }
.stagger-children.is-visible > *:nth-child(3) { transition-delay: 200ms; }
.stagger-children.is-visible > *:nth-child(4) { transition-delay: 300ms; }
.stagger-children.is-visible > *:nth-child(5) { transition-delay: 400ms; }
.stagger-children.is-visible > *:nth-child(6) { transition-delay: 500ms; }

.stagger-children.is-visible > * {
    opacity: 1;
    transform: translateY(0);
}


/* ========================================================
   10. REDUCED MOTION SUPPORT
   ========================================================
   Respect user preferences for reduced 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;
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }

    .hover-lift:hover,
    .hover-grow:hover,
    .hover-shrink:hover,
    .hover-rotate:hover {
        transform: none;
    }
}
