/* Call screen (calls.js): full screen, always dark, like Signal's. */
.call-view {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: #101315; color: #fff; overflow: hidden;
}
.call-view[open] { display: flex; flex-direction: column; }
.call-view::backdrop { background: #101315; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-info {
  position: relative; z-index: 1; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: calc(24px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 16px calc(16px + env(safe-area-inset-left));
  text-align: center;
}
.call-view.has-video .call-info { justify-content: flex-start; text-shadow: 0 1px 4px rgba(0, 0, 0, .7);
  /* Over a bright video the name, timer and status bar faded (white on light green): a scrim, as the controls' below */
  background: linear-gradient(to bottom, rgb(0 0 0 / .6), rgb(0 0 0 / 0)) top / 100% calc(140px + env(safe-area-inset-top)) no-repeat; }
.call-view.has-video .call-avatar { display: none; }
.call-view.has-video:has(.call-local:not([hidden])) .call-info h2 { max-width: calc(100% - 2 * 96px - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-avatar { width: 104px; height: 104px; font-size: 2.625rem; margin-bottom: 8px; }
.call-info h2:focus { outline: none; }
.call-info h2 { margin: 0; font-size: var(--text-2xl); font-weight: 600; overflow-wrap: anywhere; }
.call-status { margin: 0; font-size: 1rem; opacity: .85; font-variant-numeric: tabular-nums; }
.call-people { margin: 0; max-width: 340px; font-size: var(--text-md); opacity: .85; overflow-wrap: anywhere; }
.call-people[hidden] { display: none; }
.call-e2ee { margin: 0; font-size: var(--text-sm); opacity: .75; }
.call-view.mini .call-e2ee { display: none; }
.call-view.mini .call-people { display: none; }
/* UC-GC-1: a group chat with a call on shows who can Join, as Signal's banner under the header. */
.call-banner { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 16px; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); color: var(--text); font-size: var(--text-md); }
.call-banner[hidden] { display: none; }
.call-banner > svg { flex: none; color: var(--accent); }
.call-banner-text { flex: 1; min-width: 0; }
.call-banner button { flex: none; min-height: 36px; padding: 6px 16px; border-radius: 999px; }
.call-hint { margin: 10px 0 0; max-width: 340px; font-size: var(--text-md); line-height: 1.4; background: rgba(255, 255, 255, .14); padding: 8px 12px; border-radius: var(--radius-md); text-shadow: none; }
.call-close { margin-top: 14px; background: #fff; color: #101315; border: 0; border-radius: var(--radius-full); padding: 10px 28px; font-weight: 600; }
.call-local {
  position: absolute; z-index: 2; right: calc(12px + env(safe-area-inset-right)); top: calc(12px + env(safe-area-inset-top));
  width: 96px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; background: #222; /* design canvas › InCall: 96×144, radius 16 */
  box-shadow: 0 4px 16px rgba(0, 0, 0, .45);
}
.call-local.mirror { transform: scaleX(-1); }
.call-controls, .call-incoming {
  position: relative; z-index: 1; display: flex; justify-content: center; align-items: flex-start; gap: 14px; flex-wrap: wrap;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.call-incoming { gap: 36px; }
.call-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: #2a3133; color: #f2f4f4;
}
@media (hover: hover) { .call-btn:hover { background: #3a4245; } }
.call-btn[aria-pressed="true"] { background: #f2f4f4; color: #0e1112; }
.call-btn.end, .call-btn.decline { background: #d93a2f; }
.call-controls .call-btn.end { width: 72px; border-radius: 28px; } /* the widest, so it reads as the way out */
/* Over video the controls sit on a dark panel with 28 px top corners (Signal's call controls sheet; design canvas ›
   InCall), so they stay visible on a bright picture; ⌄ on a scrim */
.call-view.has-video .call-controls { background: rgb(14 17 18 / .88); border-radius: 28px 28px 0 0; }
.call-view.has-video .call-min { background: rgb(0 0 0 / .45); }
.call-btn.accept { background: #1e8e3e; }
.call-incoming .call-btn { width: 64px; height: 64px; }
.call-btn-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: var(--text-sm); }
/* five controls in one row down to 360 px (iPhone X is 375: 4 × 56 + 72 + 4 × 14 wrapped End to a second row) */
@media (max-width: 400px) { .call-controls { gap: 10px; } .call-controls .call-btn.end { width: 64px; } }
@media (max-width: 360px) { .call-btn { width: 50px; height: 50px; } .call-controls { gap: 10px; } }

/* Minimized call (calls.js setMini): a tile above the composer; tapping it goes back, the red button still ends. */
.call-min {
  position: absolute; z-index: 3; left: calc(8px + env(safe-area-inset-left)); top: calc(8px + env(safe-area-inset-top));
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .18); color: #fff;
}
.call-expand { display: none; }
.call-view.mini {
  inset: auto calc(12px + env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) auto; width: 136px; height: 196px;
  border-radius: var(--radius-lg); z-index: 50; box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}
/* Dragged tile: snaps to a corner (top corners clear the chat header) */
.call-view.mini { touch-action: none; }
.call-view.mini[data-corner="br"], .call-view.mini:not([data-corner]) { inset: auto calc(12px + env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) auto; }
.call-view.mini[data-corner="bl"] { inset: auto auto calc(88px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left)); }
.call-view.mini[data-corner="tr"] { inset: calc(72px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) auto auto; }
.call-view.mini[data-corner="tl"] { inset: calc(72px + env(safe-area-inset-top)) auto auto calc(12px + env(safe-area-inset-left)); }
@media (prefers-reduced-motion: no-preference) { .call-view.mini:not(.dragging) { transition: inset var(--dur-base) var(--ease-out); } }
.call-view.mini .call-min, .call-view.mini .call-local, .call-view.mini .call-hint, .call-view.mini .call-controls > :not(.end) { display: none; }
.call-view.mini .call-expand { display: block; position: absolute; inset: 0; z-index: 2; border: 0; background: none; }
.call-view.mini .call-info { padding: 10px 8px 0; gap: 2px; justify-content: flex-start; }
.call-view.mini .call-avatar { width: 44px; height: 44px; font-size: var(--text-lg); margin: 0 0 4px; }
.call-view.mini .call-info h2 { font-size: var(--text-md); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-view.mini .call-status { font-size: var(--text-xs); }
.call-view.mini .call-controls { z-index: 3; padding: 8px; }
.call-view.mini .call-btn.end { width: 44px; height: 44px; }

/* UC-GC-1 group video (AC-GC-12, AC-GC-19), as Signal's: the lobby shows my preview full screen, then a tile per person. */
.icon-btn.call-join-pill { width: auto; min-width: 44px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-full); background: #137333; color: #fff; font-weight: 600; }
@media (hover: hover) { .icon-btn.call-join-pill:hover { background: #18773a; } }
.call-view.lobby .call-local { inset: 0; z-index: 0; width: 100%; height: 100%; max-width: none; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.call-view.lobby:has(.call-local:not([hidden])) .call-info { justify-content: flex-start; text-shadow: 0 1px 4px rgba(0, 0, 0, .7); }
.call-view.lobby:has(.call-local:not([hidden])) .call-avatar { display: none; }
.call-view.lobby:has(.call-local:not([hidden])) .call-controls { background: linear-gradient(to top, rgb(0 0 0 / .65), rgb(0 0 0 / 0)); }
.call-view.lobby .call-controls { padding-bottom: 12px; }
.call-cam-off { margin: 4px 0 0; font-size: var(--text-md); opacity: .85; }
.call-cam-off[hidden], .call-lobby-actions[hidden], .call-tiles[hidden] { display: none; }
.call-lobby-actions {
  position: relative; z-index: 1; display: flex; justify-content: center; gap: 12px;
  padding: 0 calc(16px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.call-view.lobby:has(.call-local:not([hidden])) .call-lobby-actions { background: rgb(0 0 0 / .65); }
.call-lobby-btn { min-height: 44px; min-width: 120px; padding: 10px 28px; border: 0; border-radius: var(--radius-full); background: rgba(255, 255, 255, .18); color: #fff; font-size: 1rem; font-weight: 600; }
.call-lobby-btn.primary { background: #137333; color: #fff; } /* 5.9:1 with white text (WCAG AA 4.5:1) */
.call-lobby-btn:disabled, .call-btn:disabled { opacity: .5; }
.call-view.has-tiles .call-info { flex: none; padding-bottom: 8px; }
.call-view.has-tiles .call-avatar { display: none; }
.call-tiles {
  position: relative; z-index: 1; flex: 1; min-height: 0; display: grid; gap: 6px; grid-template-columns: 1fr; grid-auto-rows: minmax(0, 1fr);
  padding: 0 calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
}
.call-tiles[data-n="3"], .call-tiles[data-n="4"] { grid-template-columns: 1fr 1fr; }
@media (min-aspect-ratio: 1/1) { .call-tiles[data-n="2"] { grid-template-columns: 1fr 1fr; } }
.call-tile { position: relative; min-height: 0; overflow: hidden; display: grid; place-items: center; border-radius: var(--radius-md); background: #22272b; }
.call-tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.call-tile-avatar { width: 72px; height: 72px; font-size: 1.75rem; }
.call-tile.has-video .call-tile-avatar { display: none; }
.call-tile-name { position: absolute; left: 8px; bottom: 6px; max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.call-tile.connecting { opacity: .6; }
.call-view.has-tiles .call-local { top: auto; bottom: calc(108px + env(safe-area-inset-bottom)); width: 22vw; max-width: 110px; }
.call-view.mini .call-tiles, .call-view.mini .call-lobby-actions, .call-view.mini .call-cam-off { display: none; }
