/* ---------------------------------------------------------------------------
   Notifications: the bell in the top bar and its panel
   ---------------------------------------------------------------------------
   The bell is the gear's twin (a plain glyph on the bar, grey wash on hover)
   and sits 4px from it, a hairline away from the search field, so the two
   read as one set at the right of the bar. Its count is a small
   coral disc on its corner, the app's accent for "something for you". The
   panel hangs under it like the account menu, and its rows sit straight on it
   split by hairlines: a face with the channel's mark on its corner, who and
   what in a line, the company and the opening words under it, the time at the
   end. New rows carry a coral dot. App: app/notifications.js.
   --------------------------------------------------------------------------- */

.bell { position: relative; flex: 0 0 auto; margin-right: -16px; padding-left: 13px }
.bell::before {
  content: ""; position: absolute; left: 0; top: 50%; translate: 0 -50%;
  width: 1px; height: 20px; background: var(--hair);
}

.bellbtn {
  position: relative; display: grid; place-items: center;
  width: var(--control-h); height: var(--control-h); box-sizing: border-box; padding: 0;
  border-radius: var(--r-btn); cursor: pointer;
  background-color: var(--card);
  border: 1px solid transparent;
  color: color-mix(in srgb, var(--text) 72%, var(--card));
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .14s var(--ease-out);
}
.bellbtn .ms { font-size: 21px; color: inherit }
.bellbtn:hover, .bellbtn[aria-expanded="true"] {
  background-color: color-mix(in srgb, var(--text) 6%, var(--card)); color: var(--text);
}
.bellbtn:active { transform: scale(.97) }
.bellbtn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px }
.bellbtn__n {
  position: absolute; top: 1px; right: 0; pointer-events: none;
  min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
  border-radius: var(--r-pill); background: var(--coral); color: var(--on-coral);
  box-shadow: 0 0 0 2px var(--card);
  font-size: 11px; font-weight: var(--weight-strong); line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.bellpanel {
  position: absolute; top: calc(100% + 12px); right: 0; z-index: 25;
  width: 380px; max-height: calc(var(--vh) * .7);
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-top);
  animation: cdRise .16s ease both;
}
.bellpanel[hidden] { display: none }
.bellpanel__head { padding: 16px 18px 6px }
.bellpanel__head h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--text) }
.bellpanel__list { overflow-y: auto; padding: 0 6px 6px; overscroll-behavior: contain }

.bellpanel__group {
  padding: 12px 12px 4px; font-size: 12.5px; font-weight: 500; color: var(--muted);
}

.bellrow {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border-radius: 12px; cursor: pointer;
  border-top: 1px solid var(--hair);
}
.bellpanel__group + .bellrow { border-top-color: transparent }
.bellrow:hover { background: var(--page) }
.bellrow:hover, .bellrow:hover + .bellrow { border-top-color: transparent }
.bellrow:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px }

.bellrow__face { position: relative; flex: 0 0 36px; width: 36px; height: 36px }
.bellrow__photo {
  width: 36px; height: 36px; border-radius: var(--r-pill);
  display: grid; place-items: center; overflow: hidden;
  background: var(--page); color: var(--text);
  font-size: 12.5px; font-weight: 600;
}
.bellrow__channel {
  position: absolute; right: -3px; bottom: -3px;
  display: grid; place-items: center; width: 18px; height: 18px;
  border-radius: var(--r-pill); background: var(--card); color: var(--muted);
  box-shadow: 0 0 0 1px var(--hair);
}

.bellrow__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px }
.bellrow__who { font-size: 14px; color: var(--text); text-wrap: pretty }
.bellrow__who b { font-weight: 600 }
.bellrow__meta {
  font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bellrow__end {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  padding-top: 2px;
}
.bellrow__when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap }
.bellrow__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral) }
.bellrow.is-new .bellrow__when { color: var(--text); font-weight: 600 }

.bellpanel__none, .bellpanel__wait {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 36px 16px 40px; font-size: 13px; color: var(--muted);
}
.bellpanel__none .ms, .bellpanel__wait .ms { font-size: 28px; opacity: .6 }

/* On a phone the bar is ink, so the bell takes the gear's wash of the
   foreground colour, and the panel spans the screen under the bar. */
@media (max-width: 900px) {
  .bell { margin-right: 0; padding-left: 0 }
  .bell::before { content: none }
  .bellbtn, .bellbtn:hover, .bellbtn[aria-expanded="true"] {
    width: 40px; height: 40px;
    background: color-mix(in srgb, var(--on-ink) 12%, transparent);
    border-color: color-mix(in srgb, var(--on-ink) 18%, transparent);
    color: var(--on-ink);
  }
  .bellbtn__n { box-shadow: none }
  .bellpanel {
    position: fixed; left: 12px; right: 12px; width: auto;
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + 8px);
    max-height: calc(100dvh - var(--topbar-h) - 120px);
  }
  .topbar .search[data-open="1"] ~ .bell { display: none }
}

@media (prefers-reduced-motion: reduce) {
  .bellpanel { animation: none }
  .bellbtn { transition: none }
}
