/* Cinema — Persian RTL, mobile-first.
   No external fonts or CDNs: anything loaded from outside this VPS is a
   reliability risk for members behind Iranian networks. System Persian fonts
   only. */

:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2027;
  --line: #262c35;
  --text: #e9edf2;
  --muted: #93a0b1;
  --accent: #e0b15c;
  --accent-dim: #8a6c33;
  --ok: #57b894;
  --warn: #d98a5b;
  --danger: #d9605b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'IRANSansX', 'IRANSans', 'Sahel', 'Segoe UI', Tahoma, system-ui, -apple-system,
    'Noto Sans Arabic', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  overscroll-behavior: none;
}

body {
  direction: rtl;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  direction: rtl;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------ join screen */

#join {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 18px calc(24px + var(--safe-b));
}

.join-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.brand {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 4px;
  color: var(--accent);
}

.brand-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  text-align: right;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.15s;
}

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

#codeInput {
  letter-spacing: 8px;
  text-align: center;
  font-size: 22px;
  direction: ltr;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #191204;
  font-weight: 700;
  font-size: 17px;
  border-radius: 10px;
  padding: 15px;
  margin-top: 8px;
  transition: filter 0.15s, transform 0.05s;
}

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

.btn-primary:disabled {
  filter: grayscale(0.7) brightness(0.7);
  cursor: default;
}

.join-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.9;
}

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  margin-top: 10px;
}

/* ------------------------------------------------------------------ room */

#room {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.topbar .title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .spacer {
  flex: 1;
}

.pill {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.pill.live {
  color: var(--ok);
  border-color: #24483d;
}

.pill.drift-bad {
  color: var(--warn);
  border-color: #4a3524;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--muted);
  flex: 0 0 auto;
}

.icon-btn.on {
  color: var(--accent);
  border-color: var(--accent-dim);
}

/* stage + sidebar */

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stage {
  background: #000;
  position: relative;
  flex: 0 0 auto;
}

.stage video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
  max-height: 56dvh;
}

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
  pointer-events: none;
}

.buffering {
  position: absolute;
  top: 10px;
  inset-inline-start: 10px;
  background: rgba(0, 0, 0, 0.65);
  color: var(--accent);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}

/* controls */

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.controls .time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  min-width: 92px;
  text-align: center;
}

.seek {
  flex: 1;
  min-width: 60px;
  height: 26px;
  accent-color: var(--accent);
  direction: ltr;
}

.seek:disabled {
  opacity: 0.45;
}

.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #191204;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex: 0 0 auto;
}

.play-btn:disabled {
  background: var(--panel-2);
  color: var(--muted);
}

/* sidebar: tabs on mobile, columns on desktop */

.sidebar {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}

.tabs button {
  flex: 1;
  padding: 11px 4px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

.tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.panes {
  flex: 1;
  min-height: 0;
  position: relative;
}

.pane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pane.hidden {
  display: none !important;
}

/* chat */

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 88%;
  align-self: flex-start;
}

.msg .who {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 2px;
}

.msg .body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  border-top-right-radius: 4px;
  padding: 7px 11px;
  font-size: 14px;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg.mine {
  align-self: flex-end;
}

.msg.mine .body {
  background: #23303a;
  border-color: #2d3d49;
  border-top-right-radius: 12px;
  border-top-left-radius: 4px;
}

.msg.system {
  align-self: center;
  max-width: 100%;
}

.msg.system .body {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
  text-align: center;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}

.chat-form input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 15px;
  outline: none;
  min-width: 0;
}

.chat-form button {
  background: var(--accent);
  color: #191204;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 700;
  flex: 0 0 auto;
}

/* lists */

.list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px calc(10px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
}

.row .grow {
  flex: 1;
  min-width: 0;
}

.row .name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .meta {
  font-size: 11px;
  color: var(--muted);
}

.row.current {
  border-color: var(--accent-dim);
}

.mini-btn {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  flex: 0 0 auto;
}

.mini-btn.primary {
  background: var(--accent);
  color: #191204;
  border-color: var(--accent);
  font-weight: 700;
}

.mini-btn:disabled {
  opacity: 0.4;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex: 0 0 auto;
}

.dot.buffering {
  background: var(--warn);
}

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 26px 12px;
}

/* toast + reconnect banner */

.banner {
  flex: 0 0 auto;
  background: var(--warn);
  color: #1a1206;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.banner::after {
  content: ' ✕';
  opacity: 0.55;
}

.sound-nudge {
  position: absolute;
  inset-inline-end: 10px;
  bottom: 10px;
  background: var(--accent);
  color: #191204;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  z-index: 5;
}

/* desktop */

@media (min-width: 900px) {
  .layout {
    flex-direction: row;
  }

  .main-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  /* Let the stage own the leftover height so there is no dead strip under the
     controls on a tall window. */
  .stage {
    flex: 1;
    display: grid;
    place-items: center;
  }

  .stage video {
    height: 100%;
    width: auto;
    max-width: 100%;
    max-height: 100%;
  }

  .sidebar {
    width: 360px;
    flex: 0 0 360px;
    border-inline-start: 1px solid var(--line);
    background: var(--panel);
  }
}

/* A control that is present but not currently yours: dimmed, still clickable so
   it can say why. Never `disabled` — a dead button reads as a broken app. */
.muted-btn {
  filter: grayscale(0.6) brightness(0.75);
}

.warn-text {
  color: var(--warn);
}
