/*
 * Shared storefront product card (<x-product-card>), "clean marketplace" design.
 * Uses the brand tokens declared in layouts/storefront.blade.php (:root).
 * Contract: equal-height cards, 2-line title slot, price pinned to the bottom,
 * one discount badge on the image, nothing in the text column wraps.
 */

.pcard-grid { --bs-gutter-x: .5rem; --bs-gutter-y: .75rem; }
@media (min-width: 768px) { .pcard-grid { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; } }

.pcard {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Light glass: translucent white over the page background, no visible frame */
    --pcard-glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 4px 14px rgba(16, 29, 53, .05);
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--pcard-glass-shadow);
    transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.pcard:active { transform: scale(.985); }
.pcard:focus-within { box-shadow: var(--pcard-glass-shadow), 0 0 0 3px rgba(8, 104, 215, .35); }
@media (hover: hover) and (pointer: fine) {
    .pcard:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .8); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 10px 24px rgba(8, 104, 215, .10); }
    .pcard:hover .pcard__img { transform: scale(1.03); }
}

/* Image: fixed square (portrait 4:5 for beauty stores), whole product visible, blurred copy fills the bands */
.pcard__media {
    position: relative;
    flex: none;
    aspect-ratio: 1 / 1;
    margin: 6px 6px 0;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}
.pcard--portrait .pcard__media { aspect-ratio: 4 / 5; }
.pcard__media::before {
    content: "";
    position: absolute;
    inset: -20px;
    z-index: 0;
    background-image: var(--pc-img, none);
    background-size: cover;
    background-position: center;
    filter: blur(20px) saturate(1.15);
    opacity: .55;
}
.pcard__img {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform .3s ease;
}
.pcard__img--placeholder { padding: 22%; opacity: .45; }

/* Overlays on the image: discount (start corner), rating (end corner), countdown (bottom) */
.pcard__badge,
.pcard__rating,
.pcard__timer {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    line-height: 1;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.pcard__badge {
    top: 8px;
    inset-inline-start: 8px;
    padding: .32rem .5rem;
    background: var(--accent, #FF4F17);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(216, 58, 11, .3);
}
.pcard__rating {
    top: 8px;
    inset-inline-end: 8px;
    padding: .3rem .45rem;
    background: rgba(255, 255, 255, .92);
    color: var(--ink, #101D35);
    font-size: .7rem;
    font-weight: 700;
}
.pcard__rating .bi { color: #FFA800; }
.pcard__rating-count { color: var(--ink-soft, #607089); font-weight: 600; }
.pcard__timer {
    bottom: 8px;
    inset-inline-start: 8px;
    max-width: calc(100% - 16px);
    display: inline-flex;
    align-items: center;
    gap: .3em;
    padding: .32rem .55rem;
    background: rgba(255, 255, 255, .92);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    color: var(--ink, #101D35);
    font-size: .7rem;
    font-weight: 700;
    overflow: hidden;
}
.pcard__timer .bi { flex: none; color: var(--accent-dark, #D83A0B); }
.pcard__timer-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 360px) {
    .pcard__timer { gap: .2em; padding: .3rem .45rem; font-size: .66rem; }
}
.pcard__timer.is-urgent { background: var(--accent-soft, #FFF0EC); color: var(--accent-dark, #D83A0B); }
.pcard__timer.is-ended { background: #EEF1F6; color: var(--ink-soft, #607089); }
.pcard__timer.is-ended .bi { color: inherit; }

/* Sold out: overlay in the countdown's corner (the timer is not rendered then), faded photo and price.
   Everything is absolutely positioned or opacity-only, so the card keeps its height. */
.pcard__soldout {
    position: absolute;
    z-index: 3;
    bottom: 8px;
    inset-inline-start: 8px;
    max-width: calc(100% - 16px);
    padding: .32rem .6rem;
    border-radius: 999px;
    background: rgba(16, 29, 53, .82);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}
.pcard--soldout .pcard__img { opacity: .55; filter: grayscale(.6); }
.pcard--soldout .pcard__img--placeholder { opacity: .3; }
.pcard--soldout .pcard__was { opacity: .7; }
.pcard--soldout .pcard__now { color: var(--ink-soft, #607089); }

/* Text column */
.pcard__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px 12px;
}
.pcard__store {
    display: flex;
    align-items: center;
    gap: .3em;
    height: 1.15rem;
    min-width: 0;
    margin-bottom: 2px;
    font-size: .72rem;
    color: var(--ink-soft, #607089);
}
.pcard__store span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard__title {
    margin: 0;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: 0;
    min-height: calc(2em * 1.45);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}
.pcard__link, .pcard__link:hover { color: var(--ink, #101D35); }
.pcard__link::after { content: ""; position: absolute; inset: 0; z-index: 4; }
.pcard__link:focus-visible { outline: none; }

/* Price: always two rows, pinned to the bottom; the old-price row is reserved even without a discount */
.pcard__price { margin-top: auto; padding-top: 8px; display: grid; gap: 1px; }
.pcard__now { color: var(--brand, #0868D7); font-size: 1.05rem; font-weight: 800; line-height: 1.3; }
.pcard__was { min-height: 1.2rem; line-height: 1.2rem; font-size: .78rem; color: var(--ink-soft, #607089); white-space: nowrap; }
.pcard__strike { position: relative; display: inline-flex; vertical-align: middle; }
.pcard__strike::after {
    content: "";
    position: absolute;
    inset-inline: -2px;
    top: 50%;
    border-top: 1.5px solid currentColor;
    transform: translateY(-50%);
}

/* Optional actions (wishlist remove button), above the card-wide link */
.pcard__actions { position: relative; z-index: 5; padding: 0 12px 12px; }

@media (min-width: 768px) {
    .pcard__title { font-size: .95rem; }
    .pcard__now { font-size: 1.15rem; }
}
@media (prefers-reduced-motion: reduce) {
    .pcard, .pcard__img { transition: none; }
    .pcard:active { transform: none; }
}
@media (max-width: 360px) {
    .pcard__media::before { display: none; }
}

/* Store page: categories as a horizontal chip row on phones */
.cat-chips {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: .75rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.cat-chips::-webkit-scrollbar { display: none; }
.cat-chip {
    flex: none;
    padding: .4rem .85rem;
    border: 1px solid var(--line, #DFE7F2);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-soft, #607089);
    font-size: .85rem;
    font-weight: 700;
    white-space: nowrap;
}
.cat-chip:hover { color: var(--brand-dark, #071A3D); border-color: rgba(8, 104, 215, .28); }
.cat-chip.is-active { background: var(--brand, #0868D7); border-color: var(--brand, #0868D7); color: #fff; }
.cat-chip-count { opacity: .75; font-weight: 600; }
