/* ============================================================
   Notifications — bell, dropdown panel and top banners
   (homepage). Light cream/glass theme, matches the main site.
   ============================================================ */

.notif-wrap { position: relative; display: inline-flex; }

/* ── Bell button ─────────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 40px; height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast), transform var(--transition-fast);
}
.notif-bell svg { width: 19px; height: 19px; }
.notif-bell:hover { background: var(--color-surface-glass-hover); color: var(--color-text-primary); border-color: var(--color-border-hover); }
.notif-bell:active { transform: scale(0.94); }
.notif-bell:focus-visible { outline: 2px solid var(--color-accent-primary); outline-offset: 2px; }
.notif-bell.has-unread { color: var(--color-accent-primary); }
.notif-bell.has-unread svg { animation: notif-bell-swing 2.4s ease-in-out 1; transform-origin: 50% 4px; }
@keyframes notif-bell-swing {
  0%, 100% { transform: rotate(0); }
  10% { transform: rotate(13deg); }
  20% { transform: rotate(-11deg); }
  30% { transform: rotate(8deg); }
  40% { transform: rotate(-5deg); }
  50% { transform: rotate(0); }
}

.notif-bell__badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--color-error);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--color-bg-primary);
}
.notif-bell__badge[hidden] { display: none; }

/* ── Dropdown popover ────────────────────────────────────── */
.notif-pop {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(384px, calc(100vw - 32px));
  background: var(--color-surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: var(--z-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(82vh, 620px);
}
.notif-pop.is-open { opacity: 1; transform: none; pointer-events: auto; }
.notif-pop__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
}
.notif-pop__title { font-size: 15px; font-weight: 700; color: var(--color-text-primary); }

/* ── Two independent scroll panes (Announcements / Activity) ──
   The top pane scrolls only official announcements, the bottom pane scrolls
   everything else. Each has its own overflow, so scrolling one never moves
   the divider between them — the boundary stays fixed. */
.notif-pop__panes { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.notif-pane { display: flex; flex-direction: column; min-height: 0; }
/* Top (announcements) sizes to its content, capped at a generous height and
   never squished (flex-shrink 0). Bottom (activity) fills the remaining space.
   Each scrolls internally, so the divider between them never moves on scroll. */
.notif-pane--ann { flex: 0 0 auto; }
.notif-pane--act { flex: 1 1 auto; }
/* Fixed divider between the two panes. */
.notif-pane + .notif-pane { border-top: 1px solid var(--color-border); }
.notif-section__label {
  flex: none;
  display: flex; align-items: center; gap: 7px;
  padding: 9px 16px 7px; font-size: 11px; font-weight: var(--font-weight-bold);
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--color-text-tertiary);
  background: var(--color-bg-primary, #fff);
}
.notif-section__label svg { width: 14px; height: 14px; opacity: 0.8; }
.notif-pane__scroll { overflow-y: auto; min-height: 0; padding: 0 6px 6px; }
/* Announcements: content height up to a generous cap (bigger than the feed's
   minimum share). Activity: fill whatever height its pane is given. */
.notif-pane--ann .notif-pane__scroll { max-height: min(46vh, 320px); }
.notif-pane--act .notif-pane__scroll { flex: 1; }
/* A lone pane (only one category present) uses the full available height. */
.notif-pane:only-child { flex: 1 1 auto; }
.notif-pane--ann:only-child .notif-pane__scroll { max-height: none; }

/* ── List item ───────────────────────────────────────────── */
.notif-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.notif-item + .notif-item { margin-top: 2px; }
.notif-item:hover { background: var(--color-bg-secondary); }
.notif-item.is-unread { background: rgba(0, 113, 227, 0.06); }
.notif-item.is-unread:hover { background: rgba(0, 113, 227, 0.1); }
.notif-item.is-reply { cursor: pointer; }
.notif-item__icon {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(0, 113, 227, 0.1);
  color: var(--color-accent-primary);
}
.notif-item.is-important .notif-item__icon { background: rgba(255, 59, 48, 0.12); color: var(--color-error); }
.notif-item.is-reply .notif-item__icon { background: rgba(52, 199, 89, 0.14); color: var(--color-success); }
.notif-item__icon svg { width: 17px; height: 17px; }
.notif-item__main { flex: 1; min-width: 0; }
.notif-item__title {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.35;
}
.notif-item__tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-error);
  background: rgba(255, 59, 48, 0.1);
  padding: 2px 6px;
  border-radius: 999px;
}
.notif-item__body {
  font-size: 12.5px;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.notif-item__meta {
  font-size: 11.5px;
  color: var(--color-text-tertiary);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notif-item__time { font-size: 11px; color: var(--color-text-tertiary); margin-top: 5px; }
.notif-item__dot {
  position: absolute;
  top: 15px; right: 12px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-accent-primary);
}

.notif-empty { text-align: center; padding: 42px 20px; color: var(--color-text-tertiary); }
.notif-empty svg { width: 40px; height: 40px; opacity: 0.5; margin-bottom: 10px; }
.notif-empty p { font-size: 13.5px; margin: 0; }

/* ── Top banners (important announcements) ───────────────── */
/* The navbar is fixed (var(--navbar-height)), so the first banner must
   clear it. When banners are present the homepage subjects-section no
   longer needs its own full navbar offset (see below), avoiding a double gap. */
.notif-banners { display: flex; flex-direction: column; gap: 10px; }
.notif-banners:not(:empty) {
  padding: calc(var(--navbar-height, 64px) + var(--spacing-md, 16px)) clamp(16px, 5vw, 48px) 0;
}
body.has-notif-banners .subjects-section { padding-top: var(--spacing-2xl, 48px); }
.notif-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 59, 48, 0.24);
  background: linear-gradient(135deg, rgba(255, 59, 48, 0.08), rgba(255, 149, 0, 0.06));
  box-shadow: var(--shadow-md);
  animation: notif-banner-in 0.4s var(--transition-smooth) both;
}
@keyframes notif-banner-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
.notif-banner.is-leaving { animation: notif-banner-out 0.25s ease forwards; overflow: hidden; }
@keyframes notif-banner-out { to { opacity: 0; transform: translateY(-8px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; } }
.notif-banner__icon {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255, 59, 48, 0.14);
  color: var(--color-error);
}
.notif-banner__icon svg { width: 19px; height: 19px; }
.notif-banner__main { flex: 1; min-width: 0; }
.notif-banner__title { font-size: 14.5px; font-weight: 700; color: var(--color-text-primary); word-break: break-word; }
.notif-banner__body {
  font-size: 13px;
  color: var(--color-text-secondary);
  line-height: 1.55;
  margin-top: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}
.notif-banner__close {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.notif-banner__close svg { width: 16px; height: 16px; }
.notif-banner__close:hover { background: rgba(0, 0, 0, 0.06); color: var(--color-text-primary); }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 520px) {
  .notif-pop {
    position: fixed;
    top: 66px;
    left: 16px;
    right: 16px;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notif-bell.has-unread svg,
  .notif-banner { animation: none; }
}
