/* =============================================================================
   toast.css
   In-page notification toasts (Toast.success / Toast.error / Toast.flash …).
   Loaded on every page from fragments/head.jsp so any page can fire a toast
   without bringing in extra assets.

   Anatomy of a toast
   ──────────────────
       ┌────┬──────────────────────────────────┬─────┐
       │    │  Title                           │  ✕  │
       │ ⓘ  │  Optional secondary message      │     │
       │    │                                  │     │
       └────┴──────────────────────────────────┴─────┘
       └─ left accent stripe (per-type gradient)
                                                   └─ progress bar (auto-dismiss)

   Notes
   -----
   • Top-right anchor on LTR, top-left on RTL — flipped via [dir="rtl"].
   • Backdrop-blur card with type-specific accents (success/error/warning/info).
   • Pause-on-hover: Toast.js toggles a `.lingo-toast--paused` class which
     freezes the progress bar while the user reads the toast.
   • Honours `prefers-reduced-motion`: drops the slide animation but keeps a
     soft opacity fade.
   ========================================================================== */

:root {
    --lingo-toast-bg:        rgba(255, 255, 255, 0.96);
    --lingo-toast-fg:        #0f1720;
    --lingo-toast-fg-muted:  rgba(15, 23, 32, 0.65);
    --lingo-toast-border:    rgba(15, 23, 32, 0.06);
    --lingo-toast-shadow:
        0 22px 50px -14px rgba(15, 23, 32, 0.22),
        0 4px 12px rgba(15, 23, 32, 0.08);
    --lingo-toast-close-hover: rgba(15, 23, 32, 0.06);
}

[data-theme="dark"] {
    --lingo-toast-bg:        rgba(26, 37, 50, 0.96);
    --lingo-toast-fg:        #e8eef3;
    --lingo-toast-fg-muted:  rgba(232, 238, 243, 0.65);
    --lingo-toast-border:    rgba(255, 255, 255, 0.06);
    --lingo-toast-shadow:
        0 22px 50px -10px rgba(0, 0, 0, 0.55),
        0 4px 12px rgba(0, 0, 0, 0.35);
    --lingo-toast-close-hover: rgba(255, 255, 255, 0.08);
}

/* ---------- Stack container ------------------------------------------- */

.lingo-toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    pointer-events: none;
    width: min(380px, calc(100vw - 2.5rem));
}

[dir="rtl"] .lingo-toast-stack {
    right: auto;
    left: 1.25rem;
}

@media (max-width: 480px) {
    .lingo-toast-stack {
        top: 0.6rem;
        right: 0.6rem;
        left: 0.6rem;
        width: auto;
    }
    [dir="rtl"] .lingo-toast-stack {
        right: 0.6rem;
        left: 0.6rem;
    }
}

/* ---------- Toast card ------------------------------------------------ */

.lingo-toast {
    position: relative;
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.85rem 0.95rem 0.95rem 1.45rem;
    border-radius: 14px;
    background: var(--lingo-toast-bg);
    color: var(--lingo-toast-fg);
    border: 1px solid var(--lingo-toast-border);
    box-shadow: var(--lingo-toast-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    transform: translateX(120%) scale(0.96);
    opacity: 0;
    transition:
        transform 320ms cubic-bezier(0.18, 0.89, 0.32, 1.28),
        opacity 240ms ease,
        margin 220ms ease;
    will-change: transform, opacity;
}

[dir="rtl"] .lingo-toast {
    padding-left: 0.95rem;
    padding-right: 1.45rem;
    transform: translateX(-120%) scale(0.96);
}

.lingo-toast.is-visible {
    transform: translateX(0) scale(1);
    opacity: 1;
}

.lingo-toast.is-leaving {
    transform: translateX(120%) scale(0.96);
    opacity: 0;
    transition: transform 200ms ease-in, opacity 180ms ease-in;
}

[dir="rtl"] .lingo-toast.is-leaving {
    transform: translateX(-120%) scale(0.96);
}

/* Left accent stripe — colored per-type via --lingo-toast-accent. */
.lingo-toast::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    background: var(--lingo-toast-accent);
}

[dir="rtl"] .lingo-toast::before {
    left: auto;
    right: 0;
}

/* ---------- Type variants -------------------------------------------- */

.lingo-toast--success {
    --lingo-toast-accent:   linear-gradient(180deg, #4ec07a 0%, #2f9d5d 100%);
    --lingo-toast-icon-bg:  linear-gradient(135deg, #4ec07a 0%, #2f9d5d 100%);
    --lingo-toast-icon-glow: rgba(47, 157, 93, 0.35);
}

.lingo-toast--error {
    --lingo-toast-accent:   linear-gradient(180deg, #ef6b6b 0%, #c84b4b 100%);
    --lingo-toast-icon-bg:  linear-gradient(135deg, #ef6b6b 0%, #c84b4b 100%);
    --lingo-toast-icon-glow: rgba(200, 75, 75, 0.35);
}

.lingo-toast--warning {
    --lingo-toast-accent:   linear-gradient(180deg, #f5a623 0%, #d97706 100%);
    --lingo-toast-icon-bg:  linear-gradient(135deg, #f5a623 0%, #d97706 100%);
    --lingo-toast-icon-glow: rgba(217, 119, 6, 0.35);
}

.lingo-toast--info {
    --lingo-toast-accent:   linear-gradient(180deg, #204d48 0%, #2a6a63 100%);
    --lingo-toast-icon-bg:  linear-gradient(135deg, #204d48 0%, #2a6a63 100%);
    --lingo-toast-icon-glow: rgba(32, 77, 72, 0.35);
}

[data-theme="dark"] .lingo-toast--info {
    --lingo-toast-accent:   linear-gradient(180deg, #3d9b94 0%, #5fbfb4 100%);
    --lingo-toast-icon-bg:  linear-gradient(135deg, #3d9b94 0%, #5fbfb4 100%);
    --lingo-toast-icon-glow: rgba(95, 191, 180, 0.35);
}

/* ---------- Inner pieces --------------------------------------------- */

.lingo-toast__icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--lingo-toast-icon-bg);
    color: #ffffff;
    font-size: 1rem;
    box-shadow: 0 6px 16px -4px var(--lingo-toast-icon-glow);
}

/* Subtle pop on enter so the icon has a tiny celebratory bounce. */
.lingo-toast.is-visible .lingo-toast__icon {
    animation: lingoToastIconPop 360ms cubic-bezier(0.18, 0.89, 0.32, 1.6);
}

@keyframes lingoToastIconPop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.lingo-toast__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-top: 0.18rem;
}

.lingo-toast__title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.35;
    word-wrap: break-word;
}

.lingo-toast__message {
    font-size: 0.85rem;
    color: var(--lingo-toast-fg-muted);
    line-height: 1.5;
    word-wrap: break-word;
}

.lingo-toast__close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin: -0.2rem -0.3rem -0.2rem 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--lingo-toast-fg-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-size: 0.85rem;
}

[dir="rtl"] .lingo-toast__close {
    margin: -0.2rem 0 -0.2rem -0.3rem;
}

.lingo-toast__close:hover,
.lingo-toast__close:focus-visible {
    background: var(--lingo-toast-close-hover);
    color: var(--lingo-toast-fg);
    outline: none;
}

.lingo-toast__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--lingo-toast-accent);
    transform-origin: left center;
    transform: scaleX(1);
    opacity: 0.7;
}

[dir="rtl"] .lingo-toast__progress {
    transform-origin: right center;
}

/* ---------- Reduced-motion friendly fallback ------------------------- */

@media (prefers-reduced-motion: reduce) {
    .lingo-toast {
        transition: opacity 0.18s ease;
        transform: none !important;
    }
    .lingo-toast.is-leaving {
        transform: none !important;
    }
    .lingo-toast.is-visible .lingo-toast__icon {
        animation: none;
    }
    .lingo-toast__progress {
        transition: none;
    }
}
