/* The notifications: the list under the bell, its rows, and Dismiss. */
@layer views {
  /* The list under the bell, over the current view. The stage clips what
     overflows it, so the list is never wider than the stage beside the rail
     and the panel. */
  .notifications-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 8;
    width: min(400px, calc(100vw - 64px - var(--panel-w, 288px) - 24px));
    max-height: calc(100dvh - 96px);
    overflow: auto;
    padding: 12px 16px 16px;
  }
  @media (min-width: 720px) {
    .shell.panel-collapsed .notifications-panel { width: min(400px, calc(100vw - 88px)); }
  }
  .notifications-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
  }
  .notifications-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    line-height: 1;
  }
  .notifications-title svg { display: block; color: var(--muted); transform: translate(4px, -3px); }
  .notifications-empty,
  .notifications-reason {
    margin: 8px 0 0;
    color: var(--muted);
  }
  .notifications-reason { color: var(--red); }
  /* Rows run into the panel's padding, so their text lines up with the
     heading while a hovered row's tint reaches nearly to the edge. */
  .notifications-list {
    margin: 0 -12px;
    padding: 0;
    list-style: none;
  }
  .notification {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--line);
  }
  .notifications-list > .notification:first-child { border-top: 0; }
  /* One row is the whole notification: the avatar, then the agent's name
     with the time at its right, and the sentence under it. A row with a
     link opens it (a brief's, which has no address, is a button); one
     without is plain text with no hover. */
  .notification-row {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    color: inherit;
    text-decoration: none;
  }
  a.notification-row { cursor: pointer; }
  button.notification-row {
    border: 0;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .notification-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    line-height: 18px;
  }
  .notification-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
  }
  .notification-agent {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* An unseen row's mark: the Agents list's dot (agents.css .agent-row-dot),
     right after the name. */
  .notification-meta > .notification-dot {
    align-self: center;
    margin-right: auto;
    margin-left: -6px;
  }
  .notification-time {
    flex: none;
    color: var(--muted);
    font-size: 12px;
  }
  /* Cut at four lines with an ellipsis, as the Ideas and Todo notes; the
     row still opens the notification's link. */
  .notification-text {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
  }
  /* Dismiss is a small ghost ✕ at the row's end, shown on a desk while the
     row is hovered or holds focus, and always on a phone. */
  .notification-dismiss {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-right: 6px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
  }
  .notification-dismiss:disabled { cursor: default; }
  /* On a phone the ✕ is a full 44px target flush with the row's end, so a
     near miss does not open the link beside it. */
  @media (hover: none) {
    .notification-dismiss {
      width: 44px;
      height: 44px;
      margin-right: 0;
    }
  }
  @media (hover: hover) {
    .notification:has(> .notification-row[data-notification-link]):hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
    .notification-dismiss { opacity: 0; }
    .notification:hover .notification-dismiss,
    .notification:focus-within .notification-dismiss { opacity: 1; }
    .notification-dismiss:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
  }

  @media (max-width: 719.98px) {
    /* The list drops from the band across the phone's width. */
    .notifications-panel {
      position: fixed;
      top: calc(var(--controls-h) + 4px);
      right: 12px;
      left: 12px;
      width: auto;
      max-height: calc(100dvh - 116px);
    }
    /* The sentence keeps to one line across a phone's narrow list. */
    .notification-text {
      -webkit-line-clamp: 1;
      line-clamp: 1;
    }
  }
}
