/* ============================================================
   Видеозвонки — стили поверхности (Vanilla CSS, без сборщика)
   Мир: ночной холст, один акцент, крупные элементы управления.
   ============================================================ */

:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --border: #1e293b;
  --border-soft: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --primary-soft: rgba(79, 70, 229, 0.16);
  --success: #047857;
  --success-hover: #059669;
  --danger: #e11d48;
  --danger-hover: #f43f5e;
  --telegram: #0e7fb8;
  --whatsapp: #25d366;
  --whatsapp-text: #052e1b;
  --radius: 16px;
  --tap: 56px;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.45);
  --focus-ring: #93c5fd;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  /* Safe area для iPhone с чёлкой / Dynamic Island */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Иконки: одна толщина штриха во всём интерфейсе */
.icon-sprite {
  display: none;
}

.ico {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico-sm {
  width: 18px;
  height: 18px;
}

.ico-36 {
  width: 36px;
  height: 36px;
}

/* Копируемость: user-select запрещён только на кнопках и видео */
button,
.call-dock,
video {
  -webkit-touch-callout: none;
  user-select: none;
}

button,
a.btn,
.dock-btn {
  touch-action: manipulation;
}

::selection {
  background: rgba(99, 102, 241, 0.45);
  color: #fff;
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: var(--tap);
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.btn-big {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  font-size: 15px;
  min-height: 52px;
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-3);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover {
  background: var(--success-hover);
}

.btn-telegram {
  background: var(--telegram);
  font-size: 15px;
  min-height: 52px;
}

.btn-telegram:hover {
  filter: brightness(1.12);
}

.btn-whatsapp {
  background: var(--whatsapp);
  font-size: 15px;
  min-height: 52px;
  color: var(--whatsapp-text);
}

.btn-whatsapp:hover {
  filter: brightness(1.06);
}

.btn-share {
  grid-column: 1 / -1;
}

/* ---------- Лобби ---------- */

.lobby {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  text-align: center;
  overflow-y: auto;
}

.lobby-inner {
  max-width: 420px;
  width: 100%;
  margin: auto;
}

.lobby-hero {
  margin-bottom: 28px;
}

.lobby-logo {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  background: var(--primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 24px;
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.55);
}

.lobby-logo-lock {
  color: #fda4af;
  background: rgba(225, 29, 72, 0.14);
  border-color: rgba(244, 63, 94, 0.3);
}

.lobby-logo-warn {
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.3);
}

.lobby-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lobby-subtitle {
  margin: 0 auto;
  max-width: 36ch;
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--text-dim);
  text-wrap: pretty;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  animation: rise-in 0.3s cubic-bezier(0.2, 0.75, 0.25, 1);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.share-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
}

.share-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 8px 8px 8px 4px;
}

.share-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  padding: 0 8px;
  user-select: all; /* ссылку можно выделить и скопировать */
}

.share-input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
  border-radius: 8px;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.copy-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #34d399;
}

.copy-hint.error {
  color: #fb7185;
}

.lobby-error {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: #fb7185;
  text-align: center;
}

.copy-hint .ico {
  stroke-width: 2.2;
}

/* ---------- WebView-предупреждение ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.overlay-card {
  max-width: 420px;
  text-align: center;
}

.overlay-card h2 {
  margin: 0 0 10px;
  font-size: 26px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.overlay-card p {
  color: var(--text-dim);
  font-size: 16.5px;
  margin: 0 0 14px;
}

.overlay-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  background: var(--primary-soft);
  border: 1px solid rgba(99, 102, 241, 0.28);
  border-radius: 24px;
}

.webview-steps {
  text-align: left;
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 18px 18px 40px;
  margin: 0;
}

.webview-steps li + li {
  margin-top: 6px;
}

/* ---------- Экран звонка ---------- */

.call {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.remote-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-faint);
  font-size: 15px;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.remote-placeholder p {
  margin: 0;
}

.remote-placeholder.is-hidden {
  opacity: 0;
}

.placeholder-pulse {
  width: 92px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #818cf8;
  background: rgba(79, 70, 229, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.22);
  border-radius: 28px;
  animation: breathe 2.6s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    transform: scale(1.05);
    opacity: 0.75;
  }
}

.local-preview {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  z-index: 20;
  width: 104px;
  height: 150px;
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: var(--shadow-soft);
}

@media (min-width: 640px) {
  .local-preview {
    width: 148px;
    height: 204px;
  }
}

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

/* Зеркальное отображение своей фронтальной камеры */
.mirror {
  transform: scaleX(-1);
}

.call-top {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  right: 132px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

@media (min-width: 640px) {
  .call-top {
    right: 184px;
  }
}

.call-status,
.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  background: rgba(2, 6, 23, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.call-status span:last-child,
.quality-badge span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality-badge {
  color: #cbd5e1;
  font-size: 12.5px;
  padding: 7px 13px;
}

.quality-badge .ico {
  color: #34d399;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.status-waiting {
  background: #fbbf24;
  animation: pulse 1.6s ease-in-out infinite;
}

.status-connecting {
  background: #60a5fa;
  animation: pulse 1s ease-in-out infinite;
}

.status-live {
  background: #34d399;
}

.status-dead {
  background: #64748b;
}

.status-error {
  background: #fb7185;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.tap-to-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 14px 22px;
  background: rgba(15, 23, 42, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.tap-to-play:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.tap-to-play:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.call-dock-wrap {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 0 12px;
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

.call-dock {
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: rgba(2, 6, 23, 0.78);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px;
  border-radius: 26px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 68px;
  min-height: 64px;
  padding: 8px 8px 7px;
  border: none;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.dock-btn:active {
  transform: scale(0.94);
}

.dock-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.dock-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--text-dim);
}

/* Выключенное состояние видно всегда */
.dock-btn.off {
  background: #7f1d1d;
}

.dock-btn.off .dock-label {
  color: #fecaca;
}

.dock-btn-hangup {
  background: var(--danger);
}

.dock-btn-hangup .dock-label {
  color: #fff;
}

.dock-btn-hangup:hover {
  background: var(--danger-hover);
}

@media (max-width: 359px) {
  .call-dock {
    gap: 6px;
    padding: 8px;
  }

  .dock-btn {
    min-width: 60px;
    padding: 8px 5px 7px;
  }
}

/* ---------- Уважение к reduced motion ---------- */

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