/*
 * The chat fills the screen.
 *
 * A conversation used to grow with the number of messages, so on a phone
 * the box for writing was below the fold and the reader had to scroll
 * past the whole history to reach it. The frame is now the height of the
 * screen: the messages scroll inside it, and the box for writing is
 * always in reach.
 *
 * dvh is the height of the area a phone actually shows, which changes
 * when the browser's bar comes and goes; vh is the fallback for the
 * browsers that do not know dvh.
 *
 * --cb-chat-top is how much of the screen is taken up by the header and
 * the page above the frame. It is measured by the page rather than
 * guessed at, because the header is a different height on different
 * phones and a frame that is a little too tall puts the box for writing
 * off the bottom of the screen -- the one thing it must never do. The
 * numbers here are what the frame falls back to before it is measured.
 *
 * The floor is small on purpose. A phone that is shorter than the frame
 * would push the box for writing off the bottom of the screen, which is
 * the very thing this is here to stop -- so on a small screen the frame
 * is allowed to be short rather than to be too tall.
 */
.cb-chat-frame {
  height: calc(100vh - var(--cb-chat-top, 14rem));
  height: calc(100dvh - var(--cb-chat-top, 14rem));
  min-height: 320px;

  /* The row is the height of the frame, not the height of its contents.
     A row that grows with the messages makes the frame overflow and the
     messages are cut off at the bottom -- and the box for writing goes
     with them. The row is fixed here so that the column inside it
     scrolls instead. */
  grid-template-rows: minmax(0, 1fr);
}

@media (min-width: 1024px) {
  .cb-chat-frame {
    height: calc(100vh - var(--cb-chat-top, 13rem));
    height: calc(100dvh - var(--cb-chat-top, 13rem));
    min-height: 560px;
  }
}
