/* Lobby Watch: chat search (design.md 5c). Scoped under .v-chat; layout only, never component colours.
   The view is body.is-fullheight (like the lobby view): #app is a fixed-height frame with no padding, and the chat
   well scrolls on its own so the newest line can sit at the bottom the way the game's chat does. */

.v-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

/* ---- Filter column (>= 1024) and the <details> below that ---------------------------------------------------- */

.v-chat .cf-col {
  display: none;
}
/* Below 1024 the form shares the fixed-height pane with the well: when it is open and tall it shrinks and scrolls
   rather than pushing the chat off the bottom of the frame. */
.v-chat .filters {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.v-chat .filters > .sum {
  width: 100%;
}
.v-chat .cf-wrap {
  padding: 0 0 16px;
}
.v-chat .filters .cf-title {
  display: none;
}
/* Below 1024 the summary is the title; "Clear filters" sits on the summary's row, right-aligned. */
.v-chat .filters .cf-head {
  justify-content: flex-end;
  margin: -32px 0 8px;
  pointer-events: none;
}
.v-chat .filters .cf-head .tbtn {
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .v-chat {
    grid-template-columns: 272px minmax(0, 1fr);
  }
  /* The grid row is the full frame height, so the column just fills it and scrolls; no sticky positioning needed. */
  .v-chat .cf-col {
    display: block;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 24px;
    background: var(--surface);
    border-right: 1px solid var(--rule-strong);
  }
  .v-chat .filters {
    display: none;
  }
}

/* ---- The form ------------------------------------------------------------------------------------------------- */

.v-chat .cf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.v-chat .cf-title {
  font-weight: 600;
}
.v-chat .cf .field + .field {
  margin-top: 16px;
}
.v-chat .cf .ps {
  width: 100%;
}
.v-chat .cf .dd {
  min-width: 100%;
  max-width: none;
}

.v-chat .cf-game + .cf-game {
  margin-top: 4px;
}
.v-chat .cf-nums {
  display: grid;
  grid-template-columns: repeat(5, 32px);
  padding-left: 22px;
}
.v-chat .chk--n {
  gap: 4px;
  min-height: 24px;
  font-size: var(--fs-dense);
}
.v-chat .cf-lobbies-note {
  margin: 0 0 4px;
}

.v-chat .cf-kinds {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 16px;
}

.v-chat .cf-time {
  display: grid;
  gap: 8px;
}
.v-chat .cf-time .lbl {
  margin-bottom: 2px;
}
.v-chat .cf input[type="datetime-local"].in {
  width: 100%;
}
/* One typed line: "Last hour · Today · 7 days · Any time". The preset in effect is --text 500 (.is-on). */
.v-chat .cf-presets {
  display: flex;
  flex-wrap: wrap;
  column-gap: 12px;
  margin-top: 4px;
}
.v-chat .cf-presets .tbtn {
  font-size: var(--fs-dense);
}

/* Below 1024 the Text field sits under the h1, outside the <details>, so "find a message" is type-and-read. */
.v-chat .cr-q {
  margin: -4px 0 16px;
}
.v-chat .cr-q .in {
  width: 100%;
}

/* Below 1024 the same form sits in the <details>; give the fields a wider layout there. */
@media (min-width: 720px) and (max-width: 1023.98px) {
  .v-chat .cf {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 320px));
    column-gap: 32px;
  }
  .v-chat .cf-head {
    grid-column: 1 / -1;
  }
  .v-chat .cf .field + .field {
    margin-top: 0;
  }
  .v-chat .cf .field {
    margin-bottom: 16px;
  }
  .v-chat .cf-kinds {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---- Results pane -------------------------------------------------------------------------------------------- */

.v-chat .cr {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
}
/* Everything above the results keeps its own height; only the results take the slack. */
.v-chat .cr > .ph,
.v-chat .cr-q {
  flex: none;
}
.v-chat .cr-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  /* Never let the open filter <details> squeeze the chat away entirely. */
  min-height: 120px;
}
.v-chat .cr-head {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 4px;
  margin-bottom: 8px;
  font-size: var(--fs-dense);
  line-height: var(--lh-dense);
  color: var(--text-2);
}
.v-chat .cr-head .g {
  margin-left: 2px;
}
/* The well is the scroll container, oldest line at the top. .well--box turns overflow off for the page-scrolled
   variant, so it is turned back on here. overflow-anchor is off because loadOlder does the anchoring itself: the
   browser's own anchoring would fight keepScroll() and land the view somewhere in between. */
.v-chat .well {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
}
/* "Load older" / "No older lines.", scrolling with the content above the oldest line. */
.v-chat .cr-top {
  padding: 0 var(--cl-pad, 24px) 4px;
}
.v-chat .cr-end {
  padding: 4px 0;
  font-size: var(--fs-dense);
  line-height: var(--lh-dense);
  color: var(--text-3);
}
.v-chat .cr-clear {
  white-space: nowrap;
}

@media (max-width: 719.98px) {
  .v-chat .cr {
    padding: 16px var(--gutter);
  }
  .v-chat .cf-nums {
    grid-template-columns: repeat(auto-fill, 40px);
  }
  .v-chat .chk--n {
    min-height: 28px;
  }
}
