/*
 * BSB Product Carousel 1.0.1
 * A Group block with the "Product carousel" style becomes a swipeable row; Group blocks
 * inside it with the "Product card" style become cards. CSS scroll-snap, no slider library.
 * Colors and fonts follow the BSB Design System tokens, with fallbacks.
 * No em dashes anywhere by request.
 */

.is-style-bsb-carousel {
  --bsb-pcar-gap: 16px;
  --bsb-pcar-card: min(64%, 260px);
  position: relative;
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: var(--bsb-pcar-gap) !important;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding: 4px 2px 14px !important;
  margin-block: 1.25rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bsb-rule, #e2e8f0) transparent;
}
.is-style-bsb-carousel::-webkit-scrollbar { height: 6px; }
.is-style-bsb-carousel::-webkit-scrollbar-thumb { background: var(--bsb-rule, #e2e8f0); border-radius: 999px; }

/* Every direct child is a slide, so a carousel still works if a card misses its style. */
.is-style-bsb-carousel > * {
  flex: 0 0 var(--bsb-pcar-card) !important;
  max-width: var(--bsb-pcar-card) !important;
  margin: 0 !important;
  scroll-snap-align: start;
}

@media (min-width: 782px) {
  /* Three cards across with the fourth peeking, so readers can tell there is more. */
  .is-style-bsb-carousel { --bsb-pcar-card: calc((100% - 2 * var(--bsb-pcar-gap)) / 3.25); }
}

/* Cards */
.is-style-bsb-product-card {
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--bsb-rule, #e2e8f0);
  border-radius: 14px;
  padding: 10px 10px 14px !important;
  box-sizing: border-box;
  font-family: var(--bsb-font-sans, "Mulish", system-ui, sans-serif);
}
.is-style-bsb-product-card > * { margin: 0 !important; max-width: none !important; }
.is-style-bsb-product-card .wp-block-image,
.is-style-bsb-product-card figure { margin: 0 !important; }
.is-style-bsb-product-card .wp-block-image img,
.is-style-bsb-product-card figure img {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  background: #fff3f4;
}
.is-style-bsb-product-card .bsb-product-card__name {
  font-family: var(--bsb-font-serif, "Lora", Georgia, serif);
  font-weight: 500;
  font-size: 1.05rem !important;
  line-height: 1.3 !important;
  color: var(--bsb-ink, #1a202c);
}
.is-style-bsb-product-card .bsb-product-card__name a {
  color: inherit !important;
  text-decoration: none !important;
}
.is-style-bsb-product-card .bsb-product-card__name a:hover { color: var(--bsb-link, #0d6873) !important; }
.is-style-bsb-product-card .bsb-product-card__meta {
  font-size: 0.875rem !important;
  line-height: 1.4 !important;
  color: var(--bsb-ink-muted, #4a5568);
}
.is-style-bsb-product-card .wp-block-buttons { display: flex !important; margin-top: auto !important; padding-top: 4px; width: 100%; }
.is-style-bsb-product-card .wp-block-button { flex: 1 1 100% !important; width: 100% !important; margin: 0 !important; }
.is-style-bsb-product-card .wp-block-button__link { width: 100% !important; box-sizing: border-box; }
.is-style-bsb-product-card .wp-block-button__link {
  display: block;
  text-align: center;
  background: var(--bsb-button, #b44152) !important;
  color: #fff !important;
  border-radius: 999px;
  padding: 10px 14px !important;
  font-size: 0.95rem !important;
  font-weight: 700;
  text-decoration: none !important;
  line-height: 1.2;
}
.is-style-bsb-product-card .wp-block-button__link:hover { background: var(--bsb-button-hover, #c24b61) !important; }

/* Arrow buttons, added by bsb-product-carousel.js on devices with a mouse. */
.bsb-pcar-wrap { position: relative; }
.bsb-pcar-wrap > .is-style-bsb-carousel { margin-block: 1.25rem 2rem; }
.bsb-pcar-btn {
  position: absolute;
  top: calc(50% - 30px);
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--bsb-rule, #e2e8f0);
  background: #fff;
  color: var(--bsb-link, #0d6873);
  box-shadow: 0 2px 8px rgba(26, 32, 44, 0.15);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  padding: 0;
}
.bsb-pcar-btn:hover { color: var(--bsb-link-hover, #b44152); }
.bsb-pcar-btn:focus-visible { outline: 2px solid var(--bsb-link, #0d6873); outline-offset: 2px; }
.bsb-pcar-btn[disabled] { opacity: 0; pointer-events: none; }
.bsb-pcar-prev { left: -12px; }
.bsb-pcar-next { right: -12px; }
@media (hover: hover) and (pointer: fine) {
  .bsb-pcar-wrap.has-overflow .bsb-pcar-btn { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  .is-style-bsb-carousel { scroll-behavior: auto; }
}

/* In the editor, show cards side by side without forcing a scroll while editing. */
.editor-styles-wrapper .is-style-bsb-carousel { overflow-x: auto; }
