.notification-stack {
  width: min(340px, calc(100vw - 28px));
  height: 126px;
  position: fixed;
  z-index: 200;
  right: 18px;
  top: 18px;
  pointer-events: none;
  transition: height 300ms ease;
}

.notification-stack.has-expanded-card { height: 235px; }

.popup-card {
  --deck-index: 0;
  width: calc(100% - (var(--deck-index) * 14px));
  min-height: 104px;
  max-height: 104px;
  position: absolute;
  left: calc(var(--deck-index) * 7px);
  top: calc(var(--deck-index) * 10px);
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  padding: 14px 52px 13px 14px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 17px;
  background:
    radial-gradient(circle at 88% 8%, rgb(76 231 233 / 28%), transparent 27%),
    linear-gradient(145deg, #2c3e49, #176aa7 72%, #168fc7);
  color: #fff;
  box-shadow: 0 14px 38px rgb(20 52 69 / 30%);
  opacity: 0;
  transform: translateX(24px) scale(calc(1 - (var(--deck-index) * .025)));
  transform-origin: top center;
  transition: opacity 250ms ease, transform 350ms cubic-bezier(.2,1.1,.3,1), top 300ms, left 300ms, width 300ms, max-height 300ms;
  pointer-events: none;
}

.popup-card.is-visible { opacity: 1; transform: translateX(0) scale(calc(1 - (var(--deck-index) * .025))); }
.popup-card.is-top-card { pointer-events: auto; }
.popup-card:not(.is-top-card) > * { visibility: hidden; }

.popup-card.is-expanded {
  min-height: 104px;
  max-height: 220px;
}

.popup-close {
  min-width: 35px;
  height: 25px;
  position: absolute;
  right: 9px;
  top: 9px;
  padding: 0 8px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 99px;
  background: rgb(255 255 255 / 11%);
  color: #e3f7f9;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}

.popup-signal {
  width: 36px;
  height: 36px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #168fc7, #56e1e5);
  font-size: 15px;
  box-shadow: 0 7px 18px rgb(40 199 206 / 31%);
}

.popup-signal::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1px solid rgb(100 235 238 / 55%);
  border-radius: 50%;
  animation: popup-wave 1.5s ease-out infinite;
}

.popup-content { min-width: 0; }

.popup-content small {
  color: #7de5e8;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 6px;
  font-weight: 800;
}

.popup-content h2 {
  margin: 3px 0 3px;
  overflow: hidden;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 15px;
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-content p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #c4e2e9;
  font-size: 8px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.popup-card.is-expanded .popup-content h2 { white-space: normal; }
.popup-card.is-expanded .popup-content p { display: block; overflow: visible; }

.popup-action {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8aebee;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}

@keyframes popup-wave {
  from { transform: scale(.72); opacity: 1; }
  to { transform: scale(1.5); opacity: 0; }
}

@media (max-width: 600px) {
  .notification-stack {
    width: calc(100vw - 24px);
    right: 12px;
    top: max(12px, env(safe-area-inset-top));
  }
}

@media (prefers-reduced-motion: reduce) {
  .popup-card { transition: none; }
  .popup-signal::after { animation: none; }
}
