/**
 * Gift With Purchase — cart card, gift rows, shop label.
 * Loaded on the cart and checkout (and site-wide only when a rule shows its
 * gift in the shop). Gift red is fixed so it stays the same on every theme.
 */

:root {
    --tsc-gwp-red: #E02424;
    --tsc-gwp-red-soft: #FDECEC;
    --tsc-gwp-blush: #FFF5F6;      /* gift card + gift rows (Ain picked "Blush") */
    --tsc-gwp-blush-line: #F9E1E4;
    --tsc-gwp-green: #1E7A4C;
    --tsc-gwp-track: #ececef;
    --tsc-gwp-muted: #8a8b91;
    --tsc-gwp-ink: #161823;
}

/* ---- FREE GIFT chip (cart rows, checkout rows, shop cards) ---- */

.tsc-gwp-chip {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--tsc-gwp-red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.4;
    vertical-align: middle;
    white-space: nowrap;
}

.tsc-gwp-shop-label {
    margin: 4px 0;
    font-size: 12px;
    color: var(--tsc-gwp-red);
    line-height: 1.4;
}

.tsc-gwp-notsold {
    font-size: 13px;
    color: var(--tsc-gwp-muted);
}

/* ---- Free gifts card (top of the cart) ---- */

.tsc-gwp {
    margin: 0 0 12px;
    padding: 12px;
    background: var(--tsc-gwp-blush);
    border: 1px solid var(--tsc-gwp-blush-line);
    border-radius: 12px;
    overflow: hidden;
}

.tsc-gwp__head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    min-height: 24px;
}

.tsc-gwp__icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: var(--tsc-gwp-red);
}

.tsc-gwp__icon svg { width: 100%; height: 100%; }

.tsc-gwp__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--tsc-gwp-ink);
}

.tsc-gwp__count {
    font-size: 12px;
    color: var(--tsc-gwp-muted);
}

.tsc-gwp__nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.tsc-gwp__dots {
    display: flex;
    gap: 4px;
}

.tsc-gwp__dots button {
    width: 6px;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: #d4d4d8;
    cursor: pointer;
    transition: width .2s ease, background-color .2s ease;
}

/* Bigger tap target without changing the dot's look. */
.tsc-gwp__dots button { position: relative; }
.tsc-gwp__dots button::after {
    content: "";
    position: absolute;
    inset: -8px -3px;
}

.tsc-gwp__dots button.is-active {
    width: 14px;
    background: var(--tsc-gwp-red);
}

.tsc-gwp__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--tsc-gwp-track);
    border-radius: 50%;
    background: #fff;
    color: var(--tsc-gwp-ink);
    cursor: pointer;
}

.tsc-gwp__arrow svg { width: 14px; height: 14px; }

.tsc-gwp__dots button:focus-visible,
.tsc-gwp__arrow:focus-visible {
    outline: 2px solid var(--tsc-gwp-red);
    outline-offset: 2px;
}

@media (max-width: 767px) {
    .tsc-gwp__arrow { display: none; }
}

/* Slides: a native scroll-snap track, so swiping works without JS.
   Sideways only, with room under the photo for the tick badge: a track
   exactly as tall as the photo let the badge make it scroll up and down,
   so a swipe on iPhone could shift the photo up and cut off its bottom. */
.tsc-gwp__track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding-block: 2px 6px;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tsc-gwp__track::-webkit-scrollbar { display: none; }

.tsc-gwp__slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    scroll-snap-align: start;
}

.tsc-gwp__thumb {
    position: relative;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
}

.tsc-gwp__thumb img {
    display: block;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    background: #f5f5f7;
}

.tsc-gwp__slide.is-locked .tsc-gwp__thumb img { opacity: .55; }

.tsc-gwp__badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid var(--tsc-gwp-blush);
    border-radius: 50%;
    background: var(--tsc-gwp-muted);
    color: #fff;
}

.tsc-gwp__badge svg { width: 10px; height: 10px; }

.tsc-gwp__slide.is-unlocked .tsc-gwp__badge { background: var(--tsc-gwp-green); }

.tsc-gwp__text {
    flex: 1 1 auto;
    min-width: 0;
}

.tsc-gwp__line1 {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.tsc-gwp__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 13px;
    font-weight: 600;
    color: var(--tsc-gwp-ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tsc-gwp__worth {
    flex: 0 0 auto;
    font-size: 12px;
    white-space: nowrap;
}

.tsc-gwp__worth del {
    margin-right: 4px;
    color: var(--tsc-gwp-muted);
}

.tsc-gwp__worth em {
    font-style: normal;
    font-weight: 700;
    color: var(--tsc-gwp-red);
}

.tsc-gwp__line2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.tsc-gwp__bar {
    flex: 0 0 72px;
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--tsc-gwp-track);
}

.tsc-gwp__bar span {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--tsc-gwp-red);
    transition: width .3s ease;
}

.tsc-gwp__slide.is-unlocked .tsc-gwp__bar span { background: var(--tsc-gwp-green); }

.tsc-gwp__msg {
    min-width: 0;
    overflow: hidden;
    font-size: 12px;
    color: var(--tsc-gwp-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tsc-gwp__msg b { color: var(--tsc-gwp-red); font-weight: 700; }

.tsc-gwp__slide.is-unlocked .tsc-gwp__msg {
    color: var(--tsc-gwp-green);
    font-weight: 600;
}

@media (min-width: 768px) {
    .tsc-gwp__bar { flex-basis: 120px; }
    /* Keep the price next to the name on wide screens. */
    .tsc-gwp__text { flex-grow: 0; width: 100%; max-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
    .tsc-gwp__track { scroll-behavior: auto; }
    .tsc-gwp__bar span,
    .tsc-gwp__dots button { transition: none; }
}

/* ---- Gift rows in the cart and checkout item lists ---- */

.tsc-cart-item--gift,
.tsc-checkout-item--gift {
    background: var(--tsc-gwp-blush);
}

.tsc-gwp-row-note {
    margin-top: 2px;
    font-size: 12px;
    color: var(--tsc-gwp-muted);
}

.tsc-gwp-row-price {
    color: var(--tsc-gwp-red);
}

.tsc-gwp-row-price del {
    margin-left: 6px;
    font-size: 12px;
    font-weight: 400;
    color: var(--tsc-gwp-muted);
}

/* cart.css / checkout.css colour and size every price amount inside an
   item's price block; the doubled class makes the gift's red RM0.00 and
   small grey worth win over them. */
.tsc-gwp-row-price.tsc-gwp-row-price { white-space: nowrap; }
.tsc-gwp-row-price.tsc-gwp-row-price > .woocommerce-Price-amount { color: var(--tsc-gwp-red); }
.tsc-gwp-row-price.tsc-gwp-row-price del .woocommerce-Price-amount {
    color: var(--tsc-gwp-muted);
    font-size: 12px;
    font-weight: 400;
}

.tsc-gwp-row-qty {
    font-size: 13px;
    color: var(--tsc-gwp-muted);
}
