/* The Rooms list (S4a, #170; behaviour in room-list.js). Rows are links in
   lists: the lantern on the left across two lines, the name over its
   sub-line, and the time over the badges on the right. The mention card and
   invitation cards sit above the groups. Uses only existing tokens. */

#room-list { display: grid; gap: 0.35rem; align-content: start; }

.room-group { display: grid; gap: 0.1rem; }
.room-group[hidden] { display: none; }

/* Section labels (Lantern Next L3): Label type in sentence case, no capitals or tracking. */
.room-group-heading {
  margin: 0.75rem 0.65rem 0.25rem;
  color: var(--text-muted);
  font-size: var(--type-label);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.room-rows { display: grid; gap: 0.1rem; margin: 0; padding: 0; list-style: none; }

.room-row { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.room-row > .room-button { flex: 1; min-width: 0; }

/* ---- A row ---- */

.list-pane .room-button {
  display: grid;
  grid-template-areas: "mark name meta" "mark sub meta";
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.05rem;
  min-height: 3.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-field);
  font-size: var(--type-body);
  text-decoration: none;
}

.list-pane .room-button .lantern { grid-area: mark; margin: 0; }

.list-pane .room-button .room-name {
  grid-area: name;
  align-self: end;
  color: var(--text);
  font-weight: 600;
}

/* Unread or open: the name in bold (with the count, or the lit row and aria-current). */
.room-button:is(.unread, .active) .room-name { font-weight: 700; }

.room-sub {
  grid-area: sub;
  align-self: start;
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--type-label);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-sub.empty { display: none; }
.room-button:has(.room-sub.empty) .room-name { grid-row: 1 / span 2; align-self: center; }

.room-row-here { color: var(--presence-text); font-weight: 600; }

.room-row-meta {
  grid-area: meta;
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 0.25rem;
}

.room-time { color: var(--text-muted); font-size: var(--type-caption); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.room-button.unread .room-time { color: var(--text); font-weight: 700; }

.room-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.25rem; }

/* "@": an unread mention waits in this room. Honey, like presence's warmth. */
.mention-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--presence);
  color: var(--hue-ink);
  font-size: var(--type-caption);
  font-weight: 700;
  line-height: 1;
}

/* Over 99 the count goes quiet: the number stops mattering. */
.unread-count.quiet { border: 1px solid var(--line); background: var(--raised); color: var(--text); }

/* The lantern's glow in a row: the ring gap takes the colour the row sits on: the
   pane's ground, or the lit fill of the selected row (L3). */
.list-pane .room-button { --glow-gap: var(--ground); }
.list-pane .room-button.active { --glow-gap: var(--selected); }
.list-pane .room-button .lantern.glow {
  box-shadow:
    0 0 0 2px var(--glow-gap),
    0 0 0 4px var(--presence),
    0 0 10px 3px color-mix(in srgb, var(--presence) 35%, transparent);
}

.room-join { flex: none; min-height: 2.25rem; padding: 0.25rem 0.8rem; font-size: 0.85rem; }

/* ---- Invitations ---- */

.room-invitation {
  margin: 0 0.1rem;
  padding: 0.15rem 0.5rem 0.15rem 0;
  border: 1px solid color-mix(in srgb, var(--presence-text) 45%, var(--line));
  border-radius: 0.85rem;
  background: var(--raised);
}

.room-invitation .room-button:hover { background: transparent; }

/* ---- The pinned mention card ---- */

.mention-card {
  /* Flex with wrapping (S7g): Open moves to its own line, end-aligned, only once the
     text would be squeezed below about nine characters' width, at any zoom. */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0.5rem 0.25rem;
  padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  /* A strip, not a box (L3): the honey wash carries it; the transparent border is for forced colours. */
  border: 1px solid transparent;
  border-radius: var(--radius-field);
  background: var(--presence-wash);
  color: var(--text);
}

.mention-card-text { flex: 1 1 9rem; margin: 0; min-width: 0; font-size: var(--type-label); line-height: 1.35; overflow-wrap: break-word; }

.mention-card-open {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  min-height: 2.25rem;
  padding: 0 0.9rem;
  /* A pill on the page's surface (L3), like every button; it is a link, so it keeps a
     boundary that doesn't rely on the wash: the field line, 3:1 on --surface. */
  border: 1px solid var(--field-line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--type-label);
  font-weight: 600;
  text-decoration: none;
}

.mention-card-open:hover { border-color: var(--text); }

/* ---- Find rooms (phones) ---- */

.find-rooms-button { justify-self: start; margin: 0.4rem 0.6rem 0; }

.room-list-empty { margin: 0.4rem 0.6rem; }

/* Narrow panes: the sub-line and badges stay; the lantern shrinks a little. */
@media (max-width: 22rem) {
  .list-pane .room-button { column-gap: 0.5rem; padding-inline: 0.45rem; }
  .list-pane .room-button .lantern { width: 2rem; height: 2rem; }
  .room-join { padding-inline: 0.6rem; }
}

@media (any-pointer: coarse) {
  .room-join, .mention-card-open { min-height: 2.75rem; }
}

@media (forced-colors: active) {
  /* Backgrounds are dropped here, so every badge keeps a border (#378). */
  .mention-badge, .unread-count { border: 1px solid CanvasText; }
  .room-invitation, .mention-card { border-color: CanvasText; }
  .list-pane .room-button .lantern.glow { outline: 2px solid Highlight; outline-offset: 2px; }
}
