/**
 * ═══════════════════════════════════════════════════════════════════════════
 * GILGAMEZ ACCOUNTS — SONNER-STYLE STACKED TOAST DECK (CSS)
 * ═══════════════════════════════════════════════════════════════════════════
 * Pure Vanilla CSS implementation of Emil Kowalski's Sonner Notification Stack.
 * Physics: spring curve cubic-bezier(0.16, 1, 0.3, 1), 3D collapsed card deck,
 * height-aware spring expansion on hover/focus, swipe gestures, and responsive
 * bottom-sheet adaptation across all 4 viewports (360, 768, 1280, 1920 px).
 *
 * Strictly adheres to DEVELOPMENT_RULES.md (Rule #1, Rule #2, Rule #8, Rule #11).
 * ═══════════════════════════════════════════════════════════════════════════
 */

:root {
    --acc-toast-width: 380px;
    --acc-toast-gap: 12px;
    --acc-toast-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --acc-toast-bg: rgba(13, 18, 28, 0.96);
    --acc-toast-border: rgba(255, 255, 255, 0.1);
    --acc-toast-radius: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   1. TOAST CONTAINER (STACK HOST)
   ───────────────────────────────────────────────────────────────────────────── */
.acc-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: var(--acc-toast-width);
    max-width: calc(100vw - 48px);
    height: var(--front-height, 56px);
    z-index: 999999;
    pointer-events: none;
    box-sizing: border-box;
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
    outline: none;
    transition: height 0.35s var(--acc-toast-ease);
}

.acc-toast-container[data-expanded="true"] {
    height: var(--expanded-height, auto);
}

/* Hover & Focus Expand */
.acc-toast-container:hover,
.acc-toast-container:focus-within {
    height: var(--expanded-height, auto);
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. STACKED TOAST CARD
   ───────────────────────────────────────────────────────────────────────────── */
.acc-toast {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    box-sizing: border-box;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--acc-toast-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--acc-toast-border);
    border-radius: var(--acc-toast-radius);
    color: #f8fafc;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                0 4px 12px -2px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
    cursor: default;
    overflow: hidden;

    /* Stacking Physics */
    z-index: calc(50 - var(--index, 0));
    transform: translateY(calc(var(--index, 0) * -12px)) scale(calc(1 - (var(--index, 0) * 0.05)));
    transform-origin: bottom center;
    opacity: calc(1 - (var(--index, 0) * 0.16));
    transition: transform 0.35s var(--acc-toast-ease),
                opacity 0.25s ease,
                height 0.35s var(--acc-toast-ease),
                box-shadow 0.25s ease,
                border-color 0.2s ease;
}

/* Deep stack visibility clipping (Cards beyond depth 2 hidden in collapsed mode) */
.acc-toast[data-index="3"],
.acc-toast[data-index="4"],
.acc-toast[data-index="5"],
.acc-toast[data-index="6"] {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-36px) scale(0.85);
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. EXPANDED STACK PHYSICS (HOVER / FOCUS / data-expanded)
   ───────────────────────────────────────────────────────────────────────────── */
.acc-toast-container:hover .acc-toast,
.acc-toast-container:focus-within .acc-toast,
.acc-toast-container[data-expanded="true"] .acc-toast {
    transform: translateY(calc(var(--offset, 0px) * -1)) scale(1);
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.65),
                0 4px 12px -2px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Limit visible items in expanded list to 5 */
.acc-toast-container:hover .acc-toast[data-index="5"],
.acc-toast-container:hover .acc-toast[data-index="6"],
.acc-toast-container[data-expanded="true"] .acc-toast[data-index="5"],
.acc-toast-container[data-expanded="true"] .acc-toast[data-index="6"] {
    opacity: 0;
    pointer-events: none;
}

/* Front card accent when hovered directly */
.acc-toast:hover {
    border-color: rgba(255, 255, 255, 0.22);
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. TOAST TYPES & STATUS THEMES
   ───────────────────────────────────────────────────────────────────────────── */
.acc-toast[data-type="success"] {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                0 0 15px -3px rgba(16, 185, 129, 0.15),
                inset 0 1px 0 rgba(16, 185, 129, 0.2);
}

.acc-toast[data-type="error"] {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                0 0 15px -3px rgba(239, 68, 68, 0.18),
                inset 0 1px 0 rgba(239, 68, 68, 0.2);
}

.acc-toast[data-type="warning"] {
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                0 0 15px -3px rgba(245, 158, 11, 0.18),
                inset 0 1px 0 rgba(245, 158, 11, 0.2);
}

.acc-toast[data-type="info"] {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                0 0 15px -3px rgba(56, 189, 248, 0.15),
                inset 0 1px 0 rgba(56, 189, 248, 0.2);
}

.acc-toast[data-type="loading"] {
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. INTERNAL CARD ANATOMY
   ───────────────────────────────────────────────────────────────────────────── */
.acc-toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.acc-toast-icon svg {
    width: 18px;
    height: 18px;
}

.acc-toast-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(148, 163, 184, 0.25);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: accToastSpin 0.75s linear infinite;
}

@keyframes accToastSpin {
    to { transform: rotate(360deg); }
}

.acc-toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.acc-toast-title {
    font-size: 13.5px;
    font-weight: 500;
    color: #f8fafc;
    line-height: 1.4;
    word-break: break-word;
}

.acc-toast-description {
    font-size: 12.5px;
    font-weight: 400;
    color: #94a3b8;
    line-height: 1.4;
    word-break: break-word;
}

/* Action Button */
.acc-toast-action {
    flex-shrink: 0;
    padding: 5px 11px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
    white-space: nowrap;
    align-self: center;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.acc-toast-action:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.28);
}

.acc-toast-action:active {
    transform: scale(0.96);
}

/* Close Button */
.acc-toast-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-left: 2px;
    margin-top: -2px;
    margin-right: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.acc-toast:hover .acc-toast-close,
.acc-toast-container:focus-within .acc-toast-close {
    opacity: 1;
}

.acc-toast-close:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. GESTURES & ANIMATIONS
   ───────────────────────────────────────────────────────────────────────────── */
/* Initial Mount Entrance */
@keyframes accToastMount {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.acc-toast[data-state="mounting"] {
    animation: accToastMount 0.28s var(--acc-toast-ease) forwards;
}

/* Smooth Dismiss Exit */
.acc-toast[data-state="dismissing"] {
    opacity: 0 !important;
    transform: translateY(14px) scale(0.92) !important;
    transition: transform 0.22s var(--acc-toast-ease), opacity 0.2s ease !important;
    pointer-events: none !important;
}

/* Swipe Dismiss Exit */
.acc-toast[data-state="swiping-out"] {
    opacity: 0 !important;
    transform: translateX(110%) !important;
    transition: transform 0.22s ease-out, opacity 0.2s ease-out !important;
    pointer-events: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. RESPONSIVE VIEWPORTS (360px, 768px, 1280px, 1920px)
   ───────────────────────────────────────────────────────────────────────────── */
/* 1920px (4K / Large Desktop) */
@media (min-width: 1920px) {
    :root {
        --acc-toast-width: 410px;
    }
    .acc-toast-container {
        bottom: 28px;
        right: 28px;
    }
}

/* 768px (Tablet) */
@media (max-width: 768px) {
    :root {
        --acc-toast-width: 360px;
    }
    .acc-toast-container {
        bottom: 20px;
        right: 20px;
    }
    .acc-toast-close {
        opacity: 0.8;
    }
}

/* 360px (Mobile Bottom Sheet Deck) */
@media (max-width: 480px) {
    .acc-toast-container {
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: auto;
        max-width: none;
    }
    .acc-toast {
        padding: 12px 14px;
        border-radius: 10px;
    }
    .acc-toast-close {
        opacity: 0.9;
    }
}
