/* ==========================================================================
   TOAST - the one look of every message the storefront shows
   --------------------------------------------------------------------------
   Every message goes through toastr (core.js notificationSuccess / Error / Warning / Info, and
   the few direct toastr calls), and core.js toasterInit gives it its own container, toast and
   icon classes, so none of the old toastr rules in theme-core.css / toastr.css (the coloured
   boxes stacked at the top corner) can reach it.

   Two shapes:
     - success / error / warning: a flat, see-through dark card in the middle of the screen, a
       hairline icon in the state's colour over the message - green, red, orange - that draws
       itself in. A link in the message becomes an outlined button under it. One at a time: a new message
       replaces the one on screen instead of stacking under it.
     - info: Digikala's snackbar - a black bar at the bottom, the message and a blue «باشه».
   ========================================================================== */

#tc-toast {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    pointer-events: none;
}

#tc-toast > .tc-toast__item {
    --tc-toast-c: #FFF;
    position: relative;
    box-sizing: border-box;
    width: max-content;
    min-width: 184px;
    max-width: min(300px, calc(100vw - 64px));
    padding: 20px 24px;
    border-radius: 10px;
    /* flat and see-through: no shadow, no blur, the page shows through */
    background: rgba(17, 17, 17, .76);
    color: #FFF;
    font-size: var(--tc-fs-body, 14px);
    font-weight: 500;
    line-height: 24px;
    text-align: center;
    overflow-wrap: anywhere;
    cursor: pointer;
    pointer-events: auto;
    animation: tc-toast-in .28s cubic-bezier(.2, .8, .2, 1);
}

#tc-toast > .is-success { --tc-toast-c: #22C55E; }
#tc-toast > .is-error { --tc-toast-c: #F43F5E; }
#tc-toast > .is-warning { --tc-toast-c: #FB923C; }

/* ---- the icon (core.js draws it): a hairline ring that draws itself round from the top, then
   the glyph traced stroke by stroke, then a soft halo filling in behind - slow, in order ---- */
.tc-toast__icon {
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    overflow: visible;
    fill: none;
    stroke: var(--tc-toast-c);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: tc-toast-icon .7s cubic-bezier(.34, 1.3, .64, 1) both;
}

.tc-toast__icon .halo {
    stroke: none;
    fill: var(--tc-toast-c);
    opacity: 0;
    transform-origin: 24px 24px;
    animation: tc-toast-halo .6s ease-out .95s forwards;
}

.tc-toast__icon .ring,
.tc-toast__icon .g1,
.tc-toast__icon .g2 {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.tc-toast__icon .ring {
    transform: rotate(-90deg);
    transform-origin: 24px 24px;
    animation: tc-toast-draw .75s cubic-bezier(.65, 0, .35, 1) .05s forwards;
}

.tc-toast__icon .g1 {
    animation: tc-toast-draw .42s cubic-bezier(.45, 0, .2, 1) .62s forwards;
}

.tc-toast__icon .g2 {
    animation: tc-toast-draw .32s cubic-bezier(.45, 0, .2, 1) .86s forwards;
}

.tc-toast__icon .dot {
    stroke-width: 2.4;
}

@keyframes tc-toast-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes tc-toast-icon {
    from {
        transform: scale(.72);
    }
}

@keyframes tc-toast-halo {
    from {
        opacity: 0;
        transform: scale(.5);
    }

    to {
        opacity: .14;
        transform: scale(1);
    }
}

.tc-toast__title {
    margin-bottom: 4px;
    font-weight: 700;
}

.tc-toast__msg p {
    margin: 0;
}

/* a link left in the text (core.js turns the message's link into the button below) */
.tc-toast__msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 5px;
}

/* the message's link as a button, DHgate's «Go to cart»: an outlined pill under the text, so it
   reads as something to tap and not as part of the sentence */
.tc-toast__cta {
    display: inline-block;
    margin-top: 14px;
    padding: 5px 20px;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 999px;
    color: #FFF !important;
    font-size: var(--tc-fs-small, 13px);
    font-weight: 500;
    line-height: 22px;
    text-decoration: none !important;
    transition: background-color .15s ease;
}

.tc-toast__cta:hover,
.tc-toast__cta:active {
    background: rgba(255, 255, 255, .14);
}

@keyframes tc-toast-in {
    from {
        transform: scale(.94);
    }
}

/* ---- info: Digikala's snackbar ------------------------------------------------------------ */

#tc-snack {
    position: fixed;
    right: 16px;
    left: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    z-index: 2147483000;
    pointer-events: none;
}

#tc-snack > .tc-toast__item {
    position: relative;
    box-sizing: border-box;
    min-height: 56px;
    margin-top: 8px;
    padding-block: 16px;
    padding-inline: 16px 88px;
    border-radius: 8px;
    background: #0C0C0C;
    color: #FFF;
    font-size: var(--tc-fs-body, 14px);
    line-height: 24px;
    overflow-wrap: anywhere;
    pointer-events: auto;
    animation: tc-snack-in .22s cubic-bezier(.2, .8, .2, 1);
}

#tc-snack .tc-snack__ok {
    position: absolute;
    top: 50%;
    inset-inline-end: 8px;
    transform: translateY(-50%);
    padding: 8px 12px;
    border: 0;
    background: none;
    font: inherit;
    color: #3B82F6;
    cursor: pointer;
}

@keyframes tc-snack-in {
    from {
        transform: translateY(8px);
    }
}

@media (min-width: 768px) {
    #tc-snack {
        right: auto;
        left: 24px;
        bottom: 24px;
        width: 400px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #tc-toast > .tc-toast__item,
    #tc-snack > .tc-toast__item,
    .tc-toast__icon,
    .tc-toast__icon * {
        animation: none !important;
    }

    .tc-toast__icon .ring,
    .tc-toast__icon .g1,
    .tc-toast__icon .g2 {
        stroke-dashoffset: 0;
    }
}
