/* ============================================================
   Charsutra — Product Card
   ------------------------------------------------------------
   Loaded after style.css. The card root keeps .th-product and
   .product-grid so any existing selectors elsewhere still match,
   but every inner element uses the cs-pcard namespace, so none
   of the legacy inner rules apply. The block right below undoes
   the few root-level legacy rules that would otherwise fight
   this layout.
   ============================================================ */

:root {
    --csp-navy: #0F1E33;
    --csp-gold: #A9825A;
    --csp-terracotta: #B5523B;
    --csp-green: #1E8E5A;
    --csp-line: #ECE8E1;
    --csp-ink: #16233A;
    --csp-muted: #6B7688;
    --csp-radius: 16px;
}

/* --- Undo legacy root styling (padding + centred text + shadow) --- */
.cs-pcard.th-product {
    padding: 0;
    text-align: left;
    border-radius: var(--csp-radius);
    box-shadow: 0 1px 2px rgba(15, 30, 51, .05);
}

/* ============================================================
   Card shell
   ============================================================ */
.cs-pcard {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #fff;
    border: 1px solid var(--csp-line);
    border-radius: var(--csp-radius);
    overflow: hidden;
    transition: transform .32s cubic-bezier(.2, .7, .3, 1),
                box-shadow .32s ease,
                border-color .32s ease;
}

.cs-pcard:hover {
    transform: translateY(-6px);
    border-color: #DED7CB;
    box-shadow: 0 16px 34px rgba(15, 30, 51, .13);
}

/* Entrance animation, triggered by product-card.js when the card
   scrolls into view. Cards are visible without JS. */
.cs-pcard.cs-reveal {
    opacity: 0;
    transform: translateY(18px);
}

.cs-pcard.cs-reveal.is-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity .5s ease, transform .5s cubic-bezier(.2, .7, .3, 1);
}

/* ============================================================
   Media
   ============================================================ */
.cs-pcard-media {
    position: relative;
    overflow: hidden;
    background-color: #F5F3EF;
}

.cs-pcard-imglink {
    display: block;
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

/* Shimmer under the image while it loads, removed by JS on load.
   Stops the grid from flashing grey blocks on a slow connection. */
.cs-pcard-imglink::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #F1EEE9 20%, #F8F6F3 42%, #F1EEE9 64%);
    background-size: 260% 100%;
    animation: cs-pcard-shimmer 1.5s linear infinite;
    opacity: 1;
    transition: opacity .35s ease;
    z-index: 1;
}

.cs-pcard.img-loaded .cs-pcard-imglink::before {
    opacity: 0;
    animation: none;
}

@keyframes cs-pcard-shimmer {
    from { background-position: 130% 0; }
    to   { background-position: -130% 0; }
}

/* `cover` fills the square and crops. That flatters apparel shots but can
   clip the bottom of tall bottles. If your catalogue is mostly packaged
   goods, switch the two properties below to:
       object-fit: contain;  object-position: center center;
   and images will letterbox onto the card background instead of cropping. */
.cs-pcard-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    z-index: 2;
    transition: opacity .45s ease, transform .7s cubic-bezier(.2, .7, .3, 1);
}

.cs-pcard-img--hover {
    opacity: 0;
}

.cs-pcard:hover .cs-pcard-img--main {
    transform: scale(1.07);
}

/* Only swap when there actually is a second image */
.cs-pcard:hover .cs-pcard-img--hover {
    opacity: 1;
    transform: scale(1.07);
}

/* --- Badges --- */
.cs-pcard-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    pointer-events: none;
}

.cs-pcard-badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    line-height: 1.3;
    color: #fff;
    background-color: var(--csp-navy);
    box-shadow: 0 2px 8px rgba(15, 30, 51, .18);
}

.cs-pcard-badge--sale { background-color: var(--csp-terracotta); }
.cs-pcard-badge--new { background-color: var(--csp-gold); }

.cs-pcard-badge--delivery {
    background-color: rgba(255, 255, 255, .94);
    color: var(--csp-navy);
}

/* --- Wishlist --- */
.cs-pcard-wish {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 6;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, .93);
    color: var(--csp-navy);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(15, 30, 51, .14);
    transition: background-color .2s ease, color .2s ease, transform .2s ease;
}

.cs-pcard-wish:hover {
    background-color: var(--csp-navy);
    color: #fff;
    transform: scale(1.08);
}

/* addToWishlist() in the layout adds .wishlisted and swaps far → fas,
   so this state is driven by the existing JS with no changes needed. */
.cs-pcard-wish.wishlisted {
    background-color: var(--csp-gold);
    color: #fff;
}

.cs-pcard-wish.wishlisted i,
.cs-pcard-wish.wishlisted:hover i {
    color: #fff;
}

.cs-pcard-wish.is-popping {
    animation: cs-pcard-pop .42s cubic-bezier(.2, .9, .3, 1.4);
}

@keyframes cs-pcard-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.32); }
    100% { transform: scale(1); }
}

/* --- Hover action row --- */
.cs-pcard-hover {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 5;
    display: flex;
    gap: 8px;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .28s ease, transform .28s cubic-bezier(.2, .7, .3, 1);
}

.cs-pcard:hover .cs-pcard-hover,
.cs-pcard:focus-within .cs-pcard-hover {
    opacity: 1;
    transform: translateY(0);
}

.cs-pcard-hbtn {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 8px;
    border-radius: 9px;
    background-color: rgba(255, 255, 255, .96);
    color: var(--csp-navy);
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(15, 30, 51, .16);
    transition: background-color .2s ease, color .2s ease;
}

.cs-pcard-hbtn:hover {
    background-color: var(--csp-navy);
    color: #fff;
}

.cs-pcard-hbtn i { font-size: 12px; }

/* --- Sold out --- */
.cs-pcard.is-soldout .cs-pcard-img {
    filter: grayscale(.85);
    opacity: .82;
}

.cs-pcard-soldout {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    padding: 7px 20px;
    border-radius: 999px;
    background-color: rgba(15, 30, 51, .88);
    color: #fff;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================================
   Body
   ============================================================ */
.cs-pcard-body {
    display: flex;
    flex-direction: column;
    align-items: center;   /* everything centred in the card */
    text-align: center;
    flex: 1 1 auto;
    gap: 7px;
    padding: 14px 14px 14px;
}

.cs-pcard-cat {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .7px;
    text-transform: uppercase;
    color: var(--csp-gold);
}

/* The theme sets every h1–h6 to Playfair Display (a display serif). That
   reads badly for product names at 14px — "MG 5178 Ladies T-shirt" in a
   serif with old-style figures looks like a headline, not a label. Product
   names use the body sans instead; section headings keep the serif. */
.cs-pcard-title {
    margin: 0;
    width: 100%;
    font-family: var(--body-font, "Nunito Sans", sans-serif);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    letter-spacing: .1px;
    /* lining figures, so "5178" and "2150" don't drop below the baseline */
    font-variant-numeric: lining-nums tabular-nums;
    font-feature-settings: "lnum" 1;
}

.cs-pcard-title a {
    color: var(--csp-ink);
    text-decoration: none;
    /* Two lines then ellipsis: a single truncated line was cutting names
       like "Snowflakes & Cashmere Dail…" mid-word. Fixing the height to
       two lines also keeps every card in a row the same size. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
    transition: color .2s ease;
}

.cs-pcard-title a:hover { color: var(--csp-gold); }

.cs-pcard-priceline {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 1px;
}

.cs-pcard-price {
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--csp-navy);
}

.cs-pcard-price--out {
    font-size: 14px;
    color: var(--csp-terracotta);
}

.cs-pcard-old {
    font-size: 12.5px;
    font-weight: 400;
    color: var(--csp-muted);
}

.cs-pcard-save {
    padding: 2px 7px;
    border-radius: 5px;
    background-color: rgba(181, 82, 59, .1);
    color: var(--csp-terracotta);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .3px;
}

/* One pill shape for all three states, so "In stock", "Only 2 left" and
   "Out of stock" read as the same field rather than three loose bits of
   coloured text at different widths. */
.cs-pcard-stock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
}

.cs-pcard-stock i { font-size: 10.5px; }

.cs-pcard-stock b {
    font-weight: 800;
    font-variant-numeric: lining-nums tabular-nums;
}

.cs-pcard-stock--in {
    color: #14724A;
    background-color: rgba(30, 142, 90, .1);
}

.cs-pcard-stock--low {
    color: #9A5A0C;
    background-color: rgba(194, 118, 27, .13);
}

.cs-pcard-stock--out {
    color: #5C6675;
    background-color: rgba(92, 102, 117, .1);
}

/* Quantity chip sitting beside "In stock" */
.cs-pcard-qty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 17px;
    padding: 0 5px;
    margin-left: 1px;
    border-radius: 999px;
    background-color: #14724A;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0;
}

/* --- Add to cart --- */
.cs-pcard-cart {
    margin-top: auto;
    /* align-items:center on the body would otherwise shrink this to its
       text width */
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 10px;
    background-color: var(--csp-navy);
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .4px;
    text-decoration: none;
    transition: background-color .22s ease, color .22s ease, transform .12s ease;
}

.cs-pcard-cart:hover {
    background-color: var(--csp-gold);
    color: var(--csp-navy);
}

.cs-pcard-cart:active { transform: scale(.98); }

.cs-pcard-cart--disabled {
    background-color: #F3F1ED;
    color: var(--csp-muted);
}

.cs-pcard-cart--disabled:hover {
    background-color: #EAE6DF;
    color: var(--csp-navy);
}

/* Busy + done states set by product-card.js */
.cs-pcard-cart.is-busy {
    pointer-events: none;
    background-color: #33445E;
}

.cs-pcard-cart.is-busy i {
    animation: cs-pcard-spin .7s linear infinite;
}

@keyframes cs-pcard-spin {
    to { transform: rotate(360deg); }
}

.cs-pcard-cart.is-done {
    background-color: var(--csp-green);
    color: #fff;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Cards sit in col-6 on phones, so two per row. Everything below is
   about keeping that readable rather than shrinking it uniformly. */
@media (max-width: 767.98px) {
    .cs-pcard-body {
        gap: 5px;
        padding: 11px 11px 12px;
    }

    .cs-pcard-title { font-size: 13px; }
    .cs-pcard-price { font-size: 15px; }
    .cs-pcard-old { font-size: 11.5px; }

    .cs-pcard-stock {
        height: 22px;
        padding: 0 9px;
        gap: 5px;
        font-size: 9.5px;
        letter-spacing: .3px;
    }

    .cs-pcard-qty {
        min-width: 18px;
        height: 15px;
        font-size: 9px;
    }

    .cs-pcard-cart {
        height: 38px;
        font-size: 12px;
    }

    /* No hover on touch — the row would never appear, so drop it and
       let Add to cart and the wishlist button carry the actions. */
    .cs-pcard-hover { display: none; }

    .cs-pcard-wish {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .cs-pcard-badge {
        padding: 3px 7px;
        font-size: 9.5px;
    }
}

@media (max-width: 575.98px) {
    .cs-pcard-body { padding: 10px 9px 11px; }
    .cs-pcard-cat { font-size: 9.5px; }
    .cs-pcard-title { font-size: 12.5px; }
    .cs-pcard-title a { min-height: 2.8em; }
    .cs-pcard-price { font-size: 14px; }

    .cs-pcard-priceline { gap: 5px; }

    .cs-pcard-save {
        padding: 1px 5px;
        font-size: 9.5px;
    }

    .cs-pcard-stock {
        height: 21px;
        padding: 0 8px;
        font-size: 9px;
    }

    .cs-pcard-cart {
        height: 36px;
        font-size: 11.5px;
        gap: 6px;
    }
}

/* Inside a swiper slide the card must fill the slide height so a row of
   slides lines up. */
.swiper-slide .cs-pcard { height: 100%; }

/* The legacy centring wrapper caps the card at 340px on small screens;
   with two columns that leaves them off-centre. */
@media (max-width: 767.98px) {
    .cs-pcard.product-grid {
        max-width: none;
    }
}

/* ============================================================
   Accessibility
   ============================================================ */
.cs-pcard a:focus-visible,
.cs-pcard button:focus-visible {
    outline: 2px solid var(--csp-gold);
    outline-offset: 2px;
    border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
    .cs-pcard,
    .cs-pcard-img,
    .cs-pcard-hover,
    .cs-pcard-wish,
    .cs-pcard-cart {
        transition: none;
    }

    .cs-pcard:hover { transform: none; }
    .cs-pcard:hover .cs-pcard-img--main { transform: none; }

    .cs-pcard.cs-reveal,
    .cs-pcard.cs-reveal.is-in {
        opacity: 1;
        transform: none;
    }

    .cs-pcard-imglink::before,
    .cs-pcard-wish.is-popping,
    .cs-pcard-cart.is-busy i {
        animation: none;
    }
}
