/* =====================================================
   MOONLIGHT EXPRESS - 3D IMAGE STACK GALLERY
   Modern Perspective Gallery with Interactive Effects
   Version: 1.1.0 (Fixed Scrollbar & Close Button)
   ===================================================== */

:root {
  --gallery-blue: #5468ff;
  --gallery-purple: #7c3aed;
  --card-bg: rgba(42, 42, 42, 0.3);
  --card-border: rgba(84, 104, 255, 0.25);
}

/* =====================================================
   GALLERY CONTAINER
   ===================================================== */

.gallery-3d-wrapper {
  width: 100%;
  perspective: 1200px;
  padding: 2rem 1.5rem;
  box-sizing: border-box;
}

.gallery-3d-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 3rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  justify-items: center;
  align-items: start;
  perspective: 1000px;
}

/* =====================================================
   INDIVIDUAL GALLERY CARD - 3D STACK
   ===================================================== */

.gallery-card-3d {
  position: relative;
  width: 100%;
  max-width: 380px;
  height: auto;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  transform-style: preserve-3d;
  transform: translateZ(0);
  
  /* Staggered entrance animation */
  animation: cardSlideIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* Stagger entrance by nth-child */
.gallery-card-3d:nth-child(1) { animation-delay: 0s; }
.gallery-card-3d:nth-child(2) { animation-delay: 0.1s; }
.gallery-card-3d:nth-child(3) { animation-delay: 0.2s; }
.gallery-card-3d:nth-child(4) { animation-delay: 0.3s; }
.gallery-card-3d:nth-child(5) { animation-delay: 0.4s; }
.gallery-card-3d:nth-child(6) { animation-delay: 0.5s; }
.gallery-card-3d:nth-child(7) { animation-delay: 0.6s; }
.gallery-card-3d:nth-child(8) { animation-delay: 0.7s; }
.gallery-card-3d:nth-child(9) { animation-delay: 0.8s; }
.gallery-card-3d:nth-child(10) { animation-delay: 0.9s; }

/* Slide-in entrance animation */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(40px) rotateX(10deg) rotateZ(-2deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0) rotateZ(0);
  }
}

/* Gradient border accent line (hidden by default) */
.gallery-card-3d::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gallery-blue), var(--gallery-purple), var(--gallery-blue));
  background-size: 200% 100%;
  animation: borderGradientShift 3s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 10;
}

@keyframes borderGradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* =====================================================
   HOVER STATE - 3D LIFT & TILT
   ===================================================== */

.gallery-card-3d:hover {
  background: rgba(42, 42, 42, 0.5);
  backdrop-filter: blur(30px) saturate(120%);
  -webkit-backdrop-filter: blur(30px) saturate(120%);
  border: 1.5px solid rgba(84, 104, 255, 0.45);
  box-shadow: 
    0 20px 60px rgba(84, 104, 255, 0.2),
    0 0 30px rgba(84, 104, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  
  /* 3D lift with subtle rotation */
  transform: 
    translateY(-12px) 
    rotateX(5deg) 
    rotateZ(2deg) 
    scale(1.03);
}

/* Show gradient border on hover */
.gallery-card-3d:hover::before {
  opacity: 1;
}

/* =====================================================
   GALLERY IMAGE
   ===================================================== */

.gallery-card-3d-image {
  position: relative;
  width: 100%;
  height: 280px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-card-3d-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(1);
}

/* Parallax zoom effect on hover */
.gallery-card-3d:hover .gallery-card-3d-image img {
  transform: scale(1.1);
}

/* =====================================================
   CARD CONTENT
   ===================================================== */

.gallery-card-3d-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  gap: 1rem;
}

.gallery-card-3d-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  margin: 0;
  line-height: 1.3;
  transition: color 0.5s ease;
}

.gallery-card-3d:hover .gallery-card-3d-title {
  color: var(--gallery-blue);
}

.gallery-card-3d-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(84, 104, 255, 0.15);
  border: 1px solid rgba(84, 104, 255, 0.3);
  color: var(--gallery-blue);
  transition: all 0.3s ease;
  width: fit-content;
}

.gallery-card-3d:hover .gallery-card-3d-badge {
  background: rgba(84, 104, 255, 0.3);
  border: 1px solid rgba(84, 104, 255, 0.6);
  box-shadow: 0 0 12px rgba(84, 104, 255, 0.3);
}

/* =====================================================
   IMAGE MODAL POPUP - NO SCROLLBAR FIX
   ===================================================== */

.gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gallery-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

/* Modal Overlay */
.gallery-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1;
}

/* Modal Content Container - NO SCROLLBAR */
.gallery-modal-content {
  position: relative;
  z-index: 2;
  background: rgba(30, 37, 45, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid rgba(84, 104, 255, 0.3);
  border-radius: 20px;
  box-shadow: 
    0 20px 60px rgba(84, 104, 255, 0.2),
    0 0 60px rgba(84, 104, 255, 0.1);
  padding: 2rem;
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  overflow: hidden;
  animation: modalPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Modal pop-in animation */
@keyframes modalPopIn {
  from {
    transform: scale(0.8) rotateX(20deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotateX(0);
    opacity: 1;
  }
}

/* Modal Body - Contains Image */
.gallery-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.gallery-modal-body img {
  max-width: 100%;
  max-height: 60vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  animation: imageFadeIn 0.6s ease;
}

@keyframes imageFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Modal Title */
.gallery-modal-title {
  color: #ffffff;
  font-size: 1.5rem;
  margin: 0;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  font-weight: 700;
}

/* Navigation Controls - CENTERED WITH CLOSE IN MIDDLE */
.gallery-modal-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-top: 1rem;
}

.gallery-modal-prev,
.gallery-modal-next {
  background: rgba(84, 104, 255, 0.2);
  border: 1px solid rgba(84, 104, 255, 0.4);
  color: #ffffff;
  font-size: 1.2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
}

.gallery-modal-prev:hover,
.gallery-modal-next:hover {
  background: rgba(84, 104, 255, 0.4);
  border-color: rgba(84, 104, 255, 0.8);
  box-shadow: 0 0 20px rgba(84, 104, 255, 0.4);
  transform: scale(1.15);
}

/* Close Button - IN MIDDLE */
.gallery-modal-close {
  background: rgba(84, 104, 255, 0.2);
  border: 1px solid rgba(84, 104, 255, 0.4);
  color: #ffffff;
  font-size: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
  padding: 0;
}

.gallery-modal-close:hover {
  background: rgba(84, 104, 255, 0.4);
  border-color: rgba(84, 104, 255, 0.8);
  box-shadow: 0 0 20px rgba(84, 104, 255, 0.4);
  transform: scale(1.1) rotate(90deg);
}

/* =====================================================
   RESPONSIVE LAYOUTS
   ===================================================== */

/* Desktop: 3-column stacked perspective */
@media (min-width: 1200px) {
  .gallery-3d-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem 2.5rem;
  }

  .gallery-card-3d {
    max-width: 100%;
  }
}

/* Tablet: 2-column responsive */
@media (max-width: 1199.98px) and (min-width: 768px) {
  .gallery-3d-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.5rem 2rem;
  }

  .gallery-card-3d {
    max-width: 100%;
  }
}

/* Mobile: 1-column single card */
@media (max-width: 767.98px) {
  .gallery-3d-wrapper {
    padding: 1.5rem 1rem;
  }

  .gallery-3d-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    max-width: 500px;
  }

  .gallery-card-3d {
    max-width: 100%;
  }

  .gallery-card-3d:hover {
    transform: 
      translateY(-8px) 
      rotateX(3deg) 
      rotateZ(1deg) 
      scale(1.02);
  }

  /* Adjust modal for mobile */
  .gallery-modal-content {
    max-width: 95vw;
    max-height: 95vh;
    padding: 1.5rem;
    border-radius: 15px;
  }

  .gallery-modal-body img {
    max-height: 55vh;
  }

  .gallery-modal-controls {
    gap: 1rem;
  }

  .gallery-modal-prev,
  .gallery-modal-next,
  .gallery-modal-close {
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }

  .gallery-modal-close {
    font-size: 1.5rem;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .gallery-3d-wrapper {
    padding: 1rem;
  }

  .gallery-card-3d-image {
    height: 240px;
  }

  .gallery-card-3d-content {
    padding: 1.2rem;
    min-height: 100px;
  }

  .gallery-card-3d-title {
    font-size: 1rem;
  }

  .gallery-modal-content {
    padding: 1.2rem;
  }

  .gallery-modal-title {
    font-size: 1.2rem;
  }

  .gallery-modal-controls {
    gap: 0.8rem;
  }
}

/* =====================================================
   ACCESSIBILITY
   ===================================================== */

.gallery-card-3d:focus {
  outline: 2px solid var(--gallery-blue);
  outline-offset: 4px;
}

.gallery-card-3d:focus-visible {
  outline: 2px solid var(--gallery-blue);
  outline-offset: 4px;
}

.gallery-modal-close:focus,
.gallery-modal-prev:focus,
.gallery-modal-next:focus {
  outline: 2px solid var(--gallery-blue);
  outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .gallery-card-3d,
  .gallery-card-3d-image img,
  .gallery-card-3d-title,
  .gallery-card-3d-badge,
  .gallery-modal,
  .gallery-modal-content,
  .gallery-modal-body img {
    animation: none !important;
    transition: none !important;
  }

  .gallery-card-3d:hover {
    transform: none;
  }

  .gallery-modal-close:hover,
  .gallery-modal-prev:hover,
  .gallery-modal-next:hover {
    transform: none;
  }
}