:root {
  --bg: #07080a;
  --surface: #15171b;
  --surface-2: #1b1e23;
  --surface-3: #0f1114;
  --line: #262a30;
  --text: #f2f3f4;
  --text-dim: #9aa0a8;
  --text-soft: #c7cbd1;
  /* Azul extraído da logo (#0050FF). O tom claro é usado sobre o fundo
     escuro, onde o azul puro não atinge contraste legível. */
  --accent: #0050ff;
  --accent-soft: #5b8cff;
  --accent-dim: rgba(0, 80, 255, 0.18);
  --accent-dim-2: rgba(0, 80, 255, 0.35);
  --danger: #f2545b;
  --danger-dim: rgba(242, 84, 91, 0.12);
  /* Painéis flutuantes: translúcidos para o vídeo respirar por baixo. */
  --glass: rgba(16, 18, 22, 0.72);
  --glass-line: rgba(255, 255, 255, 0.09);
}

* { box-sizing: border-box; }

/* O atributo hidden equivale a display:none, mas qualquer regra de display
   posterior o sobrepõe. Esta declaração garante que hidden sempre esconda. */
[hidden] { display: none !important; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

svg { width: 100%; height: 100%; }

/* O app é a moldura das camadas: o vídeo preenche o fundo e todo o resto
   flutua por cima em position:absolute. */
#app {
  position: relative;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Palco ---------- */

.grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
  padding: 4px;
}
.grid:empty { display: none; }
.grid:not(.spotlight):has(.tile:nth-child(1):last-child) { grid-template-columns: 1fr; }
.grid:not(.spotlight):has(.tile:nth-child(2):last-child) { grid-template-columns: repeat(2, 1fr); }
.grid:not(.spotlight):has(.tile:nth-child(4):last-child) { grid-template-columns: repeat(2, 1fr); }

/* Modo destaque: um tile toma o palco, os demais viram miniaturas à direita.
   O :not(.spotlight) acima impede que as regras por contagem, de igual
   especificidade mas declaradas antes, vençam este bloco. */
.grid.spotlight {
  grid-template-columns: 1fr 230px;
  grid-auto-rows: unset;
  grid-auto-flow: row;
}
.grid.spotlight .tile { grid-column: 2; height: 130px; }
.grid.spotlight .tile.featured {
  grid-column: 1;
  grid-row: 1 / -1;
  height: auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
}
.empty-state svg { width: 38px; height: 38px; color: #3a3f47; margin-bottom: 8px; }
.empty-state p { margin: 0; font-size: 15px; color: var(--text-soft); }
.empty-state span { font-size: 13px; }

/* ---------- Tiles de vídeo ---------- */

.tile {
  position: relative;
  min-height: 0;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* O cabeçalho flutua sobre o vídeo e só aparece no hover, para não cobrir
   o conteúdo compartilhado. */
.tile-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent);
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}
.tile:hover .tile-head,
.tile:focus-within .tile-head { opacity: 1; pointer-events: auto; }

.tile-who { display: flex; align-items: center; gap: 8px; min-width: 0; }

.tile-avatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tile-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}

.tile-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.tile-timer {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.expand-btn {
  width: 28px;
  height: 28px;
  padding: 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.expand-btn:hover { background: rgba(0, 0, 0, 0.75); }
/* Só o ícone correspondente ao estado atual aparece. */
.expand-btn .ico-shrink { display: none; }
.tile.featured .expand-btn .ico-grow { display: none; }
.tile.featured .expand-btn .ico-shrink { display: block; }

/* ---------- Topbar flutuante ---------- */

.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}
/* Só os painéis capturam clique; a faixa entre eles deixa o vídeo passar. */
.topbar > * { pointer-events: auto; }

.brand,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
}

/* A logo é 3:1 e já contém o nome, então dispensa texto ao lado.
   O PNG original é azul #0050FF sobre transparente, que rende contraste 1.25
   contra o fundo quase preto — ilegível. Clarear com brightness() exigiria 4x
   e lavaria a cor. Em vez disso usamos o próprio PNG como máscara e pintamos
   com o azul claro da marca, mantendo a identidade e subindo o contraste. */
.mark {
  height: 26px;
  width: auto;
  flex-shrink: 0;
  background: var(--accent-soft);
  -webkit-mask: url('/logo.png') center / contain no-repeat;
  mask: url('/logo.png') center / contain no-repeat;
  aspect-ratio: 2172 / 724;
}

.divider { width: 1px; height: 16px; background: var(--glass-line); }

.room-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-soft);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.dot.idle { background: #3a3f47; }

.people-count { font-size: 12.5px; color: var(--text-dim); }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.icon-btn.copied { color: var(--accent-soft); }

/* ---------- Cards de participantes (flutuantes) ---------- */

.people {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  scrollbar-width: none;
  transition: opacity 0.2s, transform 0.2s;
}
.people::-webkit-scrollbar { display: none; }

/* Escondidos pelo botão de participantes: some sem sumir do layout. */
.people.collapsed {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(12px);
}

.person {
  width: 128px;
  padding: 12px 10px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
  flex-shrink: 0;
}

.person-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.person.offline .person-avatar { background: var(--surface-2); color: #5a6069; }

.person-name {
  font-size: 12px;
  color: var(--text-soft);
  max-width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.person.offline .person-name { color: var(--text-dim); }

.host-tag {
  position: absolute;
  top: 7px;
  left: 7px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent-soft);
  background: var(--accent-dim);
  border-radius: 4px;
  padding: 2px 5px;
}

.kick-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 21px;
  height: 21px;
  padding: 5px;
  border-radius: 999px;
  background: var(--danger-dim);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.person:hover .kick-btn { opacity: 1; }
.kick-btn:focus-visible { opacity: 1; }

/* ---------- Dock de controles ---------- */

.dock {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.sharing-hint {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  padding: 5px 13px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  padding: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.ctrl {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.ctrl:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.ctrl.active { color: #fff; background: var(--accent); }
.ctrl.danger { color: var(--danger); background: var(--danger-dim); }
.ctrl.danger:hover { background: rgba(242, 84, 91, 0.22); }

.ctrl-divider { width: 1px; height: 22px; background: var(--glass-line); margin: 0 3px; }

/* Botão de áudio: alterna o ícone conforme o estado. */
#audioBtn .ico-off { display: none; }
#audioBtn.muted .ico-on { display: none; }
#audioBtn.muted .ico-off { display: block; }
#audioBtn.muted { color: var(--text-dim); }
/* Autoplay bloqueado: o clique é necessário, então o botão pulsa. */
#audioBtn.attention {
  color: #fff;
  background: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-dim-2); }
  50%      { box-shadow: 0 0 0 7px transparent; }
}

/* Indica no tile que aquela tela traz som. */
.tile.has-audio .badge::after {
  content: ' ♪';
  opacity: 0.85;
}

/* ---------- Modo imersivo ---------- */

/* Esconde toda a interface para o vídeo ocupar a página inteira sem nada
   por cima. Usa opacity em vez de display para preservar a transição. */
#app.immersive .chrome {
  opacity: 0;
  pointer-events: none;
}
.chrome { transition: opacity 0.22s; }

/* Com a interface oculta o palco perde as bordas e usa cada pixel. */
#app.immersive .grid { gap: 0; padding: 0; }
#app.immersive .tile { border-radius: 0; }

.reveal {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 30;
  width: 38px;
  height: 38px;
  padding: 10px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  color: var(--text-soft);
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0.25;
  transition: opacity 0.18s;
}
#app.immersive .reveal { display: flex; }
.reveal:hover { opacity: 1; }

/* ---------- Overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 0 24px;
}

.overlay-card h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.overlay-card p {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  max-width: 380px;
  line-height: 1.5;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--accent-soft);
  border-radius: 999px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .topbar { top: 10px; left: 10px; right: 10px; }
  .people-count, .status-pill { display: none; }
  .people {
    top: auto;
    bottom: 104px;
    left: 10px;
    right: 10px;
    transform: none;
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
  }
  .people.collapsed { transform: translateY(8px); }
  .person { width: 96px; padding: 9px 7px; }
  .person-avatar { width: 34px; height: 34px; font-size: 12px; }
  .grid, .grid:not(.spotlight):has(.tile:nth-child(2):last-child) { grid-template-columns: 1fr; }
  .grid.spotlight { grid-template-columns: 1fr; }
  .grid.spotlight .tile { grid-column: 1; height: 86px; }
  .ctrl { width: 38px; height: 38px; padding: 10px; }
}
