/* Pulseheaven — Recommendations CSS (full file)
   - Uses horizontal scroll below desktop (<=61.24em)
   - Switches to a full-width 4-column grid on desktop (>=61.25em)
   - Fixes "right gap" via minmax(0,1fr) + min-width:0
   - Keeps all other rules unchanged
*/

/* spacing control */
:root {
  --rec-gap: 20px;                       /* gap between cards */
  --rec-desktop-break: 61.25em;          /* 980px */
  --rec-card-min: 240px;
  --rec-card-max: 360px;
}

/* container: keep vertical padding only (page already provides horizontal gutters) */
.ph-home-recs {
  box-sizing: border-box;
  width: 100%;
  padding: 2rem 0; /* vertical padding only, no horizontal edge padding */
  margin: 2rem 0;
  max-width: none;
}

.ph-rec-title {
  text-align: center;
  padding-bottom: 1.5rem;
}

/* --- LAYOUT (REPLACED) ---
   Default: horizontal single-line scroller (mobile → tablet)
   Desktop (>= 61.25em): 4-column fluid grid (no wrapping)
*/
.ph-rec-row {
  display: flex;
  flex-wrap: nowrap;                 /* prevent wrapping, keep cards on one line */
  gap: var(--rec-gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
}
.ph-rec-row::-webkit-scrollbar { display: none; }

/* Card sizing for scroll-mode: responsive using clamp() so cards remain reasonable */
.ph-rec-card {
  flex: 0 0 clamp(var(--rec-card-min), 40vw, var(--rec-card-max));
  min-width: clamp(var(--rec-card-min), 40vw, var(--rec-card-max));
  background: #f9f9f9;
  border-radius: 12px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  box-sizing: border-box;
  min-width: 0; /* allow grid to shrink card when in grid layout */
}

/* Keep first/last snap behavior */
.ph-rec-card:first-child { scroll-snap-align: start; }
.ph-rec-card:last-child  { scroll-snap-align: end; }

/* DESKTOP: at and above 61.25em, use a 4-column fluid grid (no wrapping) */

@media (min-width: 61.25em) {
  .ph-rec-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)); /* equal columns that fill the width */
    gap: var(--rec-gap);
    align-items: stretch;
    overflow: visible; /* no horizontal scroll on desktop */
  }

  .ph-rec-card {
    flex: none;
    width: 100%;
    min-width: 0; /* crucial to allow shrinking inside the grid */
  }
}

/* --- Mobile-scroll fixes (drop-in) --- */

/* Mobile / tablet: fluid horizontal scroller, cards resize but never wrap */
@media (max-width: 61.24em) {

  :root { --rec-card-width-mobile: 240px; } /* adjust if you want a different baseline */

  .ph-rec-row {
    display: flex !important;
    flex-wrap: nowrap !important;          /* never wrap cards */
    align-items: stretch;
    gap: var(--rec-gap);
    overflow-x: auto !important;
    overflow-y: hidden !important;         /* prevent vertical scroll */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;     /* iOS momentum */
    scroll-behavior: smooth;
    touch-action: pan-x;
    -ms-overflow-style: none;
    scrollbar-width: none;
    padding-bottom: 0.5rem;
  }
  .ph-rec-row::-webkit-scrollbar { display: none; }

  /* Fluid card sizing:
     - flex: 1 0 var(...) lets cards share available row space
     - min-width uses clamp so on very small screens cards don't explode
     - no !important necessary unless your theme overrides */
  .ph-rec-card {
    flex: 1 0 var(--rec-card-width-mobile);
    min-width: clamp(200px, 45vw, var(--rec-card-width-mobile));
    max-width: calc(100% - var(--rec-gap)); /* prevents a single card from exceeding viewport */
    background: #f9f9f9;
    border-radius: 12px;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
  }

  /* keep the snap anchors for first/last */
  .ph-rec-card:first-child { scroll-snap-align: start; }
  .ph-rec-card:last-child  { scroll-snap-align: end; }

  /* Prevent children from growing the card beyond its size */
  .ph-rec-card img,
  .ph-rec-img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  /* allow long text to wrap instead of expanding the card */
  .ph-rec-name,
  .ph-rec-cat,
  .ph-rec-price {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}


/* Optional: if you want a tiny visible hint of the next card,
   reduce the 70vw middle value above to 65vw or lower. */
/* --- end mobile-scroll fixes --- */


/* Links / images / hover */
.ph-rec-link {
  display: block;
  width: 100%;
  text-decoration: none;
  color: inherit;
}
.ph-rec-media {
  position: relative;
  width: 100%;
}
.ph-rec-link--media {
  position: relative;
  z-index: 1;
}
.ph-rec-link--meta {
  flex: 1 1 auto;
}
.ph-rec-wishlist {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
}
.ph-rec-wishlist .tinv-wishlist,
.ph-rec-wishlist .tinvwl_add_to_wishlist_button {
  margin: 0;
}
.ph-rec-img {
  width: 100%;
  height: auto;
  padding: 1rem 0;
  transition: transform .4s ease-in-out;
}
.ph-rec-link:hover .ph-rec-img { transform: scale(1.05); }

/* Meta area */
.ph-rec-meta {
  display: flex;
  flex-direction: column;
  gap: .5em;
  text-align: center;
  padding: 0 1rem 1rem;
}
.ph-rec-cat {
  font-size: clamp(0.8rem,1vw,0.85rem);
  font-weight: 400;
  color: #888;
  text-transform: none;
  margin: 0;
}
.ph-rec-name {
  margin: 0;
  font-size: clamp(0.9rem,1.2vw,1rem);
  font-weight: 500;
  padding: 0 .5rem;
  line-height: 1.2em;
  color: #000;
}
.ph-rec-price { font-weight: 400; color: #000; }
.ph-rec-price ins { color: #155724; }

/* CTA button */
.ph-rec-btn-wrap { text-align: center; padding-top: 2rem; }
.ph-rec-btn {
  display: inline-block;
  padding: .6rem 2rem;
  border: 1px solid #e4e4e4;
  border-radius: 14px;
  background: #e4e4e4;
  color: #000;
  font-weight: 400;
  text-decoration: none;
  transition: background .25s, border-color .25s, transform .25s;
}
.ph-rec-btn:hover {
  background: #fff;
  border-color: #e4e4e4;
  transform: translateY(-2px);
}