/* ===========================================
   التاج للمستلزمات الطبية - Optimized Animations
   Performance-focused for mobile
   =========================================== */

:root {
  --ease-luxury: cubic-bezier(0.23, 1, 0.32, 1);
  --duration-page: 0.3s;
  --primary-color: #0A2463;
}

/* ============ Page Transitions - Optimized ============ */
body {
  opacity: 0;
  transition: opacity var(--duration-page) ease-out;
  /* Safety: show page after 1.5s even if JS fails */
  animation: forceShowPage 0s 1.5s forwards;
}

@keyframes forceShowPage {
  to { opacity: 1; }
}

body.page-loaded {
  opacity: 1;
  animation: none;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  body {
    opacity: 1;
  }
}

/* Content Slide Up on Load - Use transform3d for GPU acceleration */
main {
  transform: translateY(10px);
  transition: transform var(--duration-page) ease-out;
  will-change: transform;
}

body.page-loaded main {
  transform: translateY(0);
  will-change: auto;
}

/* ============ Typography Reveals ============ */
.text-reveal {
  overflow: hidden;
  position: relative;
  display: block;
}

.text-reveal span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 1s var(--ease-luxury);
}

.text-reveal.visible span {
  transform: translateY(0);
}

/* ============ Modern Hover Effects (Luxury) ============ */
.hover-scale-clean {
  transition: transform 0.5s var(--ease-luxury);
}

.hover-scale-clean:hover {
  transform: scale(1.03);
}

.hover-shadow-colored {
  transition: all 0.4s ease;
}

.hover-shadow-colored:hover {
  box-shadow: 0 20px 40px -10px rgba(10, 36, 99, 0.25);
  /* Colored shadow */
  transform: translateY(-5px);
}

/* ============ Button Micro-Interactions ============ */
.btn-modern {
  position: relative;
  overflow: hidden;
}

.btn-modern::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.1);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease-luxury);
}

.btn-modern:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ============ Infinite Marquee (Optional Trend) ============ */
.marquee-container {
  overflow: hidden;
  white-space: nowrap;
}

.marquee-content {
  display: inline-block;
  animation: marquee 20s linear infinite;
}

@keyframes marquee {
  0% {
    transform: translateX(0);
  }

  100% {
    transform: translateX(-50%);
  }
}

/* ============ Skeleton Loading Animation ============ */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ============ Scroll Reveal (Reset) ============ */
.reveal-up {
  opacity: 0;
  transform: translateY(40px);
  transition: all 1s var(--ease-luxury);
}

.reveal-up.active {
  opacity: 1;
  transform: translateY(0);
}

/* ============ Button Ripple Effect ============ */
.btn, .header-action-btn, .product-action-btn, .hero-arrow {
  position: relative;
  overflow: hidden;
}

.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple-effect 0.6s ease-out;
  pointer-events: none;
}

@keyframes ripple-effect {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ============ Staggered Grid Animation ============ */
.product-card, .category-card, .feature-card, .service-card {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s var(--ease-luxury), transform 0.5s var(--ease-luxury);
}

/* Only animate when JS is ready - progressive enhancement */
.js-animations-ready .product-card,
.js-animations-ready .category-card,
.js-animations-ready .feature-card,
.js-animations-ready .service-card {
  opacity: 0;
  transform: translateY(30px);
}

.product-card.active, .category-card.active, .feature-card.active, .service-card.active,
.js-animations-ready .product-card.active,
.js-animations-ready .category-card.active,
.js-animations-ready .feature-card.active,
.js-animations-ready .service-card.active {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered delay for grid items */
.product-card:nth-child(1), .category-card:nth-child(1), .feature-card:nth-child(1) { transition-delay: 0ms; }
.product-card:nth-child(2), .category-card:nth-child(2), .feature-card:nth-child(2) { transition-delay: 60ms; }
.product-card:nth-child(3), .category-card:nth-child(3), .feature-card:nth-child(3) { transition-delay: 120ms; }
.product-card:nth-child(4), .category-card:nth-child(4), .feature-card:nth-child(4) { transition-delay: 180ms; }
.product-card:nth-child(5), .category-card:nth-child(5) { transition-delay: 240ms; }
.product-card:nth-child(6), .category-card:nth-child(6) { transition-delay: 300ms; }
.product-card:nth-child(7) { transition-delay: 360ms; }
.product-card:nth-child(8) { transition-delay: 420ms; }

/* ============ Smooth Image Load ============ */
.product-card-image img {
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Progressive enhancement: only fade-in if JS adds the class */
.js-animations-ready .product-card-image img {
  opacity: 0;
}

.js-animations-ready .product-card-image img.loaded,
.product-card-image img.loaded {
  opacity: 1;
}

/* ============ Cart Sidebar Smooth ============ */
.cart-sidebar {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-overlay {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* ============ Toast Animation ============ */
.toast {
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ============ Price Pulse on Discount ============ */
@keyframes price-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.product-badge.sale {
  animation: price-pulse 2s ease-in-out infinite;
}

/* ============ WhatsApp Float Bounce ============ */
@keyframes float-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.whatsapp-float {
  animation: float-bounce 3s ease-in-out infinite;
}

.whatsapp-float:hover {
  animation: none;
  transform: scale(1.1);
}

/* ============ Modern Store Animations ============ */

/* Smooth slide-in for sections on scroll */
.section, .products-section, .categories-section, .features-section {
  opacity: 1;
}

.js-animations-ready .section,
.js-animations-ready .products-section,
.js-animations-ready .categories-section,
.js-animations-ready .features-section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js-animations-ready .section.visible,
.js-animations-ready .products-section.visible,
.js-animations-ready .categories-section.visible,
.js-animations-ready .features-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Modern card press effect for mobile */
@media (max-width: 768px) {
  .product-card:active {
    transform: scale(0.97);
    transition: transform 0.15s ease;
  }
  
  .category-card:active {
    transform: scale(0.95);
    transition: transform 0.15s ease;
  }
  
  .btn:active, button:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
  }
}

/* Smooth count badge animation */
@keyframes badge-pop {
  0% { transform: translateX(14px) scale(1); }
  50% { transform: translateX(14px) scale(1.3); }
  100% { transform: translateX(14px) scale(1); }
}

.bottom-cart-count.updated {
  animation: badge-pop 0.3s ease;
}

@keyframes header-badge-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.cart-count.updated {
  animation: header-badge-pop 0.3s ease;
}

/* Smooth hero gradient animation */
@keyframes hero-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hero-slide {
  background-size: 200% 200%;
}

/* Product image hover zoom */
.product-card-image {
  overflow: hidden;
}

.product-card-image img {
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.product-card:hover .product-card-image img {
  transform: scale(1.08);
}

/* Smooth mobile bottom nav indicator */
.mobile-bottom-nav .bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--red-main, #c90000);
  border-radius: 0 0 3px 3px;
}

/* Add to cart success flash */
@keyframes cart-success-flash {
  0% { background: var(--primary-500); }
  30% { background: var(--primary-light, #1E40AF); }
  100% { background: var(--primary-500); }
}

.add-to-cart-btn.added {
  animation: cart-success-flash 0.8s ease;
}

/* Parallax-like scroll effect for hero */
@media (min-width: 769px) {
  .hero-image img {
    transition: transform 0.3s ease;
  }
}

/* iOS momentum scrolling improvements */
.cart-items,
.search-suggestions,
.products-grid {
  -webkit-overflow-scrolling: touch;
}