/* 
 * Centralized Image Carousel Widget
 * Provides a lightweight, scroll-snapping image gallery for property unit cards.
 * Designed to drop cleanly into any resort website (PLR, Cypress).
 */

.unit-carousel {
  --carousel-nav-bg: rgba(255, 255, 255, 0.85);
  --carousel-nav-color: #333;
  --carousel-nav-hover: #fff;
  --carousel-nav-hover-bg: #222;

  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10; /* A good balance for property photos */
  overflow: hidden;
  border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0; /* Matches typical card styling */
  background: #e9e9e9; /* Placeholder before loads */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05); /* subtle inner border */
}

/* The scrollable area */
.carousel-track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE and Edge */
}

.carousel-track::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

/* Individual slides */
.carousel-item {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  position: relative;
  background-size: cover;
  background-position: center;
  background-color: #000;
  overflow: hidden;
}

/* The blur effect overlay */
.carousel-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: inherit;
  filter: blur(15px) brightness(0.7);
  transform: scale(1.1); /* Prevents white edges from blur */
  z-index: 0;
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Shows 100% of the photo without cropping */
  display: block;
  position: relative;
  z-index: 1;
}

/* Image label/caption overlay */
.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
  color: #fff;
  padding: 20px 12px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  pointer-events: none;
  z-index: 2; /* Must sit above z-index:1 img */
}

/* Navigation Buttons */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--carousel-nav-bg);
  color: var(--carousel-nav-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  opacity: 0; /* Hidden by default */
  transition: opacity 0.2s ease, background 0.2s ease, color 0.2s ease;
  z-index: 10;
}

/* Only show buttons if the user hovers over the carousel, or on touch devices */
.unit-carousel:hover .carousel-btn {
  opacity: 1;
}

/* For touch screens where hover isn't reliable, keep buttons partially visible or logic handles it */
@media (hover: none) {
  .carousel-btn {
    opacity: 0.85;
  }
}

.carousel-btn:hover {
  background: var(--carousel-nav-hover-bg);
  color: var(--carousel-nav-hover);
}

.carousel-btn-prev {
  left: 8px;
}

.carousel-btn-next {
  right: 8px;
}

/* Remove the disabled state as we now loop infinite */
.carousel-btn:disabled {
  opacity: 1 !important;
  cursor: pointer;
}

/* Unit/property badge (e.g. "Cottage #1", "Unit #1") — must sit above image (z:1)
   and caption (z:2), so z-index:3 is required. Defined here so both sites inherit
   the fix without needing it in per-page inline styles. */
.unit-badge {
  z-index: 3;
}
