@layer components {
  /* Notifications list: on its page a notification is a row, not the card it is in the tray.
  /* ------------------------------------------------------------------------ */

  .notifications-list {
    --notification-avatar-size: 2.5rem; /* 40px */
    --notification-text: 1rem;          /* 16px */
    --notification-meta: 0.875rem;      /* 14px */
    --panel-size: 42rem;

    margin-inline: 0;

    @media (min-width: 100ch) {
      --notification-avatar-size: 2.1rem;
      --notification-text: 0.842rem;
      --notification-meta: 0.737rem;
    }

    .tray__item {
      position: relative;
      border-block-end: 1px solid var(--color-ink-light);

      &[aria-selected] {
        outline: 0;

        .card {
          outline: var(--focus-ring-size) solid var(--focus-ring-color);
          outline-offset: calc(-1 * var(--focus-ring-size));
        }
      }
    }

    /* Who at the start; then what, its words, and where, who and when on a quiet line; the dot at the end. */
    .card--notification {
      display: grid;
      grid-template-columns: var(--notification-avatar-size) minmax(0, 1fr);
      column-gap: 0.75rem;
      row-gap: 0.15rem;
      padding: 0.75rem 3rem 0.75rem 0.5rem;
      border-radius: var(--radius-md);
      background: none;
      box-shadow: none;
      font-size: var(--notification-text);

      @media (any-hover: hover) {
        &:hover {
          background-color: var(--tint-ink-3);
        }
      }
    }

    .card__body,
    .card__body > h3 {
      display: contents;
    }

    .card__body > .avatar {
      --avatar-size: var(--notification-avatar-size);

      grid-column: 1;
      grid-row: 1 / span 3;
      font-size: var(--notification-meta);
    }

    .card__title {
      grid-column: 2;
      grid-row: 1;
      color: var(--color-ink);
      font-size: var(--notification-text);
      font-weight: 400;
      line-height: 1.4;
    }

    .card--notification.unread .card__title {
      font-weight: 700;
    }

    .card__notification-body {
      grid-column: 2;
      grid-row: 2;
      color: var(--color-ink-dark);
      font-size: var(--notification-meta);
    }

    /* Where, who and when, on one quiet line. */
    .card__header {
      grid-column: 2;
      grid-row: 3;
      display: flex;
      gap: 0.4ch;
      margin: 0;
      min-inline-size: 0;
      color: var(--color-meta);
      font-size: var(--notification-meta);
    }

    .card__board {
      display: inline-flex;
      gap: 0.4ch;
      min-inline-size: 0;
      padding: 0;
      border-radius: 0;
      background: none;
      color: inherit;
      font-size: inherit;
      font-weight: 400;
    }

    .card__id::before {
      content: "#";
    }

    .card__board-name {
      margin: 0;
      padding: 0;
      border: 0;
      text-transform: none;
    }

    /* The tray's markup pushes who and when to the end with utilities; here they follow where. */
    .card__notification-meta {
      flex-grow: 0 !important;
      font-size: inherit;
      font-weight: 400;
      text-align: start !important;
      text-transform: none;

      &:has(.card__creator, .card__timestamp)::before {
        content: "· ";
      }
    }

    .card__timestamp {
      opacity: 1;
    }

    /* The unread dot, or the way to mark it unread again, at the end of the row. */
    .card__notification-meta:has(form) {
      position: absolute;
      inset-block-start: 50%;
      inset-inline-end: 0.5rem;
      translate: 0 -50%;
    }

    &:has(.card--notification) {
      .notifications-list__blank-slate {
        display: none;
      }
    }

    /* With no notification at all the list spans the page, so its blank slate is centred on the column. With older
       ones below, it stays centred over them. */
    .page:not(:has(.card--notification)) > & {
      --panel-size: 100%;
    }
  }

  .notifications-list__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--inline-space);
    margin-block: var(--block-space) var(--block-space-half);
  }

  /* Read items
  /* ------------------------------------------------------------------------ */

  .notifications-list--read {
    &:not(:has(.card--notification)) {
      display: none;
    }

    .card__notification-unread-indicator {
      --btn-background: transparent;
      --btn-size: 1.8em;

      margin: 2px;

      .icon {
        block-size: 1.7em;
        color: var(--color-ink);
        inline-size: 1.7em;
        opacity: 1;
      }
    }
  }
}
