/* MyoMed toasts + notification bell. Pairs with js/toast.js and js/notifications.js.
   The toast section is copied verbatim into rescue/web/css/toast.css. */

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast-region { display: flex; flex-direction: column; gap: 0.5rem; }
.toast-region:empty { display: none; }

.toast {
  --toast-bar: #2563eb;
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  background: var(--card, #fff);
  color: var(--ink, #1a2a33);
  border: 1px solid var(--line, #d8e1e5);
  border-left: 4px solid var(--toast-bar);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 30, 40, 0.18), 0 2px 6px rgba(15, 30, 40, 0.08);
  font-size: var(--text-sm, 0.9rem);
  line-height: 1.4;
  touch-action: pan-y;
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.toast-success { --toast-bar: #16a34a; }
.toast-info    { --toast-bar: #2563eb; }
.toast-warning { --toast-bar: #d97706; }
.toast-error   { --toast-bar: #dc2626; }
.toast-xp      { --toast-bar: #d4a017; }

.toast-icon {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: var(--font-bold, 700);
  color: #fff;
  background: var(--toast-bar);
  font-size: 0.85rem;
}
.toast-xp .toast-icon { background: transparent; color: #d4a017; font-size: 1.15rem; }
.toast-body { flex: 1; min-width: 0; }
.toast-msg { margin: 0; overflow-wrap: anywhere; }
.toast-xp .toast-msg { color: #b8860b; font-weight: var(--font-bold, 700); font-size: var(--text-base, 1rem); }
.toast-action {
  display: inline-block;
  margin-top: 0.3rem;
  font-weight: var(--font-semibold, 600);
  color: var(--toast-bar);
  text-decoration: underline;
}
.toast-close {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted, #5b6b73);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  border-radius: 4px;
}
.toast-close:hover { color: var(--ink, #1a2a33); }
.toast-close:focus-visible, .toast-action:focus-visible { outline: 2px solid var(--toast-bar); outline-offset: 2px; }

.toast-out { animation: toast-out 200ms ease-in both; }
.toast-swipe-right.toast-out { animation-name: toast-out-right; }
.toast-swipe-left.toast-out { animation-name: toast-out-left; }
.toast-dragging { transition: none; animation: none; }

@keyframes toast-in { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { from { opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
@keyframes toast-out-right { to { transform: translateX(120%); opacity: 0; } }
@keyframes toast-out-left { to { transform: translateX(-120%); opacity: 0; } }

[data-theme="dark"] .toast-xp .toast-msg { color: #f2c94c; }

@media (max-width: 480px) {
  .toast-stack { left: 0.75rem; right: 0.75rem; top: 0.75rem; width: auto; max-width: none; }
}

/* ── Notification bell ──────────────────────────────────────────────────── */
.notif-menu { position: relative; display: inline-flex; }
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--chrome-line, var(--line, #d8e1e5));
  color: var(--chrome-ink, var(--ink, #1a2a33));
  border-radius: 8px;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
  font-size: 0.95rem;
  line-height: 1;
}
.notif-bell:hover { background: color-mix(in srgb, var(--chrome-ink, #1a2a33) 10%, transparent); }
.notif-bell:focus-visible { outline: 2px solid var(--teal, #0e7c86); outline-offset: 2px; }

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: var(--font-bold, 700);
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--card, #fff);
}
.notif-badge[hidden] { display: none; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 1.5rem);
  background: var(--card, #fff);
  color: var(--ink, #1a2a33);
  border: 1px solid var(--line, #d8e1e5);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 30, 40, 0.2);
  animation: notif-pop 160ms ease-out both;
}
.notif-dropdown[hidden] { display: none; }
/* Arrow pointing up at the bell. */
.notif-dropdown::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--card, #fff);
  border-left: 1px solid var(--line, #d8e1e5);
  border-top: 1px solid var(--line, #d8e1e5);
  transform: rotate(45deg);
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line, #d8e1e5);
}
.notif-title { margin: 0; font-size: var(--text-base, 1rem); font-weight: var(--font-semibold, 600); }
.notif-markall {
  border: 0;
  background: transparent;
  color: var(--teal, #0e7c86);
  font-size: var(--text-xs, 0.8rem);
  font-weight: var(--font-semibold, 600);
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
}
.notif-markall:hover { text-decoration: underline; }
.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 360px; /* ≈ 5 items, then scroll */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.notif-item + .notif-item { border-top: 1px solid var(--line, #d8e1e5); }
.notif-link {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  color: inherit;
  text-decoration: none;
  min-height: 72px;
  box-sizing: border-box;
}
a.notif-link:hover { background: color-mix(in srgb, var(--teal, #0e7c86) 6%, transparent); }
.notif-icon { flex: none; font-size: 1.15rem; line-height: 1.3; }
.notif-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.notif-msg { font-size: var(--text-sm, 0.9rem); color: var(--muted, #5b6b73); overflow-wrap: anywhere; }
.notif-time { font-size: var(--text-xs, 0.75rem); color: var(--muted, #5b6b73); }
.notif-item.is-unread .notif-link { background: color-mix(in srgb, var(--teal, #0e7c86) 8%, transparent); }
.notif-item.is-unread .notif-msg { color: var(--ink, #1a2a33); font-weight: var(--font-semibold, 600); }
.notif-item.is-unread .notif-link::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin: 0.4rem 0 0 auto;
  border-radius: 50%;
  background: #dc2626;
}
.notif-empty { padding: 1.25rem 0.85rem; text-align: center; color: var(--muted, #5b6b73); font-size: var(--text-sm, 0.9rem); }

@keyframes notif-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Reduced motion: instant show / hide ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .toast, .toast-out, .notif-dropdown { animation: none !important; transition: none !important; }
}
.toast-static { animation: none; }
