/**
 * Bloque: Categorías (carousel) — front + editor
 */

/* Aislar del tema padre (overflow/transform que rompen scroll horizontal) */
.drc-category-carousel {
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(1.75rem, 3vw, 2.75rem) 0;
  position: relative;
  isolation: isolate;
  contain: layout style;
  box-sizing: border-box;
}

.drc-category-carousel.alignwide {
  width: min(100%, var(--wp--style--global--wide-size, 1200px));
}

.drc-category-carousel.alignfull {
  width: 100%;
}

.drc-category-carousel__head {
  text-align: center;
  margin-bottom: clamp(1.25rem, 2vw, 2rem);
}

.drc-category-carousel__title {
  margin: 0 0 0.65rem;
  font-size: clamp(1.05rem, 0.5vw + 1rem, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text, #2b2b2b);
}

.drc-category-carousel__rule {
  display: block;
  width: 48px;
  height: 2px;
  margin: 0 auto;
  background: rgba(43, 43, 43, 0.2);
  border-radius: 2px;
}

.drc-category-carousel__frame {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.drc-category-carousel__viewport {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  /* scroll-snap + JS scrollTo chocan y suelen “volver loco” el carrusel */
  scroll-snap-type: none;
  scroll-behavior: auto;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  touch-action: pan-x pinch-zoom;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.drc-category-carousel__slides {
  display: flex;
  flex-direction: row;
  width: max-content;
}

.drc-category-carousel__slide {
  flex: 0 0 100%;
  box-sizing: border-box;
  padding: 0 2px;
}

.drc-category-carousel__grid {
  display: grid;
  grid-template-columns: repeat(var(--drc-cols, 6), minmax(0, 1fr));
  gap: clamp(0.65rem, 1.5vw, 1rem);
  align-items: stretch;
}

.drc-category-carousel__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  min-height: 140px;
  padding: 1rem 0.65rem;
  background: #fff;
  border: 1px solid rgba(43, 43, 43, 0.08);
  border-radius: var(--radius, 12px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.drc-category-carousel__card:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
  border-color: rgba(230, 90, 25, 0.25);
}

.drc-category-carousel__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  margin-bottom: 0.75rem;
  padding: 10px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fafafa 0%, #f0f0f0 100%);
  border: 1px solid rgba(43, 43, 43, 0.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 4px 12px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.drc-category-carousel__card:hover .drc-category-carousel__thumb {
  border-color: rgba(230, 90, 25, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 8px 20px rgba(230, 90, 25, 0.12);
  transform: translateY(-1px);
}

.drc-category-carousel__img {
  width: 100%;
  height: 100%;
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  filter: grayscale(0.35) contrast(1.05);
  opacity: 0.96;
  transition: filter 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.drc-category-carousel__card:hover .drc-category-carousel__img {
  filter: grayscale(0) contrast(1.08);
  opacity: 1;
  transform: scale(1.04);
}

.drc-category-carousel__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff 0%, var(--color-bg-soft, #f5f5f5) 100%);
  border: 2px solid rgba(230, 90, 25, 0.15);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary, #e65a19);
  letter-spacing: -0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.drc-category-carousel__name {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  color: #8b7355;
  letter-spacing: 0.01em;
}

.drc-category-carousel__btn {
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(43, 43, 43, 0.12);
  border-radius: 999px;
  background: #fff;
  color: #666;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.drc-category-carousel__btn:hover:not(:disabled) {
  background: var(--color-bg-soft, #f5f5f5);
  color: var(--color-text, #2b2b2b);
  border-color: rgba(43, 43, 43, 0.2);
}

.drc-category-carousel__btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.drc-category-carousel__empty {
  text-align: center;
  color: var(--color-text-light, #555);
  margin: 1rem 0;
}

/* Editor */
.drc-category-carousel-editor .drc-category-carousel {
  pointer-events: none;
}

@media (max-width: 900px) {
  .drc-category-carousel__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .drc-category-carousel__frame {
    gap: 0.15rem;
  }

  .drc-category-carousel__btn {
    width: 34px;
    height: 34px;
    font-size: 1.25rem;
  }
}

@media (max-width: 600px) {
  .drc-category-carousel__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .drc-category-carousel__thumb {
    width: 64px;
    height: 64px;
  }
}

/* Contención en móvil: el rail con width:max-content no debe ampliar el layout de la página */
@media (max-width: 782px) {
  .drc-category-carousel {
    min-width: 0;
    max-width: 100%;
  }

  .drc-category-carousel__frame {
    min-width: 0;
    max-width: 100%;
  }

  .drc-category-carousel__viewport {
    min-width: 0;
  }
}
