/* /commands: a Discord channel in the server's theme, filling the screen under the site's header, with every
   command alongside (a drawer on phones). The messages, buttons and menus are site.css's Discord pieces. */

body.chat-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.chat-page .site-header { position: relative; flex: none; }
.chat { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 280px; }
.chat-channel { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* The channel's bar. */
.chat-bar .dc-channel { font-size: 1rem; }
.chat-tools { display: flex; gap: 2px; margin-left: auto; }
.chat-tool { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; color: #B7C4C6; cursor: pointer; }
.chat-tool:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.chat-tool[aria-expanded="true"] { color: #fff; background: rgba(255, 255, 255, 0.1); }
.chat-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-tool:focus-visible, .chat-cmd:focus-visible, .chat-send:focus-visible { outline: 2px solid var(--dc-link); outline-offset: 1px; }

/* The history: scrolls on its own; the newest message at the bottom. */
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px 14px; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.chat-log:focus-visible { outline: 2px solid var(--dc-link); outline-offset: -2px; }
.chat-log > .dc-msg { margin: 14px -16px 0; padding: 4px 16px; }
.chat-log > .dc-msg:hover { background: rgba(0, 0, 0, 0.08); }
.chat-log > .dc-msg.is-ephemeral:hover { background: rgba(88, 101, 242, 0.1); }

/* A card: as wide as the channel allows, never taller than the screen (--ar: its width / height); a click opens it
   full size. */
.chat-log .dc-card {
  display: block;
  max-width: max(300px, min(1000px, calc((100vh - 210px) * var(--ar))));
  max-width: max(300px, min(1000px, calc((100dvh - 210px) * var(--ar))));
  aspect-ratio: var(--ar); padding: 0; border: 0; color: inherit; font: inherit; cursor: zoom-in;
}
.chat-log .dc-card img { object-fit: contain; transition: filter 0.15s; }
.chat-log .dc-card:hover img { filter: brightness(1.06); }
.chat-log .dc-card:focus-visible { outline: 2px solid var(--dc-link); outline-offset: 2px; }
.chat-log .dc-content { transition: opacity 0.15s; }
.chat-log .dc-content.is-busy { opacity: 0.55; }

/* The card, full size: over everything, as big as the screen allows. */
.chat-zoom { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: none; overflow: hidden; }
.chat-zoom[open] { display: grid; place-items: center; }
.chat-zoom::backdrop { background: rgba(2, 10, 12, 0.88); }
.chat-zoom img { width: auto; height: auto; max-width: calc(100vw - 32px); max-height: calc(100dvh - 110px); border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); cursor: zoom-out; }
.chat-zoom-close {
  position: fixed; top: 12px; right: 12px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12); color: #fff; font: 400 1.8rem/1 var(--font); cursor: pointer;
}
.chat-zoom-close:hover { background: rgba(255, 255, 255, 0.22); }
.chat-zoom-open { position: fixed; bottom: calc(18px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); padding: 8px 14px; color: #DCE4E4; font-size: 0.85rem; }
.chat-zoom-open:hover { color: #fff; text-decoration: underline; }
.chat-zoom-close:focus-visible, .chat-zoom-open:focus-visible { outline: 2px solid var(--dc-link); outline-offset: 2px; }
.chat-start { padding: 28px 0 10px; }
.chat-start-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 2.5rem; font-weight: 300; line-height: 1; }
.chat-start h2 { margin: 12px 0 6px; color: #fff; font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); letter-spacing: -0.01em; }
.chat-start p { max-width: 46em; color: #A9B8BA; font-size: 0.95rem; }
.chat-start b, .chat-noscript b { color: #fff; }
.chat-noscript { margin-top: 16px; color: #A9B8BA; }

/* The message box. */
.chat-composer { position: relative; flex: none; padding: 0 16px 20px; }
.chat-input { cursor: text; }
.chat-input:focus-within { box-shadow: 0 0 0 2px rgba(113, 172, 243, 0.4); }
.chat-input input { flex: 1; min-width: 0; height: 46px; padding: 0; border: 0; background: none; color: var(--dc-text); font: 400 1rem var(--font); outline: none; }
.chat-input input::placeholder { color: var(--dc-faint); opacity: 1; }
.chat-send { display: none; place-items: center; width: 40px; height: 40px; margin-right: -8px; border: 0; border-radius: 8px; background: none; color: #DCE4E4; cursor: pointer; }
.chat-send svg { width: 20px; height: 20px; fill: currentColor; }
.chat-pick { left: 16px; right: 16px; bottom: calc(100% - 12px); max-height: min(360px, 50vh); overflow-y: auto; }
.chat-pick .dc-pick-item i { color: var(--dc-muted); font-style: normal; font-weight: 500; }
.chat-pick .dc-pick-item[aria-selected="true"] { background: rgba(255, 255, 255, 0.08); }

/* Every command, like Discord's member list. */
.chat-panel {
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 16px 10px;
  border-left: 1px solid rgba(0, 0, 0, 0.28); background: rgba(3, 18, 20, 0.28);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.chat-panel > * { flex: none; } /* the list scrolls; its rows keep their height instead of squeezing into each other */
.chat-panel-title { display: flex; align-items: center; justify-content: space-between; margin: 0 8px 4px; color: #fff; font-size: 0.95rem; letter-spacing: 0; }
.chat-panel-title span { color: var(--dc-muted); font-size: 0.8rem; font-weight: 600; }
.chat-group { margin: 16px 8px 4px; color: var(--dc-muted); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.chat-cmd {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 5px 8px; border: 0; border-radius: 6px;
  background: none; color: var(--dc-text); font: inherit; text-align: left; cursor: pointer;
}
.chat-cmd:hover { background: rgba(255, 255, 255, 0.07); }
.chat-cmd > span:last-child { min-width: 0; }
.chat-cmd-ico { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, 0.1); color: var(--dc-link); }
.chat-cmd-ico svg { width: 16px; height: 16px; fill: currentColor; }
.chat-cmd b { display: block; overflow: hidden; color: #E8EEEE; font-size: 0.9rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.chat-cmd small { display: block; overflow: hidden; color: var(--dc-muted); font-size: 0.76rem; white-space: nowrap; text-overflow: ellipsis; }
.chat-legal { margin-top: auto; padding: 18px 8px 4px; color: var(--dc-muted); font-size: 0.72rem; line-height: 1.5; }
.chat-legal a { color: var(--dc-link); }

@media (min-width: 1000px) { .chat-panel-toggle { display: none; } }
/* Narrower: the list slides in from the right. */
@media (max-width: 999px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat-panel {
    position: fixed; top: var(--header); right: 0; bottom: 0; z-index: 45; width: min(320px, 88vw);
    background: linear-gradient(160deg, #0F3639, #143A33); box-shadow: -30px 0 60px -20px rgba(0, 0, 0, 0.7);
    transform: translateX(100%); visibility: hidden; transition: transform 0.22s ease, visibility 0.22s;
  }
  .chat.panel-open .chat-panel { transform: none; visibility: visible; }
  .chat.panel-open::after { content: ""; position: fixed; inset: var(--header) 0 0; z-index: 44; background: rgba(0, 0, 0, 0.45); }
}
@media (max-width: 639px) {
  .chat-bar .dc-topic { display: none; }
  .chat-log { padding: 6px 12px 12px; }
  .chat-log > .dc-msg { margin-inline: -12px; padding-inline: 12px; }
  .chat-log .dc-msg { grid-template-columns: 32px minmax(0, 1fr); column-gap: 12px; }
  .chat-log .dc-avatar { width: 32px; height: 32px; }
  .chat-log .dc-reply::before { left: -30px; width: 26px; }
  .chat-log .dc-btn { padding-inline: 12px; }
  /* A card takes the message's whole width, under the avatar too. */
  .chat-log .dc-content > .dc-card { width: calc(100% + 44px); max-width: none; margin-left: -44px; }
  .chat-zoom img { max-width: 100vw; border-radius: 0; }
  .chat-composer { padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
  .chat-pick { left: 12px; right: 12px; }
  .chat-send { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-panel { transition: none; }
}
