.cd-shortcode {
    margin: 2rem 0;
}

.cd-shortcode__title {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    line-height: 1.3;
}

/*
 * A card is never wider than it would be in a three column block: --cd-card-max
 * is exactly one third of the row, so a single product or brand card is the same
 * size as one of three and is centred instead of stretched across the article.
 * Three columns and up keep 1fr, so the layout the editors already liked is
 * untouched.
 */
.cd-shortcode__grid {
    --cd-card-max: calc((100% - 2rem) / 3);
    display: grid;
    gap: 1rem;
    justify-content: center;
}

.cd-shortcode__grid--cols-1 { grid-template-columns: minmax(0, var(--cd-card-max)); }
.cd-shortcode__grid--cols-2 { grid-template-columns: repeat(2, minmax(0, var(--cd-card-max))); }
.cd-shortcode__grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cd-shortcode__grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cd-shortcode__grid--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cd-shortcode__grid--cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.cd-card {
    border: 1px solid #e3e6ea;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.cd-card:hover {
    border-color: #cfd4da;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
}

.cd-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.cd-card__link:hover,
.cd-card__link:focus {
    color: inherit;
    text-decoration: none;
}

.cd-card__media {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    padding: 0.75rem;
    background: #fff;
}

.cd-card__media--contain {
    aspect-ratio: 3 / 2;
}

.cd-card__image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.cd-card__image--empty {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: #f1f3f5;
}

.cd-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0 0.85rem 0.9rem;
}

.cd-card__name {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.cd-card__sku {
    font-size: 0.75rem;
    color: #6c757d;
}

.cd-card__price-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.35rem;
}

.cd-card__price {
    font-size: 1.05rem;
    font-weight: 700;
    color: #c0392b;
}

.cd-card__price-original {
    font-size: 0.85rem;
    color: #8a9099;
    text-decoration: line-through;
}

.cd-card__price-note {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5058;
}

@media (max-width: 1024px) {
    .cd-shortcode__grid--cols-5,
    .cd-shortcode__grid--cols-6 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .cd-shortcode__grid--cols-4,
    .cd-shortcode__grid--cols-5,
    .cd-shortcode__grid--cols-6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* A third of the row is too small to read on a phone, so the cap is dropped. */
@media (max-width: 720px) {
    .cd-shortcode__grid--cols-2,
    .cd-shortcode__grid--cols-3,
    .cd-shortcode__grid--cols-4,
    .cd-shortcode__grid--cols-5,
    .cd-shortcode__grid--cols-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cd-shortcode__grid--cols-1 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 480px) {
    .cd-shortcode__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .cd-shortcode__grid--cols-1 {
        grid-template-columns: minmax(0, 1fr);
    }
}
