/* A Ding arriving (ring.js): Ding's own card, solid in the theme's ink as
   the app's lit cards are. The sender's face with Ding's mark, rings going
   out from it while it plays, the voice's line, then Play · Open · ✕. Top
   right on a computer, across the top on a phone. */

.ring-stack {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.ring-card {
  pointer-events: auto; position: relative; overflow: hidden;
  padding: 14px 14px 12px; border-radius: 28px;
  background: var(--ink); color: var(--on-ink);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.18), 0 18px 48px rgba(20, 24, 30, 0.28);
  animation: ring-in 0.5s cubic-bezier(0.2, 1.25, 0.35, 1) both;
}
/* A soft light in its corner, as on a lit card. */
.ring-card::before {
  content: ""; position: absolute; width: 240px; height: 240px; right: -90px; top: -120px;
  background: radial-gradient(circle, color-mix(in srgb, var(--on-ink) 16%, transparent), transparent 70%);
  pointer-events: none;
}
.ring-card.leaving { animation: ring-out 0.28s ease-in both; }
@keyframes ring-in { from { opacity: 0; transform: translateY(-26px) scale(0.92); filter: blur(4px); } }
@keyframes ring-out { to { opacity: 0; transform: translateY(-14px) scale(0.96); } }

.ring-main {
  display: flex; align-items: center; gap: 13px; width: 100%; padding: 0; border: 0;
  background: none; color: inherit; text-align: left; cursor: pointer; font: inherit;
}
.ring-face { position: relative; width: 50px; height: 50px; flex: none; }
.ring-photo {
  position: relative; z-index: 1; display: grid; place-items: center; width: 50px; height: 50px;
  border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--on-ink) 18%, transparent);
}
.ring-photo img { width: 100%; height: 100%; object-fit: cover; }
.ring-initials { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 650; font-size: 17px; letter-spacing: 0.02em; }
.ring-mark {
  position: absolute; z-index: 2; right: -4px; bottom: -4px; width: 21px; height: 21px;
  border-radius: 6px; box-shadow: 0 0 0 2px var(--ink);
}
/* While it plays: rings going out from the face, as a Ding rings. */
.ring-waves { position: absolute; inset: 0; z-index: 0; }
.ring-waves i {
  position: absolute; inset: 0; border-radius: 999px;
  border: 1.5px solid color-mix(in srgb, var(--on-ink) 55%, transparent); opacity: 0;
}
.ring-card.playing .ring-waves i { animation: ring-wave 1.8s ease-out infinite; }
.ring-card.playing .ring-waves i:nth-child(2) { animation-delay: 0.6s; }
.ring-card.playing .ring-waves i:nth-child(3) { animation-delay: 1.2s; }
.ring-card.alarm.playing .ring-waves i { animation-duration: 1.1s; }
@keyframes ring-wave {
  0% { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.9); }
}

.ring-words { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ring-top { display: flex; align-items: baseline; gap: 8px; }
.ring-top b { flex: 1; min-width: 0; font-size: 16px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-when { flex: none; font-size: 12px; opacity: 0.6; }
.ring-card.alarm .ring-when { opacity: 1; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 11px; }
.ring-body {
  font-size: 14px; opacity: 0.82; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.ring-line { display: block; width: 100%; height: 26px; margin: 12px 0 10px; color: var(--on-ink); }

.ring-acts { display: flex; align-items: center; gap: 8px; }
.ring-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 650;
  background: color-mix(in srgb, var(--on-ink) 14%, transparent); color: var(--on-ink);
  transition: background 0.15s ease, transform 0.1s ease;
}
.ring-btn:hover { background: color-mix(in srgb, var(--on-ink) 22%, transparent); }
.ring-btn:active { transform: scale(0.95); }
.ring-btn svg { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ring-x svg { fill: none; }
.ring-play { padding: 0; width: 36px; background: var(--on-ink); color: var(--ink); }
.ring-play:hover { background: var(--on-ink); opacity: 0.9; }
.ring-open { margin-left: auto; }
.ring-x { padding: 0; width: 36px; }
.ring-hint { font-size: 12px; opacity: 0.7; }
.ring-card.alarm .ring-x { width: auto; padding: 0 14px; background: var(--on-ink); color: var(--ink); }
.ring-card.alarm .ring-x svg { fill: currentColor; }
/* Ringing, Stop says it all. */
.ring-card.alarm.playing .ring-play { display: none; }

.ring-card.still, .ring-card.still.leaving { animation: none; }
.ring-card.still .ring-waves i { animation: none !important; }

@media (max-width: 760px) {
  .ring-stack { top: calc(10px + env(safe-area-inset-top)); left: 16px; right: 16px; width: auto; }
  .ring-card { border-radius: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-card, .ring-card.leaving { animation: none; }
  .ring-card .ring-waves i { animation: none !important; }
}
