/* ── Unified toast / notification system ───────────────────────────────────────
   A premium, liquid-glass notification. Each toast carries the accent of its
   source (type colour, or the app's own brand colour via --xt-rgb): a glowing
   gradient hairline, a soft accent aura, a haloed app icon, and a luminous
   auto-dismiss bar. Newest sits at the bottom (near the anchor); older ones are
   pushed up. Theme-aware — surfaces/text come from the shared panel tokens, so
   it adapts to light/dark automatically. Motion is spring-like and interruptible;
   fully reduced under prefers-reduced-motion. No untrusted text touches innerHTML. */

.xtoast-stack {
  position: fixed;
  left: 50%;
  /* Top-anchored, like an Android heads-up. In minimal chrome the stack drops onto
     the clock island's spot (top: 9px, see TopbarMinimal.css); here it clears the
     full topbar and sits in the gap above the grid. Newest sits at the top (near
     the anchor); older ones are pushed down. */
  top: 74px;
  bottom: auto;
  transform: translateX(-50%);
  /* Above every overlay (settings 220, color picker / update modal 4000) so a
     confirmation never fires unseen behind a panel. */
  z-index: 5200;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  width: min(400px, calc(100vw - 28px));
  pointer-events: none; /* children re-enable; gaps stay click-through */
}

/* Actionable toast (an onClick was provided, e.g. "tap to update"). */
.xtoast-clickable { cursor: pointer; }

.xtoast {
  --xt-rgb: var(--accent-rgb);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 15px 15px;
  border-radius: 20px;
  color: var(--text);
  pointer-events: auto;
  /* Layered liquid glass: a top sheen, an accent wash bleeding from the icon
     corner, over a translucent panel that picks up the theme's surface colour. */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.015)),
    radial-gradient(135% 150% at -8% -20%, rgba(var(--xt-rgb), 0.30), transparent 52%),
    rgba(var(--panel-rgb), 0.66);
  -webkit-backdrop-filter: blur(26px) saturate(155%);
  backdrop-filter: blur(26px) saturate(155%);
  box-shadow:
    0 26px 64px -20px rgba(0, 0, 0, 0.72),
    0 11px 30px -18px rgba(var(--xt-rgb), 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.10);
  /* Enter/exit (toggled by .xtoast-in / .xtoast-out). Drops in from the top with a
     spring-like overshoot, quicker out. In minimal chrome this initial state is
     overridden to a capsule so the card expands out of the clock island (below). */
  opacity: 0;
  transform: translateY(-16px) scale(0.96);
  transform-origin: top center;
  transition:
    transform 0.5s cubic-bezier(0.22, 1.15, 0.36, 1),
    opacity 0.32s ease,
    border-radius 0.45s cubic-bezier(0.22, 1.15, 0.36, 1);
  will-change: transform, opacity;
}

/* Glowing gradient hairline border — brightest at the accent (top-left) corner. */
.xtoast::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(140deg,
    rgba(var(--xt-rgb), 0.85),
    rgba(255, 255, 255, 0.16) 32%,
    rgba(255, 255, 255, 0.03) 62%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
}

/* One-shot diagonal sheen that sweeps across on entrance. */
.xtoast::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.10) 46%, transparent 62%);
  transform: translateX(-120%);
}
.xtoast-in::after { animation: xtoast-sheen 0.9s ease 0.12s 1; }

.xtoast-in { opacity: 1; transform: none; }
.xtoast-out {
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  transition: transform 0.28s ease-in, opacity 0.26s ease-in;
}

/* ── Dynamic-Island mode (minimal topbar chrome) ──────────────────────────────
   In minimal mode the notification replaces the floating clock/date/weather island:
   the pill recedes (TopbarMinimal.css positions the stack onto its spot) and the
   toast grows out of a capsule into the full card, then collapses back into a
   capsule on the way out — the Apple Dynamic-Island expand/contract. The inner
   content fades in as the card unfolds so the squash-to-capsule never shows text.
   Purely presentational: same DOM, same swipe/pause/dismiss handling. */
body.topbar-minimal:not([data-panel]) .xtoast {
  transform-origin: top center;
  transform: translateY(-4px) scaleX(0.6) scaleY(0.32);
  border-radius: 999px;
}
body.topbar-minimal:not([data-panel]) .xtoast-in {
  transform: none;
  border-radius: 20px;
}
body.topbar-minimal:not([data-panel]) .xtoast-out {
  transform: translateY(-2px) scaleX(0.6) scaleY(0.3);
  border-radius: 999px;
  opacity: 0;
}
body.topbar-minimal:not([data-panel]) .xtoast-icon,
body.topbar-minimal:not([data-panel]) .xtoast-body {
  opacity: 0;
  transition: opacity 0.26s ease 0.06s;
}
body.topbar-minimal:not([data-panel]) .xtoast-in .xtoast-icon,
body.topbar-minimal:not([data-panel]) .xtoast-in .xtoast-body { opacity: 1; }

.xtoast-icon {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 17px;
  z-index: 1;
  display: grid;
  place-items: center;
  color: rgb(var(--xt-rgb));
  background: rgba(var(--xt-rgb), 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(var(--xt-rgb), 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
/* Soft accent halo behind the icon. */
.xtoast-icon::before {
  content: "";
  position: absolute;
  inset: -40%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--xt-rgb), 0.55), transparent 62%);
  filter: blur(8px);
}
.xtoast-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* App-supplied icon (Windows notification mirror): fill the tile with the real
   logo instead of a line-icon. The accent halo/tint still comes from --xt-rgb. */
.xtoast-icon--img { overflow: hidden; background: rgba(var(--xt-rgb), 0.16); }
.xtoast-icon--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.xtoast-body { min-width: 0; z-index: 1; }

.xtoast-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgb(var(--xt-rgb));
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xtoast-kicker::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgb(var(--xt-rgb));
  box-shadow: 0 0 8px rgba(var(--xt-rgb), 0.9);
}

.xtoast-title {
  margin-top: 3px;
  font-size: 15.5px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xtoast-msg {
  margin-top: 2px;
  color: var(--muted-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.38;
  font-variant-numeric: tabular-nums;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Explicit toast actions (opts.actions) — a second choice next to the toast's
   own tap action. Touch-sized, because the Edge is a touchscreen. */
.xtoast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}
.xtoast-action {
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}
.xtoast-action:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.26); }
.xtoast-action:active { transform: scale(0.97); }
.xtoast-action:focus-visible { outline: 2px solid rgba(var(--xt-rgb), 0.85); outline-offset: 2px; }
.xtoast-action.is-primary {
  border-color: rgba(var(--xt-rgb), 0.55);
  background: rgba(var(--xt-rgb), 0.16);
  color: rgb(var(--xt-rgb));
}
.xtoast-action.is-primary:hover { background: rgba(var(--xt-rgb), 0.24); }

.xtoast-close {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.xtoast-close:hover {
  background: rgba(233, 84, 84, 0.18);
  border-color: rgba(233, 84, 84, 0.42);
  color: #fff;
}
.xtoast-close:active { transform: scale(0.9); }
.xtoast-close:focus-visible {
  outline: 2px solid rgba(var(--xt-rgb), 0.7);
  outline-offset: 2px;
}
.xtoast-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.xtoast-progress {
  position: absolute;
  left: 15px;
  right: 15px;
  bottom: 8px;
  height: 3px;
  border-radius: 3px;
  z-index: 2;
  transform-origin: left center;
  background: linear-gradient(90deg, rgba(var(--xt-rgb), 0.35), rgb(var(--xt-rgb)));
  box-shadow: 0 0 10px rgba(var(--xt-rgb), 0.6);
  animation-name: xtoast-progress;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
/* Hover / press-hold pauses both the JS dismiss timer and this bar, in lockstep. */
.xtoast.is-held .xtoast-progress,
.xtoast:hover .xtoast-progress { animation-play-state: paused; }

/* While a finger is dragging the toast, kill the entrance transition so it tracks
   the pointer 1:1 (JS sets the transform inline). */
.xtoast.is-dragging { transition: none; }

@keyframes xtoast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes xtoast-sheen { to { transform: translateX(120%); } }

@media (prefers-reduced-motion: reduce) {
  .xtoast { transition: opacity 0.2s ease; transform: none; }
  .xtoast-in, .xtoast-out { transform: none; }
  .xtoast-in::after { animation: none; }
  /* No capsule morph or content fade under reduced motion — it just cross-fades. */
  body.topbar-minimal:not([data-panel]) .xtoast,
  body.topbar-minimal:not([data-panel]) .xtoast-in,
  body.topbar-minimal:not([data-panel]) .xtoast-out { transform: none; border-radius: 20px; }
  body.topbar-minimal:not([data-panel]) .xtoast-icon,
  body.topbar-minimal:not([data-panel]) .xtoast-body { opacity: 1; transition: none; }
}
