/* ============================================================
   notification-shell.css — "Notification Shell" (nf-shell)
   Used by pages/notifications.html AND the header notification
   drop-down in js/shared-header.js (compact density).

   Four stacked zones inside <main class="nf-shell">:
     nf-identity     — h1 + unread/updated status
     nf-controlzone  — sticky: tabs + unread toggle + filter + mark all
     nf-listhead     — time bucket label + bucket actions
     nf-ledger       — the rows

   ONE row component (.nf-row) at two densities:
     .nf-row                — comfortable (page)
     .nf-row.nf-row--compact — drop-down

   Tokens: the neutral --ss-* scale from css/series-shell.css, which
   MUST be loaded before this file. No purple, no per-page palette.
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32 / 48px only.
   ============================================================ */

/* ---------- Shell frame ---------- */
.nf-shell {
  max-width: var(--ss-max, 1120px);
  margin: 0 auto;
  padding: 0 16px 48px;
  color: var(--ss-text);
}
.nf-shell *,
.nf-shell *::before,
.nf-shell *::after { box-sizing: border-box; }

.nf-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- Zone 1: identity strip ---------- */
.nf-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 24px 0 12px;
}
.nf-h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ss-text);
}
.nf-sub {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ss-text-muted);
}
.nf-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ss-text-muted);
}

/* ---------- Buttons: one neutral set (no purple) ---------- */
.nf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--ss-ghost-fg);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.nf-btn:hover { background: var(--ss-ghost-bg-hover); color: var(--ss-text); }
.nf-btn:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: 2px; }
.nf-btn[disabled] { opacity: .5; cursor: not-allowed; }
.nf-btn--ghost {
  border-color: var(--ss-border);
  background: var(--ss-surface);
}
.nf-btn--solid {
  background: var(--ss-primary-bg);
  color: var(--ss-primary-fg);
  border-color: transparent;
}
.nf-btn--solid:hover { background: var(--ss-primary-bg-hover); color: var(--ss-primary-fg); }
.nf-btn--sm { min-height: 32px; padding: 0 10px; font-size: 13px; }

/* ---------- Zone 2: sticky control zone ---------- */
.nf-controlzone {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0 12px;
  background: var(--ss-bg);
  border-bottom: 1px solid var(--ss-border);
}
.nf-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
}
.nf-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ss-text-muted);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.nf-tab:hover { color: var(--ss-text); background: var(--ss-ghost-bg-hover); }
.nf-tab.is-active { background: var(--ss-primary-bg); color: var(--ss-primary-fg); }
.nf-tab:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: 2px; }
.nf-tab-count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: .8;
}

.nf-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nf-find {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  min-width: 200px;
  padding: 0 12px;
  background: var(--ss-surface);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  color: var(--ss-text-muted);
}
.nf-find:focus-within { border-color: var(--ss-border-strong); }
.nf-find input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  color: var(--ss-text);
}
.nf-find input::placeholder { color: var(--ss-text-muted); }

.nf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  background: var(--ss-surface);
  font-size: 14px;
  color: var(--ss-text-muted);
  cursor: pointer;
  user-select: none;
}
.nf-toggle input { accent-color: var(--ss-text); margin: 0; }
.nf-toggle.is-on { color: var(--ss-text); border-color: var(--ss-border-strong); }

/* ---------- Zone 3: list head (time bucket) ---------- */
.nf-listhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 8px;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ss-text-muted);
  background: var(--ss-bg);
}
.nf-listhead-count {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

/* ---------- Zone 4: the ledger ---------- */
.nf-ledger {
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--ss-surface);
}
.nf-ledger + .nf-listhead { margin-top: 8px; }

/* ---------- The shared row component ---------- */
.nf-row {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-areas: "media body actions";
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--ss-border);
  background: transparent;
  text-align: left;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.nf-row:last-child { border-bottom: 0; }
.nf-row:hover { background: var(--ss-surface-2); }
.nf-row:focus-visible { outline: 2px solid var(--ss-border-strong); outline-offset: -2px; }

/* Unread = left rail + dot. Same height as a read row: no jump. */
.nf-row--unread::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ss-border-strong);
}
.nf-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ss-text);
}

/* Media slot */
.nf-media {
  grid-area: media;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--ss-surface-2);
  border: 1px solid var(--ss-border);
  color: var(--ss-text-muted);
  font-size: 14px;
}
.nf-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nf-media--avatar { width: 40px; height: 40px; border-radius: 999px; }
.nf-media--glyph { width: 40px; height: 40px; border-radius: 8px; }

/* Body: subject / context / meta — fixed anatomy */
.nf-body { grid-area: body; min-width: 0; }
.nf-body > * { display: block; }
.nf-subject {
  font-size: 15px;
  font-weight: 600;
  color: var(--ss-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-context {
  margin-top: 2px;
  font-size: 13px;
  color: var(--ss-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nf-quote {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ss-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
}
.nf-metaline {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ss-text-muted);
}
.nf-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border: 1px solid var(--ss-border);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--ss-text-muted);
  background: var(--ss-bg);
}
.nf-edited { font-size: 11px; opacity: .8; }

/* Actions */
.nf-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
.nf-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ss-ghost-fg);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease, color 120ms ease;
}
.nf-row:hover .nf-iconbtn,
.nf-row:focus-within .nf-iconbtn { opacity: 1; }
.nf-iconbtn:hover { background: var(--ss-secondary-bg-hover); color: var(--ss-text); }
.nf-iconbtn:focus-visible { opacity: 1; outline: 2px solid var(--ss-border-strong); outline-offset: 1px; }

/* Touch devices have no hover: keep the actions permanently visible. */
@media (hover: none) {
  .nf-iconbtn {
    opacity: 1;
    background: var(--ss-surface);
    border-color: var(--ss-border);
  }
}

/* ---------- Compact density: the header drop-down ---------- */
.nf-row--compact {
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 48px;
  padding: 10px 12px;
}
.nf-row--compact .nf-media { width: 36px; height: 36px; border-radius: 6px; }
.nf-row--compact .nf-media--avatar { border-radius: 999px; }
.nf-row--compact .nf-subject { font-size: 13px; }
.nf-row--compact .nf-context { font-size: 12px; }
.nf-row--compact .nf-quote { font-size: 12px; -webkit-line-clamp: 1; }
.nf-row--compact .nf-metaline { font-size: 11px; margin-top: 2px; }
.nf-row--compact .nf-quote,
.nf-row--compact .nf-tag { display: none; }
.nf-row--compact .nf-iconbtn { width: 28px; height: 28px; font-size: 11px; }

/* ---------- States ---------- */
.nf-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--ss-text-muted);
  font-size: 14px;
}
.nf-empty i { font-size: 20px; display: block; margin-bottom: 12px; }
.nf-empty p { margin: 0 0 4px; }
.nf-empty--compact { padding: 32px 16px; font-size: 13px; }

.nf-skeleton {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ss-border);
}
.nf-skeleton:last-child { border-bottom: 0; }
.nf-skeleton span {
  display: block;
  height: 12px;
  border-radius: 4px;
  background: var(--ss-surface-2);
  animation: nf-pulse 1.2s ease-in-out infinite;
}
.nf-skeleton span.nf-skeleton-media { height: 64px; border-radius: 6px; }
.nf-skeleton--compact { grid-template-columns: 36px minmax(0, 1fr) 40px; padding: 10px 12px; }
.nf-skeleton--compact span.nf-skeleton-media { height: 36px; }
@keyframes nf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  .nf-skeleton span { animation: none; }
  .nf-row, .nf-btn, .nf-iconbtn { transition: none; }
}

/* ---------- Drop-down shell (header) ---------- */
.yv-notif-wrap { position: relative; display: inline-flex; align-items: center; }
.nf-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: var(--z-dropdown, 900);
  width: min(400px, calc(100vw - 24px));
  background: var(--ss-bg);
  border: 1px solid var(--ss-border);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
  overflow: hidden;
  color: var(--ss-text);
}
.nf-pop[hidden] { display: none; }
.nf-pop *, .nf-pop *::before, .nf-pop *::after { box-sizing: border-box; }
.nf-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ss-border);
  background: var(--ss-surface);
}
.nf-pop-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ss-text);
}
.nf-pop-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--ss-text-muted);
}
.nf-pop-list {
  max-height: min(58vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--ss-surface);
}
.nf-pop-foot {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--ss-border);
  background: var(--ss-bg);
}
.nf-pop-foot .nf-btn { flex: 1; min-height: 36px; font-size: 13px; }

@media (max-width: 520px) {
  .nf-pop {
    position: fixed;
    top: var(--yv-notif-top, 68px);
    right: 12px;
    left: 12px;
    width: auto;
  }
  .nf-pop-list { max-height: min(60vh, 420px); }
}

/* ---------- Mobile page density ---------- */
@media (max-width: 640px) {
  .nf-controlzone { align-items: stretch; }
  .nf-tabs { width: 100%; }
  .nf-tab { flex: 1; justify-content: center; padding: 0 8px; }
  .nf-toolbar { width: 100%; }
  .nf-find { flex: 1; min-width: 0; }
  .nf-row {
    grid-template-columns: 40px minmax(0, 1fr);
    grid-template-areas:
      "media body"
      "actions actions";
    padding: 12px;
    gap: 8px 12px;
  }
  .nf-media { width: 40px; height: 56px; }
  .nf-actions { justify-content: flex-end; }
}
