/* ==========================================================================
   xBoom — WooCommerce Card Styles
   Global product-card redesign. Scoped to .xbm-woo to outrank Salient.
   Works with both template-override (.xbm-card markup) and CSS-only fallback
   (native WooCommerce / WC-block markup).
   ========================================================================== */

/* ---------- Fonts (expect theme to load these already; fallback only) ----- */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@400;450;500;600&display=swap');

/* ==========================================================================
   1 · WRAPPER + TOKENS
   ========================================================================== */

/* Tokens ONLY — safe to inherit onto <body> because they're just variables,
   not visual properties. Descendants that reference them get the design system
   regardless of whether `.xbm-woo` is on the body or a nested wrapper. */
.xbm-woo {
  --xbm-bg:          #f4f3ee;
  --xbm-bg-card:     #ffffff;
  --xbm-bg-soft:     #ecebe4;
  --xbm-line:        rgba(10,10,10,0.12);
  --xbm-line-2:      rgba(10,10,10,0.22);
  --xbm-line-3:      rgba(10,10,10,0.40);
  --xbm-fg:          #0a0a0a;
  --xbm-fg-mute:     #55554d;
  --xbm-fg-dim:      #8a8a82;
  --xbm-accent:      #ff4a1c;
  --xbm-accent-hov:  #e63d10;
  --xbm-star:        #f5a623;
  --xbm-oos:         #8a8a82;

  --xbm-mono:    'JetBrains Mono', ui-monospace, monospace;
  --xbm-display: 'Space Grotesk', system-ui, sans-serif;
  --xbm-body:    'Inter', system-ui, sans-serif;
}

/* Visual treatment applies ONLY when .xbm-woo is a dedicated wrapper element
   (either the PHP-injected <div class="xbm-woo"> or the JS-injected one around
   <ul class="products">). `body.xbm-woo` is excluded so we don't nuke the
   site's own layout when the class is added to <body> as a fallback. */
.xbm-woo:not(body) {
  background: var(--xbm-bg);
  color: var(--xbm-fg);
  font-family: var(--xbm-body);
  padding: clamp(32px, 6vh, 72px) 0;
}

/* Full-bleed on archive templates that are inside a narrow container */
.xbm-woo.xbm-fullbleed:not(body) {
  width: 100vw;
  max-width: 100vw;
  position: relative;
  left: 50%; right: 50%;
  margin-left: -50vw; margin-right: -50vw;
}

.xbm-wrap { max-width: 1440px; margin: 0 auto; padding: 0 clamp(20px, 3vw, 40px); }

/* ==========================================================================
   2 · SECTION HEAD (optional, for archive pages)
   ========================================================================== */

.xbm-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 32px; margin-bottom: 40px; flex-wrap: wrap;
}
.xbm-eyebrow {
  font-family: var(--xbm-mono);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--xbm-fg-mute);
  display: inline-flex; align-items: center; gap: 10px;
}
.xbm-eyebrow::before {
  content: ''; width: 6px; height: 6px;
  background: var(--xbm-accent); border-radius: 50%;
}
.xbm-head h1, .xbm-head h2 {
  font-family: var(--xbm-display); font-weight: 500;
  font-size: clamp(32px, 4vw, 52px); letter-spacing: -0.025em;
  line-height: 0.98; max-width: 16ch; margin: 0;
}
.xbm-head h1 em, .xbm-head h2 em {
  color: var(--xbm-accent); font-style: italic; font-weight: 400;
}
.xbm-head-count {
  font-family: var(--xbm-mono); font-size: 11px; color: var(--xbm-fg-mute);
  letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px;
}
.xbm-head-count b { color: var(--xbm-fg); font-weight: 500; }

/* ==========================================================================
   3 · CATEGORY CHIPS (shop archive)
   ========================================================================== */

.xbm-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 40px; padding-bottom: 24px;
  border-bottom: 1px solid var(--xbm-line);
  list-style: none; padding-left: 0;
}
.xbm-chips li { margin: 0; }
.xbm-chip {
  font-family: var(--xbm-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 9px 16px;
  border: 1px solid var(--xbm-line-2); border-radius: 999px;
  color: var(--xbm-fg-mute); background: transparent;
  transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  cursor: pointer; text-decoration: none;
}
.xbm-chip:hover { border-color: var(--xbm-line-3); color: var(--xbm-fg); background: var(--xbm-bg-soft); }
.xbm-chip.is-active { background: var(--xbm-fg); color: var(--xbm-bg); border-color: var(--xbm-fg); }
.xbm-chip .xbm-n { font-size: 10px; color: var(--xbm-fg-dim); font-variant-numeric: tabular-nums; }
.xbm-chip.is-active .xbm-n { color: rgba(244,243,238,0.55); }

/* ==========================================================================
   4 · GRID (ul.products)
   Target both template-override markup and native WC / WC-block markup.
   ========================================================================== */

.xbm-woo ul.products,
.xbm-woo .wc-block-grid__products,
.xbm-woo .xbm-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 1px !important;
  background: var(--xbm-line);
  border: 1px solid var(--xbm-line);
  list-style: none; padding: 0; margin: 0;
  float: none !important;
}
/* Laptop / small desktop — 3 across */
@media (max-width: 1200px) { .xbm-woo ul.products, .xbm-woo .wc-block-grid__products, .xbm-woo .xbm-grid { grid-template-columns: repeat(3, 1fr) !important; } }
/* iPad portrait / large phones landscape — 2 across */
@media (max-width: 900px)  { .xbm-woo ul.products, .xbm-woo .wc-block-grid__products, .xbm-woo .xbm-grid { grid-template-columns: repeat(2, 1fr) !important; } }
/* Phones — 1 across (covers modern phones 390–430px which were previously cramped in 2-col) */
@media (max-width: 560px)  { .xbm-woo ul.products, .xbm-woo .wc-block-grid__products, .xbm-woo .xbm-grid { grid-template-columns: 1fr !important; } }

/* ==========================================================================
   5 · CARD (li.product | .xbm-card | .wc-block-grid__product)
   ========================================================================== */

.xbm-woo ul.products li.product,
.xbm-woo .wc-block-grid__product,
.xbm-woo .xbm-card {
  background: var(--xbm-bg-card);
  display: flex !important;
  flex-direction: column !important;
  position: relative;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  float: none !important;
  list-style: none;
  overflow: hidden;
  transition: box-shadow 0.2s, background 0.2s;
}
.xbm-woo ul.products li.product:hover,
.xbm-woo .wc-block-grid__product:hover,
.xbm-woo .xbm-card:hover {
  background: #fff;
  z-index: 2;
  box-shadow: 0 0 0 1px var(--xbm-line-3);
}

/* Reset Salient's default card chrome inside our scope */
.xbm-woo ul.products li.product::before,
.xbm-woo ul.products li.product::after { content: none !important; }
.xbm-woo ul.products li.product .onsale { display: none !important; } /* replaced by our badge */

/* ==========================================================================
   6 · GRID CODE  +  BADGE  (top L / top R)
   ========================================================================== */

.xbm-code {
  position: absolute; top: 14px; left: 14px;
  font-family: var(--xbm-mono);
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--xbm-fg-dim); z-index: 3; pointer-events: none;
}
.xbm-code b { color: var(--xbm-fg-mute); font-weight: 500; }

.xbm-badge {
  position: absolute; top: 14px; right: 14px;
  font-family: var(--xbm-mono);
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--xbm-fg-dim); z-index: 3;
  display: flex; align-items: center; gap: 5px;
}
.xbm-badge.is-featured { color: var(--xbm-accent); }
.xbm-badge.is-featured::before { content: ''; width: 5px; height: 5px; background: var(--xbm-accent); border-radius: 50%; }
.xbm-badge.is-oos { color: var(--xbm-oos); }
.xbm-badge.is-oos::before { content: ''; width: 5px; height: 5px; background: var(--xbm-oos); }

/* ==========================================================================
   7 · WISHLIST (proxies YITH click)
   ========================================================================== */

.xbm-wishlist {
  position: absolute; top: 48px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(6px);
  border: 1px solid var(--xbm-line); color: var(--xbm-fg-mute);
  opacity: 0; transform: translateX(4px);
  transition: all 0.2s; z-index: 4; cursor: pointer;
}
.xbm-woo ul.products li.product:hover .xbm-wishlist,
.xbm-card:hover .xbm-wishlist { opacity: 1; transform: translateX(0); }
.xbm-wishlist:hover { color: var(--xbm-accent); border-color: var(--xbm-accent); }
.xbm-wishlist.is-active {
  opacity: 1; transform: translateX(0);
  color: var(--xbm-accent); background: #fff;
}
.xbm-wishlist svg { width: 14px; height: 14px; }

/* Hide YITH's own button — we proxy it */
.xbm-woo ul.products .yith-wcwl-add-to-wishlist,
.xbm-woo .xbm-card .yith-wcwl-add-to-wishlist {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important;
  pointer-events: none;
}

/* ==========================================================================
   8 · IMAGE  (hover swap)
   ========================================================================== */

.xbm-woo ul.products li.product a.woocommerce-LoopProduct-link,
.xbm-woo ul.products li.product > a:first-of-type,
.xbm-woo .xbm-card-img {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  background: var(--xbm-bg-soft);
  overflow: hidden;
  border-bottom: 1px solid var(--xbm-line);
  text-decoration: none;
}

/* Constrain/contain product imagery */
.xbm-woo ul.products li.product img,
.xbm-woo .xbm-card-img img {
  position: absolute !important;
  inset: 0;
  width: 100% !important; height: 100% !important;
  object-fit: contain;
  padding: 14%;
  margin: 0 !important;
  transition: opacity 0.35s, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 2nd image (hover) — the PHP template outputs both; CSS-only fallback only
   has one image so this is a no-op there */
.xbm-card-img .xbm-img-2 { opacity: 0; transform: scale(1.04); }
.xbm-card:hover .xbm-img-1,
.xbm-woo ul.products li.product:hover .xbm-img-1 { opacity: 0; transform: scale(0.97); }
.xbm-card:hover .xbm-img-2,
.xbm-woo ul.products li.product:hover .xbm-img-2 { opacity: 1; transform: scale(1); }

/* Crosshair removed — was cutting through product photos. */

/* Touch devices: no hover swap, no crosshair darkening */
@media (hover: none) {
  .xbm-wishlist { opacity: 1; transform: none; }
  .xbm-card-img .xbm-img-2 { display: none; }
}

/* ==========================================================================
   9 · CARD BODY  (name / rating / price / CTA)
   ========================================================================== */

.xbm-woo ul.products li.product,
.xbm-card { }

.xbm-body {
  padding: 20px 20px 22px;
  display: flex; flex-direction: column; gap: 10px; flex: 1;
}

/* Product name — override WC's default .woocommerce-loop-product__title */
.xbm-woo ul.products li.product h2.woocommerce-loop-product__title,
.xbm-woo ul.products li.product .woocommerce-loop-product__title,
.xbm-name {
  font-family: var(--xbm-display) !important;
  font-weight: 500 !important;
  font-size: 15px !important;
  line-height: 1.25 !important;
  letter-spacing: -0.005em !important;
  color: var(--xbm-fg) !important;
  padding: 0 !important;
  margin: 0 !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(15px * 1.25 * 2);
  transition: color 0.15s;
}
.xbm-woo ul.products li.product:hover h2.woocommerce-loop-product__title,
.xbm-woo ul.products li.product:hover .woocommerce-loop-product__title,
.xbm-card:hover .xbm-name { color: var(--xbm-accent) !important; }

/* Rating */
.xbm-rating {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--xbm-mono); font-size: 10px;
  color: var(--xbm-fg-dim); letter-spacing: 0.06em;
}
.xbm-rating-stars { display: inline-flex; gap: 1px; }
.xbm-rating-stars svg { width: 11px; height: 11px; color: var(--xbm-star); }
.xbm-rating-stars svg.is-empty { color: var(--xbm-line-2); }
.xbm-rating .xbm-rc::before { content: '('; }
.xbm-rating .xbm-rc::after  { content: ')'; }
.xbm-rating.is-empty { opacity: 0.5; }

/* Style WC's native star markup when CSS-only mode is used */
.xbm-woo ul.products li.product .star-rating {
  font-size: 11px !important;
  color: var(--xbm-star) !important;
  margin: 0 !important;
  height: 1em !important; line-height: 1 !important;
}
.xbm-woo ul.products li.product .star-rating::before {
  color: var(--xbm-line-2) !important;
}

/* Price — wraps so old price / discount drop to a second line on narrow cards
   instead of overflowing */
.xbm-woo ul.products li.product .price,
.xbm-price {
  display: flex !important;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 4px 0 0 0 !important;
  padding: 0 !important;
  color: var(--xbm-fg) !important;
  font-variant-numeric: tabular-nums;
  font-size: clamp(16px, 3.8vw, 20px) !important;
  font-family: var(--xbm-display) !important;
  font-weight: 500 !important;
  line-height: 1.1;
}
.xbm-woo ul.products li.product .price del,
.xbm-price .xbm-price-old {
  font-family: var(--xbm-mono) !important;
  font-size: 11px !important;
  color: var(--xbm-fg-dim) !important;
  font-weight: 400 !important;
  opacity: 1 !important;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  order: 1;
}
.xbm-woo ul.products li.product .price ins,
.xbm-price .xbm-price-now {
  background: none !important;
  color: var(--xbm-fg) !important;
  font-family: var(--xbm-display) !important;
  font-size: clamp(16px, 3.8vw, 20px) !important;
  font-weight: 500 !important;
  letter-spacing: -0.01em !important;
  text-decoration: none !important;
  order: 2;
}
.xbm-price .xbm-price-discount {
  font-family: var(--xbm-mono);
  font-size: 10px;
  color: var(--xbm-accent);
  margin-left: auto;
  letter-spacing: 0.05em;
  order: 3;
}

/* Enquire state (price row replaced with a link) */
.xbm-price-enquire {
  font-family: var(--xbm-mono);
  font-size: 11px;
  color: var(--xbm-accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.xbm-price-enquire::after { content: '→'; transition: transform 0.2s; }
.xbm-price-enquire:hover::after { transform: translateX(3px); }

/* ==========================================================================
   10 · CTAS  (Add to cart / Request quote / Notify me)
   ========================================================================== */

.xbm-woo ul.products li.product a.button,
.xbm-woo ul.products li.product button.button,
.xbm-cta {
  margin-top: 14px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px !important;
  background: var(--xbm-accent) !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 999px !important;
  font-family: var(--xbm-body) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  letter-spacing: 0.01em !important;
  text-transform: none !important;
  transition: all 0.15s;
  width: fit-content !important;
  align-self: flex-start;
  text-decoration: none;
  box-shadow: none !important;
  text-shadow: none !important;
}
.xbm-woo ul.products li.product a.button:hover,
.xbm-woo ul.products li.product button.button:hover,
.xbm-cta:hover {
  background: var(--xbm-accent-hov) !important;
  gap: 10px;
}
.xbm-cta svg { width: 13px; height: 13px; }

/* Out-of-stock / read-more CTA variant */
.xbm-cta.is-oos,
.xbm-woo ul.products li.product.outofstock a.button {
  background: transparent !important;
  color: var(--xbm-fg-mute) !important;
  border: 1px solid var(--xbm-line-2) !important;
}
.xbm-cta.is-oos:hover,
.xbm-woo ul.products li.product.outofstock a.button:hover {
  background: var(--xbm-bg-soft) !important;
  color: var(--xbm-fg) !important;
}

/* Request-quote (enquire) */
.xbm-cta.is-enquire {
  background: transparent !important;
  border: 1px solid var(--xbm-fg) !important;
  color: var(--xbm-fg) !important;
}
.xbm-cta.is-enquire:hover {
  background: var(--xbm-fg) !important;
  color: var(--xbm-bg) !important;
}

/* "Added" confirmation state */
.xbm-woo ul.products li.product a.added_to_cart {
  display: none !important; /* we show our own toast via JS */
}

/* ==========================================================================
   11 · RESPONSIVE TUNING  (iPad + phones)
   Desktop (≥1201px): 4-up grid, full padding.
   Laptop (≤1200px) : 3-up grid.
   iPad portrait (≤900px) : 2-up grid, body padding tightened a little.
   Phones (≤560px) : 1-up grid, tighter body padding and type scale.
   ========================================================================== */

/* iPad portrait — slightly reduce inner padding so cards breathe */
@media (max-width: 900px) {
  .xbm-woo:not(body) { padding: clamp(24px, 4vh, 48px) 0; }
  .xbm-wrap { padding: 0 20px; }
  .xbm-body { padding: 18px 18px 20px; gap: 9px; }
  .xbm-code, .xbm-badge { top: 12px; }
  .xbm-code { left: 12px; }
  .xbm-badge { right: 12px; }
  .xbm-wishlist { right: 12px; top: 42px; }
  .xbm-woo ul.products li.product img,
  .xbm-card-img img { padding: 12%; }
}

/* Phones — 1-up grid, tighter chrome, smaller type, compact CTA */
@media (max-width: 560px) {
  .xbm-woo:not(body) { padding: 20px 0; }
  .xbm-wrap { padding: 0 14px; }

  /* Head / chips compress */
  .xbm-head { margin-bottom: 24px; gap: 16px; }
  .xbm-chips { margin-bottom: 24px; padding-bottom: 16px; gap: 6px; }
  .xbm-chip { padding: 7px 12px; font-size: 10px; }

  /* Card body */
  .xbm-body { padding: 14px 14px 16px; gap: 8px; }

  /* Product name — 14px, still clamp to 2 lines */
  .xbm-woo ul.products li.product h2.woocommerce-loop-product__title,
  .xbm-woo ul.products li.product .woocommerce-loop-product__title,
  .xbm-name {
    font-size: 14px !important;
    min-height: calc(14px * 1.25 * 2);
  }

  /* Price — keep readable at small sizes */
  .xbm-woo ul.products li.product .price,
  .xbm-price { font-size: 17px !important; gap: 4px 8px; }
  .xbm-woo ul.products li.product .price ins,
  .xbm-price .xbm-price-now { font-size: 17px !important; }
  .xbm-price .xbm-price-discount { margin-left: 0; }

  /* Code / badge / wishlist — closer to edges */
  .xbm-code, .xbm-badge { top: 10px; font-size: 9px; }
  .xbm-code  { left: 10px; }
  .xbm-badge { right: 10px; }
  .xbm-wishlist { top: 36px; right: 10px; width: 28px; height: 28px; opacity: 1; transform: none; }
  .xbm-wishlist svg { width: 12px; height: 12px; }

  /* Image — less padding so product fills more of the square */
  .xbm-woo ul.products li.product img,
  .xbm-card-img img { padding: 10%; }

  /* CTA — tighter and full-width feel */
  .xbm-woo ul.products li.product a.button,
  .xbm-woo ul.products li.product button.button,
  .xbm-cta { margin-top: 10px !important; padding: 10px 16px !important; font-size: 12.5px !important; }

  /* Section title */
  .xbm-head h1, .xbm-head h2 { font-size: clamp(26px, 7vw, 36px); }
}

/* Very narrow (≤360px) — last-resort squeeze */
@media (max-width: 360px) {
  .xbm-body { padding: 12px 12px 14px; }
  .xbm-woo ul.products li.product .price,
  .xbm-price { font-size: 16px !important; }
}

/* ==========================================================================
   12 · RELATED / UPSELLS / CROSS-SELLS  (surgical — no global Flickity touch)
   The PREVIOUS version of this block tried to neutralize Flickity globally
   (`.xbm-woo .flickity-*`), which broke every embedded slider on category
   pages that had shortcode-injected product carousels in their description.
   This version only touches items that are explicit descendants of the
   related/upsells/cross-sells section wrappers, so unrelated Flickity
   instances keep working normally.
   ========================================================================== */

/* Items in related/upsells/cross-sells: drop Flickity's absolute positioning
   so they flow into the grid — scoped to these sections only */
.related.products ul.products li.product,
.upsells.products ul.products li.product,
.cross-sells ul.products li.product {
  position: relative !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
}

/* Kill Flickity viewport/slider ONLY inside these sections */
.related.products .flickity-viewport,
.related.products .flickity-slider,
.upsells.products .flickity-viewport,
.upsells.products .flickity-slider,
.cross-sells .flickity-viewport,
.cross-sells .flickity-slider {
  position: static !important;
  height: auto !important;
  transform: none !important;
  overflow: visible !important;
  width: auto !important;
}
.related.products ul.products.flickity-enabled,
.upsells.products ul.products.flickity-enabled,
.cross-sells ul.products.flickity-enabled { height: auto !important; }

/* Hide Flickity nav chrome only within these sections */
.related.products .flickity-prev-next-button,
.related.products .flickity-page-dots,
.upsells.products .flickity-prev-next-button,
.upsells.products .flickity-page-dots,
.cross-sells .flickity-prev-next-button,
.cross-sells .flickity-page-dots { display: none !important; }

/* Auto-fit grid for these sections so 3 or 4 items fill cleanly */
.related.products ul.products,
.upsells.products ul.products,
.cross-sells ul.products {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
}
@media (max-width: 560px) {
  .related.products ul.products,
  .upsells.products ul.products,
  .cross-sells ul.products { grid-template-columns: 1fr !important; }
}

/* Section headings */
.related.products > h2,
.upsells.products > h2,
.cross-sells > h2 {
  font-family: var(--xbm-display);
  font-weight: 500;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  color: var(--xbm-fg);
}
