/* chat.css: the chat at /chat/ (js/chat.js). Full screen like the ghost:
   the bar on top, the room in the middle, the box to type in at the bottom
   (above the keyboard on phones). Monochrome and square, same tokens as
   the rest of the site; only people's pictures are in colour. */

html[data-page="chat"],
html[data-page="chat"] body {
  height: 100%;
  overflow: hidden;
}
html[data-page="chat"] #rain { opacity: .28; }
html[data-page="chat"] [hidden] { display: none !important; }

.ch {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- top bar ---------- */

.ch-top {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px 18px;
  min-height: 60px;
  padding: 10px var(--gutter);
}
.ch-top::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .3) 30%, rgba(255, 255, 255, .3) 70%, rgba(255, 255, 255, .06));
}
.ch-back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 13px;
  color: var(--fg);
  text-decoration: none;
}
.ch-back svg { width: 22px; height: 22px; flex: none; }
.ch-back:hover { color: var(--hi); }
.ch-path { overflow: hidden; color: var(--dim); white-space: nowrap; text-overflow: ellipsis; }
.ch-path b { font-weight: 400; color: var(--hi); }
.ch-tabs { display: flex; gap: 4px; }
.ch-tab {
  padding: 6px 8px;
  font-size: 13px;
  letter-spacing: .04em;
  color: var(--dim);
  text-decoration: none;
}
.ch-tab:hover { color: var(--fg); }
.ch-tab[aria-current="page"] { color: var(--hi); text-shadow: var(--glow); }
.ch-me {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 3px 10px 3px 3px;
  font: inherit;
  font-size: 12.5px;
  color: var(--fg);
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line-2);
  cursor: pointer;
}
.ch-me:hover,
.ch-me:focus-visible { color: var(--hi); border-color: var(--line-3); }
.ch-me .ch-icon { pointer-events: none; }

.ch-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.ch-wait { margin: auto; font-size: 13px; color: var(--dim); }
.ch-wait span { animation: ch-blink 1.05s steps(1) infinite; }
@keyframes ch-blink { 50% { opacity: 0; } }

/* ---------- shared bits ---------- */

.ch-h { margin: 0; font-size: 14px; font-weight: 400; letter-spacing: .04em; color: var(--hi); }
.ch-h.is-sm { margin: 16px 0 8px; font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.ch-note { margin: 8px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--dim); }
.ch-note:empty { display: none; }
.ch-empty { margin: 0; padding: 12px 4px; font-size: 13px; color: var(--dim); }

.ch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  letter-spacing: .03em;
  color: var(--fg);
  text-decoration: none;
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line-3);
  cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.ch-btn:hover,
.ch-btn:focus-visible { color: var(--hi); border-color: var(--hi); }
.ch-btn.is-solid { font-weight: 600; color: var(--bg); background: var(--hi); border-color: var(--hi); }
.ch-btn.is-solid:hover,
.ch-btn.is-solid:focus-visible { color: var(--bg); box-shadow: 0 0 18px rgba(255, 255, 255, .35); }
.ch-btn.is-quiet { padding: 6px 8px; color: var(--dim); background: none; border-color: transparent; }
.ch-btn.is-quiet:hover,
.ch-btn.is-quiet:focus-visible { color: var(--hi); border-color: var(--line-2); }
.ch-btn.is-bad { border-style: dashed; }
.ch-btn:disabled { opacity: .45; cursor: default; }
.ch-link {
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--dim);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: 0;
  cursor: pointer;
}
.ch-link:hover { color: var(--hi); }

.ch-input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--hi);
  background: rgba(0, 0, 0, .6);
  border: 1px solid var(--line-2);
  border-radius: 0;
  outline: none;
}
.ch-input:focus { border-color: var(--line-3); box-shadow: var(--glow-box); }
.ch-input::placeholder,
.ch-in::placeholder { color: var(--mute); }
.ch-row { display: flex; gap: 8px; margin-top: 8px; }
.ch-row .ch-input { flex: 1; }
.ch-check { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 12.5px; color: var(--fg); cursor: pointer; }
.ch-check input { width: 15px; height: 15px; margin: 0; accent-color: #fff; }

/* people's faces: their picture in a square, or the first letter of their name */
.ch-icon {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  color: var(--hi);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  cursor: pointer;
}
.ch-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ch-icon.is-letter { background: linear-gradient(135deg, #1a1a1a, #070707); text-shadow: var(--glow); }
.ch-icon.is-sm { width: 26px; height: 26px; font-size: 12px; }
.ch-icon.is-lg { width: 64px; height: 64px; font-size: 28px; cursor: default; }
.ch-icon:hover { border-color: var(--line-3); }

/* titles beside names; "owner" is the loud one */
.ch-title,
.ch-tag {
  display: inline-block;
  padding: 1px 6px 0;
  font-size: 9.5px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--dim);
  border: 1px solid var(--line-3);
}
.ch-title.is-owner {
  font-weight: 600;
  color: var(--bg);
  background: var(--hi);
  border-color: var(--hi);
  box-shadow: 0 0 12px rgba(255, 255, 255, .35);
}
.ch-title.is-admin { color: var(--hi); border-color: var(--hi); }
.ch-title.is-guest { border-style: dashed; }
.ch-tag { letter-spacing: .1em; }
.ch-tag.is-private {
  color: var(--hi);
  border-color: var(--line-3);
  background: linear-gradient(-45deg, rgba(255, 255, 255, .1) 0 9%, transparent 9% 50%, rgba(255, 255, 255, .1) 50% 59%, transparent 59%) 0 0 / 8px 8px;
}
.ch-tag.is-bad { border-style: dashed; }

/* ---------- the little guy ---------- */

.guy { display: grid; justify-items: center; gap: 16px; }
.guy-face { width: 64px; height: 64px; color: var(--hi); filter: drop-shadow(0 0 10px rgba(255, 255, 255, .35)); }
.guy.is-big .guy-face { width: 92px; height: 92px; }
.guy-eye { transform-box: fill-box; transform-origin: center; animation: guy-blink 4.4s steps(1) infinite; }
@keyframes guy-blink { 0%, 93%, 100% { transform: none; } 95% { transform: scaleY(.12); } }
.guy.is-no .guy-face { animation: guy-shake .42s var(--ease); }
.guy.is-happy .guy-face { animation: guy-hop .5s var(--ease-out); }
.guy.is-happy .guy-eye,
.guy.is-no .guy-eye { animation: none; }
@keyframes guy-shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes guy-hop { 40% { transform: translateY(-9px); } }
.guy-say {
  position: relative;
  min-height: 1.55em;
  max-width: 420px;
  margin: 0;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  text-align: center;
  color: var(--hi);
  overflow-wrap: anywhere;
  background: var(--panel);
  border: 1px solid var(--line-3);
  box-shadow: var(--glow-box);
}
.guy-say::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--panel);
  border-top: 1px solid var(--line-3);
  border-left: 1px solid var(--line-3);
  transform: translateX(-50%) rotate(45deg);
}
.guy-form { display: grid; justify-items: center; gap: 14px; }
.guy-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.guy-in { max-width: 320px; text-align: center; }

.ch-start {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(460px, 100% - 2 * var(--gutter));
  margin: auto;
  padding: 24px 0 8vh;
  text-align: center;
}
.ch-start-form { display: grid; justify-items: center; gap: 10px; width: 100%; }
.ch-start-form .ch-input { max-width: 320px; text-align: center; }

/* ---------- dialogs ---------- */

.ch-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .74);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.ch-dialog {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  box-shadow: var(--glow-box), 0 30px 80px rgba(0, 0, 0, .8);
  animation: ch-in .2s var(--ease-out);
}
.ch-dialog.is-guy { background: none; border: 0; box-shadow: none; }
@keyframes ch-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.ch-card-top { display: flex; align-items: center; gap: 14px; }
.ch-card-who { min-width: 0; }
.ch-card-name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 16px; color: var(--hi); overflow-wrap: anywhere; }
.ch-card-meta { margin: 4px 0 0; font-size: 11.5px; color: var(--dim); }
.ch-card-bio { margin: 14px 0 0; font-size: 13px; line-height: 1.5; color: var(--fg); overflow-wrap: anywhere; }
.ch-card-bio.is-empty { color: var(--dim); }
.ch-card-mod { margin: 12px 0 0; font-size: 11.5px; color: var(--dim); }
.ch-card-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.ch-card-acts.is-owner { border-top: 1px solid var(--line); }
.ch-card-acts.is-owner .ch-h { width: 100%; margin: 12px 0 0; }
.ch-card-x { margin-top: 14px; }
.ch-admins { display: grid; gap: 4px; }
.ch-admin { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--fg); overflow-wrap: anywhere; }
.ch-admin-who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }

/* ---------- the room list ---------- */

.ch-rooms {
  flex: 1;
  width: min(820px, 100%);
  margin: 0 auto;
  padding: 18px var(--gutter) 40px;
  overflow-y: auto;
}
.ch-rooms-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ch-count { margin-right: auto; font-size: 11.5px; color: var(--dim); }
.ch-new { margin-bottom: 16px; padding: 4px 16px 16px; background: var(--panel); border: 1px solid var(--line-2); }
.ch-new-form { display: grid; gap: 8px; }
.ch-new-form .guy-row { justify-content: flex-start; }
.ch-list { display: grid; gap: 6px; }
.ch-roomrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  text-align: left;
  color: var(--fg);
  background: rgba(0, 0, 0, .5);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: border-color .15s var(--ease);
}
.ch-roomrow:hover,
.ch-roomrow:focus-visible { border-color: var(--hi); }
.ch-roomrow-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.ch-roomrow-name { font-size: 14px; color: var(--hi); overflow-wrap: anywhere; }
.ch-roomrow-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--dim); }
.ch-roomrow-meta .is-live { color: var(--fg); }
.ch-roomrow-go { grid-row: 1 / 3; grid-column: 2; align-self: center; font-size: 12px; color: var(--dim); }
.ch-roomrow:hover .ch-roomrow-go { color: var(--hi); }

/* ---------- a room ---------- */

.ch-room {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: min(1120px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.ch-roomhead {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--line);
}
.ch-roomname { overflow-wrap: anywhere; }
.ch-roomtags { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.ch-online { font-size: 12px; }
.ch-roommain {
  position: relative;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 210px;
  min-height: 0;
}
/* wide screens show who is online; the button hides it (is-flipped) */
.ch-roommain.is-flipped { grid-template-columns: minmax(0, 1fr) 0; }
.ch-roommain.is-flipped .ch-people { display: none; }
.ch-log {
  min-height: 0;
  padding: 10px 0 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
}
.ch-people {
  min-height: 0;
  padding: 0 0 14px 14px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
}
.ch-person {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  color: var(--fg);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
}
.ch-person:hover,
.ch-person:focus-visible { border-color: var(--line-2); }
.ch-person-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ch-newer {
  position: absolute;
  bottom: 12px;
  left: 50%;
  z-index: 2;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--bg);
  background: var(--hi);
  border: 0;
  box-shadow: 0 0 18px rgba(255, 255, 255, .3);
  cursor: pointer;
  transform: translateX(-50%);
}

/* messages: the icon, then name / title / time, then the text. A run of
   messages from one person within five minutes shares one head. */
.ch-msg {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 0 12px;
  padding: 7px 34px 3px 4px;
}
.ch-msg.is-cont { padding-top: 0; }
.ch-msg.is-cont .ch-icon { visibility: hidden; height: 0; border: 0; }
.ch-msg:hover { background: rgba(255, 255, 255, .025); }
.ch-msg.is-owner { background: linear-gradient(90deg, rgba(255, 255, 255, .05), transparent 60%); }
.ch-msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
.ch-name {
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--hi);
  background: none;
  border: 0;
  cursor: pointer;
}
.ch-name:hover { text-decoration: underline; text-underline-offset: 3px; }
.ch-time { font-size: 10.5px; color: var(--dim); }
.ch-text {
  margin: 2px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ch-msg.is-owner .ch-text { color: var(--hi); }
.ch-del {
  position: absolute;
  top: 5px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  color: var(--dim);
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  opacity: 0;
}
.ch-msg:hover .ch-del,
.ch-del:focus-visible { opacity: 1; }
.ch-del:hover { color: var(--hi); border-color: var(--line-3); }
@media (hover: none) { .ch-del { opacity: .55; } }

.ch-status { flex: none; margin: 0; font-size: 11.5px; color: var(--dim); }
.ch-status:empty { display: none; }
.ch-form {
  display: flex;
  flex: none;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.ch-prompt { padding-bottom: 9px; color: var(--hi); }
.ch-in {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 132px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--hi);
  resize: none;
  background: rgba(0, 0, 0, .6);
  border: 1px solid var(--line-2);
  border-radius: 0;
  outline: none;
}
.ch-in:focus { border-color: var(--line-3); box-shadow: var(--glow-box); }
.ch-in:disabled { opacity: .55; }
.ch-left { min-width: 2ch; padding-bottom: 11px; font-size: 11px; color: var(--dim); }
.ch-left:empty { display: none; }
.ch-form .ch-btn { min-height: 40px; }

.ch-toast {
  position: fixed;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 50;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--bg);
  background: var(--hi);
  box-shadow: 0 0 22px rgba(255, 255, 255, .25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.ch-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- phones ---------- */

@media (max-width: 820px) {
  /* who is online: a sheet from the right, opened by the "online" button */
  .ch-roommain,
  .ch-roommain.is-flipped { grid-template-columns: minmax(0, 1fr); }
  .ch-people {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: none;
    width: min(260px, 82%);
    padding: 0 12px 14px;
    background: var(--panel);
    border-left: 1px solid var(--line-2);
    box-shadow: -20px 0 50px rgba(0, 0, 0, .7);
  }
  .ch-roommain.is-flipped .ch-people { display: block; }
}
@media (max-width: 640px) {
  .ch-top { flex-wrap: wrap; min-height: 0; padding-top: 8px; padding-bottom: 4px; }
  .ch-tabs { order: 3; width: 100%; margin: 0 -8px; }
  .ch-me-name { max-width: 9ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .ch-msg { grid-template-columns: 34px minmax(0, 1fr); gap: 0 10px; padding-right: 30px; }
  .ch-msg .ch-icon { width: 34px; height: 34px; font-size: 15px; }
  .ch-prompt { display: none; }
  .ch-rooms-head { flex-wrap: wrap; }
}

/* ---------- effects tiers and reduced motion ---------- */

html[data-fx="low"] .ch-layer { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(0, 0, 0, .86); }
@media (prefers-reduced-motion: reduce) {
  .guy-eye,
  .guy.is-no .guy-face,
  .guy.is-happy .guy-face,
  .ch-dialog,
  .ch-wait span { animation: none; }
  .ch-toast { transition: none; }
}
