/* Универсальная система уведомлений для всего проекта.
   API: window.notify.show({...}) — см. /js/notifications.js
   Использует переменные из /styles/index.css, но fallback есть для standalone-страниц. */

#notify-root {
    position: fixed;
    top: 20px;
    right: 20px;
    /* left/bottom: auto — на случай если браузер по popover-дефолту поставит inset:0 */
    left: auto;
    bottom: auto;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - 40px);
    font-family: Rubik, system-ui, -apple-system, sans-serif;
    /* Popover-режим: убираем дефолтные overlay-стили браузера (inset:0, margin, border, background) */
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
}
/* Popover default = display:none; когда notify-root открыт как popover,
   выставляем flex обратно. Работает благодаря :popover-open (fallback — сам JS
   вызывает showPopover, что уже показывает элемент). */
#notify-root:popover-open {
    display: flex;
}

/* Визуальный прогресс-бар внутри уведомления (например для повышения уровня).
   Отличается от .notify__progress — та полоса показывает time-to-close, а эта
   — визуализирует любой прогресс (XP до нового уровня, заполнение и т.п.). */
.notify__progressbar {
    margin-top: 8px;
    grid-column: 2;
}
.notify__progressbar-track {
    position: relative;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}
.notify__progressbar-fill {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: var(--ok);
    border-radius: inherit;
    box-shadow: 0 0 8px rgba(77, 193, 103, .35);
    transition: none;
}
.notify__progressbar-label {
    margin-top: 4px;
    opacity: .75;
    font-size: 11px;
    letter-spacing: .2px;
}
.notify__progressbar-label:empty { display: none; }
@media (max-width: 540px) {
    #notify-root {
        top: 12px;
        left: 12px;
        right: 12px;
        max-width: none;
        width: auto;
    }
}

/* === Компактный тост (style: 'toast') ===
   Негромкая подсказка внизу по центру — для того, что нужно просто сообщить,
   не забирая экран: получена ежедневка, сохранено, скопировано. Геометрия та
   же, что у тоста в чате (ToastLayer.vue), чтобы это читалось как одна вещь. */
#notify-toast-root {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    top: auto;
    right: auto;
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 32px));
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
    font-family: Rubik, system-ui, -apple-system, sans-serif;
}
#notify-toast-root:popover-open { display: flex; }

/* На телефоне поднимаем над нижней навигацией — иначе тост ложится прямо на неё */
@media (max-width: 1359px) {
    #notify-toast-root { bottom: 84px; }
}


.notify {
    pointer-events: auto;
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-gap: 12px;
    align-items: center;
    padding: 14px 38px 14px 14px;
    border-radius: 14px;
    background: rgba(30, 31, 33, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    color: var(--ink-on-dark);
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    opacity: 0;
    transform: translate3d(120%, 0, 0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
    overflow: hidden;
    will-change: transform, opacity;
    /* Смахивание (см. attachSwipe в notifications.js): жест наш, не прокрутки */
    touch-action: none;
    user-select: none; -webkit-user-select: none;
}
.notify--dragging { transition: none !important; animation: none !important; cursor: grabbing; }
.notify--in {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}
.notify--out {
    opacity: 0;
    transform: translate3d(120%, 0, 0);
    transition: transform 0.3s ease-in, opacity 0.25s;
}
@media (max-width: 540px) {
    .notify {
        transform: translate3d(0, -120%, 0);
    }
    /* Без этой строки на телефоне .notify выше перебивал .notify--in (та же
       специфичность, правило позже), и обычные уведомления так и стояли за
       верхним краем экрана — видны были только pompous, у них своя анимация. */
    .notify--in {
        transform: translate3d(0, 0, 0);
    }
    .notify--out {
        transform: translate3d(0, -120%, 0);
    }
}
.notify--clickable { cursor: pointer; }
.notify--clickable:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* === Icon === */
.notify__icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}
.notify__icon img,
.notify__icon svg { width: 22px; height: 22px; }
.notify__icon-emoji {
    font-size: 22px;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}

/* === Content === */
.notify__content { min-width: 0; overflow: hidden; }
.notify__title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 4px;
    min-height: 1.2em;
    letter-spacing: -0.1px;
}
.notify__body {
    font-size: 12.5px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.8);
    min-height: 1em;
    word-break: break-word;
}
.notify__body:empty { display: none; }
/* В pompous-режиме тело ВСЕГДА занимает место — typewriter заполняет его постепенно. */
.notify--pompous .notify__body:empty { display: block; }

/* === Hero image (top of notification) === */
.notify--has-image { padding-top: 0; padding-left: 0; padding-right: 0; padding-bottom: 0; }
.notify--has-image .notify__image {
    grid-column: 1 / -1;
    height: 120px;
    overflow: hidden;
    background: var(--ink-black);
}
.notify--has-image .notify__image img {
    width: 100%; height: 100%; object-fit: cover;
    display: block;
}
.notify--has-image .notify__icon { margin-left: 14px; margin-top: -28px; }
.notify--has-image .notify__content { padding: 12px 14px 14px 0; }
.notify--has-image .notify__close { top: 10px; right: 10px; background: rgba(0,0,0,0.5); color: var(--ink-on-dark); }

/* === Card thumbnail (превью карточки слева — покупка/дар/подписка) === */
.notify__card {
    width: 44px;
    aspect-ratio: 396 / 544;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.notify__card img {
    width: 100%; height: 100%; object-fit: cover;
    display: block;
}
.notify__header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.notify--has-card .notify__title { margin-bottom: 0; }
.notify__avatar {
    width: 18px; height: 18px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
}
.notify__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* === Close button === */
.notify__close {
    position: absolute;
    top: 8px; right: 8px;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    border: none;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, color 0.2s, transform 0.15s;
    padding: 0;
}
.notify__close:hover { background: rgba(255, 255, 255, 0.18); color: var(--ink-on-dark); transform: scale(1.1); }

/* === Actions === */
.notify__actions {
    display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.notify__action {
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: var(--ink-on-dark);
    font-size: 12px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
.notify__action:hover  { background: rgba(255, 255, 255, 0.24); }
.notify__action:active { transform: scale(0.96); }
.notify__action--primary { background: var(--ink-on-dark); color: var(--ink-strong); }
.notify__action--primary:hover { background: #f0f0f0; }

/* variant: 'brand' — главное действие в фирменном градиенте (эталон заливки
   бренда, см. дизайн-систему): голубой → синий → фиолетовый → розовый край */
.notify__action--brand,
.notify__action--brand:hover {
    background:
        radial-gradient(71.4% 94.07% at 29.77% 10.79%, rgba(79, 160, 255, .68) 0%, rgba(79, 160, 255, 0) 100%),
        radial-gradient(70.52% 169.17% at 90.29% -7.45%, #B338FF 0%, rgba(179, 56, 255, 0) 100%),
        radial-gradient(44.63% 98.29% at 23.44% 121.53%, #524FFF 0%, rgba(82, 79, 255, 0) 100%),
        linear-gradient(136.57deg, #4FA0FF 1.23%, #524FFF 35.29%, #6235E8 70.11%, #B338FF 95.8%),
        #6235E8;
    color: #fff;
}
.notify__action--brand {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: -0.1px;
    box-shadow: 0 6px 18px rgba(82, 79, 255, .38), inset 0 1px 0 rgba(255, 255, 255, .22);
    transition: filter 0.2s, transform 0.15s, box-shadow 0.2s;
}
.notify__action--brand:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(82, 79, 255, .48), inset 0 1px 0 rgba(255, 255, 255, .22); }

/* === Внизу экрана (placement: 'bottom') ===
   Карточка живёт в нижнем контейнере тостов (#notify-toast-root) — над нижней
   навигацией на телефоне, — выезжает снизу и смахивается вниз. Правила
   двойным классом: иначе мобильное .notify ниже по файлу увело бы её вверх. */
.notify.notify--bottom {
    /* Ширина — ровно как у контейнера (max-width #notify-toast-root),
       border-box: иначе отступы карточки вылезали за края экрана */
    box-sizing: border-box;
    width: min(360px, calc(100vw - 32px));
    transform: translate3d(0, 24px, 0);
}
.notify.notify--bottom.notify--in { transform: translate3d(0, 0, 0); }
.notify.notify--bottom.notify--out { transform: translate3d(0, 24px, 0); }

/* closable: false — крестика нет, место под него справа не держим */
.notify.notify--no-close { padding-right: 14px; }

/* === Предложение установить приложение (static/js/site-install.js) ===
   Одна строка, как баннер приложения в Safari: иконка, название с подписью,
   кнопка. Без крестика — закрывают смахиванием. Иконка — сама иконка
   приложения скруглённым квадратом, как на экране «Домой». Заголовок белый:
   это предложение, а не тип события (двойной класс перебивает цвета типов
   ниже по файлу). */
.notify.notify--install {
    grid-template-columns: auto minmax(0, 1fr);
    grid-gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 18px;
}
.notify.notify--install .notify__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: none;
    overflow: hidden;
    box-shadow: 0 3px 12px rgba(82, 79, 255, .3);
}
.notify.notify--install .notify__icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* align-items: start — подпись сразу под заголовком. С center строка с
   кнопкой (кнопка выше строки текста) опускала подпись к своей середине,
   и заголовок отрывался вверх */
.notify.notify--install .notify__content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    align-items: start;
}
/* Заголовок — на всю ширину («Приложение Вайфукардс» рядом с кнопкой
   переносился), под ним подпись и кнопка справа от неё */
.notify.notify--install .notify__title { grid-column: 1 / -1; margin-bottom: 2px; font-size: 14.5px; color: var(--ink-on-dark); }
.notify.notify--install .notify__body { grid-column: 1; grid-row: 2; font-size: 12px; line-height: 1.3; color: rgba(255, 255, 255, 0.62); }
.notify.notify--install .notify__actions { grid-column: 2; grid-row: 2; align-self: center; margin-top: 0; flex-wrap: nowrap; }
/* Заголовок помещается рядом с кнопкой — кнопка по центру всего текста,
   как у баннера приложения в Safari. Раскладку выбирает site-install.js по
   ширине заголовка: длинный (по-русски на узком телефоне) остаётся сверху */
.notify.notify--install-inline .notify__title { grid-column: 1; }
.notify.notify--install-inline .notify__actions { grid-row: 1 / span 2; }
.notify.notify--install .notify__action { white-space: nowrap; }
.notify.notify--install .notify__action--brand { padding: 7px 12px; font-size: 12.5px; }

/* === Type colors === */
.notify--success .notify__icon { background: linear-gradient(135deg, var(--ok), #2a9d4c); }
.notify--success .notify__title { color: var(--ok); }

.notify--warning .notify__icon { background: linear-gradient(135deg, #FF8832, #c96a1a); }
.notify--warning .notify__title { color: #FF8832; }

.notify--error   .notify__icon { background: linear-gradient(135deg, #DF5A5A, #b03434); }
.notify--error   .notify__title { color: #DF5A5A; }

.notify--info    .notify__icon { background: linear-gradient(135deg, #5A9DDF, #2a6a9a); }
.notify--info    .notify__title { color: #5A9DDF; }

.notify--achievement .notify__icon {
    background: linear-gradient(135deg, #ffd60a, var(--warn-vivid));
    color: #1a1100;
    box-shadow: 0 0 16px rgba(255, 214, 10, 0.5);
}
.notify--achievement .notify__title {
    color: #ffd60a;
    text-shadow: 0 0 12px rgba(255, 214, 10, 0.3);
}

.notify--levelup .notify__icon {
    background: linear-gradient(135deg, #b794f6, #7c3aed);
    color: var(--ink-on-dark);
    box-shadow: 0 0 16px rgba(167, 139, 250, 0.5);
}
.notify--levelup .notify__title { color: #c4b5fd; }

/* === Pompous style (большое появление) === */
.notify--pompous {
    transform: scale(0.5);
    transform-origin: center;
    border-width: 1.5px;
    padding: 18px 44px 18px 16px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6),
                0 0 40px rgba(255, 214, 10, 0.2);
}
.notify--pompous.notify--in {
    animation: pompousIn 0.65s cubic-bezier(0.34, 1.6, 0.64, 1) forwards;
}
.notify--pompous.notify--out {
    animation: pompousOut 0.4s ease-in forwards;
}
@keyframes pompousIn {
    0%   { transform: scale(0.45) rotate(-2deg); opacity: 0; }
    55%  { transform: scale(1.08) rotate(0.5deg); opacity: 1; }
    80%  { transform: scale(0.98) rotate(0); }
    100% { transform: scale(1)    rotate(0); opacity: 1; }
}
@keyframes pompousOut {
    0%   { transform: scale(1);    opacity: 1; }
    100% { transform: scale(0.88); opacity: 0; }
}
.notify--pompous .notify__title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
}
.notify--pompous .notify__body {
    font-size: 13px;
}
.notify--pompous .notify__icon { width: 44px; height: 44px; font-size: 22px; }
.notify--pompous .notify__icon-emoji { font-size: 26px; }

.notify--pompous.notify--achievement,
.notify--pompous.notify--levelup {
    border-color: rgba(255, 214, 10, 0.45);
    background: linear-gradient(135deg, rgba(40, 30, 10, 0.96), rgba(30, 31, 33, 0.96));
}
.notify--pompous.notify--levelup {
    border-color: rgba(167, 139, 250, 0.45);
    background: linear-gradient(135deg, rgba(40, 30, 60, 0.96), rgba(30, 31, 33, 0.96));
}

/* === Typewriter cursor === */
.notify__title.typing::after,
.notify__body.typing::after {
    content: '▌';
    display: inline-block;
    margin-left: 2px;
    color: currentColor;
    opacity: 0.7;
    animation: typewriterCursor 0.7s infinite;
}
@keyframes typewriterCursor {
    50% { opacity: 0; }
}

/* === Sparkles (для pompous) === */
.notify__sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: inherit;
}
.notify__sparkle {
    position: absolute;
    width: 4px; height: 4px;
    background: #ffd60a;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffd60a, 0 0 20px rgba(255, 214, 10, 0.6);
    opacity: 0;
    animation: sparkle 2.2s ease-in-out infinite;
}
.notify--levelup .notify__sparkle { background: #c4b5fd; box-shadow: 0 0 10px #b794f6, 0 0 20px rgba(167, 139, 250, 0.6); }
.notify__sparkle:nth-child(1) { top: 18%; left:  8%; animation-delay: 0.0s; }
.notify__sparkle:nth-child(2) { top: 62%; left: 82%; animation-delay: 0.3s; }
.notify__sparkle:nth-child(3) { top: 32%; left: 68%; animation-delay: 0.6s; }
.notify__sparkle:nth-child(4) { top: 78%; left: 22%; animation-delay: 0.9s; }
.notify__sparkle:nth-child(5) { top: 48%; left: 92%; animation-delay: 1.2s; }
.notify__sparkle:nth-child(6) { top: 8%;  left: 50%; animation-delay: 1.5s; }
@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0.4); }
    40%, 60% { opacity: 1; transform: scale(1.4); }
}

/* === Прогресс-полоска жизни уведомления (опционально) === */
.notify__progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 14px;
    overflow: hidden;
}
.notify__progress-bar {
    height: 100%;
    background: currentColor;
    width: 100%;
    transform-origin: left;
    animation: notifyProgress linear forwards;
    opacity: 0.7;
}
@keyframes notifyProgress {
    to { transform: scaleX(0); }
}

/* === Light theme support === */
@media (prefers-color-scheme: light) {
    /* Опционально, если страница в light-теме */
}

/* Модификаторы компактного тоста идут после базовых .notify:
   специфичность одинаковая, решает порядок. */
.notify--toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 999px;
    grid-template-columns: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .38);
    /* Выезжает снизу, а не сбоку: он и живёт внизу */
    transform: translate3d(0, 14px, 0);
    white-space: nowrap;
    max-width: 100%;
}
.notify--toast.notify--in { transform: translate3d(0, 0, 0); }
.notify--toast.notify--out { transform: translate3d(0, 8px, 0); }
@media (max-width: 540px) {
    .notify--toast { transform: translate3d(0, 14px, 0); }
    .notify--toast.notify--out { transform: translate3d(0, 8px, 0); }
}

.notify--toast .notify__icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 0;
    background: none;
    box-shadow: none;
    font-size: 15px;
    line-height: 18px;
}
.notify--toast .notify__icon img,
.notify--toast .notify__icon svg { width: 18px; height: 18px; }

.notify--toast .notify__content { min-width: 0; }
/* Текст всегда обычного цвета. Цветной заголовок уместен в большой карточке,
   где он один из нескольких элементов, — а в пилюле шириной в строку красится
   вся надпись целиком и читается как подсветка ошибки. Тип показывает иконка. */
.notify--toast .notify__title {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.35;
    color: var(--ink-on-dark);
    overflow: hidden;
    text-overflow: ellipsis;
}
.notify--toast .notify__body {
    font-size: 12.5px;
    line-height: 1.35;
    opacity: .6;
}
.notify--toast .notify__body:empty { display: none; }
