/* ========================== */
/* CUSTOM PRODUCT GRID STYLES */
/* ========================== */

/* --- 1. THE GRID CONTAINER --- */
.custom-product-grid-wrapper .custom-product-grid {
    display: grid;
    /* Desktop: 5 columns */
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    list-style: none; 
    padding: 0;       
    margin: 0;
    align-items: stretch; /* Ensures all grid items stretch to equal height */
}

/* --- Responsive Grid Columns --- */
@media (min-width: 481px) and (max-width: 1384px) {
    .custom-product-grid-wrapper .custom-product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* --- MOBILE LAYOUT: 2 COLUMNS (Vertical Cards) --- */
@media (max-width: 480px) {
    .custom-product-grid-wrapper .custom-product-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 Cards per row */
        gap: 10px; /* Tighter gap */
        padding: 0 5px; /* 5px Spacing on edges of screen */
    }
}


/* --- 2. THE CARD STYLE (Equal Height) --- */
.custom-product-grid-wrapper .custom-product-card {
    background: #fff !important;
    border: 1px solid #eee !important;
    border-radius: 2px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column; /* Always vertical (Image Top, Text Bottom) */
    text-align: center;
    transition: border-color 0.2s ease !important;
    height: 100%; /* Forces card to fill the grid cell height */
}

/* Hover: Darken border */
.custom-product-grid-wrapper .custom-product-card:hover {
    border-color: none !important;
    box-shadow: none !important;
    transform: none !important;
}


/* --- 3. IMAGE WRAPPER (Square & Grey, Full Fill) --- */
.custom-product-grid-wrapper .custom-product-card .product-image-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;      
    background: #f9f9f9;      
    border-bottom: 1px solid #f0f0f0;
    overflow: hidden;
    margin-bottom: 15px;
    flex-shrink: 0; 
}

/* Image Fit: Contain but FULL Size (No Padding) */
.custom-product-grid-wrapper .custom-product-card .product-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;      /* Ensures whole product is seen */
    padding: 0 !important;    /* REMOVED PADDING: Image takes full space */
    mix-blend-mode: multiply; /* Blends white bg images into grey */
    transition: opacity 0.3s ease-in-out;
}


/* --- Image Swap Logic (Primary/Secondary) --- */
.custom-product-grid-wrapper .custom-product-card .product-image-wrapper .primary-image,
.custom-product-grid-wrapper .custom-product-card .product-image-wrapper .secondary-image {
    position: absolute;
    top: 0; left: 0;
}

.custom-product-grid-wrapper .custom-product-card .product-image-wrapper .secondary-image {
    opacity: 0;
}

.custom-product-grid-wrapper .custom-product-card:hover .product-image-wrapper .secondary-image {
    opacity: 1;
}

.custom-product-grid-wrapper .custom-product-card:hover .product-image-wrapper:has(.secondary-image) .primary-image {
    opacity: 0;
}

@media (max-width: 1384px) {
  .custom-product-grid-wrapper .custom-product-card:hover .product-image-wrapper .secondary-image { opacity: 0; }
  .custom-product-grid-wrapper .custom-product-card:hover .product-image-wrapper:has(.secondary-image) .primary-image { opacity: 1; }
}


/* --- 4. TYPOGRAPHY & DETAILS (Vertical Layout) --- */

.custom-product-grid-wrapper .product-details {
    /* Padding prevents text from touching edges */
    padding: 0 8px 15px 8px; 
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center; /* Ensure center alignment */
    flex-grow: 1; 
}

/* BRAND (Top Line): Capitals, 14px, Bold */
.custom-product-grid-wrapper .product-brand {
    display: block;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    color: #333;           
    margin-bottom: 5px;
    margin-top: 0;
    letter-spacing: 0.5px;
}

/* PRODUCT NAME: 16px, Default Font (Normal Weight) */
.custom-product-grid-wrapper .product-title {
    font-size: 16px !important;
    font-weight: 400 !important; /* Normal weight */    
    color: #000;
    margin: 0 0 8px 0;
    line-height: 1.3;
    word-wrap: break-word;
}

/* PRICE: 14px, Bold */
.custom-product-grid-wrapper .product-price {
    font-size: 14px !important;
    font-weight: 700 !important;      
    color: #111;
    margin-bottom: 0;
    margin-top: auto; /* Pushes price to bottom */
}

/* OLD PRICE (Before Sale): Red */
.custom-product-grid-wrapper .product-price del {
    color: #d00000 !important;  /* Red */
    margin-right: 8px;
    opacity: 1;
    text-decoration: line-through;
    font-weight: 400;
}

/* CURRENT PRICE (Sale): Standard/Black */
.custom-product-grid-wrapper .product-price ins {
    text-decoration: none;
    color: #111;
}


/* --- 5. RIBBONS (Pro Style) --- */
.custom-product-grid-wrapper .sale-ribbon,
.custom-product-grid-wrapper .new-ribbon,
.custom-product-grid-wrapper .stock-ribbon.out {
    position: absolute;
    top: 8px; 
    left: 8px;
    font-size: 9px;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 2px;
    z-index: 20;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.custom-product-grid-wrapper .sale-ribbon { background-color: #d00000; }
.custom-product-grid-wrapper .new-ribbon { background-color: #000000; }
.custom-product-grid-wrapper .stock-ribbon.out { background-color: #757575; }


/* --- 6. LAYOUT HELPERS --- */
.custom-product-grid-wrapper {
    width: 100%;
    flex-grow: 1;
}

/*********************************************************/
/*** LOAD MORE BUTTON FOR PRODUCT GRID IN ARCHIVES ***/
/*********************************************************/

.load-more-wrapper {
  text-align: center;
  padding: 40px 0;    
  display: block;       
}

.custom-product-grid-wrapper .load-more-button {
  display: inline-block; 
  width: auto;            
  min-width: 400px;       
  padding: 16px 24px;    
  font-size: 16px;
  font-weight: bold;
  background: #000;
  color: #fff;
  text-decoration: none;
  border: none;
  border-radius: 1px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.1s ease;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 480px) {
    .custom-product-grid-wrapper .load-more-button {
        min-width: 100%; /* Full width button on mobile */
        width: 100%;
        box-sizing: border-box;
    }
}

.custom-product-grid-wrapper .load-more-button:hover {
  background: #333;
}

.custom-product-grid-wrapper .load-more-button:active {
  transform: scale(0.98);
  background: #000;
}