/* Vazirmatn is loaded from this binary, never from a CDN: the deployment
   network has no internet access. If the woff2 files are absent the stack
   falls through to Tahoma, which ships with Windows and renders Persian
   acceptably. See static/fonts/README.md. */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2b303b;
  --text: #e8eaed;
  --text-dim: #9aa2ae;
  --accent: #e03e52;
  --accent-text: #ffffff;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --radius: 12px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --border: #d9dde4;
    --text: #1a1d23;
    --text-dim: #5d6674;
    --accent: #c62b3f;
    --danger: #c0392b;
    --ok: #157f3c;
  }
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.is-hidden { display: none !important; }

/* --- login card --------------------------------------------------------- */

.card {
  width: 100%;
  max-width: 26rem;
  margin: auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card__title {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  font-weight: 700;
}

.card__subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field__label {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.field__input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 1rem;
  /* Phone numbers and codes read left-to-right even in an RTL page. */
  direction: ltr;
  text-align: center;
  letter-spacing: 0.04em;
}

.field__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field__input--code {
  font-size: 1.6rem;
  letter-spacing: 0.5em;
  text-indent: 0.5em; /* compensate for the trailing letter-space */
}

.btn {
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
  border: 1px solid transparent;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
  font-weight: 400;
}

.btn--link {
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 400;
  text-decoration: underline;
  padding: 0.25rem;
}

.btn--small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.message {
  margin: 1rem 0 0;
  min-height: 1.5rem;
  font-size: 0.92rem;
}

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

/* --- live page ---------------------------------------------------------- */

.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__brand { font-weight: 700; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar__name { color: var(--text-dim); }

.badge {
  padding: 0.1rem 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.stage {
  width: 100%;
  max-width: 72rem;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 60rem) {
  .stage { grid-template-columns: 2fr 1fr; }
}

.player {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.player__placeholder { color: var(--text-dim); }

.panel {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.panel__empty {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

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

/* A fixed height, so a long conversation scrolls instead of growing the page. */
.chat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 32rem;
  min-width: 0;
}

.chat__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat__meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.chat__name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chat__time {
  margin-inline-start: auto;
  color: var(--text-dim);
  flex: none;
}

.chat__body {
  margin: 0.15rem 0 0;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.chat__status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.chat__status:empty { display: none; }
.chat__status--error { color: var(--danger); }

.chat__form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat__row {
  display: flex;
  gap: 0.4rem;
}

.chat__input {
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  min-width: 0;
}

/* --- player (phase 2) --------------------------------------------------- */

.player-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.player__video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

/* At the top, clear of the native controls along the bottom of the video. */
.player__unmute {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  white-space: nowrap;
}

.player__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 1rem;
  text-align: center;
  background: var(--surface);
}

.player__hint {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.player-bar__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.player-bar__meta {
  color: var(--text-dim);
  font-size: 0.9rem;
  /* An elapsed clock reads left-to-right. */
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.1rem 0.55rem;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.live-badge__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* Honour a viewer who asked for less motion. */
@media (prefers-reduced-motion: reduce) {
  .live-badge__dot { animation: none; }
}

/* --- admin console ------------------------------------------------------ */

.admin {
  width: 100%;
  max-width: 48rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card--wide {
  max-width: none;
  margin: 0;
  padding: 1.25rem;
}

.kv {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.kv__key {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.kv__value {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.code {
  padding: 0.15rem 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.85rem;
  /* URLs and keys are left-to-right even on an RTL page. */
  direction: ltr;
  text-align: left;
  overflow-wrap: anywhere;
}

.code--block {
  display: block;
  padding: 0.6rem;
  font-size: 1rem;
}

.form--inline {
  flex-direction: row;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.field--grow { flex: 1 1 16rem; }

/* The title is Persian prose, unlike the phone and code inputs. */
.field__input--text {
  direction: rtl;
  text-align: right;
  letter-spacing: normal;
}

.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.keybox {
  margin-top: 1rem;
  padding: 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.keybox__warning {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}
