/* ==========================================================================
   Notification center — a bell with an unread count that opens a panel of
   notifications. Built on the popover (placement, Esc, focus handling).

   <button class="btn btn-gray btn-ghost btn-icon" data-moey-open="#inbox" aria-label="Notifications">
     <i class="mi mi-bell"></i><span class="badge badge-corner"></span>    ← the count fills itself in
   </button>
   <div class="popover notifications" id="inbox" data-moey-placement="bottom-end">
     <div class="notifications-header"><h3 class="notifications-title">Notifications</h3>
       <button class="btn btn-link btn-sm" data-moey-mark-all>Mark all as read</button></div>
     <ul class="notifications-list">
       <li class="notifications-group">Today</li>
       <li class="notification is-unread">
         <span class="avatar avatar-sm avatar-pink">AK</span>
         <a class="notification-content" href="/orders/10421"><span class="notification-title">Ana Kim</span>
           commented on order #10421 <time class="notification-time" datetime="2026-11-22T09:40">9:40</time></a>
       </li>
     </ul>
     <div class="notifications-empty">You're all caught up.</div>
   </div>

   moey.js: unread count on the bell, mark read on click, ✓ / ✕ buttons on each item,
   "Mark all as read", All / Unread filter, empty state, "5m ago" times, Moey.notify().
   ========================================================================== */

.notifications {
  --mo-popover-width: 24rem;
  --mo-popover-padding: 0;
  display: flex;
  flex-direction: column;
  width: var(--mo-popover-width);
  max-height: min(34rem, calc(100dvh - 5rem));
  padding: 0;
}
.notifications[popover]:not(:popover-open) { display: none; }

.notifications-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: .5rem;
  padding: .75rem .75rem .5rem 1rem;
}
.notifications-title { flex: 1; min-width: 0; margin: 0; font-size: .9375rem; font-weight: var(--mo-font-weight-semibold); }
.notifications-title .badge { margin-inline-start: .375rem; }
.notifications-toolbar { flex-shrink: 0; padding: 0 1rem .5rem; }

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: .375rem;                                /* every item stays separate — unread tints and hovers never touch */
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: .375rem .5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.notifications-group {
  padding: .625rem .75rem .25rem;
  font-size: .75rem;
  font-weight: var(--mo-font-weight-semibold);
  color: var(--mo-fg-3);
}

/* One notification ---------------------------------------------------------- */
.notification {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .625rem .75rem;
  border-radius: var(--mo-radius-control);
}
.notification:hover { background-color: color-mix(in oklab, var(--mo-fg-body) 5%, transparent); }
.notification.is-unread { background-color: color-mix(in oklab, var(--mo-theme-subtle) 70%, transparent); }
.notification.is-unread:hover { background-color: var(--mo-theme-subtle); }
.notification > :is(.avatar, .notification-icon) { flex-shrink: 0; margin-top: .0625rem; }
.notification-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  color: var(--mo-theme-fg);
  background: var(--mo-theme-subtle);
  border-radius: 50%;
}
.notification-content {
  flex: 1;
  min-width: 0;
  padding-inline-end: 1rem;                    /* room for the unread dot */
  font-size: .8125rem;
  line-height: 1.45;
  color: var(--mo-fg-2);
  text-align: start;
  text-decoration: none;
  background: none;
  border: 0;
}
/* The whole row is clickable when the content is a link or button */
:is(a, button).notification-content { font: inherit; font-size: .8125rem; cursor: pointer; }
:is(a, button).notification-content::after { position: absolute; inset: 0; content: ""; border-radius: inherit; }
:is(a, button).notification-content:focus-visible { outline: 0; }
.notification:has(> :is(a, button).notification-content:focus-visible) { outline: var(--mo-focus-ring-width) solid var(--mo-theme-focus-ring); outline-offset: -2px; }
.notification-title { font-weight: var(--mo-font-weight-medium); color: var(--mo-fg-body); }
.notification.is-unread .notification-title { font-weight: var(--mo-font-weight-semibold); }
.notification-text { display: block; margin-top: .125rem; }
.notification-time { display: block; margin-top: .25rem; font-size: .75rem; color: var(--mo-fg-3); }
.notification-body { margin-top: .5rem; }      /* extra content: a quote, buttons… */

/* Unread dot */
.notification.is-unread::after {
  position: absolute;
  top: 1.0625rem;
  inset-inline-end: .875rem;
  width: .5rem;
  height: .5rem;
  content: "";
  background: var(--mo-theme-base);
  border-radius: 50%;
}

/* ✓ (read / unread) and ✕ (dismiss) — shown on hover and keyboard focus */
.notification-actions {
  position: absolute;
  top: .375rem;
  inset-inline-end: .375rem;
  z-index: 1;
  display: flex;
  gap: .125rem;
  padding: .125rem;
  background: var(--mo-popover-bg, var(--mo-bg-raised));
  border-radius: var(--mo-radius-control);
  box-shadow: 0 1px 3px oklch(0% 0 0 / .1);
  opacity: 0;
  pointer-events: none;
}
.notification:is(:hover, :focus-within) > .notification-actions { opacity: 1; pointer-events: auto; }
.notification:is(:hover, :focus-within)::after { opacity: 0; }
@media (hover: none) {                         /* touch: always reachable */
  .notification > .notification-actions { position: static; flex-direction: column; opacity: 1; pointer-events: auto; background: none; box-shadow: none; }
  .notification.is-unread::after { display: none; }
}

/* Filter "Unread" and the empty state */
.notifications.show-unread .notification:not(.is-unread) { display: none; }
.notifications-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: .375rem;
  padding: 2.5rem 1rem;
  font-size: .875rem;
  color: var(--mo-fg-3);
  text-align: center;
}
.notifications-empty > .mi { font-size: 1.75rem; }
.notifications.is-empty .notifications-empty { display: flex; }
.notifications.is-empty .notifications-list { display: none; }
.notifications-group[hidden] { display: none; }

.notifications-footer {
  flex-shrink: 0;
  padding: .5rem;
  text-align: center;
  border-top: var(--mo-border-width) solid var(--mo-border-color);
}

/* A full page of notifications (no popover): <div class="notifications notifications-page"> */
.notifications-page { width: auto; max-height: none; background: var(--mo-bg-surface); border-radius: var(--mo-radius-card); }
.notifications-page .notifications-list { overflow: visible; }
