/* ── collab.css — real-time collab overlay for create.tokylabs.com ─── */

/* Ghost cursors (Miro-style, per-user color) */
#collab-cursor-layer {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0; /* replaces inset:0 for older browsers */
  pointer-events: none;
  overflow: hidden;
  z-index: 600;
}

.ghost-cursor {
  --cursor-color: #e53e3e;
  position: absolute;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transform: translate(-1px, -1px);
  z-index: 600;
  transition: left 60ms linear, top 60ms linear;
  will-change: left, top;
}

.ghost-cursor__pointer {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

.ghost-cursor__label {
  background: var(--cursor-color);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 2px;
  margin-left: 8px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Own-color badge (top-right pill) */
#collab-own-badge {
  --cursor-color: #4f6ef7;
  position: fixed;
  top: calc(var(--header-height, 2.2rem) + 8px);
  right: 10px;
  background: var(--cursor-color);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 700;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: opacity .2s;
}
#collab-own-badge.collab-hidden { display: none; }
#collab-own-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,.85);
  border-radius: 50%;
  flex-shrink: 0;
}
#collab-leave-btn {
  background: rgba(0,0,0,.25);
  border: none;
  color: #fff;
  border-radius: 3px;
  width: 20px;
  height: 20px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: unset;
  margin: 0 0 0 4px;
  font-weight: bold;
  transition: background .15s;
}
#collab-leave-btn:hover { background: rgba(0,0,0,.5); }

/* Collab toolbar button — injected into existing .btnBox2 */
.collab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: .85;
  transition: opacity .15s;
  margin-right: 4px;
  position: relative;
}
.collab-btn:hover { opacity: 1; }

/* The button reuses .btn-gamepad, whose rule sets the glyph to 44px (flush
   against the bar). Match the standard toolbar icons instead — same size as the
   open/save icons (.btn-file .item .fa): calc(--btn-bar-size * 0.6) = 24px,
   white, centred — so it has consistent size and top/bottom margin. */
#collab-toolbar-btn .fa { font-size: calc(var(--btn-bar-size) * 0.6); }

.collab-btn svg {
  width: calc(var(--header-height, 2.2rem) * 0.72);
  height: calc(var(--header-height, 2.2rem) * 0.5);
}

/* Colored dot on the collab button when connected */
.collab-btn .collab-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aaa;
  border: 1.5px solid #fff;
}
.collab-btn.collab-connected .collab-dot { background: #48bb78; }

/* Collab nickname modal (lightweight, doesn't block editor) */
#collab-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
#collab-modal.collab-hidden { display: none; }

.collab-modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.collab-modal-box h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1a202c;
}
.collab-modal-box input {
  padding: .55rem .75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
}
.collab-modal-box input:focus {
  outline: none;
  border-color: #4f6ef7;
  box-shadow: 0 0 0 3px rgba(79,110,247,.2);
}
.collab-modal-box label {
  font-size: .82rem;
  color: #4a5568;
  margin-bottom: -.4rem;
}
.collab-modal-box button {
  padding: .65rem;
  background: #4f6ef7;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  margin-top: .3rem;
}
.collab-modal-box button:hover { background: #3a56d4; }
.collab-modal-error {
  background: #fed7d7;
  color: #742a2a;
  padding: .4rem .7rem;
  border-radius: 5px;
  font-size: .82rem;
  display: none;
}
.collab-modal-error.collab-visible { display: block; }

/* Modal close (×) button in top-right corner */
.collab-modal-x {
  position: absolute;
  top: .6rem;
  right: .6rem;
  background: none !important;
  border: none;
  color: #718096 !important;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  min-height: unset;
  margin: 0;
  border-radius: 4px;
}
.collab-modal-x:hover { background: #edf2f7 !important; color: #1a202c !important; }

.collab-modal-box { position: relative; }

/* Connected status text */
.collab-status-info {
  font-size: .88rem;
  color: #4a5568;
  margin: 0;
  word-break: break-all;
}

/* Leave / danger button */
.collab-btn-danger {
  background: #e53e3e !important;
}
.collab-btn-danger:hover { background: #c53030 !important; }

.collab-room-link {
  font-size: .78rem;
  color: #718096;
  word-break: break-all;
}
.collab-room-link a {
  color: #4f6ef7;
  text-decoration: none;
}
.collab-room-link a:hover { text-decoration: underline; }

/* Click effects — dot pulse + expanding ring */
@keyframes collab-click-dot {
  0%   { transform: translate(-50%, -50%) scale(1);    opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(2.2);  opacity: 0; }
}

@keyframes collab-click-ring {
  0%   { transform: translate(-50%, -50%) scale(0.2);  opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1);    opacity: 0; }
}

.collab-click-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ring-color, #e53e3e);
  pointer-events: none;
  animation: collab-click-dot 0.3s ease-out forwards;
  z-index: 602;
}

.collab-click-ring {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--ring-color, #e53e3e);
  pointer-events: none;
  animation: collab-click-ring 0.5s ease-out forwards;
  z-index: 601;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ghost-cursor { transition: none; }
  .collab-click-ring, .collab-click-dot { animation-duration: 0.01ms; }
}
