/*
 * Product card: the one product tile used everywhere (product-card.php).
 * Design: Claude canvas "Product card" (Monday 13534751407).
 */

.jf-card {
    --jf-card-bg: #F3F3F3;
    --jf-card-ink: #000000;
    --jf-card-muted: #5F5F5F;
    --jf-card-red: #CE0037;
    --jf-card-in: #1E7A46;
    --jf-card-low: #B45309;
    --jf-card-out: #9E002A;

    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 20px;
    background: var(--jf-card-bg);
    color: var(--jf-card-ink);
    font-family: var(--theme-font-family-body, "Inter"), "Inter", system-ui, sans-serif;
    text-decoration: none;
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.jf-card:hover,
.jf-card:focus-visible {
    color: var(--jf-card-ink);
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.10);
}

.jf-card:focus {
    outline: none;
}

.jf-card:focus-visible {
    outline: 2px solid var(--jf-card-ink);
    outline-offset: 3px;
}

/* Image: white panel, edge to edge, product contained with ~6% padding */
.jf-card__media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    overflow: hidden;
    background: #FFFFFF;
}

.jf-card .jf-card__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    box-sizing: border-box;
    padding: 6%;
    object-fit: contain;
    border-radius: 0;
    transition: transform 300ms ease;
}

.jf-card:hover .jf-card__img {
    transform: scale(1.05);
}

/* Pill: Set (black) / search match (red) */
.jf-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.jf-card__badge--dark { background: var(--jf-card-ink); }
.jf-card__badge--red  { background: var(--jf-card-red); }

/* Text */
.jf-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px 18px;
}

.jf-card__name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: calc(2 * 1.15em); /* 2 lines kept, so short names don't make cards uneven */
    font-family: var(--theme-font-family, "Ebony"), Inter, sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.15;
    text-transform: uppercase;
}

.jf-card__line {
    min-height: 18px;
    overflow: hidden;
    color: var(--jf-card-muted);
    font-size: 13px;
    line-height: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.jf-card__foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 10px;
}

.jf-card__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.jf-card__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 6px;
    min-height: 23px;
}

.jf-card__from {
    color: var(--jf-card-muted);
    font-size: 13px;
}

.jf-card__amount {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
}

.jf-card__was {
    color: var(--jf-card-muted);
    font-size: 13px;
}

.jf-card__stock {
    min-height: 18px;
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
}

.jf-card__stock.is-in         { color: var(--jf-card-in); }
.jf-card__stock.is-low,
.jf-card__stock.is-restocking { color: var(--jf-card-low); }
.jf-card__stock.is-out        { color: var(--jf-card-out); }

/* Arrow: black circle, red on hover */
.jf-card__arrow {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--jf-card-ink);
    color: #FFFFFF;
    transition: background 200ms ease;
}

.jf-card:hover .jf-card__arrow {
    background: var(--jf-card-red);
}

/* Grid used by listings and the preview: 2 columns on mobile */
.jf-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

@media (max-width: 1024px) {
    .jf-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .jf-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

/* Phones: two cards a row leave ~130px for text, so the name gets a third line
   at a smaller size (the weight / colour at its end must show) and the rest
   tightens to match. Same card, same order. */
@media (max-width: 600px) {
    .jf-card {
        border-radius: 16px;
    }

    .jf-card__body {
        gap: 4px;
        padding: 12px 12px 14px;
    }

    .jf-card__name {
        -webkit-line-clamp: 3;
        min-height: calc(3 * 1.15em);
        font-size: 14px;
    }

    .jf-card__line,
    .jf-card__stock {
        font-size: 12px;
    }

    .jf-card__amount {
        font-size: 16px;
    }

    .jf-card__price {
        min-height: 19px;
    }

    .jf-card__foot {
        gap: 8px;
        padding-top: 8px;
    }

    .jf-card__arrow {
        width: 32px;
        height: 32px;
    }

    .jf-card__badge {
        top: 8px;
        left: 8px;
        height: 22px;
        padding: 0 8px;
        font-size: 11px;
    }
}

.jf-card-preview {
    max-width: 1280px;
    margin: 0 auto;
    padding: 48px 16px;
}

@media (prefers-reduced-motion: reduce) {
    .jf-card,
    .jf-card .jf-card__img,
    .jf-card__arrow {
        transition: none;
    }
    .jf-card:hover,
    .jf-card:hover .jf-card__img {
        transform: none;
    }
}
