/* 3D AUTO-FLIP GALLERY */
.gallery-section {
  padding: 100px 0;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  position: relative;
  overflow: hidden;
}

.gallery-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 50%, rgba(44, 95, 45, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(151, 188, 98, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.section-header {
  text-align: center;
  margin-bottom: 80px;
  position: relative;
  z-index: 1;
}

.section-label {
  color: var(--secondary-color);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 600;
}

.section-title {
  font-size: 3rem;
  color: white;
  margin: 15px 0;
  font-family: 'Playfair Display', serif;
}

.section-header p {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.1rem;
}

/* 3D Card Container */
.gallery-3d-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 50px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  perspective: 2000px;
}

/* Individual 3D Card */
.card-3d {
  position: relative;
  height: 450px;
  perspective: 1500px;
  opacity: 0;
  animation: cardFadeIn 0.8s ease forwards;
}

/* Staggered entrance */
.card-3d:nth-child(1) { animation-delay: 0.1s; }
.card-3d:nth-child(2) { animation-delay: 0.2s; }
.card-3d:nth-child(3) { animation-delay: 0.3s; }
.card-3d:nth-child(4) { animation-delay: 0.4s; }
.card-3d:nth-child(5) { animation-delay: 0.5s; }
.card-3d:nth-child(6) { animation-delay: 0.6s; }
.card-3d:nth-child(7) { animation-delay: 0.7s; }
.card-3d:nth-child(8) { animation-delay: 0.8s; }
.card-3d:nth-child(9) { animation-delay: 0.9s; }

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(50px) rotateX(-20deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* Card Inner Container */
.card-3d-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

/* Auto-flip animation - each card flips sequentially */
.card-3d:nth-child(1) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 0s; }
.card-3d:nth-child(2) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 1.5s; }
.card-3d:nth-child(3) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 3s; }
.card-3d:nth-child(4) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 4.5s; }
.card-3d:nth-child(5) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 6s; }
.card-3d:nth-child(6) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 7.5s; }
.card-3d:nth-child(7) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 9s; }
.card-3d:nth-child(8) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 10.5s; }
.card-3d:nth-child(9) .card-3d-inner { animation: autoFlip 13.5s ease-in-out infinite; animation-delay: 12s; }

@keyframes autoFlip {
  0%, 11% { transform: rotateY(0deg); }
  22%, 89% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

/* Unique hover effects for each card */
.card-3d:nth-child(1):hover .card-3d-inner {
  transform: rotateY(180deg) translateZ(30px) scale(1.05);
}

.card-3d:nth-child(2):hover .card-3d-inner {
  transform: rotateY(180deg) rotateX(10deg) translateZ(30px);
}

.card-3d:nth-child(3):hover .card-3d-inner {
  transform: rotateY(180deg) rotateZ(5deg) translateZ(30px);
}

.card-3d:nth-child(4):hover .card-3d-inner {
  transform: rotateY(180deg) translateY(-20px) translateZ(30px);
}

.card-3d:nth-child(5):hover .card-3d-inner {
  transform: rotateY(180deg) scale(1.08) translateZ(30px);
}

.card-3d:nth-child(6):hover .card-3d-inner {
  transform: rotateY(180deg) rotateX(-10deg) translateZ(30px);
}

.card-3d:nth-child(7):hover .card-3d-inner {
  transform: rotateY(180deg) rotateZ(-5deg) translateZ(30px);
}

.card-3d:nth-child(8):hover .card-3d-inner {
  transform: rotateY(180deg) translateY(20px) translateZ(30px);
}

.card-3d:nth-child(9):hover .card-3d-inner {
  transform: rotateY(180deg) scale(1.1) rotateX(5deg) translateZ(30px);
}

/* Front and Back faces */
.card-3d-front,
.card-3d-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.card-3d-front {
  background: linear-gradient(135deg, #2c5f2d 0%, #97bc62 100%);
}

.card-3d-back {
  background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
  transform: rotateY(180deg);
}

.card-3d-front img,
.card-3d-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

/* Zoom effect on hover */
.card-3d:hover .card-3d-front img,
.card-3d:hover .card-3d-back img {
  transform: scale(1.15);
}

/* Label styling */
.card-3d-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 25px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 70%, transparent 100%);
  color: white;
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  font-family: 'Playfair Display', serif;
  letter-spacing: 1px;
  transform: translateY(100%);
  transition: transform 0.5s ease;
}

.card-3d:hover .card-3d-label {
  transform: translateY(0);
}

/* Glow effect on hover */
.card-3d::before {
  content: '';
  position: absolute;
  inset: -5px;
  background: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-color));
  border-radius: 20px;
  opacity: 0;
  filter: blur(20px);
  transition: opacity 0.5s ease;
  z-index: -1;
}

.card-3d:hover::before {
  opacity: 0.6;
}

/* Responsive */
@media (max-width: 1200px) {
  .gallery-3d-container {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
  }
  
  .card-3d {
    height: 400px;
  }
}

@media (max-width: 768px) {
  .gallery-3d-container {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 10px;
  }
  
  .card-3d {
    height: 350px;
  }
  
  .section-title {
    font-size: 2rem;
  }
  
  /* Simplify hover effects on mobile */
  .card-3d:hover .card-3d-inner {
    transform: rotateY(180deg) translateZ(20px) !important;
  }
}

