/* The notification centre (notifications.js): the sidebar bell, the
   panel it opens and the pop-ups for new notifications. Loaded on every
   page; uses the tokens from _head.html, so body.theme-dark follows. */

/* ─── The bell, in the sidebar's brand row ─────────────────────── */
.sidebar .brand .nc-bell { margin-left: auto; }
.nc-bell {
  position: relative; flex: none;
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  color: #cbd5e1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .15s ease;
}
.nc-bell[hidden] { display: none; }
.nc-bell:hover { background: rgba(255,255,255,.10); color: #fff; }
.nc-bell:active { transform: scale(.94); }
.nc-bell:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(96,165,250,.45); }
.nc-bell[aria-expanded="true"] { background: rgba(124,58,237,.30); border-color: rgba(167,139,250,.5); color: #fff; }
.nc-bell .icon { width: 18px; height: 18px; }
.nc-bell.has-unread { color: #fff; }
.nc-bell.is-ringing .icon { animation: nc-ring 1.1s ease-in-out 2; transform-origin: 50% 8%; }
@keyframes nc-ring {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(16deg); } 30% { transform: rotate(-14deg); }
  45% { transform: rotate(10deg); } 60% { transform: rotate(-6deg); } 75% { transform: rotate(3deg); }
}
.nc-badge {
  position: absolute; top: -6px; right: -7px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  font: 700 10.5px/1 var(--font-mono, ui-monospace, monospace);
  color: #fff;
  background: linear-gradient(135deg, #f43f5e 0%, #dc2626 100%);
  box-shadow: 0 0 0 2px var(--side-bg-from, #0b1220), 0 4px 10px -2px rgba(220,38,38,.6);
}
.nc-badge[hidden] { display: none; }
.nc-bell.is-ringing .nc-badge { animation: nc-pop .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes nc-pop { 0% { transform: scale(.4); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }
.nc-bell.has-unread::after {
  content: ''; position: absolute; inset: -1px; border-radius: 11px; pointer-events: none;
  box-shadow: 0 0 0 0 rgba(244,63,94,.45);
  animation: nc-pulse 2.8s ease-out infinite;
}
@keyframes nc-pulse { 0% { box-shadow: 0 0 0 0 rgba(244,63,94,.40); } 70%, 100% { box-shadow: 0 0 0 9px rgba(244,63,94,0); } }
@media (max-width: 768px) { .sidebar .brand .nc-bell { margin-left: 8px; } }

/* ─── The panel ─────────────────────────────────────────────────── */
html.nc-open { overflow: hidden; }
.nc-root { position: fixed; inset: 0; z-index: 1200; }
.nc-root[hidden] { display: none; }
.nc-backdrop {
  position: absolute; inset: 0;
  background: rgba(2,6,23,.38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .28s ease;
}
.nc-root.is-open .nc-backdrop { opacity: 1; }
.nc-drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(460px, 100vw);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border-2);
  box-shadow: -24px 0 60px -20px rgba(2,6,23,.45);
  transform: translateX(104%);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.nc-root.is-open .nc-drawer { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
  .nc-drawer, .nc-backdrop { transition: none; }
  .nc-bell.is-ringing .icon, .nc-bell.has-unread::after { animation: none; }
}

.nc-head {
  padding: 18px 18px 0;
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(124,58,237,.10) 0%, transparent 60%),
    var(--surface);
  border-bottom: 1px solid var(--divider);
}
.nc-head-top { display: flex; align-items: center; gap: 12px; }
.nc-title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.nc-title-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  box-shadow: 0 10px 22px -10px rgba(124,58,237,.7), inset 0 1px 0 rgba(255,255,255,.2);
}
.nc-title-icon .icon { width: 18px; height: 18px; }
.nc-head h2 { margin: 0; font-family: var(--font-display); font-size: 17px; font-weight: 650; color: var(--ink); letter-spacing: -.01em; }
.nc-count { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; color: #7c3aed; }
.nc-count.is-zero { color: var(--text-3); font-weight: 500; }
.nc-head-actions { display: flex; gap: 4px; }
.nc-iconbtn {
  width: 34px; height: 34px; padding: 0; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  cursor: pointer; text-decoration: none;
  transition: background .15s ease, color .15s ease;
}
.nc-iconbtn[hidden] { display: none; }
.nc-iconbtn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nc-iconbtn:disabled { opacity: .35; cursor: default; background: transparent; }
.nc-iconbtn:focus-visible, .nc-tab:focus-visible, .nc-act:focus-visible, .nc-item-main:focus-visible, .nc-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 3px rgba(124,58,237,.30);
}
.nc-iconbtn .icon { width: 17px; height: 17px; }

.nc-tabs { position: relative; display: flex; gap: 4px; margin-top: 14px; }
.nc-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 12px 11px; border: 0; background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-3);
  border-radius: 8px 8px 0 0;
  transition: color .15s ease;
}
.nc-tab:hover { color: var(--ink); }
.nc-tab.is-active { color: var(--ink); }
.nc-tab-n {
  min-width: 18px; padding: 1px 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center;
  background: var(--surface-2); color: var(--text-2);
}
.nc-tab-n[hidden] { display: none; }
.nc-tab.is-active .nc-tab-n { background: rgba(124,58,237,.14); color: #6d28d9; }
.nc-tab-ink {
  position: absolute; left: 0; bottom: -1px; height: 2.5px; width: 0;
  border-radius: 2px; background: linear-gradient(90deg, #8b5cf6, #6d28d9);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), width .25s cubic-bezier(.2,.8,.2,1);
}

.nc-fresh {
  position: absolute; left: 50%; top: 128px; z-index: 3; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; border: 0; cursor: pointer;
  font-size: 12.5px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  box-shadow: 0 10px 24px -8px rgba(124,58,237,.6);
  animation: nc-pop .4s cubic-bezier(.3,1.6,.5,1);
}
.nc-fresh[hidden] { display: none; }
.nc-fresh .icon { width: 13px; height: 13px; }
.nc-list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 14px 18px;
  background: var(--surface-1);
}
.nc-group { margin-top: 12px; }
.nc-day {
  position: sticky; top: -6px; z-index: 1;
  margin: 0 0 8px; padding: 8px 4px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3);
  background: linear-gradient(var(--surface-1) 70%, transparent);
}

.nc-item {
  position: relative; display: flex; gap: 6px;
  margin-bottom: 8px; padding: 12px 10px 12px 16px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease, opacity .24s ease, height .24s ease, margin .24s ease, padding .24s ease;
  overflow: hidden;
}
.nc-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--text-mute); opacity: .55;
}
.nc-item.sev-critical::before { background: var(--crit); opacity: 1; }
.nc-item.sev-high::before { background: linear-gradient(180deg, #f97316, #dc2626); opacity: 1; }
.nc-item.sev-medium::before { background: var(--med); opacity: 1; }
.nc-item.sev-low::before { background: var(--low); opacity: 1; }
.nc-item:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.nc-item.is-unread { background: linear-gradient(90deg, rgba(124,58,237,.06), transparent 55%), var(--surface); border-color: rgba(124,58,237,.22); }
.nc-item.is-read, .nc-item.is-dismissed { box-shadow: none; }
.nc-item.is-dismissed { opacity: .82; }
.nc-item.is-leaving { opacity: 0; transform: translateX(30px); height: 0 !important; margin: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
.nc-item.is-flash { animation: nc-flash 1.6s ease; }
@keyframes nc-flash { 0%, 40% { box-shadow: 0 0 0 3px rgba(124,58,237,.45); } 100% { box-shadow: var(--shadow-sm); } }
.nc-item-main { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; }
.nc-item-top { display: flex; align-items: center; gap: 8px; }
.nc-src {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  background: #ede9fe; color: #6d28d9;
}
.nc-src .icon { width: 12px; height: 12px; }
.nc-sev { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--crit-deep); }
.nc-time { margin-left: auto; font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.nc-unread-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.18); }
.nc-item-title { margin-top: 7px; font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.nc-item.is-unread .nc-item-title { font-weight: 700; }
.nc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.nc-signal {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; color: var(--crit-deep); background: var(--crit-soft);
}
.nc-signal .icon { width: 11px; height: 11px; }
.nc-tag { padding: 2px 8px; border-radius: 999px; font: 600 11px var(--font-mono, monospace); color: var(--brand-deep); background: var(--brand-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-body {
  margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.nc-item.is-expanded .nc-body { -webkit-line-clamp: unset; display: block; max-height: 420px; overflow-y: auto; color: var(--text); }
.nc-meta { display: none; margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--border-2); }
.nc-item.is-expanded .nc-meta { display: block; }
.nc-meta-row { display: flex; gap: 10px; font-size: 12px; line-height: 1.7; }
.nc-meta-row > span:first-child { flex: none; width: 92px; color: var(--text-3); }
.nc-meta-row > span:last-child { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.nc-open-link { display: inline-flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 12.5px; font-weight: 600; color: #7c3aed; }
.nc-open-link .icon { width: 13px; height: 13px; }
.nc-item-actions {
  display: flex; flex-direction: column; gap: 4px;
  opacity: 0; transition: opacity .15s ease;
}
.nc-item:hover .nc-item-actions, .nc-item:focus-within .nc-item-actions, .nc-item.is-expanded .nc-item-actions { opacity: 1; }
@media (hover: none) { .nc-item-actions { opacity: 1; } }
.nc-act {
  width: 30px; height: 30px; padding: 0; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.nc-act:hover { background: var(--brand-soft); color: var(--brand-deep); border-color: rgba(37,99,235,.3); }
.nc-act.is-dismiss:hover { background: var(--crit-soft); color: var(--crit-deep); border-color: rgba(220,38,38,.3); }
.nc-act .icon { width: 14px; height: 14px; }

.nc-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 56px 24px; color: var(--text-3); font-size: 13px; }
.nc-empty strong { color: var(--ink); font-size: 15px; }
.nc-empty-icon {
  width: 64px; height: 64px; margin-bottom: 8px; border-radius: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #7c3aed; background: radial-gradient(circle at 30% 30%, #f5f3ff, #ede9fe);
  box-shadow: inset 0 0 0 1px rgba(124,58,237,.18);
}
.nc-empty-icon .icon { width: 28px; height: 28px; }
.nc-skel { padding-top: 14px; }
.nc-skel-card {
  height: 92px; margin-bottom: 8px; border-radius: 13px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: nc-shimmer 1.3s ease infinite;
}
@keyframes nc-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.nc-sentinel { height: 1px; }
.nc-more { display: block; margin: 8px auto 0; }

.nc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.nc-btn:hover { background: var(--surface-1); border-color: var(--border-strong); }
.nc-btn.is-primary { background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%); border-color: transparent; color: #fff; }
.nc-btn.is-primary:hover { filter: brightness(1.06); }

.nc-undo {
  position: absolute; left: 14px; right: 14px; bottom: 54px;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 12px 10px 16px; border-radius: 12px;
  font-size: 13px; color: #f8fafc; background: #0f172a;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease;
}
.nc-undo[hidden] { display: none; }
.nc-undo.is-in { opacity: 1; transform: translateY(0); }
.nc-undo > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-undo .nc-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }

.nc-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-top: 1px solid var(--divider);
  font-size: 11.5px; color: var(--text-3); background: var(--surface);
}
.nc-foot-bar { flex: 1; height: 4px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.nc-foot-bar > i { display: block; height: 100%; min-width: 3px; border-radius: 3px; background: linear-gradient(90deg, #22c55e, #06b6d4); }

/* ─── Pop-ups ───────────────────────────────────────────────────── */
.nc-toasts {
  position: fixed; top: 18px; right: 18px; z-index: 1300;
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.nc-toast {
  position: relative; overflow: hidden; pointer-events: auto;
  padding: 13px 14px 14px 18px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--border-2);
  box-shadow: 0 22px 48px -18px rgba(2,6,23,.45), 0 4px 12px -4px rgba(2,6,23,.15);
  opacity: 0; transform: translateX(28px) scale(.97);
  transition: opacity .3s ease, transform .38s cubic-bezier(.2,1.2,.3,1);
}
.nc-toast.is-in { opacity: 1; transform: none; }
.nc-toast.is-leaving { opacity: 0; transform: translateX(28px) scale(.97); }
.nc-toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--med); }
.nc-toast.sev-high::before, .nc-toast.sev-critical::before { background: linear-gradient(180deg, #f97316, #dc2626); }
.nc-toast-head { display: flex; align-items: center; gap: 8px; }
.nc-prio { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--crit-deep); }
.nc-toast-x {
  margin-left: auto; width: 26px; height: 26px; padding: 0; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--text-3); cursor: pointer;
}
.nc-toast-x:hover { background: var(--surface-2); color: var(--ink); }
.nc-toast-x .icon { width: 14px; height: 14px; }
.nc-toast-title { margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--ink); }
.nc-toast-body { margin-top: 4px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nc-toast-actions { display: flex; gap: 8px; margin-top: 11px; }
.nc-toast-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.nc-toast-timer > i { display: block; height: 100%; transform-origin: left; background: linear-gradient(90deg, #8b5cf6, #06b6d4); opacity: .7; }
.nc-toast-more {
  display: flex; align-items: center; gap: 8px; width: 100%;
  font-size: 13px; font-weight: 600; color: var(--ink); text-align: left; cursor: pointer;
}
.nc-toast-more .icon { width: 15px; height: 15px; color: #7c3aed; }
@media (max-width: 768px) { .nc-toasts { top: auto; bottom: 16px; right: 16px; } }
@media print { .nc-toasts, .nc-root, .nc-bell { display: none !important; } }

/* ─── Dark ──────────────────────────────────────────────────────── */
body.theme-dark .nc-drawer { box-shadow: -24px 0 60px -20px rgba(0,0,0,.7); }
body.theme-dark .nc-head { background: radial-gradient(140% 120% at 100% 0%, rgba(139,92,246,.18) 0%, transparent 60%), var(--surface); }
body.theme-dark .nc-count { color: #c4b5fd; }
body.theme-dark .nc-src { background: rgba(167,139,250,.18); color: #ddd6fe; }
body.theme-dark .nc-tab.is-active .nc-tab-n { background: rgba(167,139,250,.22); color: #ddd6fe; }
body.theme-dark .nc-item.is-unread { background: linear-gradient(90deg, rgba(139,92,246,.12), transparent 55%), var(--surface); border-color: rgba(167,139,250,.30); }
body.theme-dark .nc-unread-dot { background: #a78bfa; }
body.theme-dark .nc-signal, body.theme-dark .nc-prio, body.theme-dark .nc-sev { color: #fecaca; }
body.theme-dark .nc-tag { color: #bfdbfe; }
body.theme-dark .nc-open-link { color: #c4b5fd; }
body.theme-dark .nc-empty-icon { background: rgba(139,92,246,.16); color: #c4b5fd; }
body.theme-dark .nc-undo { background: #e2e8f0; color: #0f172a; }
body.theme-dark .nc-undo .nc-btn { background: rgba(15,23,42,.08); border-color: rgba(15,23,42,.2); color: #0f172a; }
