/**
 * AC Carousel — Micro-libreria carousel immagini
 * 100% JS puro, zero dipendenze, touch swipe nativo
 * Riutilizzabile ovunque: basta includere ac-carousel.css + ac-carousel.js
 */

/* ── Container ────────────────────────────────────── */
.ac-carousel {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.ac-carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.ac-carousel-track.is-dragging {
  transition: none;
}

/* ── Slide ────────────────────────────────────────── */
.ac-carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  position: relative;
}

.ac-carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
}

/* Placeholder shimmer durante il lazy load */
.ac-carousel-slide img[data-src] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: ac-shimmer 1.4s ease-in-out infinite;
}

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

/* ── Frecce navigazione ──────────────────────────── */
.ac-carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #1a1a2e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.2s ease, background 0.2s ease;
  padding: 0;
  outline: none;
}

.ac-carousel-arrow svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ac-carousel-arrow.prev { left: 8px; }
.ac-carousel-arrow.next { right: 8px; }

/* Mostra le frecce su hover del container */
.ac-carousel:hover .ac-carousel-arrow,
.ac-carousel:focus-within .ac-carousel-arrow {
  opacity: 1;
}

.ac-carousel-arrow:hover {
  background: rgba(255, 255, 255, 0.96);
  transform: translateY(-50%) scale(1.08);
}

.ac-carousel-arrow:active {
  transform: translateY(-50%) scale(0.94);
}

/* Su mobile le frecce sono sempre visibili (no hover) */
@media (max-width: 768px) {
  .ac-carousel-arrow {
    opacity: 0.7;
    width: 28px;
    height: 28px;
  }
  .ac-carousel-arrow svg {
    width: 14px;
    height: 14px;
  }
}

/* Nascondi frecce se c'è solo 1 immagine */
.ac-carousel[data-count="1"] .ac-carousel-arrow,
.ac-carousel[data-count="1"] .ac-carousel-dots {
  display: none !important;
}

/* ── Dots indicatori ─────────────────────────────── */
.ac-carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ac-carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
}

.ac-carousel-dot.active {
  background: #fff;
  transform: scale(1.3);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

/* Se ci sono troppi dots (>8), rimpicciolisci */
.ac-carousel-dots.many .ac-carousel-dot {
  width: 4px;
  height: 4px;
}

/* ── Contatore immagini (alternativa ai dots per tante foto) ─── */
.ac-carousel-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 6;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  pointer-events: none;
  line-height: 1.2;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Icona camera nel contatore */
.ac-carousel-counter::before {
  content: "📷 ";
  font-size: 0.62rem;
  vertical-align: text-top;
}
