/* The bell in the top bar (count, peek of the newest five Inbox items) and the admin pages of notification types.
   Author: Jeremiah Buttler. Colours are tokens only, so light and dark both work. */

/*
 * Class names in use:
 *   bell         the bell control in the top bar; bell-wrap = positioning box
 *   bell-btn     the round button (also its no-script link twin); bell-count = the number on it
 *   bell-panel   the peek under it (hidden attribute closes it); bell-head, bell-list, bell-item, bell-empty, bell-foot
 *   nt-*         the admin pages of notification types
 */

/* ------------------------------------------------------------------ the bell */

.bell { position: relative; display: flex; align-items: center; }
.bell-wrap { position: relative; display: flex; }
.bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg, 10px);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.bell-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell-btn:hover { border-color: var(--ink); }
.bell-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.bell-btn[hidden] { display: none; }
.bell-btn[aria-expanded="true"] { background: var(--st-live); border-color: var(--st-live); color: var(--bg); }
.bell-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--st-working);
  color: var(--acc-ink);
  font: 700 11px/18px var(--font-body, system-ui, sans-serif);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.bell-count[hidden] { display: none; }

.bell-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 61;
  width: min(24rem, calc(100vw - 2rem));
  max-height: min(34rem, 75vh);
  overflow: auto;
  padding: 12px 12px 8px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-lg, 10px);
  box-shadow: var(--shadow-3);
}
.bell-panel[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.bell-head h2 { margin: 0; font: 700 1.05rem/1.2 var(--font-sign, inherit); letter-spacing: .02em; }
.bell-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bell-item { display: flex; align-items: stretch; gap: 6px; border: 1px solid var(--line); border-radius: var(--r-lg, 10px); background: var(--bg); }
.bell-link { flex: 1 1 auto; min-width: 0; display: block; padding: 8px 10px; border-radius: var(--r-lg, 10px); color: var(--ink); text-decoration: none; }
.bell-link:hover { background: var(--surface); }
.bell-link:focus-visible, .bell-dismiss:focus-visible, .bell-foot:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.bell-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.bell-body { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.bell-time { display: block; margin-top: 2px; color: var(--muted); font: 600 12px/1.3 var(--font-mono, monospace); }
.bell-dismiss {
  flex: none;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--r-lg, 10px);
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.bell-dismiss:hover { background: var(--surface); color: var(--st-red-ink); }
.bell-empty { margin: 4px 0 8px; color: var(--muted); }
.bell-empty[hidden] { display: none; }
.bell-foot { display: flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 8px; padding: 8px 4px; font-weight: 700; color: var(--ink); }

/* a phone: the peek spans the width under the top bar */
@media (max-width: 1023px) {
  .bell-btn { width: 44px; height: 44px; }
  .bell-panel {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    width: auto;
    max-height: calc(100vh - 56px);
    border-width: 0 0 1px;
    border-radius: 0 0 var(--r-lg, 10px) var(--r-lg, 10px);
  }
  .bell-head .btn { min-height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .bell-btn { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
}

/* ------------------------------------------------------ admin pages of types */

.nt-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 14px; }
.nt-facts > div { min-width: 0; }
.nt-facts dt { color: var(--soft); font: 600 12px/1.3 var(--font); letter-spacing: .08em; text-transform: uppercase; }
.nt-facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.nt-ph { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.nt-ph li { padding: 2px 8px; border: 1px solid var(--line); border-radius: 99px; background: var(--paper); }
.nt-edit textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
.nt-more { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.nt-preview-subject { margin: 0 0 8px; font-weight: 700; overflow-wrap: anywhere; }
.nt-preview-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }

.field .notify-choice { display: flex; align-items: center; min-height: 32px; margin-bottom: 4px; color: var(--ink); font-size: 14px; font-weight: 400; }
@media (max-width: 860px) {
  .nt-edit .btn, .nt-go, .field .notify-choice { min-height: 44px; }
  .nt-go { display: inline-flex; align-items: center; }
}

/* the admin pages of types: list filters, the switch in a row, the edit page's side column */
.nt-filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 0 0 14px; }
.nt-filters .field { margin: 0; min-width: 160px; }
.nt-filters .actions { margin: 0; }
.nt-row-switch { margin: 0; }
.nt-state { min-width: 88px; }
.nt-state.nt-on { border-color: var(--ok, #2d6a50); }
.nt-state.nt-off { color: var(--soft); }
.nt-count { margin: 10px 0 0; color: var(--soft); font-size: 13px; }
.nt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.nt-main, .nt-side { min-width: 0; }
.nt-side .card { margin-bottom: 14px; }
.nt-side h2 { margin: 0 0 8px; font-size: 16px; }
.nt-vars { margin: 0; display: grid; gap: 8px; }
.nt-vars > div { min-width: 0; }
.nt-vars dt { margin: 0; }
.nt-vars dd { margin: 2px 0 0; color: var(--soft); overflow-wrap: anywhere; }
.nt-preview-html { display: block; width: 100%; min-height: 220px; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 860px) {
  .nt-layout { grid-template-columns: minmax(0, 1fr); }
  .nt-state { min-height: 44px; }
}
