/**
 * IJW Checkout Packup — inline extras block styling.
 * Colours come from CSS variables set inline (see Frontend::inline_css()).
 */

.ijw-cpu-block {
    margin: 24px 0;
    max-width: 100%;
    min-width: 0;
}

/* The block's own max-width:100% is only as good as its parents. The theme's
   basket is a flex layout whose children default to min-width:auto, so a child
   holding our slider refuses to shrink below the strip's content width and
   over-grows the basket, pushing the whole page wider on mobile. Relaxing the
   basket children to min-width:0 lets the chain shrink so the overflow is
   handled inside our own box instead of widening the page. This targets the
   theme's basket wrapper (not an ijw-cpu class) on purpose: the plugin is
   bespoke to this site's theme. */
.ijw-basket > * {
    min-width: 0;
}

/* Intro -------------------------------------------------------------- */

.ijw-cpu-block__intro {
    margin-bottom: 12px;
}

.ijw-cpu-block__title {
    margin: 0 0 6px;
    font-size: 24px;
    line-height: 1.15;
    font-weight: 800;
    color: #111;
}

.ijw-cpu-block__sub {
    margin: 0;
    font-size: 15px;
    color: #777;
}

/* Offer banner ------------------------------------------------------- */

.ijw-cpu-block__offer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--ijw-cpu-badge-bg, #fce4ef);
    color: var(--ijw-cpu-badge-tx, #d6006e);
    font-size: 16px;
    font-weight: 600;
}

.ijw-cpu-block__tag {
    width: 22px;
    height: 22px;
    flex: 0 0 auto;
    background: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E");
}

/* Cards — a responsive wrapping grid (inline, not a horizontal drawer). */

.ijw-cpu-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

/* Slider layout: all cards on one row, horizontally scrollable. */
.ijw-cpu-cards-wrap {
    position: relative;
    max-width: 100%;
    min-width: 0;
}

.ijw-cpu-cards--slider {
    display: flex;
    grid-template-columns: none;
    flex-wrap: nowrap;
    /* Never grow past the container: keeps the strip inside the viewport on
       mobile so it scrolls internally instead of widening the page. */
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox — arrows replace the scrollbar */
}

.ijw-cpu-cards--slider::-webkit-scrollbar {
    display: none; /* WebKit */
}

/* Card width is driven by "cards in view" (--ijw-cpu-perview), accounting for
   the gaps between the visible cards. Fractional values peek the next card. */
.ijw-cpu-cards--slider .ijw-cpu-card {
    flex: 0 0 calc((100% - (var(--ijw-cpu-perview, 2.25) - 1) * 14px) / var(--ijw-cpu-perview, 2.25));
    min-width: 0;
    max-width: none;
    scroll-snap-align: start;
}

/* Desktop: the per-view count is a mobile concern; fit a comfortable fixed
   width instead so wide screens aren't stretched to a handful of giant cards. */
@media (min-width: 600px) {
    .ijw-cpu-cards--slider .ijw-cpu-card {
        flex-basis: 220px;
        max-width: 240px;
    }
}

/* Slider arrows */
.ijw-cpu-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #222;
    font-size: 26px;
    line-height: 1;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transition: opacity 0.15s ease, color 0.15s ease;
}

/* Mobile: keep arrows just inside the edge so they can't push the page wider. */
.ijw-cpu-nav--prev {
    left: 2px;
}

.ijw-cpu-nav--next {
    right: 2px;
}

@media (min-width: 600px) {
    .ijw-cpu-nav--prev {
        left: -6px;
    }
    .ijw-cpu-nav--next {
        right: -6px;
    }
}

.ijw-cpu-nav:hover {
    color: var(--ijw-cpu-accent, #d6006e);
}

/* Only show the arrows once the strip actually overflows; fade at the ends. */
.ijw-cpu-cards-wrap.has-overflow .ijw-cpu-nav {
    display: flex;
}

.ijw-cpu-cards-wrap.has-overflow .ijw-cpu-nav.is-disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.ijw-cpu-card {
    border: 1px solid #ececec;
    border-radius: 14px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.ijw-cpu-card.has-coupon {
    border-color: var(--ijw-cpu-accent, #d6006e);
    box-shadow: 0 0 0 1px var(--ijw-cpu-accent, #d6006e) inset;
}

/* Out-of-stock card (only shown when "Hide out-of-stock items" is off) */
.ijw-cpu-card--oos {
    opacity: 0.7;
}

.ijw-cpu-card--oos .ijw-cpu-card__media {
    filter: grayscale(0.7);
}

.ijw-cpu-card__oos-flag {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
    background: #555;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 3px 8px;
    border-radius: 20px;
}

.ijw-cpu-card--oos .ijw-cpu-card__add {
    background: #eee;
    border-color: #ddd;
    color: #999;
    cursor: not-allowed;
}

.ijw-cpu-card--oos .ijw-cpu-card__add:hover {
    background: #eee;
    color: #999;
}

/* Gamified coupon ribbon, sits above the image */
.ijw-cpu-card__coupon {
    display: block;
    text-align: center;
    margin-bottom: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    background: linear-gradient(90deg, var(--ijw-cpu-accent, #d6006e), color-mix(in srgb, var(--ijw-cpu-accent, #d6006e) 60%, #ff8a00));
    box-shadow: 0 2px 6px color-mix(in srgb, var(--ijw-cpu-accent, #d6006e) 35%, transparent);
}

.ijw-cpu-card__media {
    position: relative;
    background: #fafafa;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ijw-cpu-card__media img,
.ijw-cpu-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ijw-cpu-card__badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--ijw-cpu-accent, #d6006e);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    z-index: 1;
}

.ijw-cpu-card__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    padding-top: 10px;
}

.ijw-cpu-card__title {
    font-size: 15px;
    line-height: 1.3;
    color: #222;
    text-decoration: none;
    display: block;
    margin-bottom: 8px;
    flex: 1 1 auto;
}

.ijw-cpu-card__title:hover {
    text-decoration: underline;
}

.ijw-cpu-card__price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}

.ijw-cpu-card__was {
    color: #9a9a9a;
    text-decoration: line-through;
    font-size: 14px;
}

.ijw-cpu-card__now {
    color: var(--ijw-cpu-accent, #d6006e);
    font-weight: 700;
    font-size: 17px;
    text-decoration: none;
}

.ijw-cpu-card__add {
    position: relative;
    width: 100%;
    border: 1.5px solid var(--ijw-cpu-accent, #d6006e);
    background: #fff;
    color: var(--ijw-cpu-accent, #d6006e);
    font-weight: 700;
    font-size: 15px;
    padding: 10px 8px;
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

/* In-flight loader — chasing-ring spinner in the button's own colour. */
.ijw-cpu-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
}

.ijw-cpu-spinner span {
    box-sizing: border-box;
    position: absolute;
    display: block;
    width: 16px;
    height: 16px;
    margin: 2px;
    border: 2px solid currentColor;
    border-color: currentColor transparent transparent transparent;
    border-radius: 50%;
    animation: ijw-cpu-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.ijw-cpu-spinner span:nth-child(1) { animation-delay: -0.45s; }
.ijw-cpu-spinner span:nth-child(2) { animation-delay: -0.3s; }
.ijw-cpu-spinner span:nth-child(3) { animation-delay: -0.15s; }

@keyframes ijw-cpu-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .ijw-cpu-spinner span { animation-duration: 2.4s; }
}

.ijw-cpu-card__add:hover {
    background: var(--ijw-cpu-accent, #d6006e);
    color: #fff;
}

.ijw-cpu-card.is-adding .ijw-cpu-card__add {
    opacity: 0.6;
    pointer-events: none;
}

.ijw-cpu-card.is-added .ijw-cpu-card__add {
    background: var(--ijw-cpu-accent, #d6006e);
    color: #fff;
    border-color: var(--ijw-cpu-accent, #d6006e);
    cursor: default;
}

.ijw-cpu-card.is-added .ijw-cpu-card__add-label::before {
    content: "\2713\00a0";
}

.ijw-cpu-cards__noscript {
    margin: 8px 0 0;
    font-size: 13px;
    color: #777;
}

/* Cart / mini-cart price: struck baseline + discounted price on our lines */
.ijw-cpu-cart-was {
    color: #9a9a9a;
    font-weight: 400;
    margin-right: 4px;
}

.ijw-cpu-cart-now {
    text-decoration: none;
    font-weight: 700;
    color: var(--ijw-cpu-accent, #d6006e);
}

/* Cart / mini-cart promo tag on our extras */
.ijw-cpu-cart-tags {
    display: block;
    margin-top: 6px;
}

.ijw-cpu-cart-badge {
    display: inline-block;
    background: var(--ijw-cpu-badge-bg, #fce4ef);
    color: var(--ijw-cpu-badge-tx, #d6006e);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: 20px;
    line-height: 1.6;
}

.ijw-cpu-cart-note {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: #777;
    font-style: italic;
}
