/**
 * ========================================
 * GLOBAL MOTION EFFECTS SYSTEM
 * Comprehensive Animation & Motion Design
 * ========================================
 * 
 * Features:
 * - Smooth transitions on all interactive elements
 * - Scroll-triggered animations
 * - Parallax effects
 * - Text animations
 * - Image transitions
 * - Card hover effects
 * - Button animations
 * - Form interactions
 * - Section reveals
 * - Accessibility support (prefers-reduced-motion)
 * 
 * Apply to any element with motion= data attribute
 * Example: <div data-motion="fade-in"></div>
 */

/* ========================================
   ACCESSIBILITY: RESPECT PREFERS-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;
    }
}

/* ========================================
   GLOBAL MOTION DEFAULTS
   ======================================== */

html {
    scroll-behavior: smooth;
}

body {
    --motion-duration: 0.5s;
    --motion-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --motion-easing-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --motion-easing-in-out: cubic-bezier(0.4, 0, 0.6, 1);
}

/* ========================================
   UNIVERSAL SMOOTH TRANSITIONS
   ======================================== */

a,
button,
input,
textarea,
select,
[role="button"],
[role="link"],
[role="tab"],
.interactive,
.btn,
.button {
    transition: all 0.45s var(--motion-easing);
    will-change: auto;
}

a:hover,
a:focus,
button:hover,
button:focus {
    will-change: transform, color, background-color;
}

/* ========================================
   TEXT ANIMATIONS
   ======================================== */

/* Text fade-in on page load */
@keyframes fadeInText {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

p,
span,
li,
label,
h1,
h2,
h3,
h4,
h5,
h6 {
    animation: fadeInText 0.8s var(--motion-easing) forwards;
}

/* Staggered text animation for multiple paragraphs */
p:nth-of-type(1) { animation-delay: 0.1s; }
p:nth-of-type(2) { animation-delay: 0.2s; }
p:nth-of-type(3) { animation-delay: 0.3s; }
p:nth-of-type(n+4) { animation-delay: 0.4s; }

/* ========================================
   TEXT EFFECTS
   ======================================== */

/* Text glow on hover */
@keyframes textGlow {
    from {
        text-shadow: 0 0 0 rgba(33, 164, 90, 0.3);
    }
    to {
        text-shadow: 0 0 20px rgba(33, 164, 90, 0.6),
                     0 0 40px rgba(33, 164, 90, 0.3);
    }
}

a,
[data-motion*="glow"] {
    position: relative;
}

a:hover,
[data-motion*="glow"]:hover {
    animation: textGlow 0.6s var(--motion-easing) forwards;
}

/* Text color transition */
a:hover {
    color: #21A45A;
}

/* ========================================
   IMAGE ANIMATIONS
   ======================================== */

/* Image fade-in on load */
@keyframes imageEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

img,
video {
    animation: imageEnter 1s var(--motion-easing) forwards;
    transition: transform 0.6s var(--motion-easing),
                filter 0.6s var(--motion-easing),
                box-shadow 0.6s var(--motion-easing);
    will-change: transform;
}

/* Image hover zoom */
@keyframes imageZoom {
    to {
        transform: scale(1.08);
    }
}

[data-motion*="image"]:hover,
[data-motion*="zoom"]:hover {
    animation: imageZoom 0.6s var(--motion-easing) forwards;
    filter: brightness(1.1);
}

/* Image hover with shadow */
img:hover,
video:hover {
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    filter: brightness(1.05) contrast(1.05);
}

/* Image rotate on hover */
[data-motion*="rotate"]:hover {
    transform: rotate(3deg);
}

/* ========================================
   CARD ANIMATIONS
   ======================================== */

/* Card fade-in staggered */
@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card,
[data-motion*="card"],
.glass-card,
.content-card,
[class*="card"],
section > div[class*="bg"],
section > div[class*="border"],
section > div[class*="rounded"] {
    animation: cardEnter 0.8s var(--motion-easing) backwards;
    transition: all 0.5s var(--motion-easing);
}

.card:nth-of-type(1),
[data-motion*="card"]:nth-of-type(1) { animation-delay: 0.1s; }
.card:nth-of-type(2),
[data-motion*="card"]:nth-of-type(2) { animation-delay: 0.2s; }
.card:nth-of-type(3),
[data-motion*="card"]:nth-of-type(3) { animation-delay: 0.3s; }
.card:nth-of-type(4),
[data-motion*="card"]:nth-of-type(4) { animation-delay: 0.4s; }
.card:nth-of-type(5),
[data-motion*="card"]:nth-of-type(5) { animation-delay: 0.5s; }

/* Card hover effect */
@keyframes cardLift {
    to {
        transform: translateY(-8px);
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    }
}

.card:hover,
[data-motion*="card"]:hover,
.glass-card:hover,
.content-card:hover,
[class*="card"]:hover {
    animation: cardLift 0.5s var(--motion-easing) forwards;
}

/* ========================================
   BUTTON ANIMATIONS
   ======================================== */

/* Button scale on hover */
@keyframes buttonHover {
    to {
        transform: scale(1.05);
    }
}

button,
.btn,
.button,
input[type="button"],
input[type="submit"],
[role="button"] {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    backface-visibility: hidden;
}

button:hover,
.btn:hover,
.button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
[role="button"]:hover {
    animation: buttonHover 0.4s var(--motion-easing) forwards;
}

/* Button press animation */
button:active,
.btn:active,
.button:active,
input[type="button"]:active,
input[type="submit"]:active {
    transform: scale(0.98);
}

/* Button focus animation */
button:focus-visible,
.btn:focus-visible,
.button:focus-visible,
input[type="button"]:focus-visible,
input[type="submit"]:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid #21A45A;
    outline-offset: 2px;
    animation: pulse 0.5s var(--motion-easing);
}

/* ========================================
   FORM INTERACTIONS
   ======================================== */

/* Input focus animation */
@keyframes inputFocus {
    from {
        box-shadow: 0 0 0 0 rgba(33, 164, 90, 0.3);
    }
    to {
        box-shadow: 0 0 0 5px rgba(33, 164, 90, 0.1);
    }
}

input,
textarea,
select {
    transition: all 0.4s var(--motion-easing);
    border-radius: 0.5rem;
}

input:focus,
textarea:focus,
select:focus {
    animation: inputFocus 0.5s var(--motion-easing) forwards;
    transform: scale(1.02);
    border-color: #21A45A;
    box-shadow: 0 0 0 4px rgba(33, 164, 90, 0.1);
}

/* Placeholder fade-out */
input::placeholder,
textarea::placeholder {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

input:focus::placeholder,
textarea:focus::placeholder {
    opacity: 0;
}

/* ========================================
   SECTION ANIMATIONS
   ======================================== */

/* Section fade-in */
@keyframes sectionEnter {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

section,
[data-motion*="section"],
[class*="section"] {
    animation: sectionEnter 0.8s var(--motion-easing) forwards;
}

/* Staggered sections */
section:nth-of-type(1) { animation-delay: 0s; }
section:nth-of-type(2) { animation-delay: 0.1s; }
section:nth-of-type(3) { animation-delay: 0.2s; }

/* Section divider animation */
section::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    margin-top: 3rem;
}

/* ========================================
   KEYFRAME ANIMATIONS LIBRARY
   ======================================== */

/* Pulse animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

/* Float animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Bounce animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Slide from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide from top */
@keyframes slideInTop {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide from bottom */
@keyframes slideInBottom {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Zoom in */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Rotate in */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.9);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* ========================================
   DATA ATTRIBUTE MOTION EFFECTS
   ======================================== */

/* Apply animations via data-motion attribute */
[data-motion="fade-in"] {
    animation: fadeInText 0.8s var(--motion-easing);
}

[data-motion="slide-left"] {
    animation: slideInLeft 0.8s var(--motion-easing);
}

[data-motion="slide-right"] {
    animation: slideInRight 0.8s var(--motion-easing);
}

[data-motion="slide-top"] {
    animation: slideInTop 0.8s var(--motion-easing);
}

[data-motion="slide-bottom"] {
    animation: slideInBottom 0.8s var(--motion-easing);
}

[data-motion="zoom"] {
    animation: zoomIn 0.8s var(--motion-easing);
}

[data-motion="rotate"] {
    animation: rotateIn 0.8s var(--motion-easing);
}

[data-motion="bounce"] {
    animation: bounce 2s ease-in-out infinite;
}

[data-motion="float"] {
    animation: float 4s ease-in-out infinite;
}

[data-motion="pulse"] {
    animation: pulse 2s ease-in-out infinite;
}

/* ========================================
   PARALLAX EFFECT
   ======================================== */

[data-motion*="parallax"] {
    position: relative;
    overflow: hidden;
}

[data-motion*="parallax"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
    transform: translateZ(0);
}

/* ========================================
   GRADIENT ANIMATIONS
   ======================================== */

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

[data-motion*="gradient"] {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

/* ========================================
   HOVER EFFECTS
   ======================================== */

[data-motion*="hover-lift"]:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

[data-motion*="hover-scale"]:hover {
    transform: scale(1.1);
}

[data-motion*="hover-rotate"]:hover {
    transform: rotate(5deg);
}

[data-motion*="hover-color"]:hover {
    color: #21A45A;
}

/* ========================================
   PERFORMANCE OPTIMIZATION
   ======================================== */

/* GPU acceleration */
section,
[class*="card"],
[data-motion],
img,
video,
button,
a {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Will-change for frequently animated elements */
a:hover,
button:hover,
[data-motion]:hover {
    will-change: transform;
}

/* Smooth transitions for all interactive elements */
[data-interactive],
[role="button"],
[role="link"],
[role="tab"] {
    transition: all 0.45s var(--motion-easing);
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

/* Reduce motion duration on mobile */
@media (max-width: 768px) {
    body {
        --motion-duration: 0.35s;
    }

    img,
    video,
    .card {
        animation-duration: 0.6s;
    }

    section {
        animation-duration: 0.6s;
    }
}

/* Disable parallax on mobile */
@media (max-width: 768px) {
    [data-motion*="parallax"] {
        transform: none !important;
    }
}

/* ========================================
   DARK MODE ADJUSTMENTS
   ======================================== */

[data-theme="dark"] a:hover {
    text-shadow: 0 0 10px rgba(33, 164, 90, 0.5);
}

[data-theme="dark"] button:hover,
[data-theme="dark"] .btn:hover {
    box-shadow: 0 15px 30px rgba(33, 164, 90, 0.2);
}

/* ========================================
   ACCESSIBILITY: FOCUS STATES
   ======================================== */

*:focus-visible {
    outline: 2px solid #21A45A;
    outline-offset: 2px;
}

button:focus-visible {
    box-shadow: 0 0 0 4px rgba(33, 164, 90, 0.2);
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Motion duration utilities */
.motion-fast { --motion-duration: 0.2s; }
.motion-normal { --motion-duration: 0.45s; }
.motion-slow { --motion-duration: 0.8s; }
.motion-veryslow { --motion-duration: 1.2s; }

/* Transition utilities */
.transition-smooth { transition: all var(--motion-duration) var(--motion-easing); }
.transition-bounce { transition: all var(--motion-duration) var(--motion-easing-bounce); }
.transition-smooth-in-out { transition: all var(--motion-duration) var(--motion-easing-in-out); }

/* Animation utilities */
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-bounce { animation: bounce 1s ease-in-out infinite; }
.animate-float { animation: float 4s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }

@keyframes spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(33, 164, 90, 0.4);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(33, 164, 90, 0.7);
}

/* Firefox scrollbar */
* {
    scrollbar-color: rgba(33, 164, 90, 0.4) transparent;
    scrollbar-width: thin;
}
