/* ================================================================
   SUNNYBANK FLOWERS — FINAL PRODUCT GRID (BlankSlate + WooCommerce)
   Fully fixed – no more first-product jumping right
   Works on desktop, tablet & mobile – tested with WooCommerce 10.3.5
================================================================ */

/* ================== 0. GLOBAL HIDES (User Request) ================== */
.woocommerce-products-header,
.tax-product_cat .page-title,
.tax-product_cat .term-description,
.post-type-archive-product .page-title,
.post-type-archive-product .page-description {
    display: none !important;
}

/* ================== 1. ARCHIVE / CATEGORY GRID ================== */
.woocommerce ul.products,
.woocommerce-page ul.products {
    display: grid !important;
    /* 4 Columns on Desktop (Max - per user request) */
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 12px;
    padding: 10px 10px;
    max-width: 1400px;
    margin: 0 auto;
    list-style: none !important;
    width: 100% !important;
    box-sizing: border-box;
}

/* Product card base – flex column so button stays at bottom */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    float: none !important;
    clear: none !important;
    margin: 0 !important;
    padding: 0;
    width: auto !important;
    min-width: 0;
    display: flex !important;
    flex-direction: column;
    text-align: center;
    background: var(--sb-bg-light, #F9F7F2);
    border-radius: 12px;
    /* Small radius */
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    /* Entrance Animation */
    animation: sbCardFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
    /* Pre-state for safe fallbacks */
}

@keyframes sbCardFadeIn {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger Delays for a cascading effect */
.woocommerce ul.products li.product:nth-child(1) {
    animation-delay: 0.04s;
}

.woocommerce ul.products li.product:nth-child(2) {
    animation-delay: 0.08s;
}

.woocommerce ul.products li.product:nth-child(3) {
    animation-delay: 0.12s;
}

.woocommerce ul.products li.product:nth-child(4) {
    animation-delay: 0.16s;
}

.woocommerce ul.products li.product:nth-child(5) {
    animation-delay: 0.20s;
}

.woocommerce ul.products li.product:nth-child(6) {
    animation-delay: 0.24s;
}

.woocommerce ul.products li.product:nth-child(7) {
    animation-delay: 0.28s;
}

.woocommerce ul.products li.product:nth-child(8) {
    animation-delay: 0.32s;
}

.woocommerce ul.products li.product:nth-child(9) {
    animation-delay: 0.36s;
}

.woocommerce ul.products li.product:nth-child(10) {
    animation-delay: 0.40s;
}

.woocommerce ul.products li.product:nth-child(11) {
    animation-delay: 0.44s;
}

.woocommerce ul.products li.product:nth-child(12) {
    animation-delay: 0.48s;
}

/* KILL EVERYTHING that could ever break the grid */
.woocommerce ul.products li.product.first,
.woocommerce ul.products li.product.last,
.woocommerce ul.products li.product[class*="columns-"],
.woocommerce-page ul.products li.product.first,
.woocommerce-page ul.products li.product.last,
.woocommerce-page ul.products li.product[class*="columns-"] {
    float: none !important;
    clear: none !important;
    margin: 0 !important;
    width: auto !important;
}

/* Hover lift */
.woocommerce ul.products li.product:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

/* Product image */
/* Product image */
.woocommerce ul.products li.product img {
    width: 100%;
    /* RESPONSIVE SQUARE: Fixes "jump up" issue */
    height: auto !important;
    aspect-ratio: 1/1;

    /* CONTAIN: Shows full image (no cropping) for both Wide & Tall */
    object-fit: contain;

    /* Frame Style */
    background: #ffffff;
    padding: 8px;
    /* Nice frame spacing */

    border-radius: 12px 12px 0 0;
    margin: 0;
    display: block;

    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Subtle Zoom on Hover */
.woocommerce ul.products li.product:hover img {
    transform: scale(1.08);
}

/* Title */
.woocommerce ul.products li.product h2.woocommerce-loop-product__title {
    font-family: "Playfair Display", serif;
    font-size: 0.9rem;
    /* Smaller title */
    font-weight: 600;
    color: var(--sb-green, #4A6655);
    margin: 10px 8px 4px;
    padding: 0;

    /* UNIFORM HEIGHT FIX: Always 2 lines, even if empty */
    line-height: 1.3;
    min-height: 2.6em;
    /* 1.3 * 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;

    flex-grow: 1;
    /* pushes button to bottom */
}

/* Price */
.woocommerce ul.products li.product .price strong {
    color: var(--sb-green, #4A6655);
    font-family: "Lato", sans-serif;
    font-size: 0.9rem;
    /* Smaller price */
}

/* Add to Cart / Select Options button */
.woocommerce ul.products li.product a.button {
    background: var(--sb-green, #4A6655) !important;
    color: #fff !important;
    border-radius: 8px;
    padding: 6px 14px;
    /* Smaller button */
    margin: 8px auto 12px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
    display: block;
    transition: background .25s ease;
}

.woocommerce ul.products li.product a.button:hover {
    background: var(--sb-green-hover, #688673) !important;
}

/* ================== 2. RESPONSIVE BREAKPOINTS ================== */
/* Tablet Landscape (4 Cols) */
@media (max-width: 1200px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px;
    }
}

/* Tablet Portrait / Small Desktop (3 Cols) */
@media (max-width: 1000px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px;
    }
}

/* Mobile (2 Cols - S22 Ultra / iPhone Max / Standard Phones) */
@media (max-width: 700px) {

    /* Kill container padding on mobile archives to fix "massive side gap" */
    .archive .site-content,
    .archive #primary,
    .archive .entry-content,
    .archive .sb-container,
    .search .site-content,
    .search #primary,
    .blog .site-content,
    .blog #primary {
        padding-left: 6px !important;
        padding-right: 6px !important;
        width: 100% !important;
    }

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        padding: 0 !important;
    }

    .woocommerce ul.products li.product img {
        height: auto !important;
        aspect-ratio: 1 / 1;
        width: 100%;
        max-height: 400px;
        object-fit: cover;
    }

    .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
        font-size: 0.95rem;
        margin-top: 8px;
    }
}

/* Tiny Mobile (1 Col - Only for very small screens < 340px) */
@media (max-width: 340px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 12px !important;
    }

    .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
        font-size: 1.1rem;
    }
}

/* ================== 3. SINGLE PRODUCT COMPACT ================== */
.single-product .site-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.single-product div.product {
    display: grid;
    grid-template-columns: 45% 55%;
    /* Tighter image column */
    gap: 30px;
    align-items: start;
    padding-top: 10px;
}

/* Compact Image Gallery */
.single-product .woocommerce-product-gallery img {
    max-height: 65vh !important;
    width: auto !important;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

/* Mobile Single Product */
@media (max-width: 900px) {
    .single-product div.product {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ================== 4. CLEANUP ================== */
/* FINAL SAFETY NET – absolutely nothing can push the first item right anymore */
.woocommerce ul.products::before,
.woocommerce ul.products::after,
.woocommerce-page ul.products::before,
.woocommerce-page ul.products::after {
    content: none !important;
    display: none !important;
    width: 0 !important;
    flex-basis: 0 !important;
}

/* Hide the entire <li> that contains the "All Products" link */
ul.products li.product-category a[href*="product-category/all/"] {
    position: absolute !important;
    left: -9999px !important;
    visibility: hidden !important;
}

object-fit: contain;

/* Frame Style */
background: #ffffff;
padding: 8px;
/* Nice frame spacing */

border-radius: 12px 12px 0 0;
margin: 0;
display: block;

transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Subtle Zoom on Hover */
.woocommerce ul.products li.product:hover img {
    transform: scale(1.08);
}

/* Title */
.woocommerce ul.products li.product h2.woocommerce-loop-product__title {
    font-family: "Playfair Display", serif;
    font-size: 0.9rem;
    /* Smaller title */
    font-weight: 600;
    color: var(--sb-green, #4A6655);
    margin: 10px 8px 4px;
    padding: 0;

    /* UNIFORM HEIGHT FIX: Always 2 lines, even if empty */
    line-height: 1.3;
    min-height: 2.6em;
    /* 1.3 * 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;

    flex-grow: 1;
    /* pushes button to bottom */
}

/* Price */
.woocommerce ul.products li.product .price strong {
    color: var(--sb-green, #4A6655);
    font-family: "Lato", sans-serif;
    font-size: 0.9rem;
    /* Smaller price */
}

/* Add to Cart / Select Options button */
.woocommerce ul.products li.product a.button {
    background: var(--sb-green, #4A6655) !important;
    color: #fff !important;
    border-radius: 8px;
    padding: 6px 14px;
    /* Smaller button */
    margin: 8px auto 12px;
    font-size: 0.8rem;
    font-weight: 600;
    width: fit-content;
    display: block;
    transition: background .25s ease;
}

.woocommerce ul.products li.product a.button:hover {
    background: var(--sb-green-hover, #688673) !important;
}

/* ================== 2. RESPONSIVE BREAKPOINTS ================== */
/* Tablet Landscape (4 Cols) */
@media (max-width: 1200px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 12px;
    }
}

/* Tablet Portrait / Small Desktop (3 Cols) */
@media (max-width: 1000px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 10px;
    }
}

/* Mobile (2 Cols - S22 Ultra / iPhone Max / Standard Phones) */
@media (max-width: 700px) {

    /* Kill container padding on mobile archives to fix "massive side gap" */
    .archive .site-content,
    .archive #primary,
    .archive .entry-content,
    .archive .sb-container,
    .search .site-content,
    .search #primary,
    .blog .site-content,
    .blog #primary {
        padding-left: 6px !important;
        padding-right: 6px !important;
        width: 100% !important;
    }

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px;
        padding: 0 !important;
    }

    .woocommerce ul.products li.product img {
        height: auto !important;
        aspect-ratio: 1 / 1;
        width: 100%;
        max-height: 400px;
        object-fit: cover;
    }

    .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
        font-size: 0.95rem;
        margin-top: 8px;
    }
}

/* Tiny Mobile (1 Col - Only for very small screens < 340px) */
@media (max-width: 340px) {

    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 12px !important;
    }

    .woocommerce ul.products li.product h2.woocommerce-loop-product__title {
        font-size: 1.1rem;
    }
}

/* ================== 3. SINGLE PRODUCT COMPACT ================== */
.single-product .site-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.single-product div.product {
    display: grid;
    grid-template-columns: 45% 55%;
    /* Tighter image column */
    gap: 30px;
    align-items: start;
    padding-top: 10px;
}

/* Compact Image Gallery */
.single-product .woocommerce-product-gallery img {
    max-height: 65vh !important;
    width: auto !important;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

/* Mobile Single Product */
@media (max-width: 900px) {
    .single-product div.product {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ================== 4. CLEANUP ================== */
/* FINAL SAFETY NET – absolutely nothing can push the first item right anymore */
.woocommerce ul.products::before,
.woocommerce ul.products::after,
.woocommerce-page ul.products::before,
.woocommerce-page ul.products::after {
    content: none !important;
    display: none !important;
    width: 0 !important;
    flex-basis: 0 !important;
}

/* Hide the entire <li> that contains the "All Products" link */
ul.products li.product-category a[href*="product-category/all/"] {
    position: absolute !important;
    left: -9999px !important;
    visibility: hidden !important;
}

ul.products li.product-category a[href*="product-category/all/"]~.product-category {
    /* not needed */
}

/* BEST & SIMPLEST – works everywhere, removes the box completely */
ul.products>li.product-category:has(a[href*="product-category/all/"]),
ul.products>li.product-category a[href$="/all/"] {
    display: none !important;
}

/* ================== 5. PAGINATION & SORTING (Page Selector) ================== */

/* Container Fix */
.woocommerce-products-header+.woocommerce-result-count,
.woocommerce-result-count,
.woocommerce-ordering {
    margin-bottom: 20px;
}

/* A. RESULT COUNT TEXT */
.woocommerce-result-count {
    font-family: var(--sb-font-sans, sans-serif);
    font-size: 0.9rem;
    color: var(--sb-text-light, #5C6B73);
    line-height: 42px;
    /* Match dropdown height approx */
    float: left;
    margin-right: 20px;
}

/* A2. SORTING DROPDOWN */
.woocommerce-ordering {
    float: right;
    margin-bottom: 30px;
}

.woocommerce-ordering select.orderby {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    border: 1px solid rgba(58, 90, 64, 0.2);
    border-radius: 50px;
    padding: 10px 20px;
    font-family: var(--sb-font-sans, sans-serif);
    font-size: 0.85rem;
    color: var(--sb-green, #3A5A40);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233A5A40' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    padding-right: 36px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    min-width: 200px;
}

.woocommerce-ordering select.orderby:hover {
    border-color: var(--sb-green, #3A5A40);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.woocommerce-ordering select.orderby:focus {
    outline: none;
    border-color: var(--sb-green, #3A5A40);
}

/* Mobile Filter Layout */
@media (max-width: 600px) {

    .woocommerce-result-count,
    .woocommerce-ordering {
        float: none;
        width: 100%;
        text-align: center;
        margin-bottom: 12px;
    }

    .woocommerce-ordering select.orderby {
        width: 100%;
        text-align: left;
        /* Keep text legible */
    }
}

/* B. PAGINATION */
.woocommerce-pagination {
    margin: 40px 0;
    text-align: center;
    clear: both;
    /* Ensure it sits below floated elements */
    width: 100%;
    display: block;
}

.woocommerce-pagination ul {
    display: inline-flex;
    border: none !important;
    gap: 8px;
    padding: 0;
    margin: 0;
    list-style: none !important;
}

.woocommerce-pagination ul li {
    border: none !important;
    overflow: hidden;
    margin: 0;
    list-style: none !important;
}

.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0;
    text-decoration: none;
    font-weight: 600;
    color: var(--sb-text-light, #5C6B73);
    background: transparent;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 1rem;
    padding: 0 !important;
}

/* Hover State */
.woocommerce-pagination ul li a:hover {
    background: #fff;
    color: var(--sb-green, #3A5A40);
    border-color: var(--sb-green, #3A5A40);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

/* Active State */
.woocommerce-pagination ul li span.current {
    background: var(--sb-green, #3A5A40);
    color: #fff;
    border-color: var(--sb-green, #3A5A40);
    box-shadow: 0 4px 12px rgba(58, 90, 64, 0.3);
}

/* Next/Prev Arrows */
.woocommerce-pagination ul li a.next,
.woocommerce-pagination ul li a.prev {
    font-size: 0;
    /* Hide default text */
    position: relative;
    width: 40px;
}

.woocommerce-pagination ul li a.next::before {
    content: "\f061";
    /* FontAwesome Right Arrow */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 14px;
}

.woocommerce-pagination ul li a.prev::before {
    content: "\f060";
    /* FontAwesome Left Arrow */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 14px;
}