/* ============================================
   AR/VR Motion Graphics — Product Preview
   Immersive holographic experience
   ============================================ */

/* ─── Keyframes ─── */
@keyframes arScanLine {
  0% { top: -2px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

@keyframes arGridPulse {
  0%, 100% { opacity: 0.03; }
  50% { opacity: 0.08; }
}

@keyframes arHologramFlicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.7; }
  94% { opacity: 1; }
  96% { opacity: 0.85; }
  97% { opacity: 1; }
}

@keyframes arDataStream {
  0% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes arCornerDraw {
  0% { width: 0; height: 0; opacity: 0; }
  50% { opacity: 1; }
  100% { width: 20px; height: 20px; opacity: 1; }
}

@keyframes arParticleFloat {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.6; }
  25% { transform: translate(10px, -15px) scale(1.2); opacity: 0.9; }
  50% { transform: translate(-5px, -25px) scale(0.8); opacity: 0.5; }
  75% { transform: translate(15px, -10px) scale(1.1); opacity: 0.8; }
}

@keyframes arPulseRing {
  0% { transform: scale(0.8); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0.2; }
  100% { transform: scale(0.8); opacity: 0.6; }
}

@keyframes arGlowPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(124, 58, 237, 0.15), 0 0 30px rgba(124, 58, 237, 0.05); }
  50% { box-shadow: 0 0 25px rgba(124, 58, 237, 0.3), 0 0 60px rgba(124, 58, 237, 0.1); }
}

@keyframes arShimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes arTextReveal {
  0% { clip-path: inset(0 100% 0 0); opacity: 0; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; }
}

@keyframes arModalEnter {
  0% {
    opacity: 0;
    transform: perspective(1200px) rotateY(-8deg) rotateX(4deg) translateZ(-80px) scale(0.9);
  }
  60% {
    opacity: 1;
    transform: perspective(1200px) rotateY(2deg) rotateX(-1deg) translateZ(10px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: perspective(1200px) rotateY(0) rotateX(0) translateZ(0) scale(1);
  }
}

@keyframes arModalExit {
  0% {
    opacity: 1;
    transform: perspective(1200px) rotateY(0) rotateX(0) translateZ(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: perspective(1200px) rotateY(8deg) rotateX(-4deg) translateZ(-100px) scale(0.85);
  }
}

@keyframes arOverlayEnter {
  0% { 
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
  100% { 
    opacity: 1;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
}

@keyframes arImageFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes arBorderTrace {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

@keyframes arHudSlideIn {
  0% { transform: translateX(-20px); opacity: 0; filter: blur(4px); }
  100% { transform: translateX(0); opacity: 1; filter: blur(0); }
}

@keyframes arBadgePop {
  0% { transform: scale(0) rotate(-12deg); }
  60% { transform: scale(1.15) rotate(2deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes arPriceGlow {
  0%, 100% { text-shadow: 0 0 8px rgba(124, 58, 237, 0.3); }
  50% { text-shadow: 0 0 20px rgba(124, 58, 237, 0.6), 0 0 40px rgba(124, 58, 237, 0.2); }
}

@keyframes arCardEntrance {
  0% {
    opacity: 0;
    transform: perspective(800px) rotateX(8deg) translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: perspective(800px) rotateX(0) translateY(0) scale(1);
  }
}

@keyframes arHexGrid {
  0%, 100% { opacity: 0.02; }
  50% { opacity: 0.06; }
}

@keyframes arParticleOrbit {
  0% { transform: rotate(0deg) translateX(60px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(60px) rotate(-360deg); }
}

/* ─── Modal Overlay AR Enhancement ─── */
.modal-overlay.modal-active {
  animation: arOverlayEnter 0.4s ease-out forwards;
  background: radial-gradient(ellipse at center, rgba(124, 58, 237, 0.08) 0%, rgba(0, 0, 0, 0.85) 70%);
}

/* ─── Modal Card — AR 3D entrance ─── */
.modal-active .modal-card {
  animation: arModalEnter 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-style: preserve-3d;
  border: 1px solid rgba(124, 58, 237, 0.2);
  box-shadow: 
    0 25px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(124, 58, 237, 0.1),
    0 0 40px rgba(124, 58, 237, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.modal-closing .modal-card {
  animation: arModalExit 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

/* Holographic border trace */
.modal-active .modal-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(124, 58, 237, 0.4) 25%,
    rgba(168, 85, 247, 0.6) 50%,
    rgba(124, 58, 237, 0.4) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: arBorderTrace 3s linear infinite;
  -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;
  z-index: 10;
}

/* ─── AR Image Section ─── */
.modal-active .modal-img-section {
  position: relative;
  overflow: hidden;
}

/* Holographic grid overlay on image */
.modal-active .modal-img-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.06) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: arGridPulse 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 3;
}

/* Scan line effect */
.modal-active .modal-img-section::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(124, 58, 237, 0.3) 20%,
    rgba(168, 85, 247, 0.8) 50%,
    rgba(124, 58, 237, 0.3) 80%,
    transparent 100%
  );
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.4), 0 0 30px rgba(124, 58, 237, 0.2);
  animation: arScanLine 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 4;
}



/* ─── AR HUD Info Elements ─── */
.modal-active .modal-breadcrumb {
  animation: arHudSlideIn 0.5s ease-out 0.3s both;
}

.modal-active .modal-product-name {
  animation: arTextReveal 0.6s ease-out 0.4s both;
  position: relative;
}

.modal-active .modal-product-name::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 40px;
  height: 2px;
  background: var(--primary-gradient);
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
  animation: arDataStream 0.4s ease-out 0.6s both;
}

.modal-active .modal-rating-row {
  animation: arHudSlideIn 0.5s ease-out 0.5s both;
}

.modal-active .modal-product-price {
  animation: arDataStream 0.5s ease-out 0.55s both;
}

.modal-active .modal-product-price .price-val {
  animation: arPriceGlow 3s ease-in-out infinite;
  animation-delay: 1s;
}

.modal-active .modal-desc-title {
  animation: arHudSlideIn 0.4s ease-out 0.6s both;
}

.modal-active .modal-desc {
  animation: arDataStream 0.5s ease-out 0.65s both;
}

.modal-active .modal-highlights {
  animation: arDataStream 0.5s ease-out 0.7s both;
}

.modal-active .modal-highlight-item {
  position: relative;
  transition: all 0.3s ease;
}

.modal-active .modal-highlight-item:hover {
  color: var(--primary);
  text-shadow: 0 0 10px rgba(124, 58, 237, 0.3);
}

.modal-active .modal-highlight-item:hover svg {
  filter: drop-shadow(0 0 4px rgba(124, 58, 237, 0.5));
}

/* Variant options AR style */
.modal-active .variant-option {
  transition: all 0.3s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}

.modal-active .variant-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(124, 58, 237, 0.05) 50%,
    transparent 100%
  );
  transition: left 0.5s ease;
}

.modal-active .variant-option:hover::before {
  left: 100%;
}

.modal-active .variant-option:hover {
  transform: translateX(4px);
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.1);
}

.modal-active .variant-option.selected {
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.15), inset 0 0 15px rgba(124, 58, 237, 0.05);
}

/* Buy button AR style */
.modal-active .btn-buy-modal {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.modal-active .btn-buy-modal::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.modal-active .btn-buy-modal:hover::after {
  width: 300%;
  height: 300%;
}

.modal-active .btn-buy-modal:hover {
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.4), 0 0 15px rgba(124, 58, 237, 0.2);
  transform: translateY(-2px);
}

/* Quantity selector AR glow */
.modal-active .qty-btn:hover {
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
  border-color: rgba(124, 58, 237, 0.4);
}



/* ─── Product Cards — AR entrance (overridden by bouncePopIn above) ─── */
/* Original arCardEntrance kept for fallback contexts */

/* Product card AR hover — holographic tilt handled by JS */
.product-card {
  transform-style: preserve-3d;
  perspective: 800px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
              border-color 0.3s ease, 
              box-shadow 0.3s ease;
}

.product-card:hover {
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(124, 58, 237, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* AR glow accent on card hover */
.product-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(124, 58, 237, 0) 0%,
    rgba(124, 58, 237, 0.1) 50%,
    rgba(124, 58, 237, 0) 100%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 0;
}

.product-card:hover::after {
  opacity: 1;
}

/* AR badge entrance */
.product-badges .badge-new,
.product-badges .badge-hot {
  animation: arBadgePop 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.product-badges .badge-new { animation-delay: 0.3s; }
.product-badges .badge-hot { animation-delay: 0.4s; }

/* ─── Category Preview Cards — AR style ─── */
.cat-preview-card {
  transform-style: preserve-3d;
  perspective: 800px;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s ease,
              box-shadow 0.3s ease;
}

.cat-preview-card:hover {
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.4),
    0 0 30px rgba(124, 58, 237, 0.08);
}

/* ─── Bounce / Pop-in Keyframes ─── */
@keyframes bouncePopIn {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(40px);
  }
  50% {
    opacity: 1;
    transform: scale(1.05) translateY(-8px);
  }
  70% {
    transform: scale(0.97) translateY(2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes elasticSlideUp {
  0% {
    opacity: 0;
    transform: translateY(60px) scale(0.9);
  }
  40% {
    opacity: 1;
    transform: translateY(-12px) scale(1.02);
  }
  65% {
    transform: translateY(6px) scale(0.99);
  }
  85% {
    transform: translateY(-2px) scale(1.005);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes titleBounceIn {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.8);
    filter: blur(8px);
  }
  45% {
    opacity: 1;
    transform: translateY(8px) scale(1.04);
    filter: blur(0);
  }
  65% {
    transform: translateY(-4px) scale(0.98);
  }
  80% {
    transform: translateY(2px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes subtitleFadeUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(4px);
  }
  60% {
    opacity: 1;
    transform: translateY(-4px);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes searchBarSlide {
  0% {
    opacity: 0;
    transform: translateY(30px) scaleX(0.7);
  }
  50% {
    opacity: 1;
    transform: translateY(-6px) scaleX(1.02);
  }
  75% {
    transform: translateY(2px) scaleX(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scaleX(1);
  }
}

@keyframes catCardPop {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(30px) rotate(-2deg);
  }
  55% {
    opacity: 1;
    transform: scale(1.06) translateY(-5px) rotate(0.5deg);
  }
  75% {
    transform: scale(0.97) translateY(3px) rotate(-0.3deg);
  }
  90% {
    transform: scale(1.01) translateY(-1px) rotate(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotate(0);
  }
}

@keyframes productBounceIn {
  0% {
    opacity: 0;
    transform: perspective(800px) rotateX(12deg) translateY(50px) scale(0.85);
  }
  45% {
    opacity: 1;
    transform: perspective(800px) rotateX(-3deg) translateY(-10px) scale(1.03);
  }
  70% {
    transform: perspective(800px) rotateX(1.5deg) translateY(4px) scale(0.99);
  }
  90% {
    transform: perspective(800px) rotateX(-0.5deg) translateY(-1px) scale(1.005);
  }
  100% {
    opacity: 1;
    transform: perspective(800px) rotateX(0) translateY(0) scale(1);
  }
}

@keyframes shimmerGlow {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

/* ─── Shop Header Entrance Animations ─── */
.shop-header.anim-visible h1 {
  animation: titleBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.shop-header.anim-visible p {
  animation: subtitleFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.shop-header.anim-visible .search-box {
  animation: searchBarSlide 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

/* ─── Category Preview Cards — Staggered Bounce Pop ─── */
.category-previews.anim-visible .cat-preview-card {
  animation: catCardPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.category-previews.anim-visible .cat-preview-card:nth-child(1) { animation-delay: 0.08s; }
.category-previews.anim-visible .cat-preview-card:nth-child(2) { animation-delay: 0.16s; }
.category-previews.anim-visible .cat-preview-card:nth-child(3) { animation-delay: 0.24s; }
.category-previews.anim-visible .cat-preview-card:nth-child(4) { animation-delay: 0.32s; }
.category-previews.anim-visible .cat-preview-card:nth-child(5) { animation-delay: 0.40s; }
.category-previews.anim-visible .cat-preview-card:nth-child(6) { animation-delay: 0.48s; }
.category-previews.anim-visible .cat-preview-card:nth-child(7) { animation-delay: 0.56s; }
.category-previews.anim-visible .cat-preview-card:nth-child(8) { animation-delay: 0.64s; }
.category-previews.anim-visible .cat-preview-card:nth-child(9) { animation-delay: 0.72s; }

/* Shimmer glow line on category card hover */
.cat-preview-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.6), rgba(168,85,247,0.8), rgba(124,58,237,0.6), transparent);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
}
.cat-preview-card:hover::before {
  opacity: 1;
  animation: shimmerGlow 2s linear infinite;
}

/* ─── Product Cards — Enhanced Bounce Entrance ─── */
.products-grid .product-card {
  opacity: 0;
  animation: productBounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center bottom;
  will-change: transform, opacity;
}

.products-grid .product-card:nth-child(1)  { animation-delay: 0.05s; }
.products-grid .product-card:nth-child(2)  { animation-delay: 0.12s; }
.products-grid .product-card:nth-child(3)  { animation-delay: 0.19s; }
.products-grid .product-card:nth-child(4)  { animation-delay: 0.26s; }
.products-grid .product-card:nth-child(5)  { animation-delay: 0.33s; }
.products-grid .product-card:nth-child(6)  { animation-delay: 0.40s; }
.products-grid .product-card:nth-child(7)  { animation-delay: 0.47s; }
.products-grid .product-card:nth-child(8)  { animation-delay: 0.54s; }
.products-grid .product-card:nth-child(9)  { animation-delay: 0.61s; }
.products-grid .product-card:nth-child(10) { animation-delay: 0.68s; }
.products-grid .product-card:nth-child(11) { animation-delay: 0.75s; }
.products-grid .product-card:nth-child(12) { animation-delay: 0.82s; }

/* ─── Buy Button Bounce on Hover ─── */
.btn-buy-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, background 0.3s ease;
}
.btn-buy-card:hover:not(.disabled) {
  transform: scale(1.05) translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}
.btn-buy-card:active:not(.disabled) {
  transform: scale(0.97);
}

/* ─── Category Back Bar Entrance ─── */
.category-back-bar {
  animation: elasticSlideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ─── Page-level: fade-up animations ─── */
[data-anim="fade-up"] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-anim="fade-up"].anim-visible {
  opacity: 1;
  transform: translateY(0);
}

[data-anim-delay="1"] { transition-delay: 0.1s; }
[data-anim-delay="2"] { transition-delay: 0.2s; }
[data-anim-delay="3"] { transition-delay: 0.3s; }

/* ─── Interactive AR Tilt Reflection ─── */
.ar-tilt-reflection {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(124, 58, 237, 0.08) 0%,
    transparent 60%
  );
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.modal-active .modal-img-section:hover .ar-tilt-reflection,
.product-card:hover .ar-tilt-reflection {
  opacity: 1;
}

/* ─── Responsive AR Adjustments ─── */
@media (max-width: 768px) {
  .modal-active .modal-card {
    animation: arModalEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }


}

/* ─── Hero Entrance Animations ─── */
.hero-entrance {
  opacity: 0;
  transform: translateY(24px);
}

body.brand-ready .hero-entrance {
  animation: czHeroIn 0.65s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

body.brand-ready .hero-entrance-d1 { animation-delay: 0.08s; }
body.brand-ready .hero-entrance-d2 { animation-delay: 0.16s; }
body.brand-ready .hero-entrance-d3 { animation-delay: 0.24s; }
body.brand-ready .hero-entrance-d4 { animation-delay: 0.32s; }

@keyframes czHeroIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hero-entrance {
    opacity: 1 !important;
    transform: none !important;
  }
}
