/* Us Player — join page. The three themes are ui/theme.py's, token for
   token; Us Blue is the default. System fonts only: iOS draws Persian with
   its own, and the page makes no third-party requests. */

:root,
:root[data-theme="us_blue"] {
  --bg0: #040a18; --bg1: #0a1426; --bg2: #122038; --bg3: #1a2c4c;
  --border: #1f3358; --text: #e8f1ff; --text-dim: #93a6c8;
  --accent: #2b7fff; --accent-hi: #4cc2ff; --danger: #f4526b; --ok: #34d399;
}
:root[data-theme="dark_purple"] {
  --bg0: #120e1d; --bg1: #181226; --bg2: #221a33; --bg3: #2d2342;
  --border: #332a4d; --text: #ece9f4; --text-dim: #9d94b8;
  --accent: #8b5cf6; --accent-hi: #a78bfa; --danger: #f4526b; --ok: #34d399;
}
:root[data-theme="dark_mint"] {
  --bg0: #0c1311; --bg1: #101a17; --bg2: #17241f; --bg3: #1f3029;
  --border: #26382f; --text: #e7f2ec; --text-dim: #8fa89c;
  --accent: #2dd4a7; --accent-hi: #5eead4; --danger: #f4526b; --ok: #60a5fa;
}

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

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg0);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Tahoma, "Vazirmatn", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

.sprite { display: none; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }

/* ------------------------------------------------------------- top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg1);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 7px; }
.brand-name { font-weight: 700; letter-spacing: 0.01em; }
.brand-sub {
  color: var(--accent-hi); font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px;
  white-space: nowrap;
}
.bar-actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
}
.icon-btn:hover { background: var(--bg3); border-color: var(--accent); }
.icon-btn.big { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn.big:hover { background: var(--accent-hi); }
.icon-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip {
  min-width: 44px; height: 40px; padding: 0 12px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border); font-weight: 700; font-size: 13px;
}
.chip:hover { border-color: var(--accent); }

/* ----------------------------------------------------------- join form */
.join { max-width: 440px; margin: 0 auto; padding: 32px 16px 48px; }
.join h1 { font-size: 24px; line-height: 1.3; margin: 0 0 8px; }
.lead { color: var(--text-dim); margin: 0 0 20px; }
.card {
  display: grid; gap: 6px;
  background: var(--bg1); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px;
}
.card label { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.card label:first-child { margin-top: 0; }
.card input {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  font-size: 16px; /* 16px stops iOS from zooming into the field */
}
.card input:focus { border-color: var(--accent); outline: none; }
.primary {
  margin-top: 14px; padding: 12px; border-radius: 12px; border: 0;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
.primary:hover { background: var(--accent-hi); }
.primary:disabled { opacity: 0.6; cursor: progress; }
.error { color: var(--danger); margin: 8px 0 0; font-size: 14px; }
.hint { color: var(--text-dim); margin: 2px 0 0; font-size: 12px; }

.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 20px;
  padding: 4px; border-radius: 12px; background: var(--bg1); border: 1px solid var(--border);
}
.mode {
  padding: 9px; border-radius: 9px; border: 0; background: transparent;
  color: var(--text-dim); font-weight: 700;
}
.mode[aria-selected="true"] { background: var(--accent); color: #fff; }

.tools { display: grid; gap: 8px; padding: 0 16px 12px; }
.link-bar { display: flex; gap: 8px; }
.link-bar input {
  flex: 1; min-width: 0; padding: 9px 12px; border-radius: 10px;
  background: var(--bg1); border: 1px solid var(--border); font-size: 16px;
}
.link-bar input:focus { border-color: var(--accent); outline: none; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.host-note {
  margin: 0; font-size: 13px; color: var(--text-dim);
  border-inline-start: 3px solid var(--accent); padding-inline-start: 10px;
}
.mini {
  padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
}
.mini:hover { border-color: var(--accent); }
.mini.danger { color: var(--danger); }
.mini.danger:hover { border-color: var(--danger); }
.fineprint { color: var(--text-dim); font-size: 13px; margin-top: 16px; }

/* ------------------------------------------------------------- account */
.user-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 46vw; }
.user-chip svg { width: 18px; height: 18px; }
.user-chip bdi { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-form .primary { margin-top: 16px; }
.linkish {
  justify-self: center; margin-top: 6px; padding: 6px 8px; border: 0;
  background: none; color: var(--accent-hi); font-size: 14px; font-weight: 600;
}
.linkish:hover { text-decoration: underline; }
.linkish:disabled { color: var(--text-dim); text-decoration: none; cursor: default; }
.switch-line { margin: 6px 0 0; text-align: center; font-size: 14px; color: var(--text-dim); }
.switch-line .linkish { margin: 0; padding: 4px; }
.card input.code-input { font-size: 24px; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }
.notice { color: var(--ok); margin: 8px 0 0; font-size: 14px; }

/* ------------------------------------------------- the app-only features */
.app-only { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.app-only h2 { font-size: 17px; margin: 0 0 4px; }
.app-only-lead { color: var(--text-dim); font-size: 13px; margin: 0 0 12px; }
.app-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.app-tile {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 11px 12px; border-radius: 12px; text-align: start;
  background: var(--bg1); border: 1px solid var(--border); color: var(--text);
  font-size: 14px; font-weight: 600; line-height: 1.35;
}
.app-tile:hover { border-color: var(--accent); background: var(--bg2); }
.app-tile svg { color: var(--accent-hi); width: 20px; height: 20px; }
.app-feature { display: inline-flex; align-items: center; gap: 6px; }
.app-feature svg { width: 18px; height: 18px; color: var(--text-dim); }
.film-note {
  margin: 0; font-size: 13px; color: var(--text-dim);
  border-inline-start: 3px solid var(--border); padding-inline-start: 10px;
}

.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  padding: 16px; background: rgba(0, 0, 0, 0.6);
}
.modal-card {
  width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 20px; border-radius: 16px; background: var(--bg1); border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.modal-card h2 { margin: 0 0 6px; font-size: 19px; }
.modal-card p { margin: 0 0 10px; }
.modal-sub { color: var(--text-dim); font-size: 13px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.modal-actions .dl {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0; text-decoration: none; font-size: 15px;
}
.modal-actions .dl svg { width: 20px; height: 20px; }
.modal-close { width: 100%; }
@media (max-width: 360px) {
  .app-grid, .modal-actions { grid-template-columns: 1fr; }
}

/* ----------------------------------------------------------------- room */
.room {
  display: grid; grid-template-columns: 1fr; gap: 0;
  max-width: 1400px; margin: 0 auto;
}
.stage-col { min-width: 0; }
.stage {
  position: relative; background: #000; aspect-ratio: 16 / 9;
  width: 100%; overflow: hidden;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.stage:fullscreen { aspect-ratio: auto; }

.overlay {
  position: absolute; inset: 0; display: grid; place-content: center;
  gap: 10px; padding: 20px; text-align: center;
  background: rgba(0, 0, 0, 0.72);
}
.overlay-text { margin: 0; font-size: 16px; max-width: 520px; }
.overlay-sub { margin: 0; color: var(--text-dim); font-size: 14px; }
.overlay-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.ghost {
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); text-decoration: none; font-size: 14px;
}
.ghost:hover { border-color: var(--accent); }

.unmute {
  position: absolute; inset-inline: 0; margin: 0 auto; bottom: 14px; width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px; border: 0;
  background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute; bottom: 8%; font-size: 34px; line-height: 1;
  animation: rise 2.6s ease-out forwards;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}
.floater small {
  display: block; font-size: 11px; color: #fff; text-align: center;
  max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@keyframes rise {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  12% { transform: translateY(-10px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-220px) scale(1); opacity: 0; }
}

.transport {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--bg1); border-bottom: 1px solid var(--border);
}
.transport .icon-btn { background: transparent; border-color: transparent; }
.transport .icon-btn.big { background: var(--accent); }
.transport .icon-btn[aria-pressed="false"] { opacity: 0.45; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text-dim); min-width: 42px; text-align: center; }
#seekBar { flex: 1; min-width: 60px; accent-color: var(--accent); height: 28px; }

.status-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 16px;
}
.status { margin: 0; font-size: 13px; color: var(--text-dim); min-height: 20px; }
.status.good { color: var(--ok); }
.status.warn { color: var(--danger); }
.reactions { display: flex; gap: 4px; }
.reactions button {
  width: 42px; height: 42px; border-radius: 12px; font-size: 22px; line-height: 1;
  background: var(--bg1); border: 1px solid var(--border);
}
.reactions button:hover { border-color: var(--accent); background: var(--bg2); }
.reactions button:active { transform: scale(0.92); }

/* ----------------------------------------------------- chat and people */
.side {
  display: flex; flex-direction: column; min-height: 0;
  border-top: 1px solid var(--border); background: var(--bg1);
  height: 52vh; height: 52dvh;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 7px 14px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-dim); font-weight: 600;
}
.tab[aria-selected="true"] { background: var(--bg2); color: var(--accent-hi); border-color: var(--border); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 12px; text-align: center;
}
.pane { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat-list { list-style: none; margin: 0; padding: 10px 12px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.chat-list li { margin: 0 0 8px; overflow-wrap: anywhere; }
.chat-list .who { font-weight: 700; color: var(--accent-hi); margin-inline-end: 6px; }
.chat-list .mine .who { color: var(--ok); }
.chat-list .system { color: var(--text-dim); font-size: 13px; font-style: italic; }
.typing { margin: 0; padding: 0 12px; min-height: 20px; font-size: 12px; color: var(--text-dim); }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bg2); border: 1px solid var(--border); font-size: 16px;
}
.chat-form input:focus { border-color: var(--accent); outline: none; }

.people { list-style: none; margin: 0; padding: 8px 12px; overflow-y: auto; }
.people li {
  display: flex; align-items: center; gap: 8px; padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}
.people .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.badge.host { color: var(--accent-hi); border-color: var(--accent); }
.ping { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  margin: 0 auto; max-width: 420px; padding: 10px 14px; border-radius: 12px;
  background: var(--bg3); border: 1px solid var(--border); text-align: center;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); z-index: 10;
}

video::cue {
  background: rgba(0, 0, 0, 0.6);
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

/* -------------------------------------------------------------- phones */
@media (max-width: 480px) {
  .transport { gap: 4px; padding: 8px 10px; }
  .transport .icon-btn { width: 34px; height: 34px; }
  .transport .icon-btn.big { width: 44px; height: 44px; }
  .time { min-width: 0; font-size: 12px; }
  #seekBar { min-width: 40px; }
  .reactions button { width: 38px; height: 38px; font-size: 20px; }
}

/* ------------------------------------------------------------- desktop */
@media (min-width: 900px) {
  .room { grid-template-columns: minmax(0, 1fr) 360px; padding: 16px; gap: 16px; }
  .stage { border-radius: 14px 14px 0 0; }
  .transport { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 14px 14px; }
  .side { height: calc(100vh - 100px); border: 1px solid var(--border); border-radius: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .floater { animation-duration: 1.2s; }
}
