/* QwarrsCall - dark, quiet, Discord-shaped but its own thing. */

:root {
  --bg: #08090d;
  --bg-soft: #0b0d13;
  --panel: #10131b;
  --panel-2: #161a24;
  --panel-3: #1c2130;
  --line: #232838;
  --text: #e7eaf3;
  --muted: #8a92a6;
  --muted-2: #6b7385;
  --violet: #a78bfa;
  --violet-deep: #7c5cff;
  --cyan: #22d3ee;
  --mint: #34d399;
  --amber: #fbbf24;
  --danger: #f87171;
  --danger-deep: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.8);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(124, 92, 255, 0.16), transparent 60%),
    radial-gradient(900px 600px at 95% 0%, rgba(34, 211, 238, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* ------------------------------------------------------------- landing -- */

.view { min-height: 100%; }

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 48px 20px 32px;
  max-width: 760px;
  margin: 0 auto;
}

.hero { text-align: center; display: grid; gap: 10px; justify-items: center; }
.mark svg { width: 64px; height: 64px; filter: drop-shadow(0 8px 30px rgba(167, 139, 250, 0.35)); }
.hero h1 {
  font-size: 40px;
  letter-spacing: -0.035em;
  background: linear-gradient(100deg, #fff 20%, #c7b8ff 55%, #7ee7f5 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { color: var(--muted); font-size: 15px; }

.card {
  width: 100%;
  background: linear-gradient(180deg, rgba(22, 26, 36, 0.9), rgba(16, 19, 27, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; }
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 11px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.is-active { background: var(--panel-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

.form { display: grid; gap: 14px; padding: 18px 16px 16px; }

.field { display: grid; gap: 6px; }
.field > span {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted-2); font-size: 11px; }

input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--muted-2); }
input:focus { border-color: rgba(167, 139, 250, 0.6); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.16); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.12s, filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  border: 0;
  background: linear-gradient(100deg, var(--violet-deep), #5b8cff 60%, #22d3ee);
  color: #07070c;
  font-weight: 700;
}
.btn.primary:disabled { filter: grayscale(0.6) brightness(0.7); cursor: progress; }
.btn.wide { width: 100%; }

.hint { color: var(--muted-2); font-size: 12.5px; line-height: 1.45; }

.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; width: 100%; grid-template-columns: 1fr; }
@media (min-width: 720px) { .facts { grid-template-columns: 1fr 1fr 1fr; } }
.facts li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: rgba(16, 19, 27, 0.6);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px;
}
.facts .ico { color: var(--violet); margin-top: 1px; }
.facts b { display: block; font-size: 13px; margin-bottom: 3px; }
.facts span { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.landing-foot { color: var(--muted-2); font-size: 12px; }

/* ---------------------------------------------------------------- call -- */

.call {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: linear-gradient(180deg, #0a0c12, #07080c);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.86);
  backdrop-filter: blur(12px);
  -webkit-app-region: drag;
}
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-left strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.tb-right { margin-left: auto; display: flex; gap: 6px; }
.timer { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 2px 7px; background: var(--panel-2); border-radius: 6px; }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12); flex: none; }
.status-dot[data-state="connected"] { background: var(--mint); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14); }
.status-dot[data-state="failed"], .status-dot[data-state="disconnected"] { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.14); }
.status-dot[data-state="connecting"] { animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.sas {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.sas .ico { width: 16px; height: 16px; color: var(--mint); }
.sas span:first-of-type { font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; }
.sas-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.sas.is-verified { border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.sas.is-verified .sas-tag { color: var(--mint); }
.sas.is-pending { animation: blink 2s ease-in-out infinite; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }

.stage { position: relative; min-height: 0; display: grid; padding: 14px; }

.tiles {
  display: grid;
  gap: 12px;
  min-height: 0;
  align-content: center;
  justify-content: center;
  grid-template-columns: minmax(0, 1fr);
}
.tiles.split { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(160deg, #141824, #0d1017);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  max-height: calc(100dvh - 220px);
  min-height: 180px;
  box-shadow: var(--shadow);
}
.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.tile.voice video { display: none; }
.tile .avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  color: #0a0b10;
  background: linear-gradient(140deg, var(--violet), var(--cyan));
  box-shadow: 0 12px 40px -12px rgba(124, 92, 255, 0.7);
  transition: transform 0.25s;
}
.tile.speaking .avatar { transform: scale(1.06); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.35), 0 12px 40px -12px rgba(124, 92, 255, 0.7); }
.tile .label {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(6, 8, 12, 0.72);
  backdrop-filter: blur(6px);
  font-size: 12.5px;
  font-weight: 600;
}
.tile .label .ico { width: 14px; height: 14px; }
.tile .badge-muted { color: var(--danger); }
.tile.local { aspect-ratio: 16 / 9; }

.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: none;
}
.waiting-card {
  pointer-events: auto;
  text-align: center;
  max-width: 460px;
  display: grid;
  gap: 12px;
  justify-items: center;
  background: rgba(16, 19, 27, 0.72);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.waiting-card h2 { font-size: 19px; }
.waiting-card p { color: var(--muted); font-size: 13.5px; }
.pulse {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.6);
  position: relative;
}
.pulse::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.5);
  animation: ring 2s ease-out infinite;
}
@keyframes ring { 0% { transform: scale(0.9); opacity: 0.9; } 100% { transform: scale(1.9); opacity: 0; } }

.invite { display: flex; gap: 8px; width: 100%; }
.invite input { font-family: var(--mono); font-size: 12px; }

.stats {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 260px;
  background: rgba(16, 19, 27, 0.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.stats-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stats dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0; font-size: 12.5px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 12px; }

/* ------------------------------------------------------------ controls -- */

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(10, 12, 18, 0.9);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.ctrl {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 74px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.ctrl .ico { width: 22px; height: 22px; }
.ctrl:hover { background: var(--panel-3); }
.ctrl:active { transform: translateY(1px); }
.ctrl[aria-pressed="true"] { background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.4); color: #fecaca; }
.ctrl.danger { background: var(--danger-deep); border-color: transparent; color: #fff; }
.ctrl.danger:hover { background: #f05252; }
.ctrl:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------------------------------------------------------- chat -- */

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 100vw);
  background: rgba(13, 15, 21, 0.98);
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr auto;
  z-index: 20;
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.9);
}

/* On a wide screen the chat becomes a real column, so it never covers a tile. */
@media (min-width: 900px) {
  .call.chat-open {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
  .call.chat-open .topbar,
  .call.chat-open .stage,
  .call.chat-open .controls {
    grid-column: 1;
  }
  .call.chat-open .chat-panel {
    position: static;
    grid-column: 2;
    grid-row: 1 / -1;
    width: auto;
    box-shadow: none;
  }
}
.chat-panel header { display: flex; align-items: center; gap: 8px; padding: 14px; border-bottom: 1px solid var(--line); }
.chat-panel header .muted { margin-right: auto; }
.chat-log { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: grid; gap: 3px; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--violet); letter-spacing: 0.02em; }
.msg .who.me { color: var(--cyan); }
.msg .body { background: var(--panel-2); border: 1px solid var(--line); padding: 8px 11px; border-radius: 12px; font-size: 13.5px; word-break: break-word; white-space: pre-wrap; }
.msg.me .body { background: rgba(34, 211, 238, 0.08); border-color: rgba(34, 211, 238, 0.22); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }

/* --------------------------------------------------------------- lobby -- */

.lobby {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 9, 0.82);
  backdrop-filter: blur(12px);
  z-index: 40;
  padding: 20px;
}
.lobby-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.lobby-card h2 { font-size: 20px; }
.lobby-card .link { text-align: center; color: var(--muted); font-size: 12.5px; text-decoration: none; }
.lobby-card .link:hover { color: var(--text); }

/* -------------------------------------------------------------- toasts -- */

.toasts { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.toast {
  background: rgba(22, 26, 36, 0.97);
  border: 1px solid var(--line);
  border-left: 3px solid var(--violet);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--mint); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 640px) {
  .hero h1 { font-size: 32px; }
  .tagline { font-size: 14px; }
  .tb-left strong { max-width: 40vw; }
  .sas-tag { display: none; }
  .ctrl { min-width: 60px; padding: 8px 10px; }
  .tile { aspect-ratio: 4 / 3; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
