@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap");

:root {
  --bg: #0b0710;
  --panel: #170f22;
  --panel-2: #1f1530;
  --line: #33234a;
  --ice: #ff3d94;
  --ice-dim: #ff9a3d;
  --ember: #9b5cff;
  --accent-gradient: linear-gradient(135deg, #ff9a3d 0%, #ff3d94 55%, #9b5cff 100%);
  --text: #f2e9f6;
  --muted: #a290b8;
  --danger: #ff5c7a;
  --radius: 14px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Topographic contour-line backdrop — the signature motif */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900' viewBox='0 0 900 900'%3E%3Cg fill='none' stroke='%23342449' stroke-width='1'%3E%3Cpath d='M-50 620 C 150 560, 250 700, 450 640 S 800 540, 950 620'/%3E%3Cpath d='M-50 560 C 150 500, 260 640, 450 580 S 800 480, 950 560'/%3E%3Cpath d='M-50 500 C 150 440, 270 580, 450 520 S 800 420, 950 500'/%3E%3Cpath d='M-50 440 C 150 380, 280 520, 450 460 S 800 360, 950 440'/%3E%3Cpath d='M-50 380 C 150 320, 290 460, 450 400 S 800 300, 950 380'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 900px 900px;
  opacity: 0.5;
}

/* Nebula glow — soft orange/pink/purple wash behind everything */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 480px at 8% -8%, rgba(255, 154, 61, 0.16), transparent 60%),
    radial-gradient(760px 560px at 105% 15%, rgba(255, 61, 148, 0.14), transparent 60%),
    radial-gradient(820px 600px at 50% 120%, rgba(155, 92, 255, 0.14), transparent 60%);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* ---------- Landing page ---------- */

.landing {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 42px;
}

.corner-brand {
  position: fixed;
  top: 20px;
  left: 24px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}

.brand-name {
  font-family: var(--font-mono);
  letter-spacing: 0.28em;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.hero {
  text-align: center;
  max-width: 620px;
  margin-bottom: 40px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--ice);
  text-transform: uppercase;
  margin: 0 0 18px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 64px);
  line-height: 1.02;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
}

.panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
  margin-bottom: 56px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus {
  border-color: var(--ice);
}

.field input::placeholder {
  color: #5c4d72;
  font-family: var(--font-body);
}

.room-row {
  display: flex;
  gap: 8px;
}

.room-row input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.btn-ghost {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ice);
  border-radius: 10px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-ghost:hover {
  border-color: var(--ice);
}

.btn-primary {
  width: 100%;
  margin-top: 6px;
  background: var(--accent-gradient);
  color: #1a0e28;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(0.98);
}

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

.hint {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}

.hint.error {
  color: var(--danger);
}

.features {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 780px;
  width: 100%;
}

.feature {
  background: rgba(18, 26, 34, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.feature .icon {
  font-size: 20px;
  margin-bottom: 10px;
  display: block;
}

.feature h3 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0 0 6px;
}

.feature p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .features {
    grid-template-columns: 1fr;
  }
}

/* ---------- Room page ---------- */

.room-body {
  overflow: hidden;
  --tile-min: 300px;
}

.room-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.room-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, 0.7);
  backdrop-filter: blur(10px);
}

.room-topbar .brand {
  margin: 0;
}

.room-code-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.room-code-badge:hover {
  border-color: var(--ice);
  transform: translateY(-1px);
}

.room-code-badge span {
  color: var(--ice);
}

.room-code-badge .copy-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--panel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.participant-count {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.participant-count::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6de08a;
  box-shadow: 0 0 0 3px rgba(109, 224, 138, 0.18);
}

/* ---- Stage: flexible grid that adapts to how many people are on the call
   instead of a flat uniform grid, so a 1:1 call and a group both feel deliberate. */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--tile-min), 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 16px;
  padding: 24px;
  overflow-y: auto;
  align-content: center;
  justify-content: center;
}

.stage:has(.tile:only-child) {
  grid-template-columns: minmax(0, min(760px, 100%));
}

.stage:has(.tile:nth-child(2):last-child) {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.tile {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.75);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  animation: tile-in 0.28s ease both;
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.tile:hover {
  border-color: var(--ice-dim);
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile.no-video video {
  display: none;
}

.tile .avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--ice) 0%, var(--ice-dim) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: #1a0e28;
  box-shadow: 0 0 0 6px rgba(255, 61, 148, 0.1);
}

.tile .name-tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(11, 15, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile .name-tag .mic-off {
  color: var(--danger);
  font-size: 11px;
}

/* Screen shares get their own accent — ember instead of ice — so they
   read instantly as "this is the shared content", not just another face. */
.tile.screen-tile {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 8;
  border-color: rgba(155, 92, 255, 0.4);
  background: #0d0916;
}

.tile.screen-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(155, 92, 255, 0.18);
  pointer-events: none;
}

.tile.screen-tile .name-tag {
  border-color: rgba(155, 92, 255, 0.35);
  color: var(--ember);
}

/* uma tela compartilhada nunca deve ser cortada nas bordas — mostra ela
   inteira (com faixas pretas se a proporção não bater), diferente da câmera
   onde preencher o quadro (cover) importa mais do que ver o enquadramento inteiro */
.tile.screen-tile video {
  object-fit: contain;
  background: #000;
}

/* botão de fechar uma transmissão só pra mim, badge de quem tá assistindo,
   e o card que aparece no lugar do vídeo quando eu fecho */
.screen-close-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(11, 7, 16, 0.72);
  color: var(--text);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.screen-close-btn:hover {
  opacity: 1;
  background: var(--danger);
  border-color: var(--danger);
}

.watcher-badge {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(11, 7, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--muted);
  pointer-events: auto;
}

.screen-reopen {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(11, 7, 16, 0.94);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.screen-reopen button {
  background: var(--accent-gradient);
  color: #1a0e28;
  border: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.tile.closed video,
.tile.closed .avatar,
.tile.closed .vol-ctrl,
.tile.closed .watcher-badge,
.tile.closed .screen-close-btn {
  display: none;
}

.tile.closed .screen-reopen {
  display: flex;
}

/* Per-participant volume: how loud someone's voice or shared-screen audio
   plays for *you* — purely local, doesn't affect what anyone else hears. */
.tile .vol-ctrl {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 15, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(4px);
  padding: 6px 10px;
  border-radius: 999px;
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.tile:hover .vol-ctrl,
.tile .vol-ctrl:focus-within {
  opacity: 1;
}

.vol-mute-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.vol-mute-btn.muted {
  color: var(--danger);
}

.vol-slider {
  width: 60px;
  height: 4px;
  accent-color: var(--ice);
  cursor: pointer;
}

@media (max-width: 640px) {
  .vol-ctrl {
    opacity: 0.85;
  }

  .vol-slider {
    width: 44px;
  }
}

/* Cinema mode (manual, or automatic whenever a screen share is active):
   the focused tile fills exactly what's left between topbar and filmstrip —
   no fixed height guess, so it can never overflow into a scrollbar. */
.room-shell.cinema .stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  gap: 0;
  overflow: hidden;
  background: #000;
}

.room-shell.cinema .tile {
  border-radius: 0;
  border: none;
  box-shadow: none;
  animation: none;
}

/* a tela em foco sempre respeita 16:9 de verdade — encolhe pelo lado que
   precisar (altura ou largura) e sobra preto nas bordas em vez de esticar,
   cortar, ou depender de um cálculo de altura fixo que nunca acerta em
   todo tamanho de tela/filmstrip. */
.room-shell.cinema .focus-tile {
  flex: none;
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

.filmstrip {
  position: relative;
  z-index: 1;
  display: none;
  gap: 10px;
  padding: 12px 20px;
  overflow-x: auto;
  background: rgba(11, 15, 20, 0.5);
  border-top: 1px solid var(--line);
}

.room-shell.cinema .filmstrip {
  display: flex;
}

.filmstrip .tile {
  flex: 0 0 168px;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  animation: none;
  cursor: pointer;
}

.filmstrip .tile:hover {
  transform: translateY(-2px);
  border-color: var(--ice-dim);
}

.controls {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: rgba(11, 15, 20, 0.7);
  backdrop-filter: blur(10px);
}

.ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.ctrl-btn:hover {
  border-color: var(--ice);
  transform: translateY(-2px);
}

.ctrl-btn:active {
  transform: translateY(0) scale(0.96);
}

.ctrl-btn.off {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0606;
}

.ctrl-btn.active {
  background: var(--ice);
  border-color: var(--ice);
  color: #1a0e28;
  box-shadow: 0 0 0 5px rgba(255, 61, 148, 0.16);
}

.ctrl-btn.leave {
  background: var(--danger);
  border-color: var(--danger);
  color: #1a0606;
  width: auto;
  padding: 0 24px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
}

.ctrl-btn.leave:hover {
  background: #ff7d7d;
  border-color: #ff7d7d;
}

.quality-select {
  height: 50px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 25px;
  padding: 0 14px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease;
}

.quality-select:hover {
  border-color: var(--ice);
}

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

@media (max-width: 640px) {
  .quality-select {
    height: 44px;
    padding: 0 10px;
    font-size: 12px;
  }
}

.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ice);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state h3 {
  font-family: var(--font-display);
  color: var(--text);
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .room-body {
    --tile-min: 100%;
  }

  .stage {
    padding: 14px;
    gap: 10px;
  }

  .room-topbar {
    padding: 12px 14px;
  }

  .participant-count {
    display: none;
  }

  .controls {
    gap: 8px;
  }

  .ctrl-btn {
    width: 44px;
    height: 44px;
  }
}
