/* 
 * ==========================================
 * SmartAim Comprehensive Animation System
 * ==========================================
 */

/* 15. SMOOTH PAGE TRANSITIONS */
body {
    transition: opacity 0.3s ease, filter 0.3s ease;
}
body.page-transitioning {
    opacity: 0 !important;
    filter: blur(5px) !important;
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* 17. LOADING SCREEN */
#global-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #0a0a0c;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: transform 0.6s cubic-bezier(0.76, 0, 0.24, 1), opacity 0.4s ease;
}
#global-loader.hidden {
    transform: translateY(-100%);
    pointer-events: none;
}
#global-loader .logo-highlight {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
    animation: loaderPulse 1s ease-in-out alternate infinite;
}
@keyframes loaderPulse {
    from { transform: scale(0.95); opacity: 0.8; filter: drop-shadow(0 0 10px rgba(139,92,246,0.4)); }
    to { transform: scale(1.05); opacity: 1; filter: drop-shadow(0 0 20px rgba(139,92,246,0.8)); }
}

/* 1. PAGE LOAD & 2. SCROLL REVEAL (IntersectionObserver) */
.reveal-up {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.33, 1, 0.68, 1), transform 0.8s cubic-bezier(0.33, 1, 0.68, 1);
    will-change: opacity, transform;
}
.reveal-up.reveal-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Header Slide Down */
.header {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), padding 0.3s ease, background 0.3s ease, backdrop-filter 0.3s ease;
}
.header.header-loaded {
    opacity: 1;
    transform: translateY(0);
}

/* 7. NAVBAR SCROLL BEHAVIOR */
.header.scrolled {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
    background: rgba(10, 10, 12, 0.98) !important;
    backdrop-filter: blur(25px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
.nav-links a {
    position: relative;
}
.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
    border-radius: 2px;
}
.nav-links a:hover::after {
    width: 100%;
}

/* 19. SCROLL PROGRESS BAR */
#scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
    z-index: 100000;
    transition: width 0.1s ease-out;
}

/* 10. GRADIENT MESH BACKGROUND */
.animated-mesh-bg {
    position: absolute;
    inset: 0;
    z-index: -2;
    background: linear-gradient(120deg, #0a0a0c 0%, #170d30 40%, #061e25 80%, #0a0a0c 100%);
    background-size: 400% 400%;
    animation: gradientMesh 20s ease infinite;
}
@keyframes gradientMesh {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 3. PARTICLE SYSTEM HERO */
#hero-canvas {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

/* 11. FLOATING ELEMENTS */
.hero-orb {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: -1;
    will-change: transform;
}
.hero-orb-1 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
    top: -50px;
    left: -50px;
    animation: floatOrb1 15s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
.hero-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.2) 0%, transparent 70%);
    bottom: -100px;
    right: -50px;
    animation: floatOrb2 18s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate-reverse;
}
.hero-orb-3 {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, transparent 70%);
    top: 40%;
    left: 60%;
    animation: floatOrb3 12s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}
@keyframes floatOrb1 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(100px, 80px) scale(1.2); } }
@keyframes floatOrb2 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-120px, -60px) scale(1.1); } }
@keyframes floatOrb3 { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-50px, 100px) scale(0.9); } }

/* 5. HERO TYPING EFFECT */
.typing-cursor {
    display: inline-block;
    width: 3px;
    background-color: var(--primary);
    margin-right: 4px; /* RTL spacing */
    animation: blinkCursor 0.8s step-end infinite;
    vertical-align: bottom;
}
@keyframes blinkCursor {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}

/* 6. GLITCH EFFECT ON LOGO */
.glitch-trigger {
    position: relative;
    display: inline-block;
}
.glitch-trigger::before,
.glitch-trigger::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
}
.glitch-trigger.is-glitching::before {
    left: 3px;
    text-shadow: -2px 0 #06b6d4;
    animation: glitchAction1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    opacity: 1;
}
.glitch-trigger.is-glitching::after {
    left: -3px;
    text-shadow: -2px 0 #8b5cf6;
    animation: glitchAction2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
    opacity: 1;
}
@keyframes glitchAction1 {
    0% { clip-path: inset(20% 0 80% 0); transform: translate(-2px, 2px); }
    20% { clip-path: inset(60% 0 10% 0); transform: translate(2px, -2px); }
    40% { clip-path: inset(40% 0 50% 0); transform: translate(-2px, 2px); }
    60% { clip-path: inset(80% 0 5% 0); transform: translate(2px, -2px); }
    80% { clip-path: inset(10% 0 70% 0); transform: translate(-2px, 2px); }
    100% { clip-path: inset(30% 0 50% 0); transform: translate(0, 0); }
}
@keyframes glitchAction2 {
    0% { clip-path: inset(10% 0 60% 0); transform: translate(2px, -2px); }
    20% { clip-path: inset(30% 0 20% 0); transform: translate(-2px, 2px); }
    40% { clip-path: inset(70% 0 10% 0); transform: translate(2px, -2px); }
    60% { clip-path: inset(20% 0 50% 0); transform: translate(-2px, 2px); }
    80% { clip-path: inset(50% 0 30% 0); transform: translate(2px, -2px); }
    100% { clip-path: inset(5% 0 80% 0); transform: translate(0, 0); }
}

/* 4. CARD 3D TILT & 12. PRODUCT CARDS HOVER */
.tilt-card {
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
}
.tilt-spotlight {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: radial-gradient(600px circle at var(--mouseX, 50%) var(--mouseY, 50%), rgba(255,255,255,0.06), transparent 40%);
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.tilt-card:hover .tilt-spotlight {
    opacity: 1;
}

/* Specific to Product Cards (12) */
.product-card {
    overflow: hidden;
}
.product-card .card-img {
    transition: transform 0.5s cubic-bezier(0.33, 1, 0.68, 1);
}
.product-card:hover .card-img {
    transform: scale(1.08);
}
.product-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(var(--border-angle, 0deg), transparent, rgba(139,92,246,0.6), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 4;
}
.product-card:hover::before {
    opacity: 1;
    animation: borderSpin 3s linear infinite;
}
@keyframes borderSpin { 100% { --border-angle: 360deg; } }
@property --border-angle { syntax: '<angle>'; inherits: true; initial-value: 0deg; }

/* Product Overlay Button */
.product-hover-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    background: rgba(139,92,246,0.9);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    backdrop-filter: blur(5px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 5;
    pointer-events: none;
}
.product-card:hover .product-hover-btn {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.product-card:hover .price {
    color: var(--primary-light) !important;
    transition: color 0.3s ease;
}

/* 8. BUTTON EFFECTS */
.btn {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s, background 0.2s;
}
.btn:active {
    transform: scale(0.95);
}
.magnetic-btn {
    display: inline-block;
}
/* Shimmer */
.btn::after {
    content: '';
    position: absolute;
    top: 0;
    right: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: skewX(-20deg);
    animation: btnShimmer 3s infinite;
}
@keyframes btnShimmer { 0% { right: -100%; } 20%, 100% { right: 200%; } }
/* Ripple */
.ripple {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: rippleAnim 0.6s linear;
    background-color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }

/* 13. STATUS BADGES */
.status-badge.safe {
    position: relative;
}
.status-badge.safe .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    margin-left: 6px;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulseSafe 2s infinite;
}
@keyframes pulseSafe {
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.status-badge.detected {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
    animation: shakeRisk 4s infinite;
}
@keyframes shakeRisk {
    0%, 90%, 100% { transform: translateX(0); }
    92% { transform: translateX(-2px); }
    94% { transform: translateX(2px); }
    96% { transform: translateX(-2px); }
    98% { transform: translateX(2px); }
}

/* 14. MODAL ENTRANCE */
.checkout-modal.active .modal-content, .checkout-modal.active .new-modal-content {
    animation: modalSpringIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.checkout-modal.active .modal-overlay {
    animation: fadeInOverlay 0.4s ease forwards;
}
@keyframes modalSpringIn {
    0% { opacity: 0; transform: scale(0.85) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes fadeInOverlay {
    0% { opacity: 0; backdrop-filter: blur(0px); }
    100% { opacity: 1; backdrop-filter: blur(8px); }
}
/* Modal Inner Stagger */
.checkout-modal.active .panel-title,
.checkout-modal.active .methods-grid,
.checkout-modal.active .info-box,
.checkout-modal.active .cta-btn,
.checkout-modal.active .price-block {
    opacity: 0;
    animation: revealUpSmall 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.checkout-modal.active .panel-title { animation-delay: 0.1s; }
.checkout-modal.active .methods-grid { animation-delay: 0.2s; }
.checkout-modal.active .info-box { animation-delay: 0.3s; }
.checkout-modal.active .cta-btn { animation-delay: 0.4s; }
.checkout-modal.active .price-block { animation-delay: 0.5s; }
@keyframes revealUpSmall {
    0% { opacity: 0; transform: translateY(15px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 16. CHAT MESSAGES */
.chat-message.anim-enter {
    opacity: 0;
    transform: translateY(15px);
    animation: chatSlideUp 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes chatSlideUp {
    to { opacity: 1; transform: translateY(0); }
}
.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    margin: 0 2px;
    animation: typingWave 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingWave {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 18. FOOTER LINKS */
.footer-links a {
    display: inline-flex;
    align-items: center;
    transition: transform 0.3s ease, color 0.3s ease;
}
.footer-links a::before {
    content: '←';
    position: absolute;
    right: -20px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    font-size: 0.9em;
}
.footer-links a:hover {
    transform: translateX(-10px); /* RTL */
    color: var(--primary-light);
}
.footer-links a:hover::before {
    opacity: 1;
    transform: translateX(0);
}

/* Reduced Motion Override */
@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;
    }
    .hero-orb { display: none; }
}
