/* Meetings call skin.
 *
 * The call runs inside third-party shadow roots (Jitsi / RealtimeKit), where
 * the page stylesheets do not reach. The meetings modules load this file into
 * each shadow root they touch, so the JavaScript carries no CSS.
 *
 * Every rule is scoped: :host(...) classes for the third-party components and
 * .meet-* names for our own controls. Nothing here leaks into the reader or
 * the admin panel.
 */

/* --- page and call layout ------------------------------------------------ */

html.meet-open {
  overflow: hidden;
}

.meet-rtk {
  width: 100%;
  height: 100%;
  position: relative !important;
  /* Above the page-level tiles, so the bar and its menus are never covered
   * by a participant tile. The host itself ignores the pointer; call.css
   * re-enables the bar, sidebar and dialogs inside its shadow root. */
  z-index: 20;
}

/* --- floating call window ------------------------------------------------ */

/* Back from the call keeps it running: the same call is shrunk into the
 * bottom-right corner instead of hanging up. `meet-mini` never hides the
 * call element, so audio and video keep flowing. */
#meetCall.meet-mini {
  top: var(--mini-top, auto);
  left: var(--mini-left, auto);
  right: var(--mini-right, 16px);
  bottom: var(--mini-bottom, 16px);
  width: var(--mini-w, min(360px, calc(100vw - 24px)));
  height: var(--mini-h, min(240px, calc(100vh - 24px)));
  cursor: move;
  touch-action: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

/* In the small window the call header and its panels do not fit. */
#meetCall.meet-mini > div:first-child {
  display: none;
}

#meetCall.meet-mini #meetReqPanel,
#meetCall.meet-mini #meetHandsPanel {
  display: none !important;
}

#meetCall.meet-mini.is-moving {
  user-select: none;
}

#meetMiniMove {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 30;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  background: rgba(28, 25, 23, 0.82);
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: move;
}

#meetCall.meet-mini #meetMiniMove {
  display: flex;
}

#meetMiniGrip {
  display: none;
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: 24px;
  height: 24px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 55%, rgba(255, 255, 255, 0.75) 55%);
}

#meetCall.meet-mini #meetMiniGrip {
  display: block;
}

#meetMiniBar {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 30;
  gap: 6px;
}

#meetCall.meet-mini #meetMiniBar {
  display: flex;
}

#meetMiniBar button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9999px;
  background: rgba(28, 25, 23, 0.82);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#meetMiniBar button:hover {
  background: #44403c;
}

/* Third-party controls we hide without touching their own styles. */
.meet-hidden {
  display: none !important;
}


/* RealtimeKit's own grid keeps its box (so the call area and sidebar still
 * size correctly) but its tiles are not painted: the page draws them. */
:host(.meet-tiles-mode) rtk-grid {
  visibility: hidden !important;
  pointer-events: none !important;
  /* Keep the box (our layout measures it) but skip laying out and decoding the
   * kit's hidden participant tiles; otherwise every camera is decoded twice
   * (kit grid + page tiles) and the share drops frames. */
  content-visibility: hidden !important;
}

/* The page tiles are siblings of the meeting and paint over the hidden grid.
 * The meeting host sits above them (z-index in .meet-rtk) but stays
 * transparent; only the interactive kit parts take the pointer, so the video
 * tiles are still clickable. This is what kept the "..." menu on phones
 * hidden behind the tiles. */
:host(.meet-tiles-mode) {
  background-color: transparent !important;
  pointer-events: none;
}

:host(.meet-tiles-mode) rtk-controlbar,
:host(.meet-tiles-mode) rtk-sidebar,
:host(.meet-tiles-mode) rtk-dialog-manager {
  pointer-events: auto;
}

/* --- dynamic participant tiles (page level) ----------------------------- */

#meetTiles {
  position: absolute;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#meetTiles::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.meet-tile {
  position: absolute;
  background: #292524;
  border-radius: 12px;
  overflow: hidden;
  transition: left 220ms ease, top 220ms ease, width 220ms ease,
    height 220ms ease, opacity 180ms ease, transform 180ms ease;
  will-change: left, top, width, height;
}

/* Only the box is stretched: the kit's own :host sets the flex display that
 * centers the avatar, and a page-level `display` would override it. The kit's
 * container-type also makes the host a stacking context, so the avatar stays
 * above the tile background. */
.meet-tile-ui {
  width: 100%;
  height: 100%;
  isolation: isolate;
}

.meet-tile-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9999px;
  background: rgba(28, 25, 23, 0.72);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.68;
  transition: opacity 150ms ease, background 150ms ease;
}

.meet-tile:hover .meet-tile-pin,
.meet-tile.is-pinned .meet-tile-pin {
  opacity: 1;
}

.meet-tile.is-pinned .meet-tile-pin {
  background: #f59e0b;
  color: #451a03;
}


/* Raised hand: amber ring on the tile and the turn number, top-left.
 * Everyone in the call sees it. */
.meet-tile.has-hand {
  box-shadow: inset 0 0 0 3px #f59e0b;
}

.meet-tile-hand {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: 9999px;
  background: #f59e0b;
  color: #451a03;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  animation: meet-hand-in 320ms ease-out;
}

.meet-tile-hand.hidden {
  display: none;
}

.meet-tile-hand i {
  animation: meet-hand-wave 1.2s ease-in-out 2;
  transform-origin: 70% 90%;
}

@keyframes meet-hand-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes meet-hand-wave {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-14deg); }
  75% { transform: rotate(14deg); }
}

/* Moderator buttons on another person's tile (shown on hover, always on
 * touch screens). */
.meet-tile-admin {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.meet-tile-admin.hidden {
  display: none;
}

.meet-tile:hover .meet-tile-admin,
.meet-tile-admin:focus-within {
  opacity: 1;
}

.meet-tile-admin button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9999px;
  background: rgba(28, 25, 23, 0.8);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.meet-tile-admin button:hover {
  background: #44403c;
}

.meet-tile-admin button.is-danger:hover {
  background: #b91c1c;
}

.meet-tile-admin button.hidden {
  display: none;
}

@media (hover: none) {
  .meet-tile-admin {
    opacity: 0.9;
  }
}

.meet-tile.is-entering {
  opacity: 0;
  transform: scale(0.97);
}

.meet-tile.is-leaving {
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

#meetTiles.is-resizing .meet-tile {
  transition: none;
}

.meet-tile-screen {
  background: #000;
  border-radius: 0 !important;
}

.meet-screen-video {
  display: block;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 5px;
  object-fit: contain;
  background: #000;
  border-radius: 0 !important;
}

.meet-screen-name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  max-width: calc(100% - 24px);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meet-screen-view {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 3px;
  border-radius: 9999px;
  background: rgba(0, 0, 0, 0.62);
}

@media (max-width: 767px) {
  .meet-screen-view {
    left: 10px;
    right: 10px;
  }
}

.meet-screen-view-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (min-width: 768px) {
  .meet-screen-view [data-slot="grow"] {
    display: none !important;
  }
}

.meet-screen-view button {
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.meet-screen-view button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}

.meet-screen-view button:disabled {
  opacity: 0.4;
  cursor: default;
}

.meet-screen-view button.is-on {
  background: #d97706;
}

.meet-screen-level {
  font-variant-numeric: tabular-nums;
  font-size: 12px !important;
}

/* Zoomed in: drag the picture to move around it. */
.meet-tile-screen.is-zoomed .meet-screen-video {
  cursor: grab;
}

/* Maximize (grow) button for the shared screen: 10px from top, 10px from left. */
.meet-screen-grow {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
}

.meet-screen-grow.hidden {
  display: none;
}

.meet-screen-grow:hover {
  background: rgba(0, 0, 0, 0.82);
}
