/* CART GIFTS ON THE STOREFRONT (cart-gifts.js): the celebration, the "هدیه" tag of a gift row in the mini cart and
   the cart over-page, and the short note. The cart page's own gift group is styled with it, in the theme
   (Shared/_CartGiftLines.cshtml). Sizes and weights from the theme's type ladder (base.less), never past 700. */

:root {
    --tcg-accent: #D9435A;
    --tcg-accent-dark: #C2334A;
    --tcg-soft: #FFF1F3;
    --tcg-ink: #262626;
    --tcg-muted: #6B6B6B;
}

/* ---------- the "هدیه" tag and "رایگان" of a gift row ---------- */

.tc-gift-tag {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    width: fit-content;
    margin-top: 4px;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--tcg-soft);
    color: var(--tcg-accent-dark);
    font-size: 11.5px;
    font-weight: var(--tc-fw-label, 600);
    line-height: 1.7;
    white-space: nowrap;
}

.tc-gift-free {
    color: var(--tcg-accent);
    font-weight: var(--tc-fw-title, 700);
}

/* a gift row qsm.js cloned from its template: the stepper and the zero price go, "رایگان" comes */
.is-gift--cloned .rh-fc-item__quantity,
.is-gift--cloned .rh-fc-item__discount,
.is-gift--cloned .rh-fc-item__price-value,
.is-gift--cloned .rh-fc-item__price-unit,
.is-gift--cloned .tc-oc-item__quantity,
.is-gift--cloned .tc-oc-item__discount {
    display: none !important;
}

.is-gift--cloned .rh-fc-item__price::before {
    content: "رایگان";
    color: var(--tcg-accent);
    font-weight: var(--tc-fw-title, 700);
}

/* ---------- the celebration ---------- */

html.tcg-locked { overflow: hidden; }

.tcg-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
    font-family: inherit;
}

.tcg-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 17, 17, .45);
    opacity: 0;
    transition: opacity .24s ease;
}

.tcg-modal__card {
    position: relative;
    width: min(420px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 28px 24px 20px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .18);
    text-align: center;
    opacity: 0;
    transform: translateY(8px) scale(.96);
    transition: opacity .24s ease, transform .28s cubic-bezier(.2, .9, .3, 1.2);
}

.tcg-modal.is-open .tcg-modal__backdrop { opacity: 1; }
.tcg-modal.is-open .tcg-modal__card { opacity: 1; transform: none; }

.tcg-modal__x {
    position: absolute;
    top: 12px;
    left: 12px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #F5F5F5;
    color: #555;
    cursor: pointer;
}

.tcg-modal__x svg { width: 16px; height: 16px; }
.tcg-modal__x:hover { background: #ECECEC; }

.tcg-modal__badge {
    position: relative;
    display: grid;
    place-items: center;
    width: 76px;
    height: 76px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--tcg-soft);
    color: var(--tcg-accent);
}

.tcg-modal__badge svg { width: 44px; height: 44px; }

.tcg-modal.is-open .tcg-modal__badge svg { animation: tcg-pop .5s cubic-bezier(.2, .9, .3, 1.4) .08s both; }

/* six small sparks thrown out once from the badge */
.tcg-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
    border-radius: 2px;
    background: var(--tcg-accent);
    opacity: 0;
}

.tcg-spark--2, .tcg-spark--5 { background: #F5B731; border-radius: 50%; }
.tcg-spark--3, .tcg-spark--6 { background: #3BB273; }

.tcg-modal.is-open .tcg-spark { animation: tcg-spark .8s ease-out .15s both; }
.tcg-spark--1 { --tcg-x: -46px; --tcg-y: -30px; }
.tcg-spark--2 { --tcg-x: 44px; --tcg-y: -34px; }
.tcg-spark--3 { --tcg-x: -52px; --tcg-y: 14px; }
.tcg-spark--4 { --tcg-x: 52px; --tcg-y: 10px; }
.tcg-spark--5 { --tcg-x: -24px; --tcg-y: -50px; }
.tcg-spark--6 { --tcg-x: 26px; --tcg-y: -50px; }

@keyframes tcg-pop {
    from { transform: scale(.55) rotate(-8deg); }
    to { transform: none; }
}

@keyframes tcg-spark {
    0% { opacity: 0; transform: translate(0, 0) scale(.4); }
    25% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--tcg-x), var(--tcg-y)) scale(1) rotate(90deg); }
}

.tcg-modal__title {
    margin: 0 0 6px;
    color: var(--tcg-ink);
    font-size: var(--tc-fs-section, 19px);
    font-weight: var(--tc-fw-title, 700);
    line-height: 1.6;
}

.tcg-modal__text {
    margin: 0 0 16px;
    color: var(--tcg-muted);
    font-size: var(--tc-fs-small, 14px);
    line-height: 1.9;
}

.tcg-modal__text b { color: var(--tcg-ink); font-weight: var(--tc-fw-label, 600); }

.tcg-modal__items {
    max-height: 232px;
    overflow: auto;
    margin: 0 0 18px;
    padding: 0;
    border: 1px solid #F0F0F0;
    border-radius: 14px;
    list-style: none;
    text-align: start;
}

.tcg-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
}

.tcg-item + .tcg-item { border-top: 1px solid #F3F3F3; }

.tcg-item__media {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    overflow: hidden;
    border-radius: 10px;
    background: #FAFAFA;
}

.tcg-item__media img { width: 100%; height: 100%; object-fit: contain; display: block; }

.tcg-item__body { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.tcg-item__name {
    color: var(--tcg-ink);
    font-size: var(--tc-fs-caption, 13px);
    font-weight: var(--tc-fw-label, 600);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tcg-item__qty {
    align-self: flex-start;
    padding: 0 8px;
    border-radius: 6px;
    background: #F5F5F5;
    color: #5E5E5E;
    font-size: 12px;
    line-height: 1.8;
}

.tcg-item__price { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tcg-item__was { color: #A6A6A6; font-size: 12px; }
.tcg-item__free { color: var(--tcg-accent); font-size: var(--tc-fs-caption, 13px); font-weight: var(--tc-fw-title, 700); }

.tcg-modal__actions { display: flex; gap: 10px; }

.tcg-btn {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-size: var(--tc-fs-small, 14px);
    font-weight: var(--tc-fw-label, 600);
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease;
}

.tcg-btn--primary { background: var(--tcg-accent); color: #fff; }
.tcg-btn--primary:hover, .tcg-btn--primary:focus { background: var(--tcg-accent-dark); color: #fff; text-decoration: none; }
.tcg-btn--ghost { background: #F5F5F5; color: var(--tcg-ink); }
.tcg-btn--ghost:hover { background: #ECECEC; }
.tcg-btn:focus-visible { outline: 2px solid var(--tcg-accent); outline-offset: 2px; }

/* a phone: a bottom sheet */
@media (max-width: 640px) {
    .tcg-modal { align-items: flex-end; padding: 0; }

    .tcg-modal__card {
        width: 100%;
        max-height: 88vh;
        padding: 26px 16px calc(16px + env(safe-area-inset-bottom));
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        transition: opacity .2s ease, transform .3s cubic-bezier(.2, .8, .2, 1);
    }

    .tcg-modal__card::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        width: 36px;
        height: 4px;
        margin-left: -18px;
        border-radius: 2px;
        background: #E2E2E2;
    }

    .tcg-modal__badge { width: 64px; height: 64px; margin-bottom: 10px; }
    .tcg-modal__badge svg { width: 38px; height: 38px; }
    .tcg-modal__title { font-size: var(--tc-fs-section, 16px); }
    .tcg-modal__items { max-height: 38vh; }
}

@media (prefers-reduced-motion: reduce) {
    .tcg-modal__card,
    .tcg-modal__backdrop { transition: opacity .15s linear; transform: none !important; }
    .tcg-modal.is-open .tcg-modal__badge svg,
    .tcg-modal.is-open .tcg-spark { animation: none; }
}

/* ---------- the note, when the theme's toastr is not on the page ---------- */

.tcg-note {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 100000;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    background: #262626;
    color: #fff;
    font-size: var(--tc-fs-small, 14px);
    line-height: 1.8;
    direction: rtl;
    opacity: 0;
    transform: translate(-50%, 12px);
    transition: opacity .25s ease, transform .25s ease;
}

.tcg-note.is-open { opacity: 1; transform: translate(-50%, 0); }
