/* ==========================================================================
   Room screen — seat grid, chat and voice controls.
   Full-height layout: the stage and chat share the space, controls pin below.
   ========================================================================== */

.room {
  display: flex;
  flex-direction: column;
  height: var(--room-height, 100dvh);
  background: linear-gradient(180deg, var(--room-cover-top, #020b1bf5), var(--room-cover-bottom, #041730a6)), url('/assets/img/room-skyline.jpg') center bottom / cover no-repeat, var(--bg);
  background-blend-mode: normal, luminosity, normal;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom, 0px));
  gap: 6px;
}

.room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}

.room-identity {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 6px;
  border-radius: 9px;
  background: var(--room-chip-bg, #05142ce8);
}

.room-thumbnail {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(145deg, var(--surface-hover), var(--surface));
  font-size: 27px;
}

.room-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.room-header__body { flex: 1; }
.room-country, .room-id { margin: 2px 0 0; color: var(--text-muted); font-size: 12px; }
.room-count { align-self: flex-end; display: flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; background: var(--room-chip-bg, #05142ce8); font-size: 12px; }
.room-banner[hidden], .room-announcement[hidden] { display: none; }

.room-header__body {
  min-width: 0;
}

.room-title {
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-banner {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  padding: 9px 14px;
  border-radius: var(--radius);
  background: rgba(0, 142, 248, 0.14);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.room-banner__reason {
  width: 100%;
  color: var(--text-dim);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* Holds the remote <audio> elements. They must be in the document to play, but
   have no visual role. `display: none` would stop playback in some browsers, so
   the sink is collapsed rather than hidden. */
.voice-audio-sink {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.room-banner__retry {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.room-banner--warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #ffe0b0;
}

/* ------------------------------------------------------------- seat grid */
.room-stage {
  flex: none;
  max-height: min(34dvh, 175px);
  overflow-y: auto;
  padding: 8px 3px;
  background: var(--room-panel-bg, #0d224bcf);
  border-block: 1px solid var(--border-soft);
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px 4px;
  justify-items: center;
}

.seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text);
  max-width: 100%;
}

.seat__avatar {
  position: relative;
  display: inline-flex;
  transition: transform 0.16s ease;
}

:is(.seat__avatar, .chat-message) .avatar,
:is(.seat__avatar, .chat-message) .avatar__media {
  border-radius: 10px;
}

.seat.is-speaking .seat__avatar {
  transform: scale(1.06);
}

/* Halo on the active speaker — the ring itself is on the avatar. */
.seat.is-speaking .seat__avatar::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 17px;
  border: 2px solid var(--accent-soft);
  opacity: 0.55;
  animation: speak-pulse 1.2s ease-out infinite;
}

@keyframes speak-pulse {
  to {
    inset: -14px;
    border-radius: 24px;
    opacity: 0;
  }
}

/* Capped by the seat, not a fixed width. The grid cell is ~78px at 375px, so
   the old fixed 84px let a name like "Hridoy Krisno" (83px) skip the
   ellipsis, spill past both sides of its seat and get its first letter cut off
   by the room's edge. */
.seat__name {
  font-size: .75rem;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat--host .seat__name {
  font-size: .75rem;
}

.seat__role {
  padding: 0 7px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(251, 191, 36, 0.5);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
}

.seat__badges {
  position: absolute;
  right: -2px;
  bottom: -2px;
  display: flex;
  gap: 3px;
}

.seat__badge {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface-hover);
  border: 2px solid var(--bg);
  color: var(--text-muted);
  font-size: 11px;
}

/* A moderator mute is not something the user can undo — colour it differently
   from their own mic being off. */
.seat__badge--forced {
  background: var(--danger);
  color: #fff;
}

.seat__badge--hand {
  background: var(--warning);
  color: #422006;
}

.seat--request .seat__request-circle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #06152e 12%, #17345d 72%, #4774ae);
  border: 2px solid var(--border);
  color: var(--text-muted);
}

/* ------------------------------------------------------------------ chat */
.room-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-announcement {
  flex: none;
  max-height: 17dvh;
  overflow: auto;
  align-self: flex-start;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--room-control-bg, #0d2449ed);
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.room-announcement strong { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.room-announcement p { margin: 3px 0 0; }

.chat-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.chat-message.is-grouped {
  margin-top: -4px;
}

.chat-message__spacer {
  width: 24px;
  flex: none;
}

.chat-message__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.chat-message__author {
  font-size: 12px;
  color: var(--text-dim);
}

.chat-message__bubble {
  align-self: flex-start;
  padding: 5px 9px;
  border-radius: 14px;
  background: var(--surface-raised);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.chat-note {
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--room-control-bg, #0d2449ed);
  color: var(--text);
  font-size: 12px;
}

.chat-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 0 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.chat-input__field {
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
}

.chat-input__field::placeholder {
  color: var(--text-dim);
}

.chat-input__send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 6px solid transparent;
  background-clip: padding-box;
  border-radius: 50%;
  background: var(--action-fill) padding-box;
  color: var(--on-primary, #fff);
}

/* -------------------------------------------------------------- controls */
.room-controls {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding-top: 0;
}

.control {
  flex: 0 0 44px;
  min-height: 44px;
  justify-content: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 11.5px;
}

.control__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  font-size: 18px;
}

.control--mic .control__icon {
  background: var(--action-fill);
  border: 0;
  color: var(--on-primary, #fff);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.control--mic.is-off .control__icon {
  background: var(--surface-hover);
  color: var(--text-muted);
  box-shadow: none;
}

.room-controls .control__label { display: none; }
.control[aria-pressed="true"] .control__icon { border-color: var(--gold); background: var(--surface-hover); }
.room-controls .chat-input { background: var(--room-input-bg, #05142cee); }

.control:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --------------------------------------------------------------- sheets */
.sheet-backdrop {
  margin: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: 0;
  color: inherit;
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgb(1 9 22 / 70%);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 80;
}

.sheet-backdrop.is-visible {
  opacity: 1;
}

.sheet {
  width: min(100%, var(--shell-max));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.sheet-backdrop.is-visible .sheet {
  transform: translateY(0);
}

.sheet--dialog {
  align-self: center;
  margin: auto 0;
}

.sheet__head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
}

.sheet__head span {
  font-size: 13px;
  color: var(--text-dim);
  /* The diagnostics sheet passes multi-line text. */
  white-space: pre-line;
}

.sheet__action {
  padding: 14px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}

.sheet__action:hover {
  background: var(--surface-hover);
}

.sheet__action--danger {
  color: #ff9db0;
}

.sheet__action--cancel {
  background: none;
  color: var(--text-muted);
}

.sheet__buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 6px;
}

@media (max-height: 480px) {
  .room-stage { max-height: 22dvh; }
  .room-banner { max-height: 15dvh; overflow: auto; }
  .room-announcement { max-height: 12dvh; }
}

.room-header .icon-button { width: 44px; height: 44px; }
