/**
 * Hello Middleton - Toast Notifications
 * Gamification nudges for trust point events
 *
 * @requires tokens.css
 * @version 1.0.0
 */

/* ==========================================================================
   TOAST CONTAINER - Fixed bottom-right stack
   ========================================================================== */

.hm-toast-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: var(--z-toast, 800);
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - 40px);
}

/* ==========================================================================
   INDIVIDUAL TOAST
   ========================================================================== */

.hm-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--hm-bg-elevated);
    border: 1px solid var(--hm-border);
    border-left: 4px solid var(--hm-primary, var(--hm-primary));
    border-radius: var(--radius-md);
    box-shadow:
        0 4px 12px rgba(28, 25, 23, 0.08),
        0 8px 24px rgba(28, 25, 23, 0.06),
        0 16px 48px rgba(28, 25, 23, 0.04);

    /* Entry animation */
    opacity: 0;
    transform: translateX(100%) scale(0.95);
    animation: hm-toast-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Closing state */
.hm-toast--closing {
    animation: hm-toast-out 0.3s ease-in forwards;
}

/* ==========================================================================
   TOAST ICON - Gold star burst
   ========================================================================== */

.hm-toast-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--hm-primary-100), var(--hm-primary-200));
    border-radius: 10px;
    font-size: 1.25rem;
    line-height: 1;
    animation: hm-toast-icon-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

.hm-toast-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--hm-primary, var(--hm-primary));
}

/* ==========================================================================
   TOAST CONTENT
   ========================================================================== */

.hm-toast-body {
    flex: 1;
    min-width: 0;
}

.hm-toast-points {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--hm-primary, var(--hm-primary));
    line-height: 1.3;
}

.hm-toast-reason {
    display: block;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--hm-text-muted);
    line-height: 1.4;
    margin-top: 2px;
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */

.hm-toast-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: -4px -4px -4px 0;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--hm-text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.hm-toast-close:hover {
    opacity: 1;
    background: var(--hm-bg-subtle);
}

.hm-toast-close svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   PROGRESS BAR - Auto-dismiss countdown
   ========================================================================== */

.hm-toast-progress {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 0;
    height: 3px;
    background: var(--hm-primary-muted);
    border-radius: 0 0 12px 0;
    overflow: hidden;
}

.hm-toast-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--hm-primary, var(--hm-primary)), var(--hm-primary-400));
    border-radius: inherit;
    animation: hm-toast-countdown 5s linear forwards;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes hm-toast-in {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes hm-toast-out {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(100%) scale(0.95);
    }
}

@keyframes hm-toast-icon-pop {
    0% {
        transform: scale(0.5) rotate(-15deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.15) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes hm-toast-countdown {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Mobile - full width at bottom */
@media (max-width: 479px) {
    .hm-toast-stack {
        bottom: 74px; /* Above mobile nav bar */
        right: 10px;
        left: 10px;
        max-width: none;
        width: auto;
    }

    .hm-toast {
        border-radius: 10px;
    }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .hm-toast {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .hm-toast--closing {
        animation: none;
        display: none;
    }

    .hm-toast-icon {
        animation: none;
    }

    .hm-toast-progress-bar {
        animation: none;
        width: 100%;
    }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {
    .hm-toast-stack {
        display: none;
    }
}
