/* Product carousels in posts (Redmine #5067). Colours follow the GeneratePress palette of the blog. */
.sn-pc-carousel {
    --sn-pc-gap: 16px;
    --sn-pc-visible: 3;
    position: relative;
    margin: 1.5em 0;
}

.sn-pc-carousel__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--sn-pc-visible) - 1) * var(--sn-pc-gap)) / var(--sn-pc-visible));
    gap: var(--sn-pc-gap);
    margin: 0;
    padding: 4px 2px 12px;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 2px;
    scrollbar-width: thin;
}

.sn-pc-card {
    margin: 0;
    scroll-snap-align: start;
}

.sn-pc-card__link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    padding: 10px 12px 12px;
    border: 1px solid #e3e0da;
    border-radius: 8px;
    background: #fff;
    color: #222222;
    text-decoration: none;
    transition: box-shadow .2s ease, border-color .2s ease;
}

.sn-pc-card__link:hover,
.sn-pc-card__link:focus-visible {
    border-color: #98bc17;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .08);
    color: #222222;
}

/* Fixed image height rather than a square: wider cards must not get taller */
.sn-pc-card__image {
    position: relative;
    display: block;
    height: 120px;
}

.sn-pc-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sn-pc-card__discount {
    position: absolute;
    top: 0;
    left: 0;
    padding: 2px 8px;
    border-radius: 4px;
    background: #d9264a;
    color: #fff;
    font-size: .8em;
    font-weight: 700;
}

.sn-pc-card__brand {
    color: #575760;
    font-size: .75em;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.sn-pc-card__name {
    display: -webkit-box;
    overflow: hidden;
    min-height: 2.6em;
    font-size: .92em;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Stock label on the left, taking the free width; prices right-aligned, the struck-through one above */
.sn-pc-card__row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-top: auto;
    padding-top: 6px;
}

.sn-pc-card__prices {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    margin-left: auto;
    line-height: 1.15;
}

.sn-pc-card__price {
    font-size: 1.1em;
    font-weight: 700;
    white-space: nowrap;
}

.sn-pc-card__price-original {
    color: #575760;
    font-size: .78em;
}

.sn-pc-card__availability {
    flex: 1;
    min-width: 0;
    padding-bottom: 1px;
    color: #575760;
    font-size: .8em;
    line-height: 1.25;
}

.sn-pc-card__availability--available {
    color: #5a8a0e;
}

/* Shop stock label statuses: available, with-delay, unavailable */
.sn-pc-card__availability--unavailable {
    color: #b3261e;
}

.sn-pc-card__button {
    display: block;
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 4px;
    background: #98bc17;
    color: #fff;
    font-size: .85em;
    font-weight: 600;
    text-align: center;
}

.sn-pc-card__link:hover .sn-pc-card__button {
    background: #7f9e12;
}

.sn-pc-carousel__nav {
    position: absolute;
    top: 35%;
    z-index: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #b2b2be;
    border-radius: 50%;
    background: #fff;
    color: #222222;
    font-size: 26px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    cursor: pointer;
}

.sn-pc-carousel__nav:hover,
.sn-pc-carousel__nav:focus-visible {
    background: #faf7f2;
    color: #222222;
}

.sn-pc-carousel__nav[hidden] {
    display: none;
}

.sn-pc-carousel__nav--prev {
    left: -12px;
}

.sn-pc-carousel__nav--next {
    right: -12px;
}

.sn-pc-end {
    margin-top: 2em;
}

/* Styled like the post h2 without being one (see Renderer) */
.sn-pc-end__title {
    margin-bottom: 20px;
    font-size: 1.6em;
    font-weight: 600;
    line-height: 1.2;
}

@media (max-width: 768px) {
    /* A partly visible card shows that the list scrolls; arrows are left to touch scrolling */
    .sn-pc-carousel {
        --sn-pc-gap: 12px;
        --sn-pc-visible: 1.6;
    }

    .sn-pc-carousel__nav {
        display: none;
    }

}

@media (prefers-reduced-motion: reduce) {
    .sn-pc-card__link {
        transition: none;
    }
}
