/* ==========================================================================
   Zenith Form Style — toasts (assets/js/zt-toast.js, window.ZTToast)
   ==========================================================================
   A stack of short messages in a corner of the screen: success, error, info,
   warning. Every visual decision is a token; the position is a class on the
   container (ZTToast.config({ position: 'bottom-right' })). Phones (≤ 600px)
   get a full-width stack at the bottom, above any fixed bottom bar
   (--zt-toast-offset-bottom-mobile). */

/* Defaults carry no specificity: a site's tokens win wherever they are declared. */
:where(:root) {
  /* Feedback/Toast (design): tinted panel + 1px border in the status colour, radius 10, padding 10/14,
     14 Medium text in the status colour, an 18px icon at the start, no close button, no timer bar. */
  --zt-toast-z: 1000000; /* above any modal or overlay */
  --zt-toast-width: 336px;
  --zt-toast-gap: 10px;
  --zt-toast-offset: 20px;
  --zt-toast-offset-mobile: 12px;
  --zt-toast-offset-bottom-mobile: var(--zt-toast-offset-mobile);
  --zt-toast-padding: 10px 14px;
  --zt-toast-padding-mobile: var(--zt-toast-padding);
  --zt-toast-radius: 10px;
  --zt-toast-border-width: 1px;
  --zt-toast-shadow: none;
  --zt-toast-font-size: 14px;
  --zt-toast-font-size-mobile: var(--zt-toast-font-size);
  --zt-toast-font-weight: 500;
  --zt-toast-line-height: 1.6;
  --zt-toast-inner-gap: 6px;
  --zt-toast-icon-size: 18px;
  --zt-toast-icon-size-mobile: var(--zt-toast-icon-size);
  --zt-toast-close-size: 30px;
  --zt-toast-close-display: none; /* inline-flex: show a close button */
  --zt-toast-icon-order: 0;     /* 0: icon first; 2: after the text */
  --zt-toast-close-order: 3;    /* 3: last; -1: first */
  --zt-toast-timer-height: 0px; /* e.g. 3px: a bar counting down (the toast closes on time either way) */
  --zt-toast-link-weight: 700;
  --zt-toast-bg: #ffffff;
  --zt-toast-border: #e4e7ec;
  --zt-toast-color: #212121;
  --zt-toast-icon-color: #2f80ed;
  --zt-toast-timer: #2f80ed;
  --zt-toast-link: inherit;
  --zt-toast-success-bg: #f3fceb;     /* Background/Green */
  --zt-toast-success-border: #52c41a; /* Alerts & Status/Success */
  --zt-toast-success-color: #52c41a;
  --zt-toast-success-icon: #52c41a;
  --zt-toast-error-bg: #ffefed;       /* Background/Red */
  --zt-toast-error-border: #f54336;   /* Others/Red */
  --zt-toast-error-color: #f54336;
  --zt-toast-error-icon: #f54336;
  --zt-toast-info-bg: #eef6fb;        /* Background/Blue */
  --zt-toast-info-border: #2f80ed;
  --zt-toast-info-color: #2f80ed;
  --zt-toast-info-icon: #2f80ed;
  --zt-toast-warning-bg: #fffceb;     /* Background/Yellow */
  --zt-toast-warning-border: #f5a623;
  --zt-toast-warning-color: #f5a623;
  --zt-toast-warning-icon: #f5a623;
}

.zt-toasts {
  position: fixed;
  z-index: var(--zt-toast-z);
  display: flex;
  flex-direction: column;
  gap: var(--zt-toast-gap);
  width: min(var(--zt-toast-width), calc(100vw - 2 * var(--zt-toast-offset)));
  pointer-events: none;
}
.zt-toasts--top-right    { top: var(--zt-toast-offset); right: var(--zt-toast-offset); }
.zt-toasts--top-left     { top: var(--zt-toast-offset); left: var(--zt-toast-offset); }
.zt-toasts--top-center   { top: var(--zt-toast-offset); left: 50%; transform: translateX(-50%); }
.zt-toasts--bottom-right { bottom: var(--zt-toast-offset); right: var(--zt-toast-offset); flex-direction: column-reverse; }
.zt-toasts--bottom-left  { bottom: var(--zt-toast-offset); left: var(--zt-toast-offset); flex-direction: column-reverse; }
.zt-toasts--bottom-center { bottom: var(--zt-toast-offset); left: 50%; transform: translateX(-50%); flex-direction: column-reverse; }
.admin-bar .zt-toasts[class*="zt-toasts--top"] { top: calc(var(--zt-toast-offset) + 32px); }

.zt-toast {
  --zt-t-bg: var(--zt-toast-bg);
  --zt-t-border: var(--zt-toast-border);
  --zt-t-color: var(--zt-toast-color);
  --zt-t-icon: var(--zt-toast-icon-color);
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--zt-toast-inner-gap);
  padding: var(--zt-toast-padding);
  border: var(--zt-toast-border-width) solid var(--zt-t-border);
  border-radius: var(--zt-toast-radius);
  background: var(--zt-t-bg);
  color: var(--zt-t-color);
  box-shadow: var(--zt-toast-shadow);
  font-family: inherit;
  font-size: var(--zt-toast-font-size);
  font-weight: var(--zt-toast-font-weight);
  line-height: var(--zt-toast-line-height);
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(12px);
  transition: transform .35s cubic-bezier(.2, .7, .3, 1), opacity .35s ease;
}
.zt-toast.is-in { opacity: 1; transform: none; }
.zt-toast.is-out { opacity: 0; transform: translateY(12px); }
.zt-toast--success { --zt-t-bg: var(--zt-toast-success-bg); --zt-t-border: var(--zt-toast-success-border); --zt-t-color: var(--zt-toast-success-color); --zt-t-icon: var(--zt-toast-success-icon); }
.zt-toast--error   { --zt-t-bg: var(--zt-toast-error-bg);   --zt-t-border: var(--zt-toast-error-border);   --zt-t-color: var(--zt-toast-error-color);   --zt-t-icon: var(--zt-toast-error-icon); }
.zt-toast--info    { --zt-t-bg: var(--zt-toast-info-bg);    --zt-t-border: var(--zt-toast-info-border);    --zt-t-color: var(--zt-toast-info-color);    --zt-t-icon: var(--zt-toast-info-icon); }
.zt-toast--warning { --zt-t-bg: var(--zt-toast-warning-bg); --zt-t-border: var(--zt-toast-warning-border); --zt-t-color: var(--zt-toast-warning-color); --zt-t-icon: var(--zt-toast-warning-icon); }

.zt-toast__icon { order: var(--zt-toast-icon-order); flex: none; display: inline-flex; color: var(--zt-t-icon); }
.zt-toast__icon svg { width: var(--zt-toast-icon-size); height: var(--zt-toast-icon-size); }
.zt-toast__body { order: 1; flex: 1; min-width: 0; }
.zt-toast__body > * { margin: 0; }
.zt-toast__body ul { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.zt-toast__body a { color: var(--zt-toast-link); font-weight: var(--zt-toast-link-weight); }
.zt-toast__action { margin-inline-start: 6px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: var(--zt-toast-link-weight); text-decoration: underline; cursor: pointer; }
.zt-toast__close {
  order: var(--zt-toast-close-order);
  flex: none;
  display: var(--zt-toast-close-display);
  align-items: center;
  justify-content: center;
  width: var(--zt-toast-close-size);
  height: var(--zt-toast-close-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: .8;
  cursor: pointer;
  transition: background-color .2s ease, opacity .2s ease;
}
.zt-toast__close:hover { background: rgba(0, 0, 0, .06); opacity: 1; }
.zt-toast__close svg { width: var(--zt-toast-icon-size); height: var(--zt-toast-icon-size); }
.zt-toast__timer {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: var(--zt-toast-timer-height);
  background: var(--zt-t-icon);
  transform-origin: left;
  animation: zt-toast-timer var(--zt-toast-duration, 5s) linear forwards;
}
.zt-toast:hover .zt-toast__timer { animation-play-state: paused; }
@keyframes zt-toast-timer { to { transform: scaleX(0); } }

@media (max-width: 600px) {
  .zt-toasts,
  .zt-toasts[class*="zt-toasts--"] {
    top: auto;
    right: var(--zt-toast-offset-mobile);
    bottom: var(--zt-toast-offset-bottom-mobile);
    left: var(--zt-toast-offset-mobile);
    width: auto;
    transform: none;
    flex-direction: column-reverse;
  }
  .zt-toast { padding: var(--zt-toast-padding-mobile); font-size: var(--zt-toast-font-size-mobile); }
  .zt-toast__icon svg, .zt-toast__close svg { width: var(--zt-toast-icon-size-mobile); height: var(--zt-toast-icon-size-mobile); }
}
@media (prefers-reduced-motion: reduce) {
  .zt-toast { transform: none; transition: opacity .2s; }
  .zt-toast.is-out { transform: none; }
}
