/* Alerting layer: the topbar bell and its panel, the Alerts page, the
   @-mention autocomplete and the mention chip. Uses the same tokens as the
   rest of the app, so both themes come for free. */

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

.alert-menu {
  position: relative;
  display: inline-flex;
}

.alert-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.alert-bell:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.alert-bell--unread {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

/* The count sits on the bell's corner. Tabular numerals stop the badge
   resizing as the count ticks between 8 and 11. */
.alert-bell__count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

/* --------------------------------------------------------------- panel --- */

.alert-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  width: min(380px, calc(100vw - 2rem));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

.alert-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.alert-panel__title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
}

.alert-panel__mark {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 0.72rem;
  cursor: pointer;
}

.alert-panel__mark:hover {
  text-decoration: underline;
}

/* Caps the panel at roughly five rows; beyond that the footer link is the
   route to the full history rather than an endless scroll in a dropdown. */
.alert-panel__body {
  max-height: 340px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  gap: 0.55rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-item:hover {
  background: var(--accent-soft);
}

/* The unread marker is a dot in its own column, so read and unread rows keep
   the same text alignment and the list does not appear to shift as it clears. */
.alert-item__dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 0.42rem;
  border-radius: 50%;
  background: transparent;
}

.alert-item--unread .alert-item__dot {
  background: var(--accent);
}

.alert-item__main {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}

.alert-item__head {
  font-size: 0.76rem;
  line-height: 1.35;
}

.alert-item__actor {
  font-weight: 600;
}

.alert-item__verb {
  color: var(--text-muted);
}

.alert-item__entity {
  font-weight: 600;
  color: var(--accent);
}

/* Two lines of preview: enough to tell what it is about, not enough for one
   long comment to push the rest of the list out of view. */
.alert-item__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.4;
}

.alert-item__time {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.alert-panel__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 1.6rem 1.2rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
}

.alert-panel__foot {
  padding: 0.55rem 0.85rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.alert-panel__all {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 600;
  text-decoration: none;
}

.alert-panel__all:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------- alerts page --- */

.alert-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.alert-tabs__tab {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.76rem;
  text-decoration: none;
  cursor: pointer;
}

.alert-tabs__tab--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.alert-browse__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}

.alert-browse__unread-pill {
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
}

.alert-browse__pageinfo {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.alert-browse__row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.alert-browse__row:last-child {
  border-bottom: none;
}

.alert-browse__dot {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-top: 0.45rem;
  border-radius: 50%;
  background: transparent;
}

.alert-browse__row--unread .alert-browse__dot {
  background: var(--accent);
}

.alert-browse__main {
  flex: 1;
  min-width: 0;
}

.alert-browse__head-line {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.alert-browse__record {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.alert-browse__record:hover {
  text-decoration: underline;
}

.alert-browse__spacer {
  flex: 1;
}

.alert-browse__excerpt {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.alert-browse__action {
  flex: 0 0 auto;
}

.alert-browse__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.alert-browse__toggle:hover {
  border-color: var(--border);
  color: var(--accent);
  background: var(--accent-soft);
}

.alert-browse__empty {
  margin: 0;
  padding: 1.8rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* ------------------------------------------------ mention autocomplete --- */

/* Anchors the suggestion menu to the textarea it belongs to. */
.comment-form__body-wrap {
  position: relative;
}

.mention-suggest-host {
  position: absolute;
  left: 0;
  right: 0;
  /* Above the textarea: the comment form sits at the bottom of the modal, so
     a menu dropping downwards would fall outside the panel. */
  bottom: calc(100% + 4px);
  z-index: 70;
}

.mention-suggest {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
}

.mention-suggest--empty {
  padding: 0.55rem 0.7rem;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.mention-suggest__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: none;
  border-radius: 7px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

/* Hover and keyboard selection share one style, so arrowing through the list
   looks the same as pointing at it. */
.mention-suggest__item:hover,
.mention-suggest__item--active {
  background: var(--accent-soft);
}

.mention-suggest__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.66rem;
  font-weight: 700;
}

.mention-suggest__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mention-suggest__name {
  font-size: 0.76rem;
  font-weight: 600;
}

.mention-suggest__handle {
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* ----------------------------------------------------------- the chip --- */

/* Inline in a rendered comment body. Deliberately not a link: the handle
   identifies a person, and there is no per-user page to send anyone to. */
.mention-chip {
  padding: 0.05rem 0.28rem;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

/* The "n notified" marker on a comment header. */
.comment__mentions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

/* The comment an alert linked to. A brief wash rather than a persistent
   border, so the modal settles back to normal once it has done its pointing. */
.comment--focused {
  animation: comment-focus 2.4s ease-out;
  border-radius: 8px;
}

@keyframes comment-focus {
  0%, 45% { background: var(--accent-soft); }
  100% { background: transparent; }
}

/* The "Mentions me" toggle on the Comments filter bar. Styled as a pill so it
   reads as a filter alongside the dropdowns rather than as a form option. */
.comment-filters__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  align-self: flex-end;
  padding: 0.42rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
  cursor: pointer;
}

.comment-filters__toggle:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.comment-filters__toggle input {
  margin: 0;
  cursor: pointer;
}

/* --------------------------------------------- usernames in admin list --- */

.user-row__handle {
  font-weight: 600;
  color: var(--accent);
}

/* An account with no handle yet — mentionable only once one is set. */
.user-row__handle--none {
  font-weight: 400;
  font-style: italic;
  color: var(--text-muted);
}


/* --------------------------------------- live mention chips while typing --- */

/* The composer highlights a confirmed @mention as it is typed. A textarea
   cannot hold markup, so .mention-highlight sits directly behind it holding
   the same text, and the textarea is made transparent except for its caret —
   what reads as highlighted text is the backdrop showing through.

   Every metric below must match .comment-form textarea exactly (padding,
   border width, font, line-height, letter-spacing) or the two copies of the
   text drift apart, which is far worse than no highlight at all. The shared
   `font: inherit` on both keeps the family and line-height in step. */

.comment-form__body-wrap .mention-highlight,
.comment-form__body-wrap .comment-form__body {
  /* One grid cell, so the two are the same size without absolute positioning
     having to guess the textarea's resized height. */
  grid-area: 1 / 1;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: normal;
  /* The textarea wraps on whitespace and preserves newlines; the backdrop must
     do exactly the same or long lines break in different places. */
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.comment-form__body-wrap {
  display: grid;
}

.mention-highlight {
  overflow: hidden;
  color: transparent;
  background: var(--surface-raised);
  border-color: var(--border);
  pointer-events: none;
  user-select: none;
}

/* Transparent so the backdrop reads through, but the caret and selection must
   stay visible — those are the only parts the textarea still paints. */
.comment-form__body-wrap .comment-form__body {
  position: relative;
  background: transparent;
  caret-color: var(--text);
}

/* The chip inside the backdrop is behind transparent glyphs, so it supplies
   only the background; the letters themselves come from the textarea above and
   keep the normal text colour. */
.mention-highlight .mention-chip {
  padding: 0;
  border-radius: 4px;
  box-shadow: 0 0 0 2px var(--accent-soft);
  background: var(--accent-soft);
  color: transparent;
  font-weight: inherit;
}

/* Focus ring belongs to the visible box (the backdrop), since the textarea's
   own border is transparent. :has keeps it tied to real focus. */
.comment-form__body-wrap:has(.comment-form__body:focus) .mention-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.comment-form__body-wrap .comment-form__body:focus {
  box-shadow: none;
}

/* A token that matches nobody. Marked, but plainly — it did not notify anyone,
   and styling it like a live mention is the confusion being avoided. */
.mention-chip--unresolved {
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: underline dotted currentColor;
  text-underline-offset: 2px;
}

/* "Will notify @sam.j" under the composer — the plain-language counterpart to
   the chips, confirming who a post actually reaches before it is sent. */
.mention-notice {
  margin: 0.35rem 0 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}
