/* toast-themes.css — แจ้งเตือนมุมจอ (toast() ใน api.js) แยกหน้าตาตามเทมเพลต ซ้อนได้สูงสุด 3 อัน
 * แบบ 1 = แคปซูลกระจกลงจากบนกลาง, แบบ 2 = การ์ดเหลี่ยมตัดมุมสไลด์จากขวาบน, แบบ 3 = แถบลอยเหนือเมนูล่างเด้งขึ้น
 * สีมาจากตัวแปรธีม --tm-* (data.js / template3.js) ถ้าไม่มีใช้ --runtime-* */

.tn-stack {
  position: fixed; z-index: 2147483602;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
  left: 50%; transform: translateX(-50%);
  width: min(92vw, 460px);
  align-items: center;
}
.tn-stack--top { top: calc(14px + env(safe-area-inset-top, 0px)); }
.tn-stack--top-end { top: calc(14px + env(safe-area-inset-top, 0px)); left: auto; right: 14px; transform: none; width: min(88vw, 360px); align-items: stretch; }
.tn-stack--bottom { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); flex-direction: column-reverse; width: min(92vw, 420px); align-items: stretch; }

.tn-toast {
  --n-acc: var(--tm-accent-rgb, var(--runtime-primary-rgb, 0,220,255));
  --n-acc2: var(--tm-accent2-rgb, var(--runtime-accent-rgb, 255,214,107));
  --n-text: var(--tm-accent-text-rgb, var(--n-acc));
  --n-ink: var(--tm-accent-ink-rgb, 16,12,4);
  --n-surf: var(--tm-surface-rgb, 14,22,38);
  --n-deep: var(--tm-deep-rgb, 6,10,20);
  --k: var(--n-acc);
  --k-ink: var(--n-ink);
  --k-text: var(--n-text);
  position: relative; overflow: hidden;
  pointer-events: auto; cursor: pointer;
  color: #f4f6fb;
  font-family: inherit;
  box-sizing: border-box;
}
.tn-toast.tn-error { --k: 255,92,112; --k-ink: 255,255,255; --k-text: 255,140,154; }
.tn-toast.tn-warning { --k: 255,186,72; --k-ink: 40,24,0; --k-text: 255,200,110; }

.tn-body { display: flex; align-items: center; gap: 12px; }
.tn-ico {
  flex: none; display: grid; place-items: center;
  width: 34px; height: 34px; font-size: 15px;
  color: rgb(var(--k-ink));
  background: rgb(var(--k));
}
html body .tn-ico i { color: rgb(var(--k-ink)) !important; }
.tn-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; text-align: left; }
.tn-label { font-size: 11px; font-weight: 700; letter-spacing: .3px; color: rgb(var(--k-text)); }
.tn-msg { font-size: 14px; font-weight: 700; line-height: 1.4; color: #f4f6fb; word-break: break-word; }
.tn-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; overflow: hidden; }
.tn-bar i { display: block; height: 100%; background: linear-gradient(90deg, rgb(var(--k)), rgb(var(--n-acc2))); transform-origin: left; animation: tnBar linear forwards; }
.tn-paused .tn-bar i { animation-play-state: paused; }
@keyframes tnBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- แบบ 1: แคปซูลกระจก ลงจากบนกลาง ---------- */
.tn-t1 {
  max-width: 100%;
  border-radius: 999px;
  padding: 8px 22px 8px 8px;
  background:
    linear-gradient(100deg, rgba(var(--k), .22), rgba(var(--n-surf), 0) 55%),
    rgba(var(--n-surf), .88);
  border: 1px solid rgba(var(--k), .45);
  box-shadow: 0 14px 36px rgba(0,0,0,.45), 0 0 0 4px rgba(var(--k), .08);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  animation: tnIn1 .38s cubic-bezier(.2,.9,.3,1.2) both;
}
.tn-t1 .tn-ico { width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 4px rgba(var(--k), .2); }
.tn-t1 .tn-bar { left: 26px; right: 26px; border-radius: 3px; }
.tn-t1.tn-hide { animation: tnOut1 .2s ease-in both; }
@keyframes tnIn1 { 0% { opacity: 0; transform: translateY(-28px) scale(.9); } 70% { opacity: 1; transform: translateY(3px) scale(1.01); } 100% { opacity: 1; transform: none; } }
@keyframes tnOut1 { to { opacity: 0; transform: translateY(-22px) scale(.94); } }

/* ---------- แบบ 2: การ์ดเหลี่ยมตัดมุม ขอบไล่สี สไลด์จากขวา ---------- */
.tn-t2 {
  border-radius: 4px;
  padding: 14px 16px 14px 12px;
  border: 1.5px solid transparent;
  background:
    linear-gradient(135deg, rgb(var(--n-surf)), rgb(var(--n-deep))) padding-box,
    linear-gradient(135deg, rgb(var(--k)), rgba(var(--n-acc2), .7) 60%, rgba(var(--k), .2)) border-box;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
  filter: drop-shadow(0 14px 24px rgba(0,0,0,.45));
  animation: tnIn2 .42s cubic-bezier(.22,1,.36,1) both;
}
.tn-t2 .tn-ico {
  width: 40px; height: 40px; font-size: 16px;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 70% 100%, 0 100%);
  background: linear-gradient(135deg, rgb(var(--k)), rgba(var(--k), .7));
}
.tn-t2 .tn-label { text-transform: uppercase; letter-spacing: 1px; }
.tn-t2 .tn-bar { top: 0; bottom: auto; right: 16px; height: 2px; }
.tn-t2.tn-hide { animation: tnOut2 .24s ease-in both; }
@keyframes tnIn2 { 0% { opacity: 0; transform: translateX(115%) skewX(-10deg); } 65% { opacity: 1; transform: translateX(-6px) skewX(2deg); } 100% { opacity: 1; transform: none; } }
@keyframes tnOut2 { to { opacity: 0; transform: translateX(115%) skewX(-6deg); } }

/* ---------- แบบ 3: แถบลอยเหนือเมนูล่าง เด้งขึ้นจากล่าง ---------- */
.tn-t3 {
  border-radius: 18px;
  padding: 14px 16px 16px;
  background:
    radial-gradient(90% 140% at 0% 0%, rgba(var(--k), .26), transparent 60%),
    linear-gradient(180deg, rgb(var(--n-surf)), rgb(var(--n-deep)));
  border: 1px solid rgba(var(--k), .35);
  box-shadow: 0 20px 44px rgba(0,0,0,.5);
  animation: tnIn3 .44s cubic-bezier(.2,.9,.3,1.15) both;
}
.tn-t3 .tn-ico { width: 42px; height: 42px; border-radius: 14px; font-size: 17px; animation: tnPop3 .5s .18s cubic-bezier(.3,1.6,.5,1) both; }
.tn-t3 .tn-msg { font-size: 15px; }
.tn-t3 .tn-bar { left: 16px; right: 16px; bottom: 6px; border-radius: 3px; background: rgba(255,255,255,.08); }
.tn-t3.tn-hide { animation: tnOut3 .22s ease-in both; }
@keyframes tnPop3 { 0% { transform: scale(.4) rotate(-20deg); } 100% { transform: none; } }
@keyframes tnIn3 { 0% { opacity: 0; transform: translateY(46px) scale(.96); } 60% { opacity: 1; transform: translateY(-6px); } 100% { opacity: 1; transform: none; } }
@keyframes tnOut3 { to { opacity: 0; transform: translateY(34px) scale(.97); } }

@media (prefers-reduced-motion: reduce) {
  .tn-t1, .tn-t2, .tn-t3, .tn-t3 .tn-ico, .tn-hide { animation-duration: .01ms !important; }
}
