/* Temporary lobby chat in the focus scene (public/js/lobby-chat.js).
   Mobile: sheet at the bottom of the 3D stage. Desktop (>= 900px): side panel on the right. */

/* ---- toggle button in .fx-stage-btns ---- */
.lc-btn {
  position: relative; pointer-events: auto;
  background: var(--glass, rgba(255, 255, 255, .82)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.lc-btn.is-open { background: var(--accent-2-soft); border-color: var(--accent-2); }
.lc-badge {
  position: absolute; top: -5px; right: -5px; min-width: 22px; height: 22px; padding: 0 6px;
  display: inline-grid; place-items: center; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--surface);
  font-size: var(--fs-xs); font-weight: 900; line-height: 1; box-shadow: var(--shadow-sm);
  animation: lc-pop .35s var(--ease-bounce, ease-out);
}

/* ---- panel ---- */
.lc-panel {
  position: absolute; z-index: 5;
  left: var(--s2, 8px); right: var(--s2, 8px); bottom: var(--s2, 8px);
  height: min(62%, 460px); min-height: 260px;
  display: flex; flex-direction: column;
  background: rgba(255, 253, 251, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius-lg, 26px); box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: lc-in .28s var(--ease-out, ease-out);
}
.lc-head { display: flex; align-items: flex-start; gap: var(--s2, 8px); padding: var(--s3, 12px) var(--s2, 8px) var(--s2, 8px) var(--s4, 16px); border-bottom: 1px solid var(--line); }
.lc-head-text { flex: 1; min-width: 0; }
.lc-title { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-md, 16px); font-weight: 900; }
.lc-sub { margin: 2px 0 0; font-size: var(--fs-xs, 12px); color: var(--text-dim); }

.lc-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: var(--s3, 12px) var(--s3, 12px) var(--s2, 8px);
  -webkit-overflow-scrolling: touch;
}
.lc-scroll:focus-visible { outline: 3px solid var(--accent-2); outline-offset: -3px; }
.lc-empty { margin: var(--s4, 16px) auto; max-width: 260px; text-align: center; font-size: var(--fs-sm, 14px); color: var(--text-dim); }
.lc-empty[hidden] { display: none; }
.lc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2, 8px); }

.lc-msg {
  align-self: flex-start; max-width: 85%;
  padding: 8px 12px 9px; border-radius: 18px 18px 18px 6px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  animation: lc-pop .25s var(--ease-out, ease-out);
}
.lc-msg.mine { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--accent-soft); border-color: transparent; }
.lc-meta { display: flex; align-items: baseline; gap: 8px; font-size: var(--fs-xs, 12px); color: var(--text-dim); }
.lc-msg.mine .lc-meta { justify-content: flex-end; }
.lc-name { color: var(--accent-2-ink); font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.lc-msg.mine .lc-name { color: var(--text-dim); }
.lc-meta time { font-variant-numeric: tabular-nums; }
.lc-text { margin: 2px 0 0; font-size: var(--fs-sm, 14px); line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }

.lc-error { margin: 0 var(--s3, 12px) var(--s1, 4px); font-size: var(--fs-sm, 14px); font-weight: 700; color: var(--bad-ink); }

.lc-form { display: flex; align-items: center; gap: var(--s2, 8px); padding: var(--s2, 8px) var(--s2, 8px) var(--s2, 8px) var(--s3, 12px); border-top: 1px solid var(--line); }
.lc-form .lc-input { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; /* >= 16px: no iOS zoom */ border-radius: 999px; padding: 8px 16px; }
.lc-send { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.lc-send:hover { background: var(--accent); filter: brightness(1.04); }

/* small screens: the sheet covers the HUD, keep it out of the tab order */
@media (max-width: 899px) {
  .fx-scene.lc-open .fx-hud-slot { visibility: hidden; }
}

/* desktop: side panel next to the 3D stage, HUD makes room */
@media (min-width: 900px) {
  .lc-panel {
    left: auto; top: 68px; right: var(--s3, 12px); bottom: var(--s3, 12px);
    width: min(370px, 44%); height: auto; min-height: 0;
    animation-name: lc-in-side;
  }
  .fx-scene.lc-open .fx-hud-slot { right: calc(min(370px, 44%) + 2 * var(--s3, 12px)); }
}

@keyframes lc-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes lc-in-side { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes lc-pop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .lc-panel, .lc-msg, .lc-badge { animation: none; }
}
