/* Тосты сайта (js/toast.js) - визуальный язык Sileo (MIT, github.com/hiaaryan/sileo):
   тёмная пилюля сверху по центру, бейдж и заголовок цвета состояния, тело с описанием
   вырастает пружиной и сливается с пилюлей SVG-фильтром. Устройство - docs/design/toasts.md. */

:root {
    /* пружина Sileo (bounce 0.25) - те же точки, что SPRING в js/toast.js */
    --rt-spring: linear(0, 0.002 0.6%, 0.007 1.2%, 0.015 1.8%, 0.026 2.4%, 0.041 3.1%, 0.06 3.8%,
        0.108 5.3%, 0.157 6.6%, 0.214 8%, 0.467 13.7%, 0.577 16.3%, 0.631 17.7%, 0.682 19.1%,
        0.73 20.5%, 0.771 21.8%, 0.808 23.1%, 0.844 24.5%, 0.874 25.8%, 0.903 27.2%, 0.928 28.6%,
        0.952 30.1%, 0.972 31.6%, 0.988 33.1%, 1.01 35.7%, 1.025 38.5%, 1.034 41.6%, 1.038 45%,
        1.035 50.1%, 1.012 64.2%, 1.003 73%, 0.999 83.7%, 1);
    --rt-dur: 600ms;
    --rt-h: 40px;
    --rt-fill: #1d1d1f;
}
@supports not (transition-timing-function: linear(0, 1)) {
    :root { --rt-spring: cubic-bezier(.34, 1.36, .64, 1); }
}

.rt-vp {
    position: fixed;
    z-index: 10001;
    top: calc(12px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 12px;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.rt-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Тост ---------- */

.rt-toast {
    /* цвета состояний подобраны под тёмную заливку (системная палитра Apple, тёмный вариант) */
    --rt-tone: #30d158;
    --rt-tone-bg: rgba(48, 209, 88, .2);
    position: relative;
    height: var(--_h, var(--rt-h));
    margin-bottom: calc(-1 * (var(--rt-h) + 12px));
    opacity: 0;
    transform: translateY(-6px) scale(.95);
    pointer-events: auto;
    touch-action: none;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.rt-toast[data-ready="true"] {
    margin-bottom: 0;
    opacity: 1;
    transform: none;
    transition:
        transform calc(var(--rt-dur) * .66) var(--rt-spring),
        opacity calc(var(--rt-dur) * .66) var(--rt-spring),
        margin-bottom calc(var(--rt-dur) * .66) var(--rt-spring),
        height var(--rt-dur) var(--rt-spring),
        translate .2s ease;
}
.rt-toast[data-ready="true"][data-exiting="true"] {
    opacity: 0;
    transform: translateY(-6px) scale(.95);
    pointer-events: none;
}

.rt-inner[data-state="error"], .rt-toast[data-state="error"] { --rt-tone: #ff453a; --rt-tone-bg: rgba(255, 69, 58, .2); }
.rt-inner[data-state="warning"], .rt-toast[data-state="warning"] { --rt-tone: #ffd60a; --rt-tone-bg: rgba(255, 214, 10, .18); }
.rt-inner[data-state="info"], .rt-toast[data-state="info"] { --rt-tone: #9aa6ff; --rt-tone-bg: rgba(154, 166, 255, .2); }
.rt-inner[data-state="action"], .rt-toast[data-state="action"] { --rt-tone: #9aa6ff; --rt-tone-bg: rgba(154, 166, 255, .2); }
.rt-inner[data-state="loading"], .rt-toast[data-state="loading"] { --rt-tone: #aeaeb2; --rt-tone-bg: rgba(174, 174, 178, .16); }
.rt-inner[data-state="success"] { --rt-tone: #30d158; --rt-tone-bg: rgba(48, 209, 88, .2); }

/* ---------- Фигура: пилюля + тело под одним gooey-фильтром ---------- */

.rt-canvas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .16)) drop-shadow(0 2px 5px rgba(0, 0, 0, .1));
}
.rt-svg { display: block; overflow: visible; }
.rt-pill, .rt-body { fill: var(--rt-fill); }

/* ---------- Шапка: бейдж + заголовок, смена содержимого с размытием ---------- */

.rt-header {
    position: absolute;
    top: 0;
    z-index: 2;
    left: var(--_px, 0px);
    max-width: var(--_pw);
    height: var(--rt-h);
    padding: 0 8px;
    display: flex;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
}
.rt-toast[data-ready="true"] .rt-header {
    transition: left var(--rt-dur) var(--rt-spring), max-width var(--rt-dur) var(--rt-spring),
        transform var(--rt-dur) var(--rt-spring);
}
.rt-toast[data-open="true"] .rt-header { transform: translateY(3px) scale(.9); }

.rt-stack {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
}
.rt-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.rt-inner[data-layer="current"] {
    position: relative;
    z-index: 1;
    animation: rt-enter var(--rt-dur) var(--rt-spring) both;
}
.rt-inner[data-layer="prev"] {
    position: absolute;
    left: 0;
    top: 50%;
    margin-top: -12px;
    pointer-events: none;
    animation: rt-exit calc(var(--rt-dur) * .7) ease forwards;
}
.rt-probe {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    top: 0;
    left: 0;
}

.rt-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    color: var(--rt-tone);
    background: var(--rt-tone-bg);
}
.rt-badge svg { width: 15px; height: 15px; display: block; }

.rt-title {
    font-size: 14px;
    line-height: 16px;
    font-weight: 500;
    letter-spacing: -.005em;
    color: var(--rt-tone);
}

/* ---------- Тело с описанием ---------- */

.rt-content {
    position: absolute;
    z-index: 1;
    top: var(--rt-h);
    left: 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
}
.rt-toast[data-ready="true"] .rt-content { transition: opacity calc(var(--rt-dur) * .08) ease; }
.rt-toast[data-open="true"] .rt-content {
    opacity: 1;
    transition: opacity calc(var(--rt-dur) * .6) ease calc(var(--rt-dur) * .3);
}
.rt-desc {
    padding: 10px 16px 14px;
    font-size: 14px;
    line-height: 20px;
    color: rgba(255, 255, 255, .72);
    text-align: left;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

/* ---------- Анимации ---------- */

.rt-spin { animation: rt-spin 1s linear infinite; }
.rt-bump { animation: rt-bump .36s var(--rt-spring); }

@keyframes rt-spin { to { transform: rotate(360deg); } }
@keyframes rt-enter { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: blur(0); } }
@keyframes rt-exit { from { opacity: 1; filter: blur(0); } to { opacity: 0; filter: blur(6px); } }
@keyframes rt-bump { 0% { scale: 1; } 40% { scale: 1.04; } 100% { scale: 1; } }

@media (prefers-reduced-motion: reduce) {
    .rt-vp *, .rt-vp *::before, .rt-vp *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
    .rt-spin { animation: rt-spin 1.6s linear infinite !important; }
}
