.thread-summary:empty {
  display: none;
}

/* A deleted parent is only a marker for its thread. Its menu keeps everything but Edit. */
.message:has(.thread-summary--parent-deleted) .message__edit-btn {
  display: none;
}

.thread-summary__link {
  align-items: center;
  color: var(--color-link);
  column-gap: 0.5em;
  display: inline-flex;
  flex-wrap: wrap;
  margin-block-start: 0.25em;
  text-decoration: none;

  strong {
    white-space: nowrap;
  }

  &:hover strong {
    text-decoration: underline;
  }
}

.thread-summary__last {
  color: var(--color-text);
  opacity: 0.66;
}

body {
  --thread-panel-width: clamp(20rem, 34vw, 30rem);
}

/* The host is always in the room page; it only takes up space while a thread is loaded. */
.thread-panel-host {
  display: none;

  &:has(.thread-panel) {
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    inset: 0;
    position: fixed;
    z-index: 4;

    @media (min-width: 100ch) {
      border-inline-start: 1px solid var(--color-border-darker);
      inline-size: var(--thread-panel-width);
      inset-block-start: var(--navbar-height);
      inset-inline: auto var(--sidebar-width);
      z-index: 2;
    }
  }

  > turbo-frame {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-block-size: 0;
  }
}

/* On a wide screen the room makes way for the panel, so its composer stays in reach. */
@media (min-width: 100ch) {
  body:has(.thread-panel) #main-content {
    margin-inline-end: var(--thread-panel-width);
  }
}

.thread-panel {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-block-size: 0;
}

/* Upstream's .messages scrolls itself; here the panel's scroller does. */
.thread-panel__replies {
  flex: none;
  overflow: visible;
  padding-block: var(--block-space);
}

/* Upstream's quote Reply writes into the room's composer, which is not where a reply in a thread goes. */
.thread-panel__replies [data-action="reply#reply"] {
  display: none;
}

.thread-panel__header {
  border-block-end: 1px solid var(--color-border);
  padding: var(--block-space-half) var(--inline-space);

  /* Room for a fingertip. */
  @media (hover: none) and (pointer: coarse) {
    .btn {
      min-block-size: 2.75rem;
    }

    .thread-panel__close {
      --btn-size: 2.75rem;
    }
  }
}

.thread-panel__scroller {
  flex-grow: 1;
  min-block-size: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.thread-panel__parent {
  border-block-end: 1px solid var(--color-border);
  padding: var(--block-space) var(--inline-space);
}

.thread-panel__parent-meta {
  column-gap: 0.5em;
  display: flex;
  margin-block-end: 0.25em;
}

.thread-panel__earlier {
  display: flex;
  justify-content: center;
  padding-block: var(--block-space-half);

  &:empty {
    display: none;
  }
}

.thread-composer {
  border-block-start: 1px solid var(--color-border);
  padding: var(--block-space-half) var(--inline-space);
}

.thread-composer__input {
  --input-border-radius: 1.3rem;
}

.threads__item {
  align-items: baseline;
  border-block-end: 1px solid var(--color-border);
  color: inherit;
  column-gap: var(--inline-space);
  display: flex;
  padding: var(--block-space-half) var(--inline-space);
  text-decoration: none;

  &.unread .threads__excerpt {
    font-weight: 700;
  }

  /* On a phone the room and the reply count share a line and the excerpt gets its own. */
  @media (max-width: 100ch) {
    flex-wrap: wrap;
    justify-content: space-between;

    .threads__excerpt {
      flex-basis: 100%;
      order: 1;
    }
  }
}

.threads__room {
  flex: none;

  @media (max-width: 100ch) {
    flex: 1 1 0;
    min-inline-size: 0;
  }
}

/* The sidebar layout bottom-aligns #main-content, which suits a timeline but not a list, and floats the nav over it. */
.threads {
  margin-block: 0 auto;
  padding-block-start: calc(var(--navbar-height) + var(--block-space-half));
}

.threads__empty {
  opacity: 0.66;
}
