/* Gallery Grid is scoped to public catalogue pages. */
body[data-gallery-grid] #catalog {
  --gallery-card: var(--bh-polish-paper, #151719);
  --gallery-photo: var(--bh-polish-tint, #212427);
  --gallery-ink: var(--bh-polish-ink, #f5f2ed);
  --gallery-muted: var(--bh-polish-subtle, #bcc1c8);
  --gallery-divider: var(--bh-polish-divider, #3a3e43);
  --gallery-accent: var(--bh-polish-accent, #ffb682);
  --gallery-gold: #ab9161;
  --gallery-gold-text: #e2c78b;
  --gallery-ice: #8baab6;
  --gallery-ice-text: #b4d8df;
  --gallery-title-impact: #effbff;
  --gallery-stock: var(--bh-polish-available, #a0d4b2);
}
body.storefront-page[data-gallery-grid] main #catalog .results { min-width: 0; }
body.storefront-page[data-gallery-grid] main #catalog #products.product-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0,1fr)) !important;
  align-items: stretch;
  gap: clamp(12px, 1.4vw, 21px) !important;
  padding-top: 0;
}

body.storefront-page[data-gallery-grid] main #catalog #products > .product-card.gallery-card {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  align-content: start !important;
  justify-content: flex-start;
  gap: 4px !important;
  box-sizing: border-box;
  position: relative;
  isolation: isolate;
  min-width: 0;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 7px !important;
  border: 1px solid var(--gallery-divider) !important;
  border-radius: 4px !important;
  color: var(--gallery-ink) !important;
  background: var(--gallery-card) !important;
  box-shadow: none !important;
  transition: none !important;
  animation: none !important;
}
body[data-gallery-grid] #catalog #products > .gallery-card > :is(.ext-frame, .rarity-badge) { display: none !important; }
body.storefront-page[data-gallery-grid] main #catalog #products > .product-card.gallery-card::after {
  content: none !important;
  animation: none !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .product-card.gallery-card::before {
  content: none !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .product-card.gallery-card[data-rarity="gold"] {
  border-color: var(--gallery-gold) !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .product-card.gallery-card[data-rarity="extreme"] {
  border: 0 !important;
  border-radius: 0 !important;
  padding: 8px !important;
  clip-path: polygon(9px 0,100% 0,100% calc(100% - 9px),calc(100% - 9px) 100%,0 100%,0 9px);
}
body[data-gallery-grid] #catalog #products > .gallery-card > .gallery-cut-frame {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--gallery-ice);
  pointer-events: none;
  /* The inner polygon cuts out the centre of the one-pixel outline. */
  clip-path: polygon(evenodd,
    9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px, 9px 0,
    9.5px 1px, 1px 9.5px, 1px calc(100% - 1px), calc(100% - 9.5px) calc(100% - 1px),
    calc(100% - 1px) calc(100% - 9.5px), calc(100% - 1px) 1px, 9.5px 1px);
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .cg-photo {
  position: relative;
  inset: auto;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  background: var(--gallery-photo) !important;
  border-radius: 0;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-photo .product-image {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  aspect-ratio: 1.12 !important;
  padding: 0 !important;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: var(--gallery-photo) !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-photo .product-image :is(picture,img,svg) {
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: contain !important;
  padding: 0 !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-photo :is(.quick-view,.rarity-plaque,.ext-photo-plaque) {
  display: none !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .cg-title {
  display: block !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin: 3px 0 0 !important;
  padding: 0 !important;
  color: var(--gallery-ink) !important;
  font-size: clamp(.875rem, 1.3vw, 1.08rem) !important;
  font-weight: 650 !important;
  line-height: 1.3 !important;
  text-transform: none !important;
  text-shadow: none !important;
  white-space: normal !important;
  overflow: visible !important;
  overflow-wrap: anywhere;
  -webkit-line-clamp: unset !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .cg-label {
  display: block !important;
  position: static !important;
  inset: auto;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  pointer-events: auto;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .cg-label:empty,
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > :is(.cg-details,.growth-facts):empty {
  display: none !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-rarity {
  display: inline-block;
  padding: 0 !important;
  margin: 0;
  border: 0 !important;
  background: transparent !important;
  color: var(--gallery-gold-text) !important;
  font-size: .75rem !important;
  font-weight: 650;
  line-height: 1.2;
  box-shadow: none !important;
  text-shadow: none !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card[data-rarity="extreme"] .cg-rarity {
  color: var(--gallery-ice-text) !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > :is(.cg-details,.growth-facts) {
  display: block;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  color: var(--gallery-muted);
  margin: 0 !important;
  font-size: .75rem !important;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .cg-price {
  display: flex !important;
  align-items: baseline !important;
  align-self: stretch !important;
  justify-content: flex-start !important;
  flex-wrap: wrap;
  order: 2;
  min-height: 0 !important;
  height: auto !important;
  margin: 3px 0 0 !important;
  gap: 2px 8px;
}
body[data-gallery-grid] #catalog #products > .gallery-card > .growth-facts { order: 1; }
body[data-gallery-grid] #catalog #products > .gallery-card .cg-saving { flex-basis: 100%; }
body[data-gallery-grid] #catalog #products > .gallery-card .cg-saving:empty { display: none !important; }
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-amount {
  color: var(--gallery-ink) !important;
  font-size: clamp(1rem, 1.55vw, 1.24rem) !important;
  font-weight: 680;
  line-height: 1.2;
  white-space: nowrap;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-stock {
  color: var(--gallery-stock) !important;
  font-size: .75rem !important;
  white-space: normal !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .cg-stock.cg-low {
  color: var(--gallery-accent) !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card > .shortlist-actions {
  display: flex !important;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 12px;
  order: 3;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .shortlist-actions button,
body.storefront-page[data-gallery-grid] main #catalog .results > .growth-panel > button {
  min-height: 44px !important;
  min-width: 0 !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--gallery-muted) !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: .75rem !important;
}
body.storefront-page[data-gallery-grid] main #catalog #products > .gallery-card .shortlist-actions button[aria-pressed="true"],
body.storefront-page[data-gallery-grid] main #catalog .results > .growth-panel > button {
  color: var(--gallery-accent) !important;
}
body[data-gallery-grid] #catalog #products > .gallery-card .shortlist-actions button[aria-pressed="true"]:not(:focus-visible) {
  outline: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
body[data-gallery-grid] #catalog #products > .gallery-card .shortlist-actions button:hover,
body[data-gallery-grid] #catalog .results > .growth-panel > button:hover { text-decoration: underline; }
body[data-gallery-grid] #catalog .results > .growth-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 6px 0 9px;
  padding: 0 8px;
  color: var(--gallery-muted);
  background: var(--gallery-photo);
  border: 0;
  border-top: 1px solid var(--gallery-divider);
  border-radius: 0;
  box-shadow: none;
}
body[data-gallery-grid] #catalog .growth-panel > h2 { display: none; }
body[data-gallery-grid]:has(.csm-header-wishlist) #catalog .growth-panel[data-compare-count="0"] { display: none; }

.gallery-rarity-wording { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  body[data-gallery-grid] .gallery-title-reveal { animation: gallery-cinematic-title 1.35s both; }
}
@keyframes gallery-cinematic-title {
  0% { clip-path:inset(0 98% 0 0); opacity:0; filter:blur(4px); transform:translateY(3px) scaleX(1.10); }
  38% { clip-path:inset(-5px -8px); opacity:.9; filter:blur(1.25px); transform:scaleX(1.045); color:var(--gallery-title-impact); }
  58% { clip-path:inset(-5px -8px); opacity:1; filter:blur(0); transform:none; color:var(--gallery-title-impact); }
  100% { clip-path:inset(-5px -8px); opacity:1; filter:blur(0); transform:none; color:var(--gallery-ice-text); }
}
body.storefront-page[data-gallery-grid] main #catalog .results-toolbar {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 2px 12px;
}
body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #results-count { margin-inline-end: auto; }
body.storefront-page[data-gallery-grid] main #catalog .results-toolbar > label { display: inline-flex !important; align-items: center; gap: 6px; width: auto !important; }
body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #sort { width: auto !important; max-width: 100%; }
body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #filter-toggle {
  display: inline-flex !important;
  align-items: center;
  min-height: 44px;
  gap: 4px;
  padding: 0 4px !important;
  color: var(--gallery-accent) !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
body[data-gallery-grid] #catalog #catalog-status:empty { display:none; }

@media (min-width: 761px) {
  body.storefront-page[data-gallery-grid] main #catalog .shop-layout {
    display: grid !important;
    grid-template-columns: clamp(170px, 17vw, 230px) minmax(0, 1fr) !important;
    gap: clamp(14px, 2vw, 28px);
    align-items: start;
  }
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #filter-toggle {
    display: none !important;
  }
}
@media (min-width: 761px) and (max-width: 1050px) {
  body.storefront-page[data-gallery-grid] main #catalog #products.product-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  }
}
@media (max-width: 760px) {
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) auto minmax(0,1.5fr);
    gap: 6px;
  }
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar > label {
    grid-area: 1 / 3 !important;
    min-width: 0;
    font-size: 0;
  }
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #sort {
    width: 100% !important;
    min-width: 0;
    font-size: .875rem;
  }
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #filter-toggle {
    min-width: 0 !important;
    font-size: .875rem;
  }
  body.storefront-page[data-gallery-grid] main #catalog #products.product-grid {
    grid-template-columns: repeat(2,minmax(0,1fr)) !important;
    gap: 8px !important;
  }
}
@media (max-width: 760px), (max-width: 950px) and (max-height: 500px) and (pointer: coarse) {
  body[data-gallery-grid] #catalog {
    --gallery-gold: #a48750;
    --gallery-gold-text: #73551e;
    --gallery-ice: #76a1ac;
    --gallery-ice-text: #255e6a;
    --gallery-title-impact: #173e4b;
  }
}
@media (max-width: 760px) and (prefers-color-scheme: dark),
       (max-width: 950px) and (max-height: 500px) and (pointer: coarse) and (prefers-color-scheme: dark) {
  body[data-gallery-grid] #catalog {
    --gallery-gold: #ab9161;
    --gallery-gold-text: #e2c78b;
    --gallery-ice: #8baab6;
    --gallery-ice-text: #b4d8df;
    --gallery-title-impact: #effbff;
  }
}
@media (scripting: none) {
  body[data-gallery-grid] #catalog #filters { display: none !important; }
  body.storefront-page[data-gallery-grid] main #catalog .results-toolbar #filter-toggle { display: none !important; }
}
