/* Toasts (utils.js ToastManager). Its own file so pages that do not load
   base.css (onboarding) still style them. */

/* ===== TOAST NOTIFICATION SYSTEM ===== */
/* Responsive toast notifications - center-top on mobile, top-right on desktop */

.toast-container {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 8px;

    /* Promoted to the top layer via popover="manual" so toasts out-stack modal
       dialogs. Strip the UA [popover] chrome (border/padding/background, auto
       centering, fit-content sizing) so it stays a transparent layout host. */
    bottom: auto;
    width: auto;
    height: auto;
    margin: 0;
    border: 0;
    padding: 0;
    background: transparent;
    overflow: visible;

    /* Desktop: top-right, 10% from top */
    top: 10%;
    right: 22%;
    left: auto;
    align-items: flex-end;
    max-width: 400px;
}

/* Mobile: full width, just under the 54px top bar, so a toast never
   straddles the header or hides the bell */
@media (max-width: 768px), (pointer: coarse) {
    .toast-container {
        top: calc(var(--safe-area-inset-top, env(safe-area-inset-top, 0px)) + 62px);
        left: calc(16px + env(safe-area-inset-left, 0px));
        right: calc(16px + env(safe-area-inset-right, 0px));
        align-items: stretch;
        max-width: none;
    }
}

/* Toasts that carry an action (Undo) sit at the bottom: on a phone the top
   one covers the bar and the first menu row, the next thing a thumb reaches
   for, and a tap there would take the action by accident. */
.toast-container.toast-container-bottom {
    top: auto;
    bottom: 10%;
}

@media (max-width: 768px), (pointer: coarse) {
    .toast-container.toast-container-bottom {
        top: auto;
        bottom: calc(var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)) + 16px);
    }
}

.toast-container-bottom .toast:not(.toast-visible):not(.toast-hiding) {
    transform: translateY(20px);
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 100%;
    word-break: break-word;
    box-shadow: 0 4px 20px var(--shadow-strong);
    /* A card. The bracket corners it used to carry are for hero panels. */
    border-radius: var(--radius-md);
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-hiding {
    opacity: 0;
    transform: translateY(-10px);
}

.toast-icon .aq-icon {
    width: 14px;
    height: 14px;
    /* Restated from base.css .aq-icon for pages that load only this file */
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

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

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: var(--text-color);
}

/* Toast type variants */
.toast-error {
    border-color: var(--error-color);
    background: linear-gradient(rgba(var(--error-rgb), 0.1), rgba(var(--error-rgb), 0.1)), var(--bg-elevated);
}

.toast-error .toast-icon {
    color: var(--error-color);
}

.toast-success {
    border-color: var(--dice-success);
    background: linear-gradient(var(--dice-success-dim), var(--dice-success-dim)), var(--bg-elevated);
}

.toast-success .toast-icon {
    color: var(--dice-success);
}

.toast-warning {
    border-color: var(--warning-color);
    background: linear-gradient(rgba(var(--warn-orange-rgb), 0.1), rgba(var(--warn-orange-rgb), 0.1)), var(--bg-elevated);
}

.toast-warning .toast-icon {
    color: var(--warning-color);
}

.toast-info {
    border-color: var(--accent-color);
    background: linear-gradient(var(--accent-subtle), var(--accent-subtle)), var(--bg-elevated);
}

.toast-info .toast-icon {
    color: var(--accent-color);
}

/* Mobile touch target for close button; a phone held sideways is wider
   than 768px but still a phone */
@media (max-width: 768px), (pointer: coarse) {
    .toast {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .toast-close {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        margin: -10px -8px -10px 0;
    }
}
