/* Everheim Online Idle - Social: friends, private messages, guilds. Uses the tokens from style.css (light + dark). */
:root {
  --soc-whisper: var(--log-rare, #6a2fb8);
  --soc-whisper-soft: rgba(122, 61, 200, 0.07);
  --soc-whisper-line: var(--log-rare-line, #a98ae0);
  --soc-guild: #17704a;
  --soc-guild-text: #1f4d39;
  --soc-guild-soft: rgba(27, 115, 64, 0.07);
  --soc-guild-line: #7cbf96;
  --soc-tag: var(--primary-text, #1d4fa8);
  --soc-on: var(--good, #1b7340);
}
:root[data-theme="dark"] {
  --soc-whisper: #d9c4ff;
  --soc-whisper-soft: rgba(154, 100, 232, 0.11);
  --soc-whisper-line: #9a64e8;
  --soc-guild: #8fe6c0;
  --soc-guild-text: #cdeee0;
  --soc-guild-soft: rgba(143, 230, 192, 0.07);
  --soc-guild-line: #4a9a78;
  --soc-tag: #8dbdff;
}

/* ---------------------------------------------------------------- names, tags, pills */
.name-link {
  appearance: none; display: inline; padding: 0; margin: 0; border: 0; background: none; border-radius: 3px; cursor: pointer;
  font: inherit; font-weight: 800; color: var(--text-strong); text-align: left;
}
.name-link:hover { color: var(--sel-text); text-decoration: underline; text-underline-offset: 2px; }
.name-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.name-self { font-weight: 800; color: var(--text-strong); }
.gtag { margin-right: 4px; font-size: 0.86em; font-weight: 800; letter-spacing: 0.2px; color: var(--soc-tag); white-space: nowrap; }
.pill.sel, .pill.cost-pill { color: var(--sel-text); border-color: var(--sel-line); background: var(--sel-soft); }
.on-text { color: var(--soc-on); font-weight: 700; }
.player .btn.icon, .soc-row .btn.icon { flex: none; font-size: 15px; line-height: 1; }
.rank .name-link { font-weight: 700; }

/* ---------------------------------------------------------------- chat box: channels, whispers, guild lines */
.chat-tabs [hidden], .chip-n[hidden] { display: none !important; }
.chip-n {
  display: inline-block; margin-left: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-pill);
  background: var(--primary); color: var(--text-on-primary); font-size: 10px; font-weight: 900; font-style: normal; line-height: 16px; text-align: center;
}
.chat-line .cn { color: var(--chat-name); }
.chat-line .cn:hover { color: var(--link-hover); }
.chat-line.me .cn, .chat-line .name-self.cn { color: var(--sel-text); }
.chat-line .gtag { margin-right: 3px; }
.chat-line.wh { color: var(--soc-whisper); background: var(--soc-whisper-soft); border-left: 2px solid var(--soc-whisper-line); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; margin: 1px 0; }
.chat-line.wh .cn { color: var(--soc-whisper); }
.chat-line.wh.out { background: transparent; }
.wh-dir { font-size: var(--fs-micro); font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; opacity: 0.85; }
.chat-line.gc { color: var(--soc-guild-text); }
.chat-line.gc .cn { color: var(--soc-guild); }
.chat-line.gc.me .cn, .chat-line.gc .name-self.cn { color: var(--soc-guild); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.chat-line.sys.gsys { color: var(--soc-guild); background: var(--soc-guild-soft); border-left-color: var(--soc-guild-line); }
.chat-line.sys.gsys .sys-mark { color: var(--soc-guild); }
.chat-empty b { color: var(--text-soft); }

.toast.whisper { --toast-c: var(--soc-whisper); }
.toast.whisper::before { content: '\2709'; font-size: 11px; }

/* ---------------------------------------------------------------- name menu */
.name-menu {
  position: fixed; z-index: calc(var(--z-tooltip, 90) - 2); min-width: 220px; max-width: 290px; padding: 6px;
  border-radius: var(--radius); background: var(--surface-glass); border: 1px solid var(--border); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: nm-in var(--dur-fast, 120ms) var(--ease, ease);
}
@keyframes nm-in { from { opacity: 0; transform: translateY(-3px); } }
.nm-head { display: flex; align-items: center; gap: 10px; padding: 5px 8px 9px; margin-bottom: 4px; border-bottom: 1px solid var(--hairline-2); line-height: 1.3; }
.nm-head .avatar { width: 32px; height: 32px; font-size: 14px; }
.nm-name b { color: var(--text-strong); }
.nm-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.nm-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 32px; padding: 0 10px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--text); font: inherit; font-size: 13px; font-weight: 700; text-align: left; cursor: pointer;
}
.nm-item .pi { width: 15px; height: 15px; color: var(--sel-text); }
.nm-item:hover, .nm-item:focus-visible { background: var(--sel-soft); color: var(--text-strong); outline: none; }
.nm-item:focus-visible { box-shadow: 0 0 0 2px var(--focus) inset; }
.nm-item.bad, .nm-item.bad .pi { color: var(--bad); }
.nm-item.bad:hover, .nm-item.bad:focus-visible { background: var(--bad-soft); color: var(--bad-strong); }
.nm-item.good .pi { color: var(--good); }

/* ---------------------------------------------------------------- friends panel */
.soc-form { display: flex; gap: var(--s-2); margin-bottom: var(--s-3); }
.soc-form .search-field { flex: 1 1 auto; min-width: 0; }
.soc-actions { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.soc-counts { display: inline-flex; align-items: center; gap: 6px; }
.soc-row .player-main { min-width: 0; }
.soc-row .player-main > div { overflow-wrap: anywhere; }
.player.req { border-color: var(--border-accent); background: linear-gradient(90deg, var(--primary-soft), var(--surface-2) 65%); }
.player.pending { background: var(--surface-sunken); }
.player.is-off { background: var(--surface-sunken); }
.player.is-off .avatar { filter: saturate(0.35); opacity: 0.8; }
.soc-row .btn .tab-count { margin-left: 2px; }

/* conversations */
.dm-list { display: flex; flex-direction: column; gap: 6px; }
.dm-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border-soft); transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.dm-row:hover { border-color: var(--border); background: var(--surface-3); }
.dm-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dm-row.unread { border-color: var(--sel-line); background: linear-gradient(90deg, var(--sel-soft), var(--surface-2) 70%); }
.dm-row-main { min-width: 0; line-height: 1.3; }
.dm-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); }
.dm-row-top b { color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-time { flex: none; font-size: var(--fs-micro); color: var(--text-faint); font-variant-numeric: tabular-nums; }
.dm-preview { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-row.unread .dm-preview { color: var(--text); font-weight: 700; }

/* thread */
.dm-head { display: flex; align-items: center; gap: 10px; padding-bottom: var(--s-2); margin-bottom: var(--s-2); border-bottom: 1px solid var(--hairline-2); }
.dm-head-main { min-width: 0; line-height: 1.3; }
.dm-head-name { font-weight: 800; overflow-wrap: anywhere; }
.dm-thread {
  display: flex; flex-direction: column; gap: 2px; height: clamp(240px, calc(100vh - 380px), 620px); height: clamp(240px, calc(100dvh - 380px), 620px);
  overflow-y: auto; overscroll-behavior: contain; padding: 8px 8px 10px; border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border-soft);
}
.dm-msg { display: flex; flex-direction: column; max-width: 84%; margin: 2px 0; }
.dm-msg.mine { align-self: flex-end; align-items: flex-end; }
.dm-msg.theirs { align-self: flex-start; align-items: flex-start; }
.dm-bubble { padding: 7px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.dm-msg.theirs .dm-bubble { background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--text); border-bottom-left-radius: 4px; box-shadow: var(--shadow-1); }
.dm-msg.mine .dm-bubble { background: var(--btn-primary-bg); border: 1px solid var(--primary-line); color: var(--text-on-primary); border-bottom-right-radius: 4px; box-shadow: 0 1px 4px var(--primary-glow); }
.dm-msg + .dm-msg.mine, .dm-msg + .dm-msg.theirs { margin-top: 1px; }
.dm-meta { margin: 1px 5px 0; font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.dm-day { display: flex; align-items: center; gap: var(--s-2); margin: 8px 0 4px; font-size: var(--fs-micro); font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }
.dm-day::before, .dm-day::after { content: ''; flex: 1; height: 1px; background: var(--hairline-2); }
.dm-start { padding: 10px 8px 4px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }
.dm-start b { color: var(--text-soft); }
.dm-older { display: flex; justify-content: center; padding: 2px 0 6px; }
.dm-empty { margin: auto; padding: var(--s-3); }
.dm-form { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
.dm-form label { display: flex; min-width: 0; }
.dm-form input { width: 100%; min-height: 38px; }
.dm-form .btn { min-height: 38px; }
.dm-foot { gap: var(--s-2); margin-top: var(--s-2); }
.dm-blocked { margin: var(--s-2) 0 0; }

/* ---------------------------------------------------------------- guild panel */
.gd-crest {
  flex: none; display: grid; place-items: center; width: 54px; height: 60px; padding-bottom: 6px;
  font-family: var(--title); font-size: 14px; font-weight: 800; letter-spacing: 0.4px; color: var(--text-on-primary); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  background: var(--btn-primary-bg); clip-path: polygon(50% 0, 100% 13%, 100% 60%, 50% 100%, 0 60%, 0 13%);
}
.gd-crest.sm { width: 34px; height: 38px; padding-bottom: 4px; font-size: 10.5px; }
.gd-head { display: flex; align-items: center; gap: 14px; }
.gd-title { font-family: var(--title); font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.3px; color: var(--text-strong); overflow-wrap: anywhere; }
.gd-title .gtag { font-family: var(--font); font-size: var(--fs-sm); }
.gd-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.gd-motd .card-head { margin-bottom: 6px; }
.gd-motd-text { margin: 0; padding: 8px 11px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; color: var(--text); background: var(--sel-softer); border-left: 3px solid var(--sel-line); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.gd-motd p.muted { margin: 0; }
.gd-motd textarea { font-family: var(--font); font-size: 13.5px; line-height: 1.45; }
.gd-motd .card-actions { margin-top: var(--s-2); }
.rank-pill { margin-left: 4px; }
.rank-pill.rk-leader { color: var(--text-on-primary); background: var(--btn-primary-bg); border-color: var(--primary-line); }
.rank-pill.rk-officer { color: var(--sel-text); border-color: var(--sel-line); background: var(--sel-soft); }
.gd-invites { display: flex; flex-direction: column; gap: 4px; margin: -4px 0 var(--s-3); }
.gd-invite { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); padding: 6px 10px; font-size: 13px; border-radius: var(--radius-sm); background: var(--surface-sunken); border: 1px dashed var(--border); }
.gd-invite b { color: var(--text-strong); }
.gd-note { margin: -4px 2px var(--s-3); }
.gd-danger { margin-top: var(--s-4); }
.gd-fields { grid-template-columns: minmax(0, 1fr) 100px; }
.gd-create .card-sub { margin-top: 0; }

@media (max-width: 720px) {
  .soc-row { flex-wrap: wrap; }
  .soc-row .soc-actions { width: 100%; justify-content: flex-start; padding-left: 44px; }
  .dm-msg { max-width: 92%; }
  .gd-head { flex-wrap: wrap; }
}
