/*
 * MC Toast — toast ở góc màn hình, không chặn thao tác.
 * Token màu/radius/font theo DESIGN.md của theme.
 */

.mct-stack {
    position: fixed;
    z-index: 4900; /* trên header (1003), dưới trailer modal (5000) */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: var(--mct-w, 320px);
    max-width: calc(100vw - 24px);
    pointer-events: none; /* chỉ toast nhận sự kiện, vùng trống không chặn trang */
}

.mct-stack--br { right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); }
.mct-stack--bl { left: 12px;  bottom: calc(16px + env(safe-area-inset-bottom)); }
.mct-stack--tr { right: 12px; top: calc(16px + env(safe-area-inset-top)); }
.mct-stack--tl { left: 12px;  top: calc(16px + env(safe-area-inset-top)); }

.mct {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    min-height: 96px;
    padding: 14px 14px 16px 17px;
    overflow: hidden;
    color: #fff;
    font: 400 14px/1.45 Inter, Arial, sans-serif;
    background: rgba(11, 16, 24, .94);
    border: 1px solid #263241;
    border-radius: 14px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, .62);
    pointer-events: auto;
    touch-action: pan-y;

    opacity: 0;
    transform: translateY(14px) scale(.96);
    transition: opacity .38s cubic-bezier(.16, 1, .3, 1),
                transform .38s cubic-bezier(.16, 1, .3, 1);
    will-change: opacity, transform;
}

.mct.is-in { opacity: 1; transform: none; }

.mct.is-out {
    opacity: 0;
    transform: translateY(8px) scale(.97);
    transition-duration: .2s;
}

/* Kính mờ chỉ là lớp trang trí: máy yếu hoặc trình duyệt không hỗ trợ vẫn đọc rõ
   vì nền đã đủ đặc. */
@supports (backdrop-filter: blur(1px)) {
    .mct--blur { backdrop-filter: blur(14px) saturate(140%); }
}

/* Vạch màu bên trái, đổi theo loại thông báo */
.mct::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--mct-accent, #8ec5f2);
}

.mct--info    { --mct-accent: #8ec5f2; }
.mct--update  { --mct-accent: #ff7e08; }
.mct--success { --mct-accent: #22c55e; }
.mct--warning { --mct-accent: #ffc400; }

/* ------------------------------------------------------------------ phần đầu */

.mct__head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.mct__thumb {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    background: #10151c;
}

.mct__main {
    min-width: 0;
    flex: 1 1 auto;
    /* Chừa chỗ cho nút đóng ở góc trên phải */
    padding-right: 22px;
}

.mct__title {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.mct__body {
    display: -webkit-box;
    margin: 4px 0 0;
    overflow: hidden;
    color: #9ca3af;
    font-size: 13px;
    line-height: 1.42;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* --------------------------------------------------------------------- nút */

.mct__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mct__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    min-height: 40px; /* đủ lớn cho ngón tay */
    padding: 0 18px;
    color: #0b1018;
    font-size: 13.5px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    background: var(--mct-accent, #8ec5f2);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: filter .18s ease, transform .18s ease;
}

.mct__btn:hover  { filter: brightness(1.08); text-decoration: none; }
.mct__btn:active { transform: scale(.97); }

.mct__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.mct__btn svg {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

/* Nút đóng: icon 14px nhưng vùng bấm 48x48 theo hướng dẫn Material Design.
   ::after mở rộng vùng chạm mà không phá layout. */
.mct__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: 22px;
    height: 22px;
    padding: 0;
    color: #9ca3af;
    background: none;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}

.mct__close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    transform: translate(-50%, -50%);
}

.mct__close:hover { color: #fff; }

.mct__close svg {
    display: block;
    width: 14px;
    height: 14px;
    margin: auto;
}

/* ---------------------------------------------------------------- tiến trình */

.mct__progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--mct-accent, #8ec5f2);
    transform-origin: left center;
    opacity: .55;
}

.mct.is-held .mct__progress { animation-play-state: paused; }

@keyframes mct-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Kéo để tắt: bỏ transition trong lúc ngón tay còn trên màn hình */
.mct.is-drag { transition: none; }

/* Mobile — vẫn là toast ở góc, không phải banner ngang màn hình */
@media (max-width: 767px) {
    .mct-stack {
        right: 12px;
        left: auto;
        top: auto;
        bottom: calc(12px + env(safe-area-inset-bottom));
        width: min(var(--mct-w, 320px), calc(100vw - 24px));
    }

    .mct-stack--bl { right: auto; left: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .mct {
        transform: none;
        transition: opacity .2s linear;
    }

    .mct.is-in, .mct.is-out { transform: none; }
    .mct__progress { animation: none; }
    .mct__btn { transition: none; }
}
