/* Compact Product Card V2.1. Reusable opt-in body + card classes.
   Only Shop currently opts in. Original WooCommerce desktop markup stays intact. */
.s1688-cpc-v2__topbar, .s1688-cpc-v2__footer { display: none; }
@media (max-width: 767px) {
  body.s1688-compact-cards-v2 {
    --cpc-surface: #181b19;
    --cpc-border: #c8a55c24;
    --cpc-ink: #f3f1eb;
    --cpc-muted: #aaa9a4;
    --cpc-gold: #c8a55c;
    --cpc-media-ratio: 1 / 1;
  }
  /* The legacy inline archive CSS forces min-height:392/405/470px and flex:1.
     These scoped !important resets are necessary, not global archive changes. */
  body.s1688-compact-cards-v2 #main ul.products > li.product.s1688-cpc-v2 {
    position: relative !important;
    float: none !important;
    display: flex !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px !important;
    box-sizing: border-box;
    border: 1px solid var(--cpc-border) !important;
    border-radius: 10px !important;
    background: var(--cpc-surface) !important;
    box-shadow: none !important;
    overflow: hidden !important;
    transform: none !important;
    opacity: 1 !important;
    text-align: left !important;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 > a.woocommerce-loop-product__link {
    position: static !important;
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: column !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--cpc-ink) !important;
    text-decoration: none;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-image-hover-wrap,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 a.woocommerce-loop-product__link > img {
    display: block !important;
    position: relative !important;
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 160px !important;
    align-self: center;
    height: auto !important;
    aspect-ratio: var(--cpc-media-ratio);
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 0 6px !important;
    padding: 0 !important;
    border-radius: 6px !important;
    object-fit: contain !important;
    object-position: center !important;
    overflow: hidden;
    transform: none !important;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-image-hover-wrap img {
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: contain !important;
    object-position: center !important;
    transform: none !important;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-hover-image { display: none !important; }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-loop-brand {
    position: static !important;
    display: block !important;
    flex: 0 0 13px !important;
    height: 13px !important;
    min-height: 13px !important;
    margin: 0 0 1px !important;
    padding: 0 !important;
    color: var(--cpc-muted) !important;
    font-size: 10.5px !important;
    font-weight: 400 !important;
    line-height: 13px !important;
    letter-spacing: .03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left !important;
    transform: none !important;
    opacity: 1 !important;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .woocommerce-loop-product__title {
    position: static !important;
    display: -webkit-box !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    flex: 0 0 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    color: var(--cpc-ink) !important;
    font-size: 12.5px !important;
    line-height: 17px !important;
    font-weight: 600 !important;
    text-align: left !important;
    letter-spacing: 0 !important;
    overflow-wrap: anywhere;
    transform: none !important;
    opacity: 1 !important;
  }
  /* Hide legacy duplicate price/large CTA/secondary controls, not their data. */
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 a.woocommerce-loop-product__link .price,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 > a.button,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-card-note,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-card-actions,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-card-close,
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .steam1688-card-variant { display: none !important; }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__topbar {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: space-between;
    inset: 10px 10px auto;
    height: 20px;
    pointer-events: none;
    z-index: 1;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__badge {
    /* Existing helper emits verified labels only; reserve the top-left position
       without adding a fabricated label to unmarked products. */
    position: static;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    margin: 0;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--cpc-gold);
    color: #181b19;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    white-space: nowrap;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__heart {
    --cpc-icon-size: 14px;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-left: auto;
    border-radius: 50%;
    background: #181b19e8;
    color: #ddd9ce;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0 4px;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__price {
    flex: 1 1 0;
    min-width: 0;
    color: var(--cpc-gold);
    font-size: 14px;
    font-weight: 700;
    line-height: 18px;
    overflow-wrap: anywhere;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__price :is(ins, del) { display: block; background: none; }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__price del { font-size: 10px; color: var(--cpc-muted); font-weight: 400; }
  /* Visual gold circle:33px. Transparent 44px hit area for touch/keyboard. */
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__cart {
    position: relative !important;
    display: grid !important;
    place-items: center;
    flex: 0 0 44px;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    color: #181b19 !important;
    box-shadow: none !important;
    text-decoration: none;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__cart::before {
    content: '';
    position: absolute;
    inset: 5.5px;
    border-radius: 50%;
    background: var(--cpc-gold);
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 :is(.s1688-cpc-v2__heart, .s1688-cpc-v2__cart) svg {
    position: relative;
    display: block;
    width: var(--cpc-icon-size, 16px);
    height: var(--cpc-icon-size, 16px);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__cart.loading { opacity: .6; pointer-events: none; }
  /* Keep WooCommerce's real success link; never imitate a Wishlist/add success. */
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 .s1688-cpc-v2__footer .added_to_cart {
    display: block;
    flex: 0 0 100%;
    padding: 3px 0;
    color: var(--cpc-gold);
    font-size: 11px;
    line-height: 18px;
    text-decoration: underline;
  }
  body.s1688-compact-cards-v2 #main li.product.s1688-cpc-v2 :is(a.woocommerce-loop-product__link, .s1688-cpc-v2__cart):focus-visible {
    outline: 2px solid var(--cpc-gold);
    outline-offset: -2px;
  }
}
