/* ============================================================================
   Notification Centre — Aurora Glass
   ----------------------------------------------------------------------------
   The bell modal rebuilt as a proper centre: title + subtitle, a toolbar
   (filter / mark all read / settings), a scrolling category tab rail with
   per-tab unread counts, cards that carry an icon, an unread dot and a delete
   action, and a settings sheet (categories · channels · history & retention).

   Markup lives in views/partials/dashboard-avatar.hbs; the taxonomy and the
   retention numbers come from models/notification-preferences.js.
   Loaded after dashboard-avatar.css, so the rules here win where they overlap.
   ========================================================================== */

.nc-modal {
  --nc-bg: var(--surface-sunken);
  --nc-bg-elev: var(--glass);
  --nc-bg-elev-hover: var(--glass-strong);
  --nc-line: var(--line);
  --nc-line-soft: var(--line-soft);
  --nc-text: var(--ink);
  --nc-text-soft: var(--ink-soft);
  --nc-text-muted: var(--ink-muted);
  --nc-brand: #777777;
  --nc-brand-light: var(--brand-fill);
  --nc-grad: linear-gradient(105deg, #636363 0%, #777777 55%, #7e7e7e 120%);
}

/* ID-scoped so these beat the legacy `#userNotificationsModal .modal-content`
   sizing rules in dashboard-avatar.css (same specificity, loaded later). */
#userNotificationsModal .modal-dialog {
  max-width: 520px;
  width: calc(100% - 1.5rem);
  max-height: none;
}

#userNotificationsModal .notifications-modal-content {
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(119, 119, 119, 0.16), transparent 62%),
    var(--nc-bg);
  border: 1px solid var(--nc-line);
  border-radius: 22px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(84vh, 760px);
}

/* A view is the whole sheet (list or settings) — only one is mounted at a time. */
.nc-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.nc-view.d-none { display: none !important; }

/* ── Head ─────────────────────────────────────────────────────────────── */
.nc-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 14px;
}

.nc-head-text { flex: 1; min-width: 0; }

.nc-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--nc-text);
  line-height: 1.2;
}

.nc-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--nc-text-muted);
}

.nc-icon-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--nc-line);
  border-radius: 11px;
  background: var(--nc-bg-elev);
  color: var(--nc-text-soft);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.nc-icon-btn:hover {
  background: var(--nc-bg-elev-hover);
  color: var(--nc-text);
}

.nc-icon-btn:active { transform: scale(0.94); }

.nc-back { margin-top: 2px; }

/* ── Toolbar ──────────────────────────────────────────────────────────── */
.nc-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px 12px;
  flex-wrap: wrap;
}

.nc-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--nc-line);
  border-radius: 999px;
  background: var(--nc-bg-elev);
  color: var(--nc-text-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nc-pill-btn i { font-size: 14px; }

.nc-pill-btn:hover:not(:disabled) {
  background: var(--nc-bg-elev-hover);
  color: var(--nc-text);
}

.nc-pill-btn:disabled { opacity: 0.55; cursor: default; }

.nc-pill-btn.is-active {
  border-color: var(--line-strong);
  background: var(--scrim-soft);
  color: var(--nc-brand-light);
}

.nc-pill-btn--icon {
  width: 36px;
  padding: 0;
  justify-content: center;
  margin-left: auto;
}

/* ── Category tab rail ────────────────────────────────────────────────── */
.nc-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 20px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  border-bottom: 1px solid var(--nc-line-soft);
}

.nc-tabs::-webkit-scrollbar { display: none; }

.nc-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--nc-text-muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.nc-tab i { font-size: 15px; color: var(--nc-accent, var(--nc-brand-light)); opacity: 0.85; }

.nc-tab:hover { color: var(--nc-text-soft); background: var(--nc-bg-elev); }

.nc-tab.is-active {
  color: var(--nc-text);
  background: var(--scrim-soft);
  border-color: var(--line-strong);
}

.nc-tab.is-active i { opacity: 1; }

.nc-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--fill-mid);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ── Body / list ──────────────────────────────────────────────────────── */
.nc-body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  /* The list must never become a horizontal scroller — cards wrap and clamp
     instead (see .notif-title / .notif-message below). */
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 12px 16px 18px;
}

.nc-body::-webkit-scrollbar { display: none; }

/* `minmax(0, 1fr)`, not the implicit `auto` track: an auto track is floored at
   the card's min-content width, so one long unbreakable line would push the
   whole list wider than the modal. */
.nc-modal .notifications-list {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

/* Per-category accent, set on both cards and tabs */
.nc-accent-violet { --nc-accent: #575757; --nc-accent-bg: rgba(119, 119, 119, 0.14); --nc-accent-line: rgba(119, 119, 119, 0.34); }
.nc-accent-cyan   { --nc-accent: #717171; --nc-accent-bg: rgba(133, 133, 133, 0.13); --nc-accent-line: rgba(133, 133, 133, 0.32); }
.nc-accent-gold   { --nc-accent: #d79000; --nc-accent-bg: rgba(187, 125, 0, 0.14); --nc-accent-line: rgba(187, 125, 0, 0.34); }
.nc-accent-pink   { --nc-accent: #606060; --nc-accent-bg: rgba(119, 119, 119, 0.14); --nc-accent-line: rgba(119, 119, 119, 0.34); }
.nc-accent-slate  { --nc-accent: #616161; --nc-accent-bg: rgba(0, 0, 0, 0.07); --nc-accent-line: rgba(0, 0, 0, 0.16); }

.nc-modal .notif-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  padding: 14px 14px 12px 26px;
  border: 1px solid var(--nc-line-soft);
  border-radius: 16px;
  background: var(--nc-bg-elev);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.nc-modal .notif-item:hover {
  background: var(--nc-bg-elev-hover);
  border-color: var(--nc-accent-line, var(--nc-line));
}

.nc-modal .notif-item:active { transform: scale(0.995); }

.nc-modal .notif-item.notif-unread {
  background: linear-gradient(180deg, var(--nc-accent-bg, rgba(119, 119, 119, 0.12)), rgba(0, 0, 0, 0.02));
  border-color: var(--nc-accent-line, rgba(119, 119, 119, 0.3));
}

/* Collapse-out when deleted */
.nc-modal .notif-item.is-removing {
  opacity: 0;
  transform: translateX(14px) scale(0.98);
  pointer-events: none;
}

/* Unread dot, pinned to the card's left gutter */
.nc-modal .notif-dot {
  position: absolute;
  top: 22px;
  left: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fill-mid);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.nc-modal .notif-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--nc-accent-line, var(--nc-line));
  background: var(--nc-accent-bg, rgba(0, 0, 0, 0.05));
  color: var(--nc-accent, var(--nc-brand-light));
  font-size: 17px;
}

.nc-modal .notif-thumb {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
}

/* A CHARACTER's message is a different kind of card from "your payout cleared".
   The rounded square is a thumbnail of a thing; a person gets a face. Set by
   `data.kind === 'character_message'` in renderNotificationList()
   (views/partials/dashboard-avatar.hbs) — the same flag the live card in
   public/js/character-notice.js reads. See docs/NOTIFICATION_SYSTEM.md. */
.nc-modal .notif-item.nc-character .notif-thumb {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  overflow: hidden;
}

.nc-modal .notif-item.nc-character .notif-thumb img {
  border-radius: 50%;
}

/* The name leads, because the name is who is talking. */
.nc-modal .notif-item.nc-character .notif-title {
  font-weight: 700;
}

/* The line is what they said — quoted, not reported. */
.nc-modal .notif-item.nc-character .notif-message {
  font-style: italic;
}

.nc-modal .notif-content { flex: 1; min-width: 0; }

.nc-meta-row,
.nc-modal .notif-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 3px;
}

.nc-modal .notif-category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--nc-accent, var(--nc-brand-light));
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nc-modal .notif-time {
  font-size: 11.5px;
  color: var(--nc-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Title + message are clamped when collapsed. `overflow-wrap: anywhere` is load
   bearing, not cosmetic: it lets a long word contribute a small min-content
   width, so a card can always shrink to the modal instead of widening it.
   (The legacy .notif-title in dashboard-avatar.css is `white-space: nowrap` —
   that made the card's min-content the full title width and blew the list out
   sideways, which is what turned this into a horizontal scroller.) */
.nc-modal .notif-title {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--nc-text);
  line-height: 1.35;
  margin-bottom: 3px;
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.nc-modal .notif-message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--nc-text-soft);
  overflow-wrap: anywhere;
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Expanded card: full title + message, no clamp. */
.nc-modal .notif-item.is-expanded .notif-title,
.nc-modal .notif-item.is-expanded .notif-message {
  display: block;
  -webkit-line-clamp: none;
  overflow: visible;
}

.nc-modal .notif-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.nc-link-btn,
.nc-more-btn,
.nc-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--nc-text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

/* "More" sits on the left of the row; Open / Delete stay right. It only exists
   for cards whose text is actually clipped (JS adds .is-clipped). */
.nc-more-btn {
  margin-right: auto;
  padding-left: 0;
}

.nc-modal .notif-item:not(.is-clipped):not(.is-expanded) .nc-more-btn { display: none; }

.nc-more-btn:hover { color: var(--nc-brand-light); }

.nc-more-btn i { transition: transform 0.18s ease; }

.nc-modal .notif-item.is-expanded .nc-more-btn i { transform: rotate(180deg); }

.nc-link-btn:hover {
  background: var(--scrim-soft);
  border-color: var(--line-strong);
  color: var(--nc-brand-light);
}

.nc-delete-btn:hover {
  background: var(--scrim-soft);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.nc-modal .notifications-empty { padding: 56px 20px; color: var(--nc-text-muted); }
.nc-modal .notifications-empty i { font-size: 38px; opacity: 0.35; }

/* ── Settings sheet ───────────────────────────────────────────────────── */
.nc-set-group {
  border: 1px solid var(--nc-line-soft);
  border-radius: 18px;
  background: var(--glass);
  padding: 6px 14px 8px;
  margin-bottom: 14px;
}

.nc-set-group-title {
  margin: 12px 2px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nc-brand-light);
}

.nc-set-group-note {
  margin: 0 2px 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--nc-text-muted);
}

.nc-set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
  border-top: 1px solid var(--nc-line-soft);
}

.nc-set-row:first-of-type { border-top: none; }

.nc-set-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--nc-accent-line, var(--nc-line));
  background: var(--nc-accent-bg, rgba(0, 0, 0, 0.05));
  color: var(--nc-accent, var(--nc-brand-light));
  font-size: 16px;
}

.nc-set-text { flex: 1; min-width: 0; }

.nc-set-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--nc-text);
  margin-bottom: 2px;
}

.nc-set-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--glass-strong);
  color: var(--nc-text-soft);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}

.nc-set-desc {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--nc-text-muted);
}

.nc-set-control { flex: 0 0 auto; }

.nc-required-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(119, 119, 119, 0.55);
  border-radius: 999px;
  color: var(--nc-brand-light);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Toggle switch */
.nc-switch {
  position: relative;
  width: 52px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--glass-strong);
  cursor: pointer;
  transition: background 0.22s ease;
}

.nc-switch.is-on { background: var(--nc-grad); }

.nc-switch:disabled { opacity: 0.6; cursor: default; }

.nc-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-fill);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.nc-switch.is-on .nc-switch-knob { transform: translateX(22px); }

/* Retention block */
.nc-retention { padding: 2px 2px 8px; }

.nc-retention-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px dashed var(--nc-line-soft);
}

.nc-retention-row:first-child { border-top: none; }

.nc-retention-label {
  font-size: 13px;
  color: var(--nc-text-muted);
}

.nc-retention-value {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--nc-text);
  white-space: nowrap;
}

/* ── Small screens ────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  #userNotificationsModal .modal-dialog {
    width: 100%;
    max-width: 100%;
    max-height: none;
    margin: 0;
    align-items: flex-end;
    min-height: 100%;
  }

  #userNotificationsModal .notifications-modal-content {
    border-radius: 22px 22px 0 0;
    max-height: 92vh;
    border-bottom: none;
  }

  .nc-head { padding: 16px 16px 12px; }
  .nc-title { font-size: 19px; }
  .nc-toolbar { padding: 0 16px 10px; }
  .nc-tabs { padding: 2px 16px 12px; }
  .nc-body { padding: 12px 12px 20px; }
  .nc-modal .notif-item { padding: 13px 12px 11px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .nc-modal *,
  .nc-modal *::before,
  .nc-modal *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
