/* ==========================================
   PRODUCT CARD - Modern Pop-Out Design
   - Floating product image with 3D drop-shadow
   - Compact vertical layout (image closer to title)
   - Yellow vertical tab sticking out on right
   - Specs row + solid black "Buy Now" button
   - Container-query responsive (works in narrow grid columns)
   ========================================== */

/* ---------- Grid Container ---------- */
.collection-products-grid {
    --pc-tab-out: clamp(
        0.25rem,
        1vw,
        0.9rem
    ); /* How far the yellow tab sticks out */

    /* Smaller cards: lowered the min column width from 18.5rem to 15.5rem so a
       ~1200px container fits 4 columns instead of 3 (each card drops from
       ~385px to ~285px). 15.5rem still leaves room for the title, price row and
       Buy Now button without triggering the small-card container queries. */
    /* Tighter min width so 4-5 cards fit beside the filter sidebar. */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
    gap: clamp(1.1rem, 1.6vw, 1.5rem);
    padding-inline-end: var(--pc-tab-out);
    contain: layout;
}

/* ---------- Card Shell ---------- */
.product-card {
    --pc-page-bg: #f1f1f1; /* Set to your page/section background color */
    --pc-pop: 50%; /* Percentage of image overlapping above white card */
    --pc-ink: #0b0b0c;
    --pc-muted: #8b8f96;
    --pc-green: #12b76a;
    --pc-yellow: #ffe600;
    --pc-star: #f5b301;
    --pc-accent: #1d3686;
    --pc-ease: cubic-bezier(0.22, 0.9, 0.25, 1);

    container: pc / inline-size;
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    /* `paint` containment clips the absolutely-positioned ribbon and media
       inside the card box, so they can never spill onto the page. */
    contain: layout paint;
    isolation: isolate;
}

/* ---------- Product Image (Floating 3D Effect) ---------- */
.product-card-media {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    pointer-events: none;
}

.product-card-image {
    display: block;
    aspect-ratio: 1 / 1;
    overflow: visible;
    border: 0;
    background: transparent;
    text-decoration: none;
    pointer-events: auto;
}

.product-card-image > img {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    object-fit: contain;
    background: transparent;
    /* Soft ambient shadow behind transparent product PNGs */
    filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.16));
    transition:
        transform 450ms var(--pc-ease),
        filter 450ms var(--pc-ease);
}

/* ---------- White Card Body ---------- */
.product-card-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;

    margin-top: calc(var(--pc-pop) - 100%);
    /* Tightened top padding brings title up closer to the image */
    padding: calc(100% - var(--pc-pop) + 0.15rem) 1.25rem 1.15rem;
    border-radius: 2.2rem;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.035);
}

/* ---------- Title ---------- */
.product-card-copy {
    display: block;
    color: inherit;
    text-decoration: none;
}

.product-card-title {
    display: -webkit-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--pc-ink);
    font-family: var(--font-heading, inherit);
    font-size: 1.12rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* ---------- Rating Row ---------- */
.product-card-rating {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.5rem 0 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eceeed;
}

.product-card .product-review-stars {
    color: var(--pc-star);
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.product-card-rating a {
    color: var(--pc-muted);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
}

.product-card-rating a:hover {
    color: var(--pc-ink);
}

/* ---------- Discount Badge ---------- */
.product-card-discount {
    margin: 0.45rem 0 0;
    color: var(--pc-green);
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.2;
}

/* ---------- Price + Swatches Row ---------- */
.product-card-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.2rem;
}

.product-card-prices {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.6rem;
    min-width: 0;
}

.product-card-price {
    margin: 0;
    color: var(--pc-ink);
    font-family: var(--font-heading, inherit);
    font-size: 1.55rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.product-card-original-price {
    margin: 0;
    color: var(--pc-muted);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: line-through;
    white-space: nowrap;
}

/* Color Swatches */
.product-card-swatches {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.45rem;
}

.product-card-swatch {
    flex: 0 0 1rem;
    width: 1rem;
    height: 1rem;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    background: var(--swatch-color);
    cursor: pointer;
    transition: transform 200ms var(--pc-ease);
}

.product-card-swatch:hover {
    transform: scale(1.15);
}

.product-card-swatch[aria-pressed="true"] {
    outline: 2px solid rgba(0, 0, 0, 0.25);
    outline-offset: 2px;
}

/* ---------- Footer: Specs + Buy Now ---------- */
.product-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 0.85rem;
}

.product-card-specs {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.product-card-spec {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
    line-height: 1.15;
}

.product-card-spec + .product-card-spec {
    padding-left: 0.6rem;
    border-left: 1px solid #e0e2e5;
}

.product-card-spec strong {
    color: #33363b;
    font-size: 0.72rem;
    font-weight: 800;
}

.product-card-spec small {
    color: var(--pc-muted);
    font-size: 0.64rem;
    font-weight: 500;
}

/* Black Buy Now Button */
.product-card-cart {
    flex: 0 0 auto;
}

.product-card-cart > div {
    display: contents;
}

.product-card-add-button,
.product-card-cart .product-card-add-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.55rem 1.15rem;
    border: 0;
    border-radius: 999px;
    color: #ffffff;
    background: var(--pc-ink);
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background 200ms ease,
        transform 200ms var(--pc-ease);
}

.product-card-add-button svg {
    width: 1rem;
    height: 1rem;
}

.product-card-add-button:hover,
.product-card-cart .product-card-add-button:hover {
    color: #ffffff;
    background: #25262a;
}

.product-card-add-button:active {
    transform: scale(0.96);
}

/* ---------- Yellow Vertical Tab (Ribbon) ----------
   Sits flush on the card's right edge. Previously this faked a "cut-out" with
   a BORDER painted in --pc-page-bg, but that colour (#f1f1f1) never matched the
   real page surface (white + a red radial gradient), so it rendered as a grey
   stripe. It now needs no page-colour dependency at all.
   writing-mode alone rotates the glyphs; the extra rotate(180deg) used to flip
   the whole box and fight the padding, so it is gone and alignment is handled
   with normal centring. */
.product-card-ribbon {
    position: absolute;
    /* Anchored to the white body (relative parent), not the media box, so it
       sits beside the title instead of overlapping it. */
    top: 1.1rem;
    right: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    min-height: 4.5rem;
    max-height: 7rem;
    padding: 0.75rem 0.15rem;

    border: 0;
    border-radius: 0 0.75rem 0.75rem 0;

    color: #ffffff;
    background: #e11d2e;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
    font-size: 0.66rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    pointer-events: none;
}

/* ---------- Wishlist Button ---------- */
.product-card-wishlist {
    position: absolute;
    top: 3%;
    left: 3%;
    z-index: 3;
    display: grid;
    width: 2.2rem;
    height: 2.2rem;
    place-items: center;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 50%;
    color: #6f7278;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    font-size: 0;
    line-height: 0;
    white-space: nowrap;
    cursor: pointer;
    transition:
        color 180ms ease,
        transform 200ms var(--pc-ease);
}

.product-card-wishlist svg {
    width: 1.1rem;
    height: 1.1rem;
}

.product-card-wishlist:hover,
.product-card-wishlist[aria-pressed="true"] {
    color: var(--pc-accent);
    transform: scale(1.1);
}

/* ---------- Hidden Unused Elements ---------- */
.product-card-description,
.product-card-tags,
.product-card-sale-badge {
    display: none;
}

/* ---------- Focus States ---------- */
.product-card-image:focus-visible,
.product-card-copy:focus-visible,
.product-card-add-button:focus-visible,
.product-card-wishlist:focus-visible,
.product-card-swatch:focus-visible {
    outline: 2px solid var(--pc-accent);
    outline-offset: 3px;
}

/* ---------- Hover Interactions (Hover Devices Only) ---------- */
@media (hover: hover) {
    .product-card:hover .product-card-image > img {
        transform: translateY(-10px) scale(1.05);
        filter: drop-shadow(0 22px 26px rgba(0, 0, 0, 0.22));
    }
}

/* ==========================================
   CONTAINER QUERIES - Card-Level Sizing
   ========================================== */

/* Medium Cards (Tablet or Medium Grids) */
@container pc (max-width: 26rem) {
    .product-card-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .product-card-specs {
        justify-content: space-between;
        gap: 0;
    }

    .product-card-spec {
        flex: 1 1 0;
        text-align: center;
    }

    .product-card-spec + .product-card-spec {
        padding-left: 0;
    }

    .product-card-cart,
    .product-card-add-button,
    .product-card-cart .product-card-add-button {
        width: 100%;
    }
}

/* Small Cards (Mobile 2-Column Grids) */
@container pc (max-width: 15rem) {
    .product-card {
        --pc-pop: 28%;
    }

    .product-card-body {
        padding-inline: 0.7rem;
        padding-bottom: 0.85rem;
        border-radius: 1.2rem;
    }

    .product-card-title {
        font-size: 0.82rem;
        line-height: 1.3;
        min-height: 2.6em;
    }

    .product-card-price {
        font-size: 0.98rem;
    }

    .product-card-original-price {
        font-size: 0.68rem;
    }

    .product-card-specs {
        display: none;
    }

    .product-card-rating {
        margin-top: 0.45rem;
        padding-bottom: 0.4rem;
        gap: 0.2rem;
    }

    .product-card .product-review-stars {
        font-size: 0.75rem;
    }

    .product-card-rating a {
        font-size: 0.75rem;
    }

    .product-card-discount {
        margin-top: 0.4rem;
        font-size: 0.78rem;
    }

    .product-card-swatch {
        flex-basis: 0.85rem;
        width: 0.85rem;
        height: 0.85rem;
    }

    .product-card-footer {
        padding-top: 0.65rem;
    }

    .product-card-add-button,
    .product-card-cart .product-card-add-button {
        min-height: 2.3rem;
        padding: 0.5rem 0.65rem;
        border-radius: 999px;
        font-size: 0.78rem;
    }

    .product-card-ribbon {
        top: 0.6rem;
        width: 1.1rem;
        min-height: 3.2rem;
        max-height: 4.2rem;
        padding: 0.45rem 0.1rem;
        border-radius: 0 0.5rem 0.5rem 0;
        font-size: 0.55rem;
        letter-spacing: 0.04em;
    }

    .product-card-wishlist {
        width: 1.8rem;
        height: 1.8rem;
    }
}

/* ---------- Page-Level Grid Adjustments ---------- */
@media (min-width: 641px) and (max-width: 1024px) {
    .collection-products-grid {
        /* Kept just above the base 15.5rem so tablets fit 3 columns rather than 2,
           but still smaller than the old 17.5rem. */
        grid-template-columns: repeat(
            auto-fill,
            minmax(min(100%, 15.75rem), 1fr)
        );
    }
}

/* Laptop band (1024px-1439px): a 1366x768 screen resolves the auto-fill track to
   exactly 4 columns of ~317px. Pin that to 4 explicit columns so the row is
   always balanced (never 4+1 orphan rows) and the cards keep a comfortable
   width without dropping into the tiny-card container queries. */
@media (min-width: 1024px) and (max-width: 1439px) {
    .collection-products-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: clamp(1.15rem, 1.7vw, 1.5rem);
    }
}

/* Large desktop (>= 1440px): back to the fluid auto-fill track (typically 5 up). */
@media (min-width: 1440px) {
    .collection-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
    }
}

@media (max-width: 640px) {
    .collection-products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem 0.6rem;
    }
}

@media (max-width: 340px) {
    .collection-products-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Legacy Compatibility Cleansers ---------- */
.product-card:hover {
    transform: none;
    border-color: transparent;
    box-shadow: none;
}

.product-card:hover .product-card-image {
    background: transparent;
}

.product-card:hover .product-card-add-button,
.product-card:hover .product-card-cart .product-card-add-button {
    border-color: transparent;
    color: #ffffff;
    background: var(--pc-ink);
    box-shadow: none;
}

.product-card .product-card-add-button:hover,
.product-card .product-card-cart .product-card-add-button:hover {
    border-color: transparent;
    color: #ffffff;
    background: #25262a;
    box-shadow: none;
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .product-card-image > img,
    .product-card-swatch,
    .product-card-wishlist,
    .product-card-add-button {
        transition: none;
    }

    .product-card:hover .product-card-image > img {
        transform: none;
    }
}
