/* ==========================================================================
 * TbToast — 全站底部消息提示（独立组件）
 * 层级高于登录弹窗 / 下载门禁 / 付费下载，避免被模糊遮罩挡住
 * ========================================================================== */

:root {
  --tb-toast-z: 30050;
  --tb-toast-ease: cubic-bezier(0.22, 0.8, 0.28, 1);
  --tb-toast-ok: #16a34a;
  --tb-toast-err: #ef4444;
  --tb-toast-info: #0ea5e9;
  --tb-toast-warn: #f59e0b;
}

#tb-toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--tb-toast-z);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 0.55rem;
  padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

body:has(.fixed-post-dock) #tb-toast-root {
  padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}

.tb-toast {
  --tb-toast-accent: var(--tb-toast-info);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: min(100%, 22.5rem);
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow:
    0 18px 40px -20px rgba(15, 23, 42, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  opacity: 0;
  transform: translate3d(0, 18px, 0) scale(0.98);
  transition:
    opacity 0.28s var(--tb-toast-ease),
    transform 0.32s var(--tb-toast-ease);
  will-change: transform, opacity;
}

.tb-toast.is-in {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.tb-toast.is-out {
  opacity: 0;
  transform: translate3d(0, 12px, 0) scale(0.98);
}

.tb-toast--success { --tb-toast-accent: var(--tb-toast-ok); }
.tb-toast--error { --tb-toast-accent: var(--tb-toast-err); }
.tb-toast--warning { --tb-toast-accent: var(--tb-toast-warn); }
.tb-toast--info { --tb-toast-accent: var(--tb-toast-info); }

.tb-toast__icon {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: 0.05rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--tb-toast-accent);
  box-shadow: 0 8px 16px -10px var(--tb-toast-accent);
}

.tb-toast__icon svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

.tb-toast__body {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 0.12rem;
}

.tb-toast__title {
  margin: 0 0 0.15rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  color: #0f172a;
}

.tb-toast__msg {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 550;
  line-height: 1.45;
  color: #475569;
  word-break: break-word;
}

.tb-toast__close {
  flex: 0 0 auto;
  width: 1.65rem;
  height: 1.65rem;
  margin: -0.1rem -0.15rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: #94a3b8;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.tb-toast__close:hover {
  background: rgba(15, 23, 42, 0.1);
  color: #334155;
}

.tb-toast__close svg {
  width: 0.75rem;
  height: 0.75rem;
}

.tb-toast__bar {
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.35rem;
  height: 2px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.tb-toast__bar > i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--tb-toast-accent);
  animation: tbToastBar linear forwards;
}

.tb-toast {
  position: relative;
  padding-bottom: 0.95rem;
}

@keyframes tbToastBar {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .tb-toast,
  .tb-toast__bar > i {
    transition: none !important;
    animation: none !important;
  }

  .tb-toast.is-in {
    opacity: 1;
    transform: none;
  }
}

.nice-dark-mode .tb-toast {
  color: #f1f5f9;
  background: rgba(28, 31, 40, 0.96);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.65);
}

.nice-dark-mode .tb-toast__title {
  color: #f8fafc;
}

.nice-dark-mode .tb-toast__msg {
  color: #94a3b8;
}

.nice-dark-mode .tb-toast__close {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.nice-dark-mode .tb-toast__close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

.nice-dark-mode .tb-toast__bar {
  background: rgba(255, 255, 255, 0.1);
}
