/* Toast notifications (notifications_controller). They also appear on published previews,
   which do not carry the .pg tokens, so every token has a literal fallback. */
.notification-source { display: none !important; }

.flash-region:has(.toast-notification) {
  position: fixed;
  z-index: 300;
  top: max(20px, env(safe-area-inset-top));
  inset-inline-end: max(20px, env(safe-area-inset-right));
  width: min(420px, calc(100% - 40px));
  max-height: calc(100dvh - 40px);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 4px 4px 40px;
  pointer-events: none;
}

.flash-region[data-controller] .notice.toast-notification {
  --toast-color: var(--pg-primary, #245cff);
  --toast-soft: var(--pg-primary-soft, #edf2ff);
  --toast-surface: var(--pg-surface, #fff);
  --toast-night: var(--pg-night, #070b1a);
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 32px;
  align-items: start;
  gap: 12px;
  flex-shrink: 0;
  margin: 0;
  padding-block: 16px 19px;
  padding-inline: 16px 12px;
  border: 1px solid color-mix(in srgb, var(--toast-color) 20%, var(--pg-line, #e3e8ef));
  border-radius: var(--pg-radius-lg, 18px);
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--toast-soft) 80%, transparent), transparent 52%),
    color-mix(in srgb, var(--toast-surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  color: var(--pg-text, #273349);
  box-shadow:
    0 22px 44px -22px color-mix(in srgb, var(--toast-night) 46%, transparent),
    0 2px 6px color-mix(in srgb, var(--toast-night) 7%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--toast-surface) 85%, transparent);
  font-size: 14px;
  line-height: 1.55;
  text-align: start;
  overflow: hidden;
  pointer-events: auto;
  transition: box-shadow .2s ease, border-color .2s ease;
  animation: toast-enter .42s cubic-bezier(.2, .9, .3, 1.15) backwards;
}
[dir=rtl] .flash-region[data-controller] .notice.toast-notification {
  background:
    linear-gradient(260deg, color-mix(in srgb, var(--toast-soft) 80%, transparent), transparent 52%),
    color-mix(in srgb, var(--toast-surface) 92%, transparent);
}
.flash-region[data-controller] .notice.toast-notification:hover, .flash-region[data-controller] .notice.toast-notification:focus-within {
  border-color: color-mix(in srgb, var(--toast-color) 38%, var(--pg-line, #e3e8ef));
  box-shadow:
    0 26px 52px -22px color-mix(in srgb, var(--toast-night) 56%, transparent),
    0 2px 6px color-mix(in srgb, var(--toast-night) 9%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--toast-surface) 85%, transparent);
}

.flash-region[data-controller] .notice.toast-success { --toast-color: var(--pg-success, #23805a); --toast-soft: var(--pg-success-soft, #eaf6ef); }
.flash-region[data-controller] .notice.toast-error { --toast-color: var(--pg-danger, #c14d40); --toast-soft: var(--pg-danger-soft, #fff0ec); }
.flash-region[data-controller] .notice.toast-notification .toast-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--toast-surface, #fff); color: var(--toast-color); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--toast-color) 26%, transparent), 0 6px 14px -8px var(--toast-color); animation: toast-icon-pop .5s cubic-bezier(.2, .9, .3, 1.4) .1s backwards; }
.flash-region[data-controller] .notice.toast-notification .toast-icon svg { width: 22px; height: 22px; }
.flash-region[data-controller] .notice.toast-notification .toast-message { display: block; min-width: 0; align-self: center; overflow-wrap: anywhere; color: var(--pg-ink, #17202b); font-weight: 500; }
.flash-region[data-controller] .notice.toast-notification .toast-message > strong { display: block; margin-bottom: 2px; color: var(--pg-ink, #17202b); font-size: 14px; font-weight: 700; line-height: 1.45; }
.flash-region[data-controller] .notice.toast-notification .toast-message p { margin: 0; color: var(--pg-muted, #526078); font-size: 13px; font-weight: 400; line-height: 1.6; }
.flash-region[data-controller] .notice.toast-notification .toast-message a { color: var(--toast-color); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.flash-region[data-controller] .notice.toast-notification .toast-message form, .flash-region[data-controller] .notice.toast-notification .toast-message .button { margin-top: 10px; }
.flash-region[data-controller] .notice.toast-notification .toast-message .button { min-height: 36px; padding: 7px 14px; font-size: 12px; }
.flash-region[data-controller] .notice.toast-notification .toast-close { display: grid; margin: 0; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--pg-subtle, #6b778b); cursor: pointer; transition: background-color .15s, color .15s, transform .15s; }
.flash-region[data-controller] .notice.toast-notification .toast-close:hover { background: color-mix(in srgb, var(--toast-color) 10%, transparent); color: var(--pg-ink, #273349); }
.flash-region[data-controller] .notice.toast-notification .toast-close:active { transform: scale(.9); }
.flash-region[data-controller] .notice.toast-notification .toast-close:focus-visible { outline: 2px solid var(--toast-color); outline-offset: 1px; }
.flash-region[data-controller] .notice.toast-notification .toast-close svg { width: 18px; height: 18px; }
.flash-region[data-controller] .notice.toast-notification .toast-progress { position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--toast-color) 12%, transparent); }
.flash-region[data-controller] .notice.toast-notification .toast-progress > span { display: block; width: 100%; height: 100%; border-radius: 0 3px 3px 0; background: linear-gradient(90deg, var(--toast-color), color-mix(in srgb, var(--toast-color) 55%, var(--pg-violet, #7c5cff))); transform-origin: left; }
[dir=rtl] .flash-region[data-controller] .notice.toast-notification .toast-progress > span { border-radius: 3px 0 0 3px; background: linear-gradient(270deg, var(--toast-color), color-mix(in srgb, var(--toast-color) 55%, var(--pg-violet, #7c5cff))); transform-origin: right; }

@keyframes toast-enter { from { opacity: 0; transform: translateY(-8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-icon-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .flash-region:has(.toast-notification) { top: max(12px, env(safe-area-inset-top)); inset-inline-end: 8px; width: calc(100% - 16px); max-height: calc(100dvh - 24px); gap: 8px; }
  .flash-region[data-controller] .notice.toast-notification { grid-template-columns: 32px minmax(0, 1fr) 36px; gap: 10px; padding-block: 13px 16px; padding-inline: 13px 9px; border-radius: 16px; }
  .flash-region[data-controller] .notice.toast-notification .toast-icon { width: 32px; height: 32px; border-radius: 10px; }
  .flash-region[data-controller] .notice.toast-notification .toast-close { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-region[data-controller] .notice.toast-notification, .flash-region[data-controller] .notice.toast-notification .toast-icon { animation: none; }
  .flash-region[data-controller] .notice.toast-notification, .flash-region[data-controller] .notice.toast-notification .toast-close { transition: none; }
  .flash-region[data-controller] .notice.toast-notification .toast-close:active { transform: none; }
}
