/**
 * Carousel Gallery Component
 * Clinica Mobile - Homepage Image Carousel
 *
 * PERFORMANCE:
 * - Zero JavaScript framework dependencies
 * - Native CSS transforms for smooth transitions
 * - GPU-accelerated animations
 * - Lazy loading ready
 *
 * LAYOUT:
 * - 1 central image (prominent, high z-index)
 * - 2 side images (partial visibility ~35%, lower z-index, reduced opacity)
 * - Responsive: mobile shows only central image
 */

.carousel-gallery {
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 4rem auto;
  padding: 0 1rem;
  overflow: hidden;
}

.carousel-gallery__title {
  text-align: center;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 700;
  color: #51AFDA;
  margin-bottom: 3rem;
  font-family: 'Poppins', sans-serif;
}

/* Carousel Container */
.carousel-gallery__viewport {
  position: relative;
  width: 100%;
  height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
}

/* Carousel Track */
.carousel-gallery__track {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Slide Base */
.carousel-gallery__slide {
  position: absolute;
  width: 70%;
  max-width: 800px;
  height: 470px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8) translateX(0);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* Image Styling */
.carousel-gallery__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* Active/Center Slide - HIGH Z-INDEX, PROMINENT */
.carousel-gallery__slide--active {
  z-index: 10;
  opacity: 1;
  transform: scale(1) translateX(0);
  pointer-events: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* Previous Slide - LEFT SIDE, LOWER Z-INDEX, PARTIAL VISIBILITY */
.carousel-gallery__slide--prev {
  z-index: 5;
  opacity: 0.4;
  transform: scale(0.75) translateX(-60%);
  filter: blur(1px);
  pointer-events: auto;
  cursor: pointer;
}

/* Next Slide - RIGHT SIDE, LOWER Z-INDEX, PARTIAL VISIBILITY */
.carousel-gallery__slide--next {
  z-index: 5;
  opacity: 0.4;
  transform: scale(0.75) translateX(60%);
  filter: blur(1px);
  pointer-events: auto;
  cursor: pointer;
}

/* Hidden Slides */
.carousel-gallery__slide--hidden {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

/* Navigation Controls */
.carousel-gallery__controls {
  position: absolute;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: 20;
}

.carousel-gallery__btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid #51AFDA;
  background: white;
  color: #51AFDA;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.carousel-gallery__btn:hover {
  background: #51AFDA;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(81, 175, 218, 0.3);
}

.carousel-gallery__btn:active {
  transform: scale(0.95);
}

.carousel-gallery__btn svg {
  width: 24px;
  height: 24px;
}

/* Dot Indicators */
.carousel-gallery__dots {
  position: absolute;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  z-index: 20;
}

.carousel-gallery__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #51AFDA;
  background: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-gallery__dot--active {
  background: #51AFDA;
  transform: scale(1.3);
}

.carousel-gallery__dot:hover {
  background: #B04872;
  border-color: #B04872;
}

/* Auto-play Pause Button (Optional) */
.carousel-gallery__pause {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 15;
}

.carousel-gallery__pause:hover {
  background: rgba(0, 0, 0, 0.5);
  transform: scale(1.1);
}

/* Loading State */
.carousel-gallery__slide--loading {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

/* RESPONSIVE: Mobile - Only Central Image */
@media (max-width: 768px) {
  .carousel-gallery__viewport {
    height: 370px;
  }

  .carousel-gallery__slide {
    width: 90%;
    height: 320px;
  }

  .carousel-gallery__slide--active {
    width: 90%;
  }

  /* Hide side slides on mobile */
  .carousel-gallery__slide--prev,
  .carousel-gallery__slide--next {
    opacity: 0;
    transform: scale(0.6) translateX(-100%);
    pointer-events: none;
  }

  .carousel-gallery__slide--next {
    transform: scale(0.6) translateX(100%);
  }

  .carousel-gallery__controls {
    bottom: -50px;
  }

  .carousel-gallery__btn {
    width: 44px;
    height: 44px;
  }

  .carousel-gallery__dots {
    bottom: -80px;
  }

  .carousel-gallery__title {
    margin-bottom: 2rem;
  }
}

@media (max-width: 480px) {
  .carousel-gallery__viewport {
    height: 300px;
  }

  .carousel-gallery__slide {
    height: 260px;
  }
}

/* Accessibility */
.carousel-gallery__btn:focus,
.carousel-gallery__dot:focus {
  outline: 3px solid #51AFDA;
  outline-offset: 4px;
}

/* Print */
@media print {
  .carousel-gallery__controls,
  .carousel-gallery__dots,
  .carousel-gallery__pause {
    display: none;
  }

  .carousel-gallery__slide--prev,
  .carousel-gallery__slide--next {
    display: none;
  }
}
