/* =====================================================================
 * Toast — bottom-center slide-up, studio language
 * ---------------------------------------------------------------------
 * 별도 파일로 분리한 이유: studio main 페이지(main.modal.css 로드)와
 * studio editor 페이지(editor.css 로드)는 서로 다른 CSS 번들을 사용한다.
 * 토스트 알림은 두 페이지 모두에서 필수이므로 양쪽 모두 이 파일을
 * 추가로 link 한다 (studio/index.ejs 참고).
 *
 * 변경 시 주의: editor.js / main.js 가 동일한 `#toast-container`
 * 마크업과 `.toast`, `.toast-show`, `.toast-hide` 클래스 시퀀스를
 * 사용하므로 이름을 바꾸려면 양쪽 JS도 함께 손봐야 한다.
 * ===================================================================== */
#toast-container {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    /* SSHOW core(edit mode) overlays use z-index:10000. Toasts are
       a system-level alert layer that MUST sit above any in-canvas
       UI, so we live in a dedicated higher band. */
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    /* 너무 긴 메시지가 ...으로 잘리지 않도록 넉넉한 폭을 준다.
     * 작은 화면에선 92vw로 폴백 */
    max-width: min(92vw, 640px);
    padding: 0 8px;
}

.toast {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 10px 18px 10px 16px;
    background: var(--global-card-background, #fff);
    border: 1px solid var(--studio-hairline, rgba(var(--global-text-color-rgb), 0.08));
    /* 길어지면 자연스럽게 두 줄 이상으로 넘어가도록 캡슐 대신
     * 더 큰 rounded-rect 모양을 사용하고 줄바꿈을 허용한다. */
    border-radius: 16px;
    /* DESIGN.md §6.2 — shadows use iris brand tint, not plain black.
       Layer 1: hairline crispness via text-rgb twin (theme-aware).
       Layer 2 & 3: ambient lift via iris alpha. */
    box-shadow:
        0 1px 2px rgba(var(--global-text-color-rgb), 0.04),
        0 16px 40px rgba(var(--brand-iris-rgb), 0.14),
        0 8px 20px rgba(var(--global-text-color-rgb), 0.04);
    pointer-events: auto;
    transform: translateY(14px) scale(0.96);
    opacity: 0;
    transition: transform 280ms var(--studio-ease, cubic-bezier(0.22, 0.61, 0.36, 1)),
                opacity 220ms var(--studio-ease, cubic-bezier(0.22, 0.61, 0.36, 1));
    max-width: 100%;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.toast-show { transform: translateY(0) scale(1); opacity: 1; }
.toast-hide { transform: translateY(14px) scale(0.96); opacity: 0; }

.toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.toast-icon svg { width: 100%; height: 100%; }
.toast-success .toast-icon { color: var(--global-success-color); }
.toast-error .toast-icon { color: var(--global-error-color); }
/* Warning toasts: amber/cognac to fit DI's "needs attention but not
   destructive" categorical slot — used e.g. for "invitation created
   but email failed to send". */
.toast-warning .toast-icon { color: rgb(var(--brand-cognac-rgb, 252, 146, 84)); }

.toast-message {
    font-family: var(--studio-font-body, 'Pretendard Variable'), sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.005em;
    color: var(--global-text-color);
    line-height: 1.4;
    max-width: 100%;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

@media (max-width: 520px) {
    .toast {
        border-radius: 14px;
        padding: 10px 14px;
        min-height: 44px;
    }
}

@media (prefers-color-scheme: dark) {
    .toast {
        background: var(--studio-project-background, #2a2a2c);
        border-color: var(--studio-hairline-strong, rgba(255, 255, 255, 0.1));
        /* Dark mode still uses iris tint for the ambient lift; the
           hairline + bottom shadow lean on text-rgb (which is light
           in dark mode) so the toast sits cleanly on dark surfaces. */
        box-shadow:
            0 1px 2px rgba(0, 0, 0, 0.4),
            0 16px 40px rgba(var(--brand-iris-rgb), 0.40);
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast { transition: opacity 220ms ease; transform: none; }
    .toast-show, .toast-hide { transform: none; }
}
