/* ==========================================================================
   Notification bell

   The count on the bell and the panel it opens. Every class here is the
   bell's own: the panel is not a .menu, because the shared menu fills an
   empty box with "No actions available for your role", and it is not a row
   menu, because those are placed by script.
   ========================================================================== */

/* The count sits on the button's corner. The button is already positioned,
   so nothing about the button itself changes. */
.bell__count {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  /* One red in both themes, so white stays readable on it at this size. */
  background: var(--red-600);
  color: var(--white);
  font-size: 10.5px;
  font-weight: var(--fw-bold);
  line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}
.bell__count[hidden] { display: none; }

/* ---- Stock levels on a list --------------------------------------------- */

/* The tags saying a product is under its minimum or over its maximum, under
   its figure or its name. A row of their own, because the column they sit in
   is a flex column that would otherwise stretch each tag to its full width. */
.levels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.cell-amount .levels { justify-content: flex-end; }

/* ---- The bell ----------------------------------------------------------- */

/* Anchored to the bell on a tablet or a desktop, where there is room to the
   left of it for the whole panel. */
.bell { position: relative; flex: none; }

.bell-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-menu);
  width: min(384px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 96px));
  max-height: min(560px, calc(100dvh - 96px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  animation: mkh-rise 0.16s var(--ease);
}
.bell-panel[hidden] { display: none; }
.bell-panel:focus { outline: none; }
.bell-panel:focus-visible { box-shadow: 0 0 0 3px var(--primary-ring), var(--sh-lg); }

/* On a phone the bell is too near the middle for a panel hung from it, so
   the bell lets go and the panel spans the header instead, under all of it. */
@media (max-width: 620px) {
  .bell { position: static; }

  .bell-panel {
    left: 8px;
    right: 8px;
    width: auto;
    top: calc(100% + 6px);
    max-height: calc(100vh - 150px);
    max-height: calc(100dvh - 150px);
  }
}

.bell-panel__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 12px 14px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.bell-panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--txt);
}

.bell-panel__asat { font-size: var(--fs-xs); color: var(--txt-3); white-space: nowrap; }

.bell-panel__state {
  margin: 0;
  padding: 18px 14px 20px;
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--txt-2);
}

.bell-panel__body { padding: 4px 0 8px; }

.bell-panel__failed {
  margin: 6px 14px 4px;
  padding: 8px 10px;
  border-radius: var(--r-xs);
  background: var(--warn-bg);
  color: var(--warn-fg);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

/* ---- One kind of notice ------------------------------------------------- */

.bell-group { padding: 8px 6px 6px; }
.bell-group + .bell-group { border-top: 1px solid var(--line-soft); }

/* A heading for the outline, but set like the notices under it rather than
   in the display face headings otherwise get. */
.bell-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 2px 8px 4px;
  font-family: var(--font-sans);
  letter-spacing: normal;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--txt);
}

.bell-group__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 7px;
}
.bell-group__icon svg { width: 14px; height: 14px; }

.bell-group--danger .bell-group__icon { background: var(--bad-bg); color: var(--bad); }
.bell-group--warning .bell-group__icon { background: var(--warn-bg); color: var(--warn); }
.bell-group--info .bell-group__icon { background: var(--info-bg); color: var(--info); }

.bell-group__title { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.bell-group__new {
  flex: none;
  padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary-soft-fg);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  white-space: nowrap;
}

.bell-group__list { margin: 0; padding: 0; list-style: none; }

/* In line with the notices' text, under the kind's name. */
.bell-group__more {
  display: block;
  margin: 0 8px 0 40px;
  padding: 4px 0 2px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
p.bell-group__more { color: var(--txt-3); font-weight: var(--fw-regular); }

/* ---- One notice --------------------------------------------------------- */

.bell-item { position: relative; }

.bell-item__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 8px 7px 40px;
  border-radius: var(--r-xs);
  color: var(--txt);
  text-decoration: none;
}
a.bell-item__body:hover { background: var(--surface-2); text-decoration: none; }
a.bell-item__body:hover .bell-item__text { color: var(--primary); }

.bell-item__text {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  overflow-wrap: anywhere;
}

.bell-item__detail {
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--txt-2);
  overflow-wrap: anywhere;
}

/* New is said in words as well as with the dot, so colour is never the only
   thing that tells it apart. */
.bell-item__new {
  position: absolute;
  top: 9px;
  right: 8px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary-soft-fg);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-wide);
  pointer-events: none;
}
.bell-item.is-new .bell-item__body { padding-right: 52px; }
.bell-item.is-new .bell-item__body::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 24px;
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--primary);
}

/* A finger needs more than a line of small text to land on. */
@media (pointer: coarse) {
  .bell-item__body { padding-top: 10px; padding-bottom: 10px; }
  .bell-group__more { padding-top: 12px; padding-bottom: 12px; }
}

@media (forced-colors: active) {
  .bell-panel, .bell__count, .bell-item__new, .bell-group__new { border: 1px solid currentColor; }
}
