/* =================================================================
   CG Loop Swatches  v1.2.0
   ================================================================= */

/* ── Strip wrapper ──────────────────────────────────────────── */

.cgls-swatches {
  margin: 15px 0 2px;
  line-height: 1;
  user-select: none;
}

.cgls-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-left: 10px;
  align-items: center;
}
.archive .cgls-list{
  padding-left: 0px;
}
/* ── Base swatch button ─────────────────────────────────────── */

.cgls-swatch {
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  border: 0px solid transparent;
  outline: 1px solid rgba(0, 0, 0, 0.2);
  cursor: pointer;
  padding: 0;
  margin: 2px;
  overflow: visible;
  background-clip: padding-box;
  transition: transform 0.12s ease, outline-color 0.12s ease, border-color 0.12s ease;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Hover: slight scale only, no image changes */
.cgls-swatch:hover {
  transform: scale(1.15);
  outline-color: rgba(0, 0, 0, 0.45);
  z-index: 100;
}

/* Active (clicked) state */
.cgls-swatch.cgls-active {
  border-color: #111;
  outline-color: #111;
  transform: scale(1.20);
  z-index: 100;
}

/* White swatch visibility */
.cgls-swatch[style*="#ffffff"],
.cgls-swatch[style*="#fff"],
.cgls-swatch[style*="rgb(255, 255, 255)"] {
  outline-color: rgba(0, 0, 0, 0.3);
}

/* Hidden (beyond SHOW_LIMIT) – these never show since +N redirects */
.cgls-swatch.cgls-hidden {
  display: none;
}

/* ── CSS Tooltip (shown on hover via data-tooltip attribute) ─── */

.cgls-swatch[data-tooltip] {
  position: relative;
}

/* Tooltip text */
.cgls-swatch[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 9999;
  
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Tooltip arrow */
.cgls-swatch[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 9999;
  
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Show tooltip on hover */
.cgls-swatch[data-tooltip]:hover::after,
.cgls-swatch[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Optional: add a small delay for better UX */
.cgls-swatch[data-tooltip]::after,
.cgls-swatch[data-tooltip]::before {
  transition-delay: 0.1s;
}

/* ── Image swatch ───────────────────────────────────────────── */

.cgls-swatch.cgls-type-image {
  background: #f5f5f5;
  outline-color: rgba(0, 0, 0, 0.15);
}

.cgls-swatch.cgls-type-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50% !important;
  pointer-events: none;
}

/* ── Dual-colour swatch ─────────────────────────────────────── */
/* linear-gradient set inline by PHP – no extra CSS needed */

/* ── "+N" pill → redirects to product page ──────────────────── */

.cgls-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0px 0px;
  background: transparent;
  color: #333;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  border: 0px;
}

/* =================================================================
   Suppress theme secondary-image hover effect.
   ================================================================= */

/* Scenario 1 – swatch locked (clicked) */
.product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail {
  opacity: 1 !important;
}
.product.cgls-has-active .woocommerce-loop-product__image img.secondary-image {
  opacity: 0 !important;
}

/* Column-scoped (mirrors CommerceKit rules for specificity) */
.products.columns-2  .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-3  .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-4  .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-5  .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-6  .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-100 .product.cgls-has-active .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail { opacity: 1 !important; }

.products.columns-2  .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image,
.products.columns-3  .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image,
.products.columns-4  .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image,
.products.columns-5  .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image,
.products.columns-6  .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image,
.products.columns-100 .product.cgls-has-active .woocommerce-loop-product__image img.secondary-image { opacity: 0 !important; }

/* Scenario 2 – hovering the swatch strip (no click yet) */
.product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail { opacity: 1 !important; }
.product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image               { opacity: 0 !important; }

/* Column-scoped hover-strip rules */
.products.columns-2  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-3  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-4  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-5  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-6  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail,
.products.columns-100 .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.attachment-woocommerce_thumbnail { opacity: 1 !important; }

.products.columns-2  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image,
.products.columns-3  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image,
.products.columns-4  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image,
.products.columns-5  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image,
.products.columns-6  .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image,
.products.columns-100 .product:has(.cgls-swatches:hover) .woocommerce-loop-product__image img.secondary-image { opacity: 0 !important; }

@media only screen and (max-width: 767px) {
    .cgls-list {
        display: block;
    }

    .cgls-more {
        margin-top: 10px;
    }
}