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

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

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

.cgls-list {
  display: inline-grid;
  grid-template-columns: repeat(5, 25px);   /* 5 per row -> 2 rows (9 swatches + "+N") */
  gap: 8px 9px;
  padding-left: 10px;
  align-items: center;
  justify-items: center;
  max-width: 100%;
}
.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;
  min-width: 25px;
  white-space: nowrap;
  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; }

/* =================================================================
   EQUAL-HEIGHT CARDS (desktop + mobile)
   Applies to EVERY card in the main product grid (with or without
   swatches) so all cards in a row stretch to the tallest one.
   Sliders (.strapsco-2025-product-slider) are left alone.
   ================================================================= */
ul.products:not(.strapsco-2025-product-slider *) {
  align-items: stretch !important;
}

ul.products:not(.strapsco-2025-product-slider *) > li.product {
  display: flex !important;
  flex-direction: column;
  align-self: stretch !important;
  height: auto;
}

ul.products:not(.strapsco-2025-product-slider *) > li.product > a.woocommerce-LoopProduct-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

/* swatch strip pinned to the bottom of the card content */
ul.products:not(.strapsco-2025-product-slider *) > li.product .cgls-swatches {
  margin-top: auto;
  padding-top: 12px;
}

/* =================================================================
   MOBILE – centered grid, slightly smaller swatches
   ================================================================= */
@media only screen and (max-width: 767px) {

  .cgls-swatches { width: 100%; }

  .cgls-list,
  .archive .cgls-list {
    display: grid;
    grid-template-columns: repeat(5, 22px);
    justify-content: center;
    gap: 8px 8px;
    width: 100%;
    padding-left: 0;
    box-sizing: border-box;
  }

  .cgls-swatch {
    width: 22px;
    height: 22px;
    margin: 0;
  }

  .cgls-more {
    margin: 0;
    height: 22px;
    font-size: 15px;
    white-space: nowrap;
  }
}

/* Very narrow phones */
@media only screen and (max-width: 360px) {
  .cgls-list,
  .archive .cgls-list { grid-template-columns: repeat(5, 20px); gap: 6px; }
  .cgls-swatch { width: 20px; height: 20px; }
  .cgls-more { font-size: 14px; }
}
