@font-face {
  font-family: "fontawesome-ep_webrtc";
  /* License: ../fonts/fontello/LICENSE.txt */
  src: url("../fonts/fontello/font/fontawesome-custom.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
}

/*
 * The "Failed to access camera/microphone" gritter notifications spawned by
 * showUserMediaError() are sticky and span the top of the editor. Without
 * this rule, the gritter's container/items intercept pointer events on the
 * editor underneath (Playwright's stability check fails with "subtree
 * intercepts pointer events"), making the pad unusable until the user
 * dismisses each toast. Pass clicks through everything except the close
 * button so the toast stays visible and dismissible without blocking
 * the editor.
 */
#gritter-container,
#gritter-container .gritter-item-wrapper,
#gritter-container .gritter-item,
#gritter-container .popup-content,
#gritter-container .gritter-content,
#gritter-container .gritter-title,
#gritter-container .gritter-image { pointer-events: none; }
#gritter-container .gritter-close { pointer-events: auto; }

#rtcbox {
  align-items: start;
  display: none;
  flex: 0 1 auto;
  flex-direction: column;
  justify-content: start;
  padding: 0;
  order: -1; /* on left side */
  box-sizing: border-box;
  background-color: transparent;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  overflow: auto;
  width: auto;
}

#rtcbox .video-container {
  flex: 0 0 auto;
  align-items: center;
  background-color: black;
  border: 1px solid black;
  border-left: 5px solid;
  box-sizing: content-box;
  overflow: hidden;
  position: relative;
}
#rtcbox .video-container:not(:first-child) {
  margin-top: 5px;
}
#rtcbox video {
  box-sizing: content-box;
  background-color: black;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

#rtcbox .video-container .interface-btn,
#rtcbox .video-container .user-name,
#rtcbox .video-container .resize-handle {
  --interface-text-color-rgb: 87, 98, 115; /* --dark-color */
  --interface-background-color-rgb: 242, 243, 244; /* --light-color */
  --interface-text-alpha: 0.6;
  --interface-background-alpha: 0.2;
  background-color: rgba(var(--interface-background-color-rgb),
                         var(--interface-background-alpha));
  color: rgba(var(--interface-text-color-rgb), var(--interface-text-alpha));
  transition: background-color .2s, color .2s;
}
#rtcbox .video-container:hover .interface-btn,
#rtcbox .video-container:hover .user-name,
#rtcbox .video-container:hover .resize-handle {
  --interface-text-alpha: 0.8;
  --interface-background-alpha: 0.7;
}
#rtcbox .video-container:hover .interface-btn:hover,
#rtcbox .video-container:hover .user-name:hover,
#rtcbox .video-container:hover .resize-handle:hover {
  --interface-text-alpha: 1.0;
  --interface-background-alpha: 1.0;
}
#rtcbox .video-container:hover .interface-btn:hover {
  filter: drop-shadow(0 0 2px rgba(var(--interface-text-color-rgb),
                                   var(--interface-text-alpha)));
}
#rtcbox .video-container .disallowed {
  display: none;
}

#rtcbox .interface-container {
  display: flex;
  min-width: min-content;
  position: absolute;
  bottom: 0px;
  left: 0px;
  padding: 5px;
  width: 100%;
  z-index: 2;
}
#rtcbox .interface-btn {
  flex: 0 0 auto;
  border-radius: 50%;
  padding: 5px;
  margin: 3px;
  cursor: pointer;
  width: 28px;
  height: 28px;
}

#rtcbox .interface-btn.audio-btn:before { content: '\e83d'; }
#rtcbox .interface-btn.audio-btn.muted:before { content: '\e83e'; }

#rtcbox .interface-btn.video-btn:before { content: '\e83b'; }
#rtcbox .interface-btn.video-btn.off:before { content: '\e83c'; }

#rtcbox .interface-btn.screenshare-btn:before {
  content: "\f108";
  font-family: "fontawesome-ep_webrtc";
}
#rtcbox .interface-btn.screenshare-btn.off:before { content: "\f109"; }

#rtcbox .interface-btn.enlarge-btn:before { content: '\e840'; }
#rtcbox .interface-btn.enlarge-btn.large:before { content: '\e83f'; }

#rtcbox .video-container .interface-container .interface-btn.error-btn {
  --interface-background-alpha: 1.0;
  --interface-text-alpha: 1.0;
  --interface-text-color-rgb: 255, 0, 0;
}
#rtcbox .video-container .interface-container .interface-btn.error-btn:before {
  content: "\f071";
  font-family: "fontawesome-ep_webrtc";
}

#rtcbox .video-container .resize-handle {
  --handle-size: 15px;
  background-color: transparent;
  bottom: 0;
  cursor: nwse-resize;
  font-family: "fontawesome-ep_webrtc";
  font-size: var(--handle-size);
  line-height: var(--handle-size);
  position: absolute;
  right: 0;
  text-shadow: 1px 1px 0 rgba(var(--interface-background-color-rgb),
                              var(--interface-background-alpha));
  touch-action: none;
  user-select: none;
  z-index: 3;
}
#rtcbox .video-container .resize-handle:before {
  content: "\e83f";
}

#rtcbox .video-container .user-name {
  /*
   * Use absolute positioning to remove the name from the normal document flow.
   * This prevents a long name from making the .video-container div overly wide.
   */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-weight: bold;
  height: min-content;
  overflow: hidden;
  padding: 0px 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
  z-index: 1;
}
#rtcbox .video-container.local-user {
  order: -1; /* first position */
}

@media (max-width: 800px) {
  #editorcontainerbox {
    flex-direction: column;
  }
  #rtcbox {
    flex-direction: row;
    order: 2;
  }
  #rtcbox .video-container:not(:first-child) {
    margin-top: 0;
    margin-left: 5px;
  }
}

/*
 * In-pad history mode (timeslider) renders the read-only pad inside an
 * absolutely-positioned iframe — core's #history-frame-mount, inset:0,
 * z-index:4 — that overlays #editorcontainerbox. #rtcbox is a normal
 * in-flow child of that same container, so without this it paints
 * *underneath* the history iframe and the live call appears to vanish the
 * moment you start scrubbing history. The call never actually drops (the
 * pad page stays alive in history mode); we just lift the video column
 * above the overlay so it stays visible and usable while a reviewer scrubs
 * through revisions and gives play-by-play commentary on the same call.
 */
body.history-mode #rtcbox {
  position: relative;
  z-index: 5;
}
