/*
 * SDL Related Products v1.0 — styles
 *
 * Contains a scoped subset of Swiper 11.2.1 core CSS (MIT, © Vladimir
 * Kharlampidi) plus the card/slider styling. Everything is namespaced under
 * .sdl-related-products so it can never leak into Squarespace's own sliders.
 *
 * Typography and colour inherit from the active Squarespace theme; override the
 * custom properties below to depart from it.
 */

.sdl-related-products {
  --sdl-rp-ratio: 3 / 4;
  --sdl-rp-gap: 16px;
  --sdl-rp-gap-lg: 24px;
  --sdl-rp-radius: 0px;
  --sdl-rp-text: currentColor;
  --sdl-rp-muted: color-mix(in srgb, currentColor 60%, transparent);
  --sdl-rp-nav-size: 40px;
  --sdl-rp-nav-bg: hsla(var(--white-hsl, 0 0% 100%), 1);
  --sdl-rp-nav-color: hsla(var(--black-hsl, 0 0% 0%), 1);
  --sdl-rp-badge-bg: hsla(var(--black-hsl, 0 0% 0%), 1);
  --sdl-rp-badge-color: hsla(var(--white-hsl, 0 0% 100%), 1);
  --sdl-rp-sale-color: #c0392b;

  position: relative;
  width: 100%;
}

/* Hidden until the JS has rendered slides, so no unstyled flash. */
.sdl-related-products:not(.sdl-rp-ready) {
  min-height: 0;
}
.sdl-related-products[data-loading="empty"],
.sdl-related-products[data-loading="error"] {
  display: none;
}

/* ------------------------------------------------------------------ *
 *  Swiper core (scoped)
 * ------------------------------------------------------------------ */
/* NB: the slider container deliberately does NOT use the bare `swiper` class.
 * Many Squarespace sites ship a global `.swiper { ...!important }` rule (from
 * other slider plugins) that would hijack our width/overflow. Swiper only ever
 * adds `swiper-*` prefixed classes, so `.sdl-rp-swiper` is all we need. */
.sdl-related-products .sdl-rp-swiper {
  position: relative;
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
  list-style: none;
  padding: 0;
  z-index: 1;
  display: block;
}
.sdl-related-products .swiper-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  box-sizing: content-box;
  transition-property: transform;
  transition-timing-function: var(--swiper-wrapper-transition-timing-function, initial);
}
.sdl-related-products .swiper-android .swiper-slide,
.sdl-related-products .swiper-ios .swiper-slide,
.sdl-related-products .swiper-wrapper {
  transform: translate3d(0px, 0, 0);
}
.sdl-related-products .swiper-horizontal {
  touch-action: pan-y;
}
.sdl-related-products .swiper-slide {
  flex-shrink: 0;
  width: 100%;
  height: auto;
  position: relative;
  transition-property: transform;
  display: block;
}
.sdl-related-products .swiper-slide-invisible-blank {
  visibility: hidden;
}
.sdl-related-products .swiper-backface-hidden .swiper-slide {
  transform: translateZ(0);
  backface-visibility: hidden;
}
.sdl-related-products .swiper-button-lock,
.sdl-related-products .swiper-pagination-lock {
  display: none;
}

.sdl-related-products.sdl-rp-grab .sdl-rp-swiper {
  cursor: grab;
}
.sdl-related-products.sdl-rp-grab .sdl-rp-swiper:active {
  cursor: grabbing;
}

/* ------------------------------------------------------------------ *
 *  Header
 * ------------------------------------------------------------------ */
.sdl-rp-header {
  display: flex;
  align-items: center;
  margin-bottom: clamp(16px, 2.5vw, 32px);
}
.sdl-rp-header.align-center {
  justify-content: center;
  text-align: center;
}
/* Heading + top-right nav share the row. */
.sdl-rp-header.has-nav {
  justify-content: space-between;
  text-align: left;
}
.sdl-rp-heading {
  margin: 0;
  font-size: inherit;
}

/* ------------------------------------------------------------------ *
 *  Auto-inserted section (product #page-regions / blog page)
 *  Borrows Squarespace's `.page-section` + colour-theme class for colours,
 *  but uses our own inner wrapper for layout (horizontal padding is set
 *  inline by the JS to match the site's content column). We neutralise the
 *  borrowed section min-height and add vertical spacing.
 * ------------------------------------------------------------------ */
.sdl-rp-autosection.page-section {
  min-height: 0;
}
.sdl-rp-autoinner {
  box-sizing: border-box;
  width: 100%;
  margin-inline: auto;
  padding-block: clamp(40px, 6vw, 80px);
}
.sdl-rp-blog-inline {
  margin-top: clamp(32px, 5vw, 64px);
}

/* ------------------------------------------------------------------ *
 *  Full-bleed slider (width + offset are set inline by the JS)
 * ------------------------------------------------------------------ */
.sdl-rp-swiper--fullbleed {
  max-width: none;
  box-sizing: border-box;
}
/* In full-bleed the JS drives slidesPerView:"auto", sizing each slide so the
 * requested slides-per-view fill the gutter-to-screen-edge region and the
 * partial slide bleeds to the edge. Width comes from the measured CSS var. */
.sdl-related-products .sdl-rp-swiper--fullbleed .sdl-rp-slide {
  width: var(--sdl-rp-slide-w, 100%);
}

/* ------------------------------------------------------------------ *
 *  Card
 * ------------------------------------------------------------------ */
.sdl-rp-slide {
  display: flex;
  flex-direction: column;
  color: var(--sdl-rp-text);
}

.sdl-rp-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--sdl-rp-ratio);
  overflow: hidden;
  border-radius: var(--sdl-rp-radius);
  background: color-mix(in srgb, currentColor 6%, transparent);
}

.sdl-rp-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.4s ease, transform 0.6s ease;
}
.sdl-rp-img--hover {
  opacity: 0;
}
.sdl-rp-slide.has-hover-image .sdl-rp-media:hover .sdl-rp-img--hover {
  opacity: 1;
}
.sdl-rp-slide:not(.has-hover-image) .sdl-rp-media:hover .sdl-rp-img--primary {
  transform: scale(1.04);
}

.sdl-rp-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 4px 10px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  border-radius: 2px;
  background: var(--sdl-rp-badge-bg);
  color: var(--sdl-rp-badge-color);
}
.sdl-rp-badge--sale {
  background: var(--sdl-rp-sale-color);
  color: #fff;
}

.sdl-rp-info {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sdl-rp-category {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sdl-rp-muted);
}

.sdl-rp-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
}
.sdl-rp-title a {
  color: inherit;
  text-decoration: none;
  background-image: none;
}
.sdl-rp-title a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sdl-rp-price {
  margin: 0;
  font-size: 0.95rem;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.sdl-rp-price-original {
  text-decoration: line-through;
  color: var(--sdl-rp-muted);
}
.sdl-rp-price-sale {
  color: var(--sdl-rp-sale-color);
}

.sdl-rp-description {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--sdl-rp-muted);
  margin-top: 2px;
}
.sdl-rp-description p {
  margin: 0;
}
.sdl-rp-description p + p {
  margin-top: 0.5em;
}

/* ------------------------------------------------------------------ *
 *  Navigation — shared button
 * ------------------------------------------------------------------ */
.sdl-rp-nav {
  width: var(--sdl-rp-nav-size);
  height: var(--sdl-rp-nav-size);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--sdl-rp-nav-bg);
  color: var(--sdl-rp-nav-color);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.2s ease;
}
.sdl-rp-nav:focus-visible {
  opacity: 1;
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.sdl-rp-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.sdl-rp-nav-icon svg,
.sdl-rp-nav-icon img {
  display: block;
  width: 100%;
  height: 100%;
}
/* Prev mirrors the icon so a single glyph serves both directions. */
.sdl-rp-nav--prev .sdl-rp-nav-icon {
  transform: scaleX(-1);
}
.sdl-rp-nav.swiper-button-disabled {
  pointer-events: none;
}

/* --- Grouped nav (top-right / bottom-*): sits in the flow --- */
.sdl-rp-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sdl-rp-nav-group .sdl-rp-nav.swiper-button-disabled {
  opacity: 0.35;
}

/* --- Centre nav: overlays the sides of the image --- */
.sdl-rp-swiper > .sdl-rp-nav {
  position: absolute;
  top: calc((100% - var(--sdl-rp-info-height, 80px)) / 2);
  transform: translateY(-50%);
  z-index: 5;
}
.sdl-rp-swiper > .sdl-rp-nav--prev {
  left: 12px;
}
.sdl-rp-swiper > .sdl-rp-nav--next {
  right: 12px;
}
.sdl-rp-swiper > .sdl-rp-nav.swiper-button-disabled {
  opacity: 0 !important;
}

/* Visibility: always-on by default; hover-only when opted in (centre nav). */
.sdl-related-products.sdl-rp-nav-hover .sdl-rp-swiper > .sdl-rp-nav {
  opacity: 0;
}
.sdl-related-products.sdl-rp-nav-hover:hover .sdl-rp-swiper > .sdl-rp-nav {
  opacity: 1;
}

@media (hover: none) {
  .sdl-rp-swiper > .sdl-rp-nav {
    display: none;
  }
}

/* ------------------------------------------------------------------ *
 *  Bottom controls row (pagination + bottom-positioned nav)
 * ------------------------------------------------------------------ */
.sdl-rp-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.sdl-rp-zone {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.sdl-rp-zone.zone-left {
  justify-content: flex-start;
}
.sdl-rp-zone.zone-center {
  justify-content: center;
}
.sdl-rp-zone.zone-right {
  justify-content: flex-end;
}

/* ------------------------------------------------------------------ *
 *  Pagination
 * ------------------------------------------------------------------ */
.sdl-rp-pagination {
  display: flex;
  gap: 8px;
}
.sdl-related-products .swiper-pagination-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.sdl-related-products .swiper-pagination-bullet-active {
  opacity: 1;
}

/* ------------------------------------------------------------------ *
 *  Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 767px) {
  .sdl-rp-swiper > .sdl-rp-nav {
    display: none;
  }
  .sdl-rp-title {
    font-size: 0.9rem;
  }
}
