/* Section layout - Figma: ivory bg, 96px padding, centered header, 96px gap */
.collection-product-grid {
  background-color: #fefefd;
  padding: 48px 24px;
}

@media (min-width: 1024px) {
  .collection-product-grid {
    padding: 96px;
  }
}

.collection-product-grid__container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

@media (min-width: 1024px) {
  .collection-product-grid__container {
    gap: 96px;
  }
}

/* Header: eyebrow + heading, centered */
.collection-product-grid__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  width: 100%;
}

@media (min-width: 1024px) {
  .collection-product-grid__header {
    gap: 24px;
  }
}

.collection-product-grid__eyebrow {
  font-family: var(--font-body, 'Lexend Deca', sans-serif);
  font-weight: 300;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #545a6d;
  margin: 0;
}

.collection-product-grid__heading {
  font-family: var(--font-serif, 'Conso Serif', serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 40px;
  color: #2a2d37;
  margin: 0;
  max-width: 872px;
}

@media (min-width: 1024px) {
  .collection-product-grid__heading {
    font-size: 48px;
    line-height: 56px;
  }
}

/* Grid: 1 col mobile, 2 col tablet, 3 col desktop */
.collection-product-grid__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

@media (min-width: 750px) {
  .collection-product-grid__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .collection-product-grid__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Stack/bundle products always render last in the grid (visual reorder via
   CSS `order` so we don't have to duplicate the card markup or do two-pass
   Liquid iteration). The matched cards still occupy their natural DOM slot
   so screen readers / SEO order is preserved as Fluid returns it. */
.collection-product-grid__card[data-product-handle*="stack"] {
  order: 999;
}

/* Card base — no forced min-height. Cards size to their content, which
   removes the awkward gap between title and CTA on products without a
   subtitle. Within a row, CSS Grid's default align-items: stretch keeps
   all cards visually aligned to the tallest card's height, so neighbors
   stay in sync without explicit min-height. */
.collection-product-grid__card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  border-radius: 16px;
  box-sizing: border-box;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.collection-product-grid__card:hover {
  transform: translateY(-2px);
}

/* ─── Theme color palettes (from Figma variables) ────────────── */
/* glacier - BPC 157 */
.collection-product-grid__card[data-theme="glacier"] {
  background-color: #e9edf6;
}
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__title,
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__price {
  color: #313745;
}
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__subtitle,
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__subscription-price,
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__btn--subscribe {
  color: #626e8b;
}
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__btn--subscribe {
  border-color: #626e8b;
}
.collection-product-grid__card[data-theme="glacier"] .collection-product-grid__btn--atc {
  background-color: #626e8b;
  color: #e9edf6;
}

/* moss - TB4 Frag */
.collection-product-grid__card[data-theme="moss"] {
  background-color: #eef1f0;
}
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__title,
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__price {
  color: #393e3c;
}
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__subtitle,
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__subscription-price,
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__btn--subscribe {
  color: #737d79;
}
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__btn--subscribe {
  border-color: #737d79;
}
.collection-product-grid__card[data-theme="moss"] .collection-product-grid__btn--atc {
  background-color: #737d79;
  color: #eef1f0;
}

/* shale - Epitalon */
.collection-product-grid__card[data-theme="shale"] {
  background-color: #dddee2;
}
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__title,
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__price {
  color: #1c1e24;
}
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__subtitle,
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__subscription-price,
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__btn--subscribe {
  color: #545a6d;
}
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__btn--subscribe {
  border-color: #545a6d;
}
.collection-product-grid__card[data-theme="shale"] .collection-product-grid__btn--atc {
  background-color: #545a6d;
  color: #dddee2;
}

/* dune - KPV */
.collection-product-grid__card[data-theme="dune"] {
  background-color: #f8f6f3;
}
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__title,
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__price {
  color: #494641;
}
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__subtitle,
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__subscription-price,
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__btn--subscribe {
  color: #938b83;
}
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__btn--subscribe {
  border-color: #938b83;
}
.collection-product-grid__card[data-theme="dune"] .collection-product-grid__btn--atc {
  background-color: #938b83;
  color: #f8f6f3;
}

/* canyon - Thymogen Alpha-1 */
.collection-product-grid__card[data-theme="canyon"] {
  background-color: #f7ece6;
}
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__title,
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__price {
  color: #47352c;
}
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__subtitle,
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__subscription-price,
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__btn--subscribe {
  color: #8e6a58;
}
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__btn--subscribe {
  border-color: #8e6a58;
}
.collection-product-grid__card[data-theme="canyon"] .collection-product-grid__btn--atc {
  background-color: #8e6a58;
  color: #f7ece6;
}

/* Image - Figma: 384 tall, 16px radius, flex-shrink 0 */
.collection-product-grid__image-wrapper {
  display: block;
  width: 100%;
  aspect-ratio: 352 / 384;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  text-decoration: none;
}

.collection-product-grid__image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.collection-product-grid__card:hover .collection-product-grid__image-wrapper img {
  transform: scale(1.03);
}

/* Content wrapper — stacks title/subtitle and footer top-down with a
   24px gap. Previously used justify-content: space-between, but that
   pushed the footer to the bottom of the card when a neighbor row-card
   was taller (grid align-items: stretch), creating the visible gap
   between title and CTA on products without a subtitle. Packing to the
   top means any "stretched to match neighbor" extra space sits below
   the CTA rather than between title and CTA. */
.collection-product-grid__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 24px;
}

/* Title + subtitle */
.collection-product-grid__text {
  display: flex;
  flex-direction: column;
}

.collection-product-grid__title {
  font-family: var(--font-serif, 'Conso Serif', serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 40px;
  margin: 0;
}

/* Title link — visually indistinct from the H3 by default, but with a
   clear hover affordance (opacity dip + underline) to signal it's
   navigable to the PDP. `display: inline-block` keeps the multi-line
   text wrapping natural while making the entire title text a direct
   click target (was inline before, which only made the text glyphs
   themselves clickable). */
.collection-product-grid__title a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  transition: opacity 0.15s ease, text-decoration-color 0.15s ease;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}
.collection-product-grid__title a:hover,
.collection-product-grid__title a:focus-visible {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 4px;
}
.collection-product-grid__title a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 2px;
}

.collection-product-grid__subtitle {
  font-family: var(--font-body, 'Lexend Deca', sans-serif);
  font-weight: 300;
  font-size: 16px;
  line-height: 24px;
  margin: 0;
}

/* Footer: price + buttons */
.collection-product-grid__footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.collection-product-grid__price-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.collection-product-grid__price {
  font-family: var(--font-serif, 'Conso Serif', serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 40px;
  white-space: nowrap;
}

.collection-product-grid__subscription-price {
  font-family: var(--font-body, 'Lexend Deca', sans-serif);
  font-weight: 300;
  font-size: 16px;
  line-height: 24px;
  white-space: nowrap;
}

/* Button row */
.collection-product-grid__buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.collection-product-grid__btn {
  flex: 1 0 0;
  min-width: 0;
  height: 48px;
  padding: 8px 24px;
  border-radius: 8px;
  font-family: var(--font-body, 'Lexend Deca', sans-serif);
  font-weight: 400;
  font-size: 14px;
  line-height: 24px;
  letter-spacing: 1.4px;
  text-transform: capitalize;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.collection-product-grid__btn:hover {
  opacity: 0.88;
}

.collection-product-grid__btn:active {
  transform: translateY(1px);
}

.collection-product-grid__btn--subscribe {
  background-color: transparent;
  border: 1px solid currentColor;
}

.collection-product-grid__btn--atc {
  border: none;
}

.collection-product-grid__empty {
  text-align: center;
  color: #545a6d;
  padding: 48px 0;
}

/* Mobile: stack buttons vertically, full-width per Figma 3473:10807 */
@media (max-width: 749px) {
  .collection-product-grid__buttons {
    flex-direction: column;
    gap: 8px;
  }
  .collection-product-grid__btn {
    flex: 0 0 auto;
    width: 100%;
  }
}
