/* ═══════════════════════════════════════════════════════
   ГОЛОСОВАЯ РУЛЕТКА — CSS
   Telegram Mini App · Dark Violet/Blue Gradient Design
═══════════════════════════════════════════════════════ */

:root {
  --bg-top: #241139;
  --bg-bottom: #070b1a;
  --accent-blue: #38bdf8;
  --accent-red: #ef4444;
  --glass: rgba(255,255,255,0.07);
  --glass-border: rgba(255,255,255,0.12);
  --text: #ffffff;
  --text-muted: rgba(255,255,255,0.45);
  --btn-grad: linear-gradient(90deg, #7c3aed 0%, #38bdf8 100%);
}

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

html, body {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, var(--bg-top) 0%, #0e0b2e 50%, var(--bg-bottom) 100%);
  color: var(--text);
  font-family: -apple-system, 'SF Pro Display', 'Segoe UI', sans-serif;
  overflow: hidden;
  user-select: none;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ════════ ГЛАВНЫЙ ЭКРАН ════════ */
#screen-home { padding: 32px 24px 40px; justify-content: space-between; }

.home-header { width: 100%; text-align: center; padding-top: 16px; }

.home-title {
  font-size: 30px; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(180deg, #ffffff 0%, #a5d8f3 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.home-center {
  display: flex; flex-direction: column; align-items: center; gap: 32px;
  flex: 1; justify-content: center;
}

/* Двойное кольцо — внешний glow + внутренний стакан */
.mic-outer-ring {
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(123,58,237,0.12);
  border: 1px solid rgba(123,58,237,0.3);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 48px rgba(123,58,237,0.25);
  animation: outerRingPulse 3s ease-in-out infinite alternate;
}
@keyframes outerRingPulse {
  from { box-shadow: 0 0 30px rgba(123,58,237,0.2); }
  to   { box-shadow: 0 0 60px rgba(56,189,248,0.3); }
}

.mic-glass-circle {
  width: 116px; height: 116px; border-radius: 50%;
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1.5px solid rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.mic-glass-circle svg { width: 52px; height: 52px; opacity: .95; }

.home-tags { display: flex; gap: 12px; }

.tag {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px; padding: 9px 18px;
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.tag svg { width: 15px; height: 15px; opacity: .75; }

.home-footer { width: 100%; }

.btn-start-main {
  width: 100%; padding: 18px 24px; border: none; border-radius: 18px;
  background: var(--btn-grad); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  box-shadow: 0 6px 32px rgba(139,92,246,0.45);
  transition: transform .15s, box-shadow .15s; letter-spacing: 0.2px;
}
.btn-start-main:active { transform: scale(0.97); box-shadow: 0 2px 12px rgba(139,92,246,.3); }
.btn-start-main svg { width: 22px; height: 22px; }

/* ════════ ЭКРАН ПОИСКА ════════ */
#screen-searching { gap: 32px; padding: 24px; }

.search-ring-wrap {
  position: relative; width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
}
.search-ring {
  position: absolute; border-radius: 50%;
  border: 2px solid rgba(56,189,248,0.4);
  animation: searchPulse 2s ease-out infinite;
}
.search-ring:nth-child(1) { width: 64px; height: 64px; animation-delay: 0s; }
.search-ring:nth-child(2) { width: 100px; height: 100px; animation-delay: .5s; }
.search-ring:nth-child(3) { width: 140px; height: 140px; animation-delay: 1s; }
@keyframes searchPulse {
  0% { transform: scale(.7); opacity: .8; }
  100% { transform: scale(1.1); opacity: 0; }
}

.search-icon-inner {
  width: 56px; height: 56px;
  background: rgba(255,255,255,0.07); border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(10px); z-index: 1;
}
.search-icon-inner svg { width: 26px; height: 26px; }

.search-title {
  font-size: 22px; font-weight: 700;
  background: linear-gradient(180deg, #fff 0%, #a5d8f3 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.search-sub { font-size: 14px; color: var(--text-muted); margin-top: -20px; }

.btn-cancel {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 50px; padding: 12px 28px;
  color: rgba(255,255,255,0.6); font-size: 15px; cursor: pointer;
  backdrop-filter: blur(10px); transition: background .2s;
}
.btn-cancel:active { background: rgba(255,255,255,0.12); }

/* ════════ ЭКРАН ЗВОНКА ════════ */
#screen-call { justify-content: flex-start; padding: 0; }

/* ── Видео ── */
.video-container { position: absolute; inset: 0; background: #000; z-index: 0; }
.video-container.hidden { display: none !important; }
.video-remote { width: 100%; height: 100%; object-fit: cover; }
.video-local {
  position: absolute; width: 100px; height: 136px;
  right: 14px; top: 80px; border-radius: 14px; object-fit: cover;
  border: 1.5px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 20px rgba(0,0,0,.5); z-index: 2;
  transform: scaleX(-1); /* зеркало */
}

/* ── Аватар-блок (только аудиорежим) ── */
#call-info {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  pointer-events: none;
}
#screen-call.has-video #call-info { display: none; }

.call-avatar-circle {
  width: 120px; height: 120px; border-radius: 50%;
  background: linear-gradient(160deg, #1e2a6e 0%, #0d1333 100%);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 40px rgba(56,189,248,0.15); position: relative;
}
.call-avatar-circle svg { width: 54px; height: 54px; opacity: .7; }
.call-avatar-circle::before {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  border: 1.5px solid rgba(56,189,248,0.25);
  animation: avatarGlow 2.5s ease-in-out infinite;
}
@keyframes avatarGlow {
  0%, 100% { opacity: .4; transform: scale(1); }
  50%       { opacity: .9; transform: scale(1.04); }
}
.call-partner-name { font-size: 18px; font-weight: 600; color: #fff; }
.call-partner-status { font-size: 13px; color: var(--text-muted); }

/* ── Оверлей управления ── */
#call-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column;
  pointer-events: none;       /* прозрачный для кликов в пустых зонах */
  transition: opacity .4s ease;
}
/* Только кнопки кликабельны */
#call-overlay button { pointer-events: all; }

/* Градиент поверх видео для читаемости */
#screen-call.has-video #call-overlay {
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.55) 0%, transparent 22%,
    transparent 68%, rgba(0,0,0,0.65) 100%
  );
}

/* Автоскрытие */
#call-overlay.ui-hidden { opacity: 0; }
#call-overlay.ui-hidden button { pointer-events: none; }

/* Верхняя строка: таймер + кнопки камеры */
.overlay-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 20px 0;
  pointer-events: none;
}
.overlay-top button { pointer-events: all; }

.call-timer {
  font-size: 28px; font-weight: 700; color: var(--accent-blue);
  letter-spacing: 3px; font-variant-numeric: tabular-nums;
}
/* В видеорежиме — таймер-таблетка */
#screen-call.has-video .call-timer {
  font-size: 17px; letter-spacing: 2px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 6px 16px; border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.13);
}

.cam-btns { display: flex; gap: 10px; }
#btn-flip-camera { display: none; }
#screen-call.has-video #btn-flip-camera { display: flex; }

/* Нижний блок: эквалайзер + кнопки */
.overlay-bottom {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 24px 44px;
}

/* Компактный эквалайзер */
.equalizer { display: flex; align-items: flex-end; gap: 3px; height: 20px; }
.eq-bar {
  width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-blue) 0%, #7c3aed 100%);
  animation: eqAnim 1.2s ease-in-out infinite alternate; min-height: 3px;
}
.eq-bar:nth-child(1)  { --h:16px; animation-delay: 0.00s; }
.eq-bar:nth-child(2)  { --h:20px; animation-delay: 0.10s; }
.eq-bar:nth-child(3)  { --h:11px; animation-delay: 0.20s; }
.eq-bar:nth-child(4)  { --h:18px; animation-delay: 0.30s; }
.eq-bar:nth-child(5)  { --h:20px; animation-delay: 0.15s; }
.eq-bar:nth-child(6)  { --h:14px; animation-delay: 0.25s; }
.eq-bar:nth-child(7)  { --h:18px; animation-delay: 0.05s; }
.eq-bar:nth-child(8)  { --h:12px; animation-delay: 0.35s; }
.eq-bar:nth-child(9)  { --h:18px; animation-delay: 0.10s; }
.eq-bar:nth-child(10) { --h:16px; animation-delay: 0.22s; }
@keyframes eqAnim { from { height: 3px; } to { height: var(--h, 18px); } }

.controls-main { display: flex; align-items: center; justify-content: center; gap: 24px; }

/* Кнопки */
.ctrl-sm {
  width: 58px; height: 58px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.09);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .18s, transform .12s;
  box-shadow: 0 4px 18px rgba(0,0,0,.3);
}
.ctrl-sm:active { transform: scale(0.91); }
.ctrl-sm svg { width: 22px; height: 22px; }
.ctrl-sm.is-active { background: rgba(239,68,68,0.25); border-color: rgba(239,68,68,0.4); }

.ctrl-end {
  width: 70px; height: 70px; border-radius: 50%; border: none;
  background: var(--accent-red); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 28px rgba(239,68,68,0.5);
  transition: transform .12s, box-shadow .15s;
}
.ctrl-end:active { transform: scale(0.91); box-shadow: 0 2px 10px rgba(239,68,68,.4); }
.ctrl-end svg { width: 26px; height: 26px; }

/* Иконки мут / камера переключаются через CSS */
.icon-mic-on  { display: block; } .icon-mic-off { display: none; }
.ctrl-sm.is-active  .icon-mic-on  { display: none; }
.ctrl-sm.is-active  .icon-mic-off { display: block; }
.icon-cam-on  { display: block; } .icon-cam-off { display: none; }
.ctrl-sm.cam-active .icon-cam-on  { display: none; }
.ctrl-sm.cam-active .icon-cam-off { display: block; }

/* ─── Toast ─── */
.toast {
  position: fixed; top: 18px; left: 50%;
  transform: translateX(-50%) translateY(-70px);
  background: rgba(20,15,40,0.9); border: 1px solid rgba(255,255,255,0.1);
  color: #fff; padding: 11px 20px; border-radius: 50px;
  font-size: 14px; font-weight: 500; backdrop-filter: blur(16px);
  z-index: 999; opacity: 0; pointer-events: none; white-space: nowrap;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
