/* ============================================
   ADVANCED INTERACTIVE ANIMATIONS
   Merged from LifeSync design system
   ============================================ */

/* ============================================
   1. SCROLL REVEAL
   ============================================ */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ============================================
   2. PAGE TRANSITIONS
   ============================================ */
.page-transition {
    animation: fadeSlideIn 0.5s ease forwards;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   3. TILT CARD 3D EFFECT
   ============================================ */
.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
}
.tilt-card-inner {
    transition: transform 0.1s ease-out;
}
.tilt-card:hover .tilt-card-inner {
    transform: rotateX(var(--rotateX)) rotateY(var(--rotateY));
}
.tilt-card .tilt-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    border-radius: inherit;
}
.tilt-card:hover .tilt-shine { opacity: 1; }

/* ============================================
   4. RIPPLE EFFECT
   ============================================ */
.ripple-btn {
    position: relative;
    overflow: hidden;
}
.ripple-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    animation: ripple-effect 0.6s linear;
    pointer-events: none;
}
@keyframes ripple-effect {
    to { transform: scale(4); opacity: 0; }
}

/* Legacy ripple container */
.ripple-container {
    position: relative;
    overflow: hidden;
}
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(126, 82, 160, 0.5);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}
@keyframes rippleEffect {
    to { transform: scale(4); opacity: 0; }
}

/* ============================================
   5. GLITCH EFFECT
   ============================================ */
.glitch {
    position: relative;
}
.glitch:hover {
    animation: glitch-skew 0.5s infinite linear alternate-reverse;
}
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
}
.glitch:hover::before {
    opacity: 0.8;
    color: #7E52A0;
    animation: glitch-before 0.3s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}
.glitch:hover::after {
    opacity: 0.8;
    color: #BF5A8E;
    animation: glitch-after 0.3s infinite linear alternate-reverse;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}
@keyframes glitch-before {
    0% { transform: translateX(-2px); }
    100% { transform: translateX(2px); }
}
@keyframes glitch-after {
    0% { transform: translateX(2px); }
    100% { transform: translateX(-2px); }
}
@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    20% { transform: skew(-1deg); }
    40% { transform: skew(1deg); }
    60% { transform: skew(0deg); }
    80% { transform: skew(1deg); }
    100% { transform: skew(-1deg); }
}

/* ============================================
   6. NEON PULSE
   ============================================ */
.neon-pulse {
    animation: neonPulse 2s ease-in-out infinite;
}
@keyframes neonPulse {
    0%, 100% {
        text-shadow:
            0 0 5px #7E52A0,
            0 0 10px #7E52A0,
            0 0 20px #BF5A8E;
    }
    50% {
        text-shadow:
            0 0 10px #7E52A0,
            0 0 20px #7E52A0,
            0 0 40px #BF5A8E,
            0 0 60px #BF5A8E;
    }
}

/* ============================================
   7. ELASTIC SCALE
   ============================================ */
.elastic-scale {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.elastic-scale:hover { transform: scale(1.08); }
.elastic-scale:active { transform: scale(0.95); }

/* ============================================
   8. MAGNETIC BUTTONS
   ============================================ */
.magnetic-btn {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}
.magnetic-btn:hover {
    transform: scale(1.05);
}

/* ============================================
   9. SHAKE ANIMATION
   ============================================ */
.shake-hover:hover {
    animation: shake 0.5s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px) rotate(-1deg); }
    40% { transform: translateX(5px) rotate(1deg); }
    60% { transform: translateX(-3px) rotate(-0.5deg); }
    80% { transform: translateX(3px) rotate(0.5deg); }
}

/* ============================================
   10. BOUNCE HOVER
   ============================================ */
.bounce-hover {
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.bounce-hover:hover {
    animation: bounceHover 0.6s ease;
}
@keyframes bounceHover {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-15px); }
    50% { transform: translateY(-7px); }
    75% { transform: translateY(-3px); }
}

/* ============================================
   11. ROTATING BORDER
   ============================================ */
.rotating-border {
    position: relative;
}
.rotating-border::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: conic-gradient(from 0deg, #7E52A0, #BF5A8E, #E91E8C, #BF5A8E, #7E52A0);
    border-radius: inherit;
    z-index: -1;
    animation: rotate-border 3s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}
.rotating-border:hover::before { opacity: 1; }
@keyframes rotate-border {
    to { transform: rotate(360deg); }
}

/* ============================================
   12. MORPHING SHAPE
   ============================================ */
.morph-shape {
    animation: morph 8s ease-in-out infinite;
}
@keyframes morph {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
    50% { border-radius: 50% 60% 30% 60% / 30% 40% 70% 60%; }
    75% { border-radius: 60% 40% 60% 30% / 70% 50% 40% 50%; }
}

/* ============================================
   13. CLICK BURST
   ============================================ */
.click-burst {
    position: relative;
}
.click-burst::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(191,90,142,0.5) 0%, transparent 70%);
    opacity: 0;
    transform: scale(0);
    border-radius: inherit;
    pointer-events: none;
}
.click-burst.burst::before {
    animation: burst 0.5s ease-out forwards;
}
@keyframes burst {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* Burst particles */
.burst-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: burstParticle 0.8s ease-out forwards;
}
@keyframes burstParticle {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* ============================================
   14. CARD STACK
   ============================================ */
.card-stack {
    position: relative;
}
.card-stack::before, .card-stack::after {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    border-radius: inherit;
    border: 1px solid rgba(255,255,255,0.05);
    z-index: -1;
    transition: all 0.4s ease;
}
.card-stack::before {
    transform: translateY(8px) scale(0.95);
    opacity: 0.5;
}
.card-stack::after {
    transform: translateY(16px) scale(0.9);
    opacity: 0.3;
}
.card-stack:hover::before {
    transform: translateY(12px) translateX(8px) rotate(2deg) scale(0.95);
}
.card-stack:hover::after {
    transform: translateY(24px) translateX(-8px) rotate(-2deg) scale(0.9);
}

/* ============================================
   15. GRADIENT UNDERLINE
   ============================================ */
.gradient-underline {
    position: relative;
    display: inline-block;
}
.gradient-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #7E52A0, #BF5A8E, #7E52A0);
    background-size: 200% 100%;
    transition: width 0.4s ease;
}
.gradient-underline:hover::after {
    width: 100%;
    animation: gradientSlide 3s linear infinite;
}
@keyframes gradientSlide {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

/* Hover underline (LifeSync style) */
.hover-underline {
    position: relative;
}
.hover-underline::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #7E52A0, #BF5A8E);
    transition: width 0.3s ease;
}
.hover-underline:hover::after { width: 100%; }

/* ============================================
   16. STAGGER ANIMATION
   ============================================ */
.stagger-item { opacity: 0; transform: translateY(30px); }
.stagger-item.animate {
    animation: stagger-in 0.6s ease forwards;
}
@keyframes stagger-in {
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   17. LOADING STATES
   ============================================ */
.loading-shimmer {
    background: linear-gradient(90deg,
        rgba(126, 82, 160, 0.1) 0%,
        rgba(126, 82, 160, 0.3) 50%,
        rgba(126, 82, 160, 0.1) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ============================================
   18. BEFORE/AFTER SLIDER
   ============================================ */
.ba-container {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    background: #0d1424;
}
.ba-before, .ba-after {
    position: relative;
    width: 100%; height: 100%;
}
.ba-after {
    position: absolute;
    top: 0; left: 0;
    overflow: hidden;
}
.ba-slider {
    position: absolute;
    top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #7E52A0, #BF5A8E);
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
    animation: sliderIntro 0.8s ease-out;
}
.ba-slider::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 40px; height: 40px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}
.ba-slider:hover::before {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, #7E52A0, #BF5A8E);
    box-shadow: 0 6px 20px rgba(126, 82, 160, 0.5);
}
@keyframes sliderIntro {
    0% { left: 50%; opacity: 0; }
    100% { left: 50%; opacity: 1; }
}
.ba-label {
    pointer-events: none;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 5;
}
.ba-label-before { background: rgba(239, 68, 68, 0.8); }
.ba-label-after { background: rgba(34, 197, 94, 0.8); }

/* ============================================
   19. METRIC CARD ENHANCEMENTS
   ============================================ */
.metric-card {
    transition: all 0.3s ease;
}
.metric-card:hover {
    background: rgba(126, 82, 160, 0.2);
    border-color: rgba(126, 82, 160, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(126, 82, 160, 0.2);
}

/* ============================================
   20. ISLAMIC PATTERN ANIMATIONS
   ============================================ */
.pattern-layer-1 {
    animation: patternShift 30s ease-in-out infinite;
}
.pattern-layer-2 {
    animation: patternShift 25s ease-in-out infinite reverse;
}
.pattern-layer-3 {
    animation: patternRotate 60s linear infinite;
    transform-origin: center center;
}
.pattern-layer-4 {
    animation: zellige-shimmer 10s ease-in-out infinite;
}
.islamic-star {
    animation: starGlow 4s ease-in-out infinite;
}
.geometric-line {
    animation: geometricPulse 3s ease-in-out infinite;
}
.arabesque path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: arabesque-draw 8s ease-in-out infinite;
}

@keyframes patternShift {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(25px) translateY(10px); }
    50% { transform: translateX(0) translateY(20px); }
    75% { transform: translateX(-25px) translateY(10px); }
}
@keyframes patternRotate {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes starGlow {
    0%, 100% { filter: drop-shadow(0 0 2px rgba(126,82,160,0.3)); }
    50% { filter: drop-shadow(0 0 8px rgba(191,90,142,0.6)); }
}
@keyframes geometricPulse {
    0%, 100% { stroke-width: 0.5; opacity: 0.4; }
    50% { stroke-width: 1.2; opacity: 0.8; }
}
@keyframes arabesque-draw {
    0%, 100% { stroke-dashoffset: 200; }
    50% { stroke-dashoffset: 0; }
}
@keyframes zellige-shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .cursor-glow, .star, .islamic-pattern-bg { display: none; }
}

@media (max-width: 768px) {
    .cursor-glow { display: none; }
    .tilt-card { transform: none !important; }
    .magnetic-btn { transform: none !important; }
    .neon-pulse { animation-duration: 3s; }
}
