/*! Copyright (c) 2026 BamByte (bambyte.net). All rights reserved.
 * Proprietary code: no copying, redistribution, or use to train or prompt
 * AI / machine-learning systems without written permission from BamByte. */
/* InkBuds -- online mode (game.html?mode=online).
   The site's shared online chrome: the control cluster and account strip at
   the top of the sidebar HUD panel, and the room chat (Chat / Players / Info)
   under the HUD. Same class names (.cn-online-*) and shared button art as
   every other online game; taken from Bamzee's online.css. A drawing room has
   no lobby card -- the canvas is live from the start -- so that part is left
   out, and the Room box and the tool rail on the board are added at the end.
   Every rule is gated on body.online-mode, or names markup that only exists
   online. */

/* ---- The bar itself never shows: its contents live in the sidebar ---------- */
.cn-online-control-bar,
body.online-mode .cn-online-control-bar { display: none; }
body.online-mode .bb-toolbar,
body.online-mode .ink-side { display: none !important; }
/* No coaching and no offline-only keys in a game against people. */
body.online-mode #hud-hint,
body.online-mode .ink-offline-only { display: none; }

/* ---- Control cluster, at the top of the HUD panel ------------------------- */
body.online-mode #rightPanel .cn-online-control-bar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 16px;
  background: #4a4a4a;
  border: 2px solid #6d6d6d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.45);
}
.cn-online-control-bar-icon-btn {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 0;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.cn-online-control-bar-icon-btn img { display: block; width: 100%; height: 100%; }
.cn-online-control-bar-icon-btn[hidden] { display: none; }
.cn-online-control-bar-icon-btn:hover,
.cn-online-control-bar-icon-btn:focus-visible { filter: brightness(1.18); transform: translateY(-1px); }
.cn-online-control-bar-icon-btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }

/* "Hide HUD" / the chat view collapse the panel to just the cluster. */
body.online-mode #rightPanel .hud-collapsed > *:not(.cn-online-control-bar-controls) { display: none; }

/* ---- Account strip (name / avatar / Boins), above the cluster ------------- */
.cn-online-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 8px;
}
.cn-online-profile[hidden] { display: none; }
.cn-online-profile__name {
  color: #eef2f5;
  font-weight: 700;
  font-size: 15px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cn-online-profile__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--game-accent);
  background: #222;
}
.cn-online-profile__badge {
  position: relative;
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 10px 0 30px;
  border: 2px solid var(--game-accent);
  border-radius: 17px;
  background: rgba(0, 0, 0, 0.35);
}
.cn-online-profile__badge-coin {
  position: absolute;
  left: -6px;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
}
.cn-online-profile__badge-value { display: flex; align-items: center; gap: 3px; }
.cn-online-profile__badge-sign { height: 14px; width: auto; }
.cn-online-profile__badge-amount { color: #fff; font-weight: 800; font-size: 14px; }

/* ---- Layout menu (Dock Left / Right) and Quick Switch popover ------------- */
.cn-online-layout-menu {
  position: fixed;
  z-index: 610;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: #242323;
  border: 2px solid var(--game-accent);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
}
.cn-online-layout-menu[hidden] { display: none; }
.cn-online-layout-menu-item {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #eef2f5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid #2b2b2b;
  border-radius: 8px;
  cursor: pointer;
}
.cn-online-layout-menu-item:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); }
.cn-online-layout-menu-item:disabled { opacity: 0.45; cursor: default; }

.cn-online-switch-menu {
  position: fixed;
  z-index: 610;
  min-width: 260px;
  max-height: calc(var(--bb-vh, 100dvh) - 24px);
  overflow-y: auto;
  background: #242323;
  border: 3px solid var(--game-accent);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.cn-online-switch-menu[hidden] { display: none; }
.cn-online-switch-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  color: #eeeeee;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s ease, transform .15s ease;
}
.cn-online-switch-item:hover,
.cn-online-switch-item:focus-visible { background: rgba(255, 255, 255, 0.08); transform: scale(1.02); outline: none; }
.cn-online-switch-item img {
  display: block;
  width: 46px;
  height: 28px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 2px solid var(--game-accent);
}

/* ---- Chat panel under the HUD ---------------------------------------------- */
body.online-mode #sb-content {
  display: block;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background-color: rgba(12, 16, 24, 0.4);
  border: 3px solid var(--game-accent);
  border-radius: 8px;
  padding: 8px;
}
/* The HUD panel shares the column with the chat: it may scroll, never crowd it out. */
body.online-mode #rightPanel > .hud-panel { flex: 0 1 auto; max-height: 60%; }

.sidebar-tabs-overlay {
  position: absolute;
  inset: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.sidebar-tabs { display: flex; gap: 8px; }
.sidebar-tabs .tab {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #2b2b2b;
  background: rgba(0, 0, 0, .25);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-tabs .tab.active { outline: 2px solid rgba(var(--game-accent-rgb), .6); }
.tab-panels { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tab-panel { flex: 1; min-height: 0; }
.tab-panel .pad { padding: 8px; opacity: .8; }

.chat-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 8px; }
.chat-messages { flex: 1; min-height: 0; overflow: auto; border-radius: 8px; padding: 8px; background: rgba(0, 0, 0, .08); }
.chat-row { padding: 6px 8px; border: 2px solid #00000072; border-radius: 8px; margin: 4px 0; background: rgba(255, 255, 255, .04); }
.chat-row.mine { background: rgba(255, 255, 255, .1); }
.chat-row-meta { display: flex; gap: 6px; font-size: 12px; opacity: .75; margin-bottom: 2px; }
.chat-row-text { word-wrap: break-word; overflow-wrap: anywhere; }
/* Emoji / GIF on their own line, input + Send under them: four across never
   fit the sidebar's width. */
.chat-input-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas:
    "emoji gif   .     .   "
    "input input input send";
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.chat-input-row .btn-emoji { grid-area: emoji; }
.chat-input-row .btn-gif { grid-area: gif; }
.chat-input-row #chat-send { grid-area: send; }
.chat-input-row input[type="text"] { grid-area: input; min-width: 0; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; border: 1px solid #2b2b2b; }
.chat-input-row button { padding: 8px 12px; border-radius: 8px; border: 1px solid #2b2b2b; cursor: pointer; background: rgba(0, 0, 0, .06); }
.chat-input-row .btn-emoji { background: url('/assets/img/yellow_glass_button.webp') center/100% 100% no-repeat; border: none; }
.chat-input-row .btn-gif { background: url('/assets/img/red_glass_button.webp') center/100% 100% no-repeat; border: none; color: #fcfcfc; font-weight: 700; }
.chat-input-row #chat-send { background: url('/assets/img/green_glass_button.webp') center/100% 100% no-repeat; border: none; color: #0a0a0a; font-weight: 700; }

.chat-toolbar { display: flex; gap: 8px; margin-bottom: 6px; }
.chat-toolbar button { padding: 6px 10px; border-radius: 8px; border: 3px solid #9f0e0e; background: rgba(0, 0, 0, .06); cursor: pointer; }
.popover {
  position: absolute;
  top: 70px; left: 8px; right: 8px;
  max-height: calc(var(--bb-vh, 100vh) * .8); overflow: auto;
  background: rgba(0, 0, 0, .85);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; padding: 8px; z-index: 999;
  backdrop-filter: blur(2px);
}
.emoji-mart, .emoji-mart * { box-sizing: border-box; }
.gif-search { margin-bottom: 8px; }
.gif-search input { width: 50%; padding: 8px 10px; border-radius: 8px; border: 1px solid #2b2b2b; background: #111; color: #eee; }
.gif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gif-item { border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 8px; overflow: hidden; }
.gif-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-img { max-width: 100%; border-radius: 8px; display: block; }

/* ---- Players tab (/net/players_list.js) ------------------------------------ */
#panel-players { display: flex; flex-direction: column; min-height: 0; }
#panel-players[hidden] { display: none; }
.bb-players-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.bb-players-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 13px;
}
.bb-players-avatar { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: #4a4949; }
.bb-players-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--bb-chat-name-color, #fff);
}
.bb-players-role { flex: 0 0 auto; font-size: 11px; color: #fff; opacity: 0.75; }
.bb-players-bump {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.bb-players-bump img { display: block; width: 100%; height: 100%; }
.bb-players-bump:hover,
.bb-players-bump:focus-visible { opacity: 1; transform: scale(1.12); outline: none; }

/* ---- Info tab (net/info_tab.js: the rules) --------------------------------- */
#panel-info,
#game-info-panel { overflow-y: auto; }
.game-info { padding: 4px 6px; color: #fff; }
.game-info h3 { margin: 0 0 10px; font-size: 15px; color: var(--game-accent); }
.game-info dt { margin-top: 10px; font-weight: 800; font-size: 13px; color: var(--game-accent); }
.game-info dd { margin: 2px 0 8px; font-size: 12.5px; line-height: 1.45; color: #fff; }

/* ==== Phones and tablets ==================================================== */
@media (orientation: portrait) and (max-width: 1024px) {
  /* The chat needs a height of its own in the scrolling stack. */
  body.online-mode #rightPanel { height: min(640px, calc(var(--bb-vh, 100dvh) * .85)); }
  body.online-mode #rightPanel > .hud-panel { max-height: none; }
  body.online-mode #sb-content { min-height: 260px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.online-mode #sb-content { flex: 1 0 auto; min-height: 240px; }
}

/* ---- Room box (top of the HUD body, js/online/session.js) ----------------- */
.ink-room-count { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.ink-room-status { margin: 0 0 8px; font-size: 12.5px; line-height: 1.4; color: #fff; }
.ink-room-btns { display: flex; gap: 6px; }
.ink-room-btns .ink-btn { flex: 1 1 0; }
.ink-room-btns .ink-btn[hidden] { display: none; }
.ink-layer-name small { color: var(--game-accent); font-weight: 800; }

.ink-room-invite { margin-top: 6px; }
.ink-room-invite[hidden] { display: none; }

