/* 
 * 3D Effects CSS for Terzon Homepage
 * Provides styles for 3D animations, parallax effects and depth
 */

/* Base 3D styles */
:root {
  --card-tilt-amount: 5deg;
  --card-depth: 10px;
  --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  --card-shadow-dark: 0 10px 30px rgba(0, 0, 0, 0.4);
  --parallax-depth: 20px;
}

/* 3D Card Base */
.card-3d {
  transform-style: preserve-3d;
  perspective: 1000px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Inner card container to handle 3D transforms */
.card-3d-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.2s ease;
}

/* Smooth lift effect on hover */
.card-3d:hover {
  transform: translateZ(var(--card-depth));
  box-shadow: var(--card-shadow);
}

body.dark-mode .card-3d:hover {
  box-shadow: var(--card-shadow-dark);
}

/* 3D effects for product images */
.img-3d {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.card-3d:hover .img-3d {
  transform: translateZ(15px);
}

/* 3D effects for category section */
.category-card {
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.category-icon {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.card-3d:hover .category-icon {
  transform: translateZ(25px);
}

/* 3D effects for text elements */
.hero-title, .hero-subtitle, .section-title {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.hero-title {
  transform: translateZ(10px);
}

.hero-subtitle {
  transform: translateZ(5px);
}

/* Hero section 3D enhancements */
.hero-section {
  perspective: 1000px;
  overflow: hidden;
}

.hero-content {
  transform-style: preserve-3d;
  z-index: 2;
}

/* Enhanced Hero title and subtitle */
.hero-title {
  transform-style: preserve-3d;
  margin-bottom: 1.5rem;
  position: relative;
}

.hero-title .accent-text {
  background: linear-gradient(90deg, #7928ca, #ff0080);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
  position: relative;
  transform: translateZ(10px);
  text-shadow: 0 5px 15px rgba(255, 0, 128, 0.2);
}

body.dark-mode .hero-title .accent-text {
  background: linear-gradient(90deg, #35a79c, #4ecdc4);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 5px 15px rgba(53, 167, 156, 0.3);
}

.hero-subtitle {
  transform: translateZ(5px);
  font-size: 1.1rem;
  max-width: 90%;
  margin-bottom: 2rem;
  line-height: 1.6;
}

/* Enhanced 3D Buttons */
.btn-3d-special {
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-position 0.5s ease;
  position: relative;
  overflow: visible;
}

.btn-3d-special:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: inherit;
  filter: blur(10px);
  opacity: 0;
  z-index: -1;
  border-radius: inherit;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateZ(-10px) scale(0.9);
}

.btn-3d-special:hover {
  transform: translateY(-8px) translateZ(20px);
  box-shadow: 0 15px 35px rgba(121, 40, 202, 0.3);
  background-position: right center;
}

.btn-3d-special:hover:before {
  opacity: 0.7;
  transform: translateZ(-10px) scale(1);
}

body.dark-mode .btn-primary.btn-3d-special:hover {
  box-shadow: 0 15px 35px rgba(53, 167, 156, 0.4);
}

.btn-primary.btn-3d-special {
  background-size: 200% auto;
}

.btn-secondary.btn-3d-special:hover {
  box-shadow: 0 15px 35px rgba(247, 183, 49, 0.3);
}

/* 3D Logo Effects */
.logo-3d {
  position: relative;
  transform-style: preserve-3d;
  perspective: 500px;
  transition: all 0.3s ease;
}

.logo-container {
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.3s ease;
  overflow: visible;
}

.logo-img {
  transform-style: preserve-3d;
  transition: all 0.3s ease;
  position: relative;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.1));
}

.logo-shine {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0) 30%,
    rgba(255, 255, 255, 0.5) 45%,
    rgba(255, 255, 255, 0.8) 50%,
    rgba(255, 255, 255, 0.5) 55%,
    rgba(255, 255, 255, 0) 70%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateZ(1px);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: all 1.2s ease;
  pointer-events: none;
}

.logo-3d:hover .logo-shine {
  animation: shine 1.5s ease forwards;
}

@keyframes shine {
  0% {
    transform: translateX(-100%) translateZ(1px);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%) translateZ(1px);
    opacity: 0;
  }
}

.logo-text {
  position: relative;
  transform-style: preserve-3d;
  transition: all 0.3s ease;
  font-weight: 700;
  position: relative;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  background: linear-gradient(to right, #333, #555);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

body.dark-mode .logo-text {
  background: linear-gradient(to right, #f9fafb, #ccc);
  -webkit-background-clip: text;
  background-clip: text;
}

.logo-glow {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 30px;
  filter: blur(10px);
  background: radial-gradient(circle at center, rgba(121, 40, 202, 0.2), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

body.dark-mode .logo-glow {
  background: radial-gradient(circle at center, rgba(53, 167, 156, 0.3), transparent 70%);
}

.logo-3d:hover .logo-glow {
  opacity: 1;
}

.logo-3d:hover .logo-img {
  transform: translateZ(15px);
}

.logo-3d:hover .logo-text {
  transform: translateZ(10px);
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Enhanced Hero Image */
.hero-image {
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  position: relative;
}

.hero-img-container {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.hero-img {
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
  border-radius: 12px;
  filter: drop-shadow(0 10px 25px rgba(0, 0, 0, 0.15));
}

.hero-img-glow {
  position: absolute;
  top: -10%;
  left: -10%;
  right: -10%;
  bottom: -10%;
  background: radial-gradient(circle at center, rgba(121, 40, 202, 0.15), transparent 70%);
  opacity: 0.5;
  filter: blur(40px);
  z-index: -1;
  border-radius: 50%;
  animation: pulse 5s infinite alternate ease-in-out;
}

body.dark-mode .hero-img-glow {
  background: radial-gradient(circle at center, rgba(53, 167, 156, 0.2), transparent 70%);
}

/* Floating elements animation */
.hero-img-floating-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform-style: preserve-3d;
}

.floating-element {
  position: absolute;
  transform-style: preserve-3d;
  padding: 5px 10px;
  border-radius: 50px;
  font-weight: bold;
  font-size: 0.8rem;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  /* Initial transform state (no animation applied yet) */
  transform: translateZ(30px);
  /* Using CSS transitions for smoother animation control */
  transition: transform 2s ease-in-out;
}

/* Individual positioning and styling */
.fe-1 {
  top: 10%;
  right: 10%;
  background: linear-gradient(90deg, #7928ca, #ff0080);
  animation: float-1 4s infinite ease-in-out;
  animation-delay: 0s;
}

.fe-2 {
  top: 40%;
  left: 5%;
  background: linear-gradient(90deg, #f7b731, #fc4a1a);
  animation: float-2 5s infinite ease-in-out;
  animation-delay: 0.5s;
}

.fe-3 {
  bottom: 20%;
  right: 15%;
  background: linear-gradient(90deg, #35a79c, #1e4a69);
  /* SAVE tag has its own specific animation */ 
  animation: float-3 4.5s infinite ease-in-out;
  /* No delay for the SAVE tag to fix the initial movement issue */
  animation-delay: 0s;
}

/* Separate keyframes for each floating element for better control */
@keyframes float-1 {
  0%, 100% {
    transform: translateZ(30px) translateY(0);
  }
  50% {
    transform: translateZ(40px) translateY(-10px);
  }
}

@keyframes float-2 {
  0%, 100% {
    transform: translateZ(30px) translateY(0);
  }
  50% {
    transform: translateZ(35px) translateY(-8px);
  }
}

/* Special animation for SAVE tag with reduced movement */
@keyframes float-3 {
  0%, 100% {
    transform: translateZ(30px) translateY(0);
  }
  50% {
    /* Less vertical movement for more stability */
    transform: translateZ(32px) translateY(-5px);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.3;
    transform: scale(0.95);
  }
  50% {
    opacity: 0.6;
    transform: scale(1);
  }
  100% {
    opacity: 0.3;
    transform: scale(0.95);
  }
}

/* Benefits section 3D effects */
.benefit-3d {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.benefit-3d:hover {
  transform: translateZ(10px);
}

.icon-3d {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.benefit-3d:hover .icon-3d {
  transform: translateZ(20px) scale(1.1);
}

/* Button 3D effects */
.btn {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.btn:hover {
  transform: translateY(-5px) translateZ(10px);
}

.btn-primary:hover {
  box-shadow: 0 15px 30px rgba(121, 40, 202, 0.3);
}

body.dark-mode .btn-primary:hover {
  box-shadow: 0 15px 30px rgba(53, 167, 156, 0.3);
}

/* 3D effects for product badge */
.product-badge {
  transform-style: preserve-3d;
  transition: transform 0.3s ease;
}

.card-3d:hover .product-badge {
  transform: translateZ(20px) rotate(-3deg);
}

/* Layer depth for category cards */
.category-title {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.category-description {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.card-3d:hover .category-title {
  transform: translateZ(25px);
}

.card-3d:hover .category-description {
  transform: translateZ(15px);
}

/* Dark mode specific 3D adjustments */
body.dark-mode .card-3d {
  --card-depth: 15px;
}

/* Scroll-based animations */
.scroll-animate {
  opacity: 0;
  transition: opacity 0.8s ease, transform 0.8s ease;
  will-change: opacity, transform;
}

/* Product page specific fixes */
.products-page .category-card {
  overflow: visible !important;
  /* Force border-radius to be maintained at all times */
  border-radius: 20px !important;
  /* Use !important to ensure it's never overridden */
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1), 
              box-shadow 0.5s cubic-bezier(0.23, 1, 0.32, 1), 
              border-radius 0s linear !important; /* Prevent border-radius from animating */
}

.products-page .card-3d-inner {
  border-radius: 20px !important; /* Match the card's border radius exactly */
  overflow: hidden;
  height: 100%;
  width: 100%;
  /* Make sure the inner element transitions match the outer */
  transition: transform 0.3s ease, border-radius 0s linear !important;
}

/* Fix for the card contents */
.products-page .category-image,
.products-page .category-content {
  position: relative;
  transform-style: preserve-3d;
}

/* Fix for the image corners */
.products-page .category-image {
  border-top-left-radius: 20px !important;
  border-top-right-radius: 20px !important;
}

/* Fix for hover transitions */
.products-page .card-3d:hover,
.products-page .card-3d:hover .card-3d-inner {
  border-radius: 20px !important;
}

/* Different animation types */
.fade-up {
  transform: translateY(40px);
}

.fade-down {
  transform: translateY(-40px);
}

.fade-in {
  opacity: 0;
}

.fade-in-3d {
  transform: scale(0.9) rotateX(10deg);
  transform-origin: center bottom;
}

/* When element is visible in viewport */
.scroll-animate.visible {
  opacity: 1;
  transform: translateY(0) rotateX(0) scale(1);
}

/* Add additional 3D depth to scroll animations */
.product-card.scroll-animate,
.category-card.scroll-animate {
  perspective: 1000px;
}

/* Staggered animation for product grid */
.products-grid .product-card {
  transition-duration: 0.8s;
}

/* Animation for section headers */
.section-header.scroll-animate {
  transition-duration: 1s;
}

/* Featured products special animation */
.featured-section .product-card.scroll-animate {
  transform-style: preserve-3d;
  transform: translateY(40px) rotateY(5deg);
}

.featured-section .product-card.scroll-animate.visible {
  transform: translateY(0) rotateY(0);
}

/* Mobile responsiveness for 3D effects */
@media (max-width: 768px) {
  :root {
    --card-tilt-amount: 3deg;
    --card-depth: 5px;
    --parallax-depth: 10px;
  }
  
  .hero-title {
    transform: translateZ(5px);
  }
  
  .hero-subtitle {
    transform: translateZ(2px);
  }
  
  /* Reduce animation distance on mobile */
  .fade-up, .fade-down {
    transform: translateY(20px);
  }
  
  .fade-down {
    transform: translateY(-20px);
  }
}

/* Devices that can handle motion */
@media (hover: hover) and (pointer: fine) {
  .card-3d:hover .card-3d-inner {
    transform: translateZ(var(--card-depth));
  }
}

/* Devices without hover (mobile touch) */
@media (hover: none) {
  .card-3d:active .card-3d-inner {
    transform: translateZ(calc(var(--card-depth) / 2));
  }
}
