/* Unified desktop call surfaces. Loaded after style.css to retire legacy mock feeds. */

#call-modal {
  padding: 32px 0 0;
  background: var(--shade-a-80);
}

#call-modal .call-overlay-container {
  width: min(1180px, calc(100vw - 48px));
  height: min(760px, calc(100vh - 72px));
  max-width: none;
  max-height: none;
  padding: 18px;
  border: 1px solid var(--tint-a-10);
  border-radius: 8px;
  background: var(--bg-primary);
  box-shadow: 0 24px 70px var(--shade-a-60);
}

#call-modal .call-bg-glow,
#call-modal .call-bg-blur-avatar,
#call-modal .call-voice-profile {
  display: none !important;
}

#call-modal .call-top-bar {
  min-height: 42px;
  justify-content: space-between !important;
}

#call-modal .call-encrypted-badge {
  margin: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
}

#call-modal .call-main-content {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 12px 0 84px;
}

#call-modal .call-video-grid,
#call-modal .call-video-grid.layout-split {
  position: relative !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100% !important;
  height: 100% !important;
  min-height: 280px !important;
  max-height: none !important;
  margin: 0 !important;
}

#call-modal .call-video-grid.hidden {
  display: grid !important;
}

#call-modal .video-stream-box,
#call-modal .call-video-grid.layout-split .video-stream-box,
#call-modal .call-video-grid.layout-remote-max .video-stream-box,
#call-modal .call-video-grid.layout-local-max .video-stream-box {
  position: relative !important;
  inset: auto !important;
  width: auto !important;
  height: auto !important;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--tint-a-9) !important;
  border-radius: 8px !important;
  background: var(--bg-tertiary) !important;
  overflow: hidden;
  box-shadow: none !important;
}

#call-modal .call-video-grid.layout-remote-max .remote-video,
#call-modal .call-video-grid.layout-local-max .local-video {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 1 !important;
}

#call-modal .call-video-grid.layout-remote-max .local-video,
#call-modal .call-video-grid.layout-local-max .remote-video {
  position: absolute !important;
  right: 14px !important;
  bottom: 14px !important;
  width: clamp(150px, 20vw, 220px) !important;
  height: clamp(100px, 15vw, 150px) !important;
  z-index: 4 !important;
}

.call-live-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-deep);
  z-index: 2;
}

.call-live-video.is-screenshare {
  object-fit: contain;
  filter: none !important;
}

#call-modal .video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-tertiary);
}

#call-modal .video-stream-box.has-media .video-placeholder {
  visibility: hidden;
}

#call-modal .call-avatar {
  width: clamp(72px, 9vw, 112px) !important;
  height: clamp(72px, 9vw, 112px) !important;
  font-size: 28px !important;
  border: 2px solid var(--tint-a-16);
  box-shadow: none !important;
}

#call-modal .video-label {
  color: var(--text-secondary);
  font-size: 13px;
}

.call-media-kind {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  display: none;
  padding: 5px 8px;
  border-radius: 5px;
  background: var(--surface-overlay);
  border: 1px solid var(--tint-a-12);
  color: var(--text-primary);
  font-size: 11px;
}

.video-stream-box.has-media .call-media-kind {
  display: block;
}

#call-modal .call-controls-dock {
  bottom: 18px;
  min-height: 58px;
  padding: 8px 10px;
  gap: 8px;
  border-radius: 8px;
  background: var(--glass-strong) !important;
}

#call-modal .call-dock-btn {
  width: 46px;
  height: 46px;
  border-radius: 7px !important;
}

#server-voice-panel .room-header {
  min-height: 64px;
}

.voice-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.voice-stage-collapse {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--tint-a-10);
  border-radius: 14px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.voice-stage-collapse:hover {
  color: var(--text-bright);
  background: var(--surface-highlight);
  border-color: var(--tint-a-20);
}

.voice-stage-collapse svg {
  width: 18px;
  height: 18px;
}

#server-voice-panel .voice-channel-panel {
  position: relative;
  min-height: 0;
  padding: 14px 14px 84px;
  border: 0;
  border-radius: 0;
  background: var(--bg-primary);
}

#server-voice-panel .voice-float-preview,
#server-voice-panel .voice-fullscreen-overlay {
  display: none !important;
}

/* По классу, а не по id: этой же сценой рисуется войс комнаты
   (#room-voice-grid-constellation), раньше там оставались старые заглушки. */
.voice-constellation.love-voice-grid {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  grid-auto-rows: minmax(210px, 1fr);
  align-content: center;
  gap: 10px;
}

/* Один участник: трек тянулся на всю высоту сцены, а .has-media держал 16/9 —
   пропорция спорила с высотой строки, плитка выходила узкой вертикальной, и
   демонстрация с object-fit: contain сжималась в тонкую полоску. Поэтому размер
   задаём самой плитке, а не треку. */
.voice-constellation.love-voice-grid[data-count="1"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
}

.voice-constellation.love-voice-grid[data-count="1"] .love-voice-tile {
  width: min(100%, 760px);
  height: 100%;
}

/* С медиа — плитка забирает сцену целиком, чтобы кадр не терял место по бокам. */
.voice-constellation.love-voice-grid[data-count="1"] .love-voice-tile.has-media {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

/* Разворачивать нечего, когда участник один: span 2 создавал неявную вторую
   строку и сцена уезжала в скролл. */
.voice-constellation.love-voice-grid[data-count="1"] .love-voice-tile.is-focused {
  grid-row: 1;
  min-height: 0;
}

.love-voice-tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--tint-a-9);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 42%, var(--tint-a-4), transparent 38%),
    var(--bg-secondary);
  color: var(--text-bright);
  cursor: default;
  transition: border-color 160ms ease, background 160ms ease;
}

.love-voice-tile.speaking {
  border-color: var(--danger-glow);
}

.love-voice-tile.has-media {
  cursor: pointer;
  aspect-ratio: 16 / 9;
}

.love-voice-tile.is-focused {
  grid-column: 1 / -1;
  grid-row: 1 / span 2;
  /* .has-media держит 16/9, и на развёрнутой плитке это спорит с min-height:
     высота получалась то от пропорции, то от минимума — отсюда дёрганый кадр. */
  aspect-ratio: auto;
  min-height: 360px;
}

.love-voice-tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--bg-deep);
}

.love-voice-tile.is-screen .love-voice-tile-video {
  object-fit: contain;
}

.love-voice-tile-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.love-voice-tile.has-media .love-voice-tile-placeholder {
  display: none;
}

.love-voice-tile-avatar {
  width: clamp(88px, 10vw, 124px);
  height: clamp(88px, 10vw, 124px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--tint-a-18);
  background:
    linear-gradient(145deg, var(--tint-a-12), var(--tint-a-4)),
    var(--surface-highlight) center / cover no-repeat;
  box-shadow: 0 18px 50px var(--shade-a-40), inset 0 0 0 1px var(--tint-a-4);
  font-size: 28px;
  font-weight: 700;
  color: var(--tint-a-85);
  transition: background-image 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.love-voice-tile-avatar.has-image {
  background-size: cover;
  background-position: center;
}

.love-voice-tile.speaking .love-voice-tile-avatar {
  transform: scale(1.035);
  border-color: var(--danger-glow);
  box-shadow: 0 0 0 5px var(--danger-bg), 0 18px 50px var(--shade-a-40);
}

.love-voice-tile-footer {
  position: absolute;
  z-index: 3;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.love-voice-tile-name,
.love-voice-tile-mode {
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid var(--tint-a-10);
  background: var(--surface-overlay);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1;
}

#server-voice-panel .voice-footer-bar {
  width: max-content;
  min-height: 62px;
  align-self: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 20px;
  border: 1px solid var(--tint-a-10);
  background: linear-gradient(180deg, var(--glass-strong), var(--glass-strong));
  box-shadow: 0 18px 46px var(--shade-a-50), inset 0 1px 0 var(--tint-a-6);
  backdrop-filter: blur(22px) saturate(130%);
}

#server-voice-panel .voice-footer-center {
  gap: 8px;
}

#server-voice-panel .voice-footer-right {
  margin-left: 2px;
  padding-left: 10px;
}

#server-voice-panel .voice-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  border-color: var(--tint-a-10);
  background: var(--tint-a-6);
  color: var(--tint-a-80);
  box-shadow: inset 0 1px 0 var(--tint-a-4);
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease, color 150ms ease;
}

#server-voice-panel .voice-control-btn svg {
  width: 19px;
  height: 19px;
}

#server-voice-panel .voice-control-btn:hover {
  transform: translateY(-2px);
  background: var(--tint-a-12);
  border-color: var(--tint-a-20);
}

#server-voice-panel .voice-control-btn.active-state {
  background: var(--text-primary);
  border-color: var(--text-bright);
  color: var(--bg-tertiary);
}

#server-voice-panel .voice-control-btn.muted-state {
  background: var(--tint-a-4);
  border-color: var(--tint-a-8);
  color: var(--tint-a-35);
}

#server-voice-panel #voice-btn-mic.muted-state {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

#server-voice-panel .voice-disconnect-btn {
  min-height: 44px;
  gap: 7px;
  padding: 0 15px;
  border-radius: 15px;
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 12px;
}

#server-voice-panel .voice-disconnect-btn svg {
  width: 17px;
  height: 17px;
}

#server-voice-panel .voice-disconnect-btn:hover {
  transform: translateY(-2px);
  background: var(--danger);
  border-color: var(--danger-text);
  color: var(--text-bright);
}

.love-voice-tile-mode:empty {
  display: none;
}

/* ── Большой просмотр демки/камеры ─────────────────────────────────────────
   Специально не системный фуллскрин: окно приложения остаётся на месте, снизу
   видно остальных участников, а кадр можно приближать и тащить. */
.voice-theater {
  position: fixed;
  inset: 0;
  /* Выше экрана входа (5000) и лайтбокса картинок (17000), но ниже
     объявлений и жалоб — иначе просмотр перекрывал бы системные окна. */
  z-index: 18500;
  display: grid;
  place-items: center;
  /* Титлбар в Electron лежит выше по z-index — без этого отступа шапка
     просмотра уходила бы под него, как раньше таблетка звонка. */
  padding: calc(var(--titlebar-h, 0px) + 18px) 18px 18px;
  background: var(--shade-a-80);
  backdrop-filter: blur(14px);
}

.voice-theater.hidden {
  display: none;
}

.voice-theater-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: min(1400px, 100%);
  height: 100%;
  min-height: 0;
}

.voice-theater-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--tint-a-10);
  border-radius: 12px;
  background: var(--surface-overlay);
}

.voice-theater-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-bright);
  font-size: 13px;
  font-weight: 600;
}

.voice-theater-zoom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-theater-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--tint-a-12);
  border-radius: 9px;
  background: var(--tint-a-4);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.voice-theater-btn:hover {
  background: var(--tint-a-12);
  border-color: var(--tint-a-18);
  color: var(--text-bright);
}

.voice-theater-btn svg {
  width: 16px;
  height: 16px;
}

.voice-theater-zoom-value {
  min-width: 58px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--tint-a-12);
  border-radius: 9px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.voice-theater-zoom-value:hover {
  border-color: var(--tint-a-18);
  color: var(--text-bright);
}

.voice-theater-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--tint-a-9);
  border-radius: 16px;
  background: var(--bg-deep);
}

.voice-theater-stage.is-zoomed {
  cursor: grab;
}

.voice-theater-stage.is-dragging {
  cursor: grabbing;
}

/* Кадр прибит к сцене абсолютно: при обычном потоке <video> брало высоту от
   своей пропорции и вылезало за границы, из-за чего contain считался от
   элемента, а не от сцены — картинку подрезало. */
.voice-theater-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* contain, а не cover: демонстрацию нельзя обрезать — за кадром остаётся
     ровно то, на что человек показывает. */
  object-fit: contain;
  transform-origin: center;
  transition: transform 120ms ease-out;
}

.voice-theater-stage.is-dragging .voice-theater-video {
  transition: none;
}

.voice-theater-video.hidden {
  display: none;
}

.voice-theater-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 13px;
}

.voice-theater-empty.hidden {
  display: none;
}

.voice-theater-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: thin;
}

.voice-theater-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  max-width: 220px;
  padding: 6px 10px 6px 6px;
  border: 1px solid var(--tint-a-10);
  border-radius: 12px;
  background: var(--surface-overlay);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, opacity 140ms ease;
}

.voice-theater-chip:disabled {
  cursor: default;
  opacity: 0.55;
}

.voice-theater-chip.has-media:hover {
  border-color: var(--tint-a-18);
  background: var(--tint-a-8);
}

.voice-theater-chip.is-current {
  border-color: var(--tint-a-40);
  background: var(--tint-a-12);
}

.voice-theater-chip-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--tint-a-18);
  background: linear-gradient(145deg, var(--tint-a-12), var(--tint-a-4));
  color: var(--tint-a-85);
  font-size: 12px;
  font-weight: 700;
}

.voice-theater-chip-avatar.has-image {
  background-size: cover;
  background-position: center;
  color: transparent;
}

.voice-theater-chip-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.voice-theater-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-bright);
}

.voice-theater-chip-mode {
  font-size: 11px;
  color: var(--text-muted);
}

/* Кнопка «в большой вид» на плитке участника */
.love-voice-tile-expand {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--tint-a-12);
  border-radius: 9px;
  background: var(--surface-overlay);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.love-voice-tile.has-media .love-voice-tile-expand {
  display: grid;
}

.love-voice-tile-expand:hover {
  background: var(--tint-a-18);
  color: var(--text-bright);
}

.love-voice-tile-expand svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 850px) {
  #call-modal .call-overlay-container {
    width: calc(100vw - 20px);
    height: calc(100vh - 48px);
    padding: 12px;
  }

  #call-modal .call-video-grid,
  #call-modal .call-video-grid.layout-split {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .voice-constellation.love-voice-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(180px, 1fr);
  }
}
