/* ============================================================
   CENTIR · Carrusel móvil (scroll-snap) — utilidad compartida
   Opt-in: añade  data-cmn-carousel  al contenedor de tarjetas.
   Solo actúa en móvil (<=768px). Escritorio: intacto.
   CSS-first: funciona aunque el JS no cargue (swipe nativo).
   ============================================================ */

@media (max-width: 768px) {
  [data-cmn-carousel] {
    display: flex !important;
    flex-wrap: nowrap !important;
    grid-template-columns: none !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 0;
    gap: 14px !important;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  [data-cmn-carousel]::-webkit-scrollbar { display: none; }

  /* Cada hijo directo es una diapositiva */
  [data-cmn-carousel] > * {
    scroll-snap-align: start;
    flex: 0 0 var(--cmn-slide, 84%) !important;
    width: var(--cmn-slide, 84%) !important;
    max-width: var(--cmn-slide, 84%) !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  /* Permite alcanzar la última tarjeta sin que quede a medias */
  [data-cmn-carousel]::after {
    content: '';
    flex: 0 0 2px;
  }

  /* --- Controles (dots + flechas + contador) --- */
  .cmn-carousel-wrap { display: block; position: relative; }

  .cmn-carousel-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
  }

  .cmn-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
  }
  .cmn-dot {
    width: 7px; height: 7px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(122, 171, 168, 0.32);
    cursor: pointer;
    transition: width 0.25s ease, background 0.25s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .cmn-dot.is-active {
    width: 22px;
    border-radius: 4px;
    background: var(--primary-dark, #7aaba8);
  }

  .cmn-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid rgba(122, 171, 168, 0.35);
    border-radius: 50%;
    background: var(--surface, #fff);
    color: var(--primary-dark, #7aaba8);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .cmn-arrow:active { transform: scale(0.92); }
  .cmn-arrow:disabled { opacity: 0.3; cursor: default; }
  .cmn-arrow svg { width: 18px; height: 18px; }

  /* Pista de "desliza" para descubribilidad (solo la primera vez) */
  .cmn-swipe-hint {
    display: block;
    margin-top: 10px;
    text-align: center;
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 0.72rem;
    letter-spacing: 0.4px;
    color: var(--text-light, #9e9eaf);
  }
}

/* Escritorio: wrapper neutro (sin caja) y controles ocultos */
.cmn-carousel-wrap { display: contents; }
.cmn-carousel-bar, .cmn-swipe-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
  [data-cmn-carousel] { scroll-behavior: auto; }
  .cmn-dot, .cmn-arrow { transition: none; }
}
