/* vibeos.top/discussion: an mIRC-style window (channel tree, chat, nick list, input line) on the site's tokens.
   Event lines keep mIRC's classic colours: joins/parts/topics green, quits navy, actions purple, notices maroon. */
:root {
  --irc-panel: #f4f5f8;
  --irc-ts: #8a90a0;
  --irc-ev: #1f7a1f;
  --irc-quit: #1E2D4A;
  --irc-act: #8a1c8a;
  --irc-notice: #7f1d1d;
  --irc-info: #2f4b86;
  --irc-err: #b42318;
  --irc-mono: "Roboto Mono", ui-monospace, "SF Mono", "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --irc-panel: #171a20; --irc-ts: #7c8392; --irc-ev: #7ccf7c; --irc-quit: #a8b8e6; --irc-act: #d99ae0;
    --irc-notice: #e8a0a0; --irc-info: #a8b8e6; --irc-err: #ff8a80;
  }
}
:root[data-theme="dark"] {
  --irc-panel: #171a20; --irc-ts: #7c8392; --irc-ev: #7ccf7c; --irc-quit: #a8b8e6; --irc-act: #d99ae0;
  --irc-notice: #e8a0a0; --irc-info: #a8b8e6; --irc-err: #ff8a80;
}

body.chat-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
/* with the on-screen keyboard open: the height that is actually visible (set from visualViewport) */
body.chat-page.irc-vv { height: var(--irc-vh); }
body.chat-page > .top { position: relative; flex: none; }

.irc {
  flex: 1; min-height: 0; width: 100%; max-width: 1400px; margin: 0 auto; padding: 14px 20px 18px;
  display: grid; grid-template-columns: 190px minmax(0, 1fr) 180px; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "title title title" "tree win nicks" "input input input";
}
.irc > * { border: 0 solid var(--line); }
.irc-no-nicks .irc { grid-template-columns: 190px minmax(0, 1fr) 0; }
.irc-no-nicks .irc-nicks { display: none; }

/* title bar */
.irc-titlebar {
  grid-area: title; display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--brand); color: var(--bg); padding: 7px 10px 7px 14px; border-radius: 12px 12px 0 0;
  font-family: var(--irc-mono); font-size: 14px;
}
.irc-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.irc-status { margin-left: auto; opacity: .75; white-space: nowrap; font-size: 13px; }
.irc-users-btn {
  display: none; border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); background: transparent; color: inherit;
  font: inherit; font-size: 13px; border-radius: 8px; padding: 3px 10px; cursor: pointer;
}

/* channel tree */
.irc-tree {
  grid-area: tree; background: var(--irc-panel); border-width: 0 1px 0 1px; overflow-y: auto; padding: 6px 0;
  display: flex; flex-direction: column;
}
.irc-item {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 0; background: none; color: var(--muted);
  font-family: var(--irc-mono); font-size: 14px; padding: 5px 14px; cursor: pointer; border-left: 3px solid transparent;
}
.irc-item:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.irc-item.is-status { color: var(--text); font-weight: 700; }
.irc-item.is-active { color: var(--text); background: var(--bg); border-left-color: var(--brand); }
.irc-item.has-unread { color: var(--text); font-weight: 700; }
.irc-item.has-mention { color: var(--irc-err); }
.irc-item.is-off .irc-item-name { opacity: .55; }
.irc-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.irc-badge {
  margin-left: auto; font-size: 11px; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 99px;
  background: var(--line); color: var(--text);
}
.irc-item.has-mention .irc-badge { background: var(--irc-err); color: #fff; }

/* the chat window */
.irc-window { grid-area: win; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.irc-topic {
  flex: none; padding: 7px 14px; border-bottom: 1px solid var(--line); font-family: var(--irc-mono); font-size: 13px;
  color: var(--muted); line-height: 1.45; max-height: calc(2 * 1.45em + 14px); overflow: hidden; overflow-wrap: anywhere;
}
.irc-log {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 14px 10px;
  font-family: var(--irc-mono); font-size: 14px; line-height: 1.5;
}
.irc-lines .l { white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 8ch; text-indent: -8ch; }
.irc-lines .ts { color: var(--irc-ts); }
.irc-lines .n { cursor: pointer; }
.irc-lines .n:hover { text-decoration: underline; }
.irc-lines a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.l-own .n { font-weight: 700; }
.l-join, .l-part, .l-nick, .l-topic, .l-mode, .l-kick { color: var(--irc-ev); }
.l-quit { color: var(--irc-quit); }
.l-action { color: var(--irc-act); }
.l-notice { color: var(--irc-notice); }
.l-info { color: var(--irc-info); }
.l-error { color: var(--irc-err); }
.l-hl { background: color-mix(in srgb, var(--irc-err) 9%, transparent); box-shadow: inset 3px 0 0 var(--irc-err); }
.f-b { font-weight: 700; } .f-i { font-style: italic; } .f-u { text-decoration: underline; } .f-s { text-decoration: line-through; }

/* nick list */
.irc-nicks { grid-area: nicks; background: var(--irc-panel); border-width: 0 1px 0 1px; overflow-y: auto; min-height: 0; }
.irc-nicks-head { font-family: var(--irc-mono); font-size: 12px; color: var(--faint); padding: 8px 14px 4px; }
.irc-nicks ul { list-style: none; margin: 0; padding: 0 0 8px; }
.irc-nicks li {
  font-family: var(--irc-mono); font-size: 14px; padding: 2px 14px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.irc-nicks li:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.irc-nicks li.is-away { color: var(--faint); }

/* input line */
.irc-input {
  grid-area: input; display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--irc-panel);
  border-width: 1px; border-radius: 0 0 12px 12px;
}
.irc-nick, .irc-send {
  flex: none; font-family: var(--irc-mono); font-size: 14px; border-radius: 9px; padding: 8px 12px; cursor: pointer;
  max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.irc-nick { border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.irc-send { border: 0; background: var(--brand); color: var(--bg); font-weight: 700; }
/* a textarea, not an input: Chrome on Android hangs its password/card/address bar over any text input */
.irc-input textarea {
  flex: 1; min-width: 0; font-family: var(--irc-mono); font-size: 15px; line-height: 1.4; padding: 8px 11px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none;
  resize: none; overflow-y: auto; height: calc(1.4em + 18px); min-height: calc(1.4em + 18px); max-height: calc(4 * 1.4em + 18px);
  field-sizing: content; white-space: pre-wrap; overflow-wrap: anywhere; display: block;
}
.irc-input textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.irc-noscript { padding: 24px 20px; }

/* phones: mIRC's switchbar on top, the nick list slides in from the right */
@media (max-width: 760px) {
  .irc {
    padding: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "title" "tree" "win" "input";
  }
  .irc-no-nicks .irc { grid-template-columns: minmax(0, 1fr); }
  .irc-titlebar { border-radius: 0; padding: 6px 8px 6px 14px; }
  .irc-status { display: none; }
  .irc-users-btn { display: block; margin-left: auto; }
  .irc-tree {
    flex-direction: row; overflow-x: auto; overflow-y: hidden; border-width: 0 0 1px; padding: 0 6px; scrollbar-width: none;
  }
  .irc-tree::-webkit-scrollbar { display: none; }
  .irc-item { width: auto; flex: none; padding: 9px 11px; border-left: 0; border-bottom: 3px solid transparent; }
  .irc-item.is-active { border-bottom-color: var(--brand); }
  .irc-log { padding: 6px 12px 8px; font-size: 13.5px; }
  .irc-lines .l { padding-left: 0; text-indent: 0; }
  .irc-topic { padding: 6px 12px; }
  .irc-nicks {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(72vw, 260px); z-index: 30; border-width: 0 0 0 1px;
    transform: translateX(105%); transition: transform .18s ease; box-shadow: var(--shadow); padding-top: 8px;
  }
  .irc-show-nicks .irc-nicks { transform: none; }
  .irc-input { border-width: 1px 0 0; border-radius: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .irc-input textarea { font-size: 16px; }
  .irc-send { display: none; }
}
@media (prefers-reduced-motion: reduce) { .irc-nicks { transition: none; } }
