/* =========================================================
   MOON BOOK — اعلان «نشان تازه باز شد»
   =========================================================
   هر جای سایت که کاربر باشد (خانه، مطالعهٔ فصل، پروفایل، نظرها و ...)
   همین کارت کوچک نشانِ تازه را با تبریک نشان می‌دهد، بعد از ۵ ثانیه
   خودش می‌رود و با کلیک/Enter هم به بخش دستاوردهای پروفایل می‌رود.

   کارت پایین‌چپ باز می‌شود تا با زنگولهٔ اعلان‌ها (بالا)، Swal و ناوبری
   پایین موبایل برخورد نکند.
   ========================================================= */

.achievement-unlock {
    position: fixed;
    inset-inline-start: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 10850;
    display: flex;
    justify-content: flex-start;
    pointer-events: none;
    width: min(380px, calc(100vw - 32px));
}

.achievement-unlock[hidden] {
    display: none !important;
}

/* در موبایل بالای نوار ناوبری پایین می‌نشیند تا دکمه‌ها را نپوشاند */
@media (max-width: 800px) {
    .achievement-unlock {
        inset-inline: 12px;
        width: auto;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    }
}

.achievement-unlock__card {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(170, 85, 255, .45);
    border-radius: 16px;
    background:
        radial-gradient(120% 120% at 100% 0%, rgba(170, 85, 255, .22), transparent 60%),
        linear-gradient(160deg, #1a1526, #10131b);
    color: #f4f1fa;
    text-align: start;
    font: inherit;
    cursor: pointer;
    box-shadow: 0 18px 42px rgba(0, 0, 0, .5);
    transform: translateY(14px) scale(.98);
    opacity: 0;
    transition: transform .28s ease, opacity .28s ease;
    /* دکمهٔ کامل: کل کارت کلیک‌پذیر است */
    -webkit-tap-highlight-color: transparent;
}

.achievement-unlock.is-visible .achievement-unlock__card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.achievement-unlock__card:focus-visible {
    outline: 2px solid #d8b4fe;
    outline-offset: 3px;
}

.achievement-unlock__icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .14);
    background: linear-gradient(150deg, rgba(170, 85, 255, .35), rgba(170, 85, 255, .08));
    color: #f0d7ff;
    font-size: 20px;
    animation: achievement-unlock-pulse 2.4s ease-in-out infinite;
}

.achievement-unlock__body {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.achievement-unlock__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #d8b4fe;
    font-size: 11px;
    font-weight: 700;
}

.achievement-unlock__title {
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.achievement-unlock__text {
    color: #b9c0cc;
    font-size: 11.5px;
    line-height: 1.75;
}

.achievement-unlock__cta {
    color: #c58af0;
    font-size: 11px;
    font-weight: 600;
    margin-top: 2px;
}

.achievement-unlock__rarity {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    color: #f5e6ff;
    background: rgba(170, 85, 255, .22);
    border: 1px solid rgba(170, 85, 255, .4);
    vertical-align: middle;
}

/* نوار زمان باقی‌مانده تا حذف خودکار (۵ ثانیه) */
.achievement-unlock__timer {
    position: absolute;
    inset-inline: 12px;
    bottom: 6px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.achievement-unlock__timer::after {
    content: "";
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #aa55ff, #e3b9ff);
    transform-origin: right center;
}

.achievement-unlock.is-visible .achievement-unlock__timer::after {
    animation: achievement-unlock-countdown var(--achievement-visible-ms, 5000ms) linear forwards;
}

@keyframes achievement-unlock-countdown {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@keyframes achievement-unlock-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(170, 85, 255, .35); }
    50% { box-shadow: 0 0 0 7px rgba(170, 85, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .achievement-unlock__card {
        transition: none;
        transform: none;
    }

    .achievement-unlock__icon {
        animation: none;
    }

    .achievement-unlock.is-visible .achievement-unlock__timer::after {
        animation: none;
    }
}
