/* ==========================================================================
   FIGMA MULTIPLAYER CURSOR SWARM & SCROLL CONSTRUCTION SYSTEM
   Inspired by Joel Califa's Swarm & Swarm Rebuild
   - Minimalist, authentic Figma cursors with collaborator name tags
   - Fully responsive across desktop, tablet, and mobile screens
   - Active during scroll; extra cursors smoothly disappear when idle
   - Strict layout isolation: zero transform interference on portrait/cards
   ========================================================================== */

/* Fullscreen Isolated Overlay Layer */
#swarm-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9950;
  overflow: hidden;
  contain: layout style paint;
}

/* Individual Multiplayer Cursor Agent */
.swarm-agent {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  user-select: none;
  will-change: transform;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.swarm-agent.visible {
  opacity: 1;
}

.swarm-cursor-icon-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 2px 7px rgba(0, 0, 0, 0.65));
  display: flex;
  align-items: center;
  justify-content: center;
}

.swarm-cursor-svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* Figma Collaborator Pill Tag — Hidden (no name over cursor) */
.swarm-name-pill {
  display: none !important;
}

/* Option (Alt) Duplicate Badge */
.swarm-alt-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-block;
  padding: 1px 4px;
  font-size: 9px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 2px;
  color: #FFFFFF;
  pointer-events: none;
}

/* Figma Selection Drag Frame */
.swarm-selection-frame {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border: 2px solid var(--swarm-active-color, #0D99FF);
  background-color: rgba(13, 153, 255, 0.05);
  border-radius: 4px;
  z-index: 10;
  box-shadow: 0 0 20px rgba(13, 153, 255, 0.35);
  transition: opacity 0.28s ease;
  max-width: calc(100vw - 16px);
  overflow: visible;
}

.swarm-selection-badge {
  position: absolute;
  top: -21px;
  left: -2px;
  background: var(--swarm-active-color, #0D99FF);
  color: #FFFFFF;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px 3px 0 0;
  white-space: nowrap;
}

/* Wireframe Drag Marquee Box */
.swarm-marquee-box {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  border: 1.5px dashed var(--swarm-active-color, #0D99FF);
  background-color: rgba(13, 153, 255, 0.08);
  border-radius: 4px;
  z-index: 1;
  box-shadow: 0 0 15px rgba(13, 153, 255, 0.2);
  transition: opacity 0.35s ease;
  animation: swarmMarqueeDash 1.8s linear infinite;
  max-width: calc(100vw - 16px);
  overflow: visible;
}

@keyframes swarmMarqueeDash {
  0% {
    stroke-dashoffset: 0;
  }

  100% {
    stroke-dashoffset: 20;
  }
}

/* Figma Corner Resize Handles */
.swarm-corner-handle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #FFFFFF;
  border: 1.5px solid var(--swarm-active-color, #0D99FF);
  border-radius: 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.swarm-handle-tl {
  top: -3px;
  left: -3px;
}

.swarm-handle-tr {
  top: -3px;
  right: -3px;
}

.swarm-handle-bl {
  bottom: -3px;
  left: -3px;
}

.swarm-handle-br {
  bottom: -3px;
  right: -3px;
}

/* Figma Live Dimensions Badge */
.swarm-dimension-badge {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 15, 15, 0.94);
  color: #FFFFFF;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

/* Figma Ruler Alignment Guide Lines */
.swarm-guide-line {
  position: absolute;
  pointer-events: none;
  background-color: #F24822;
  box-shadow: 0 0 8px rgba(242, 72, 34, 0.65);
  z-index: 2;
  opacity: 1;
  transition: opacity 0.35s ease;
  max-width: 100vw;
}

.swarm-guide-line.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

.swarm-guide-line.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.swarm-guide-line.segment {
  position: absolute;
}

/* Red Measurement Distance / Coordinate Tag */
.swarm-guide-badge {
  position: absolute;
  background: #F24822;
  color: #FFFFFF;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 1px 6px;
  border-radius: 2.5px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  z-index: 3;
}

/* Typewriter Characters & Live Caret */
.swarm-char {
  display: inline;
  transition: opacity 0.12s ease;
}

.swarm-caret {
  display: inline-block;
  width: 2.5px;
  height: 1.1em;
  background-color: var(--swarm-active-color, #F24E1E);
  vertical-align: -0.15em;
  margin-left: 2px;
  animation: swarmCaretBlink 0.65s step-end infinite;
  box-shadow: 0 0 8px var(--swarm-active-color, #F24E1E);
}

@keyframes swarmCaretBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

/* ==========================================================================
   TARGET ELEMENT REVEAL STATES
   Physical drag-and-drop feeling for cards & components!
   Strict guarantee: #hero-portrait-stage is preserved with zero displacement.
   ========================================================================== */

#hero-portrait-stage {
  opacity: 1 !important;
  filter: none !important;
}

.swarm-pending {
  opacity: 0.22 !important;
  filter: grayscale(0.8) blur(0.5px) !important;
  transform: translate3d(0, 35px, 0) scale(0.97) !important;
  will-change: transform, opacity, box-shadow;
}

.swarm-dragging {
  will-change: transform, opacity, box-shadow;
  z-index: 15 !important;
}

.swarm-building {
  opacity: 0.9 !important;
  filter: none !important;
}

.swarm-built {
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

/* ==========================================================================
   RESPONSIVE SCALING BREAKPOINTS
   Ensures smooth performance and crisp ergonomics on tablets and mobile phones
   ========================================================================== */

/* Tablets & Small Laptops (600px - 900px) */
@media (max-width: 900px) {
  .swarm-cursor-icon-wrap {
    width: 20px;
    height: 20px;
  }


  .swarm-cursor-svg {
    width: 19px;
    height: 19px;
  }

  .swarm-name-pill {
    margin-left: 11px;
    padding: 1.5px 5.5px;
    font-size: 9px;
  }

  .swarm-dimension-badge {
    font-size: 9px;
    bottom: -20px;
  }

  .swarm-guide-badge {
    font-size: 8.5px;
    padding: 1px 5px;
  }
}

/* Mobile Phones (< 600px) */
@media (max-width: 600px) {
  .swarm-cursor-icon-wrap {
    width: 18px;
    height: 18px;
  }

  .swarm-cursor-svg {
    width: 16px;
    height: 16px;
  }

  .swarm-name-pill {
    margin-left: 8px;
    padding: 1px 4.5px;
    font-size: 8px;
    border-radius: 2px;
    letter-spacing: 0.2px;
  }

  .swarm-alt-badge {
    font-size: 7.5px;
    padding: 0 3px;
  }

  .swarm-dimension-badge {
    font-size: 8px;
    padding: 1px 4px;
    bottom: -18px;
  }

  .swarm-corner-handle {
    width: 4.5px;
    height: 4.5px;
  }

  .swarm-guide-badge {
    font-size: 8px;
    padding: 1px 4px;
  }
}

/* Small Mobile Screens (< 400px) */
@media (max-width: 400px) {
  .swarm-cursor-icon-wrap {
    width: 16px;
    height: 16px;
  }

  .swarm-cursor-svg {
    width: 14px;
    height: 14px;
  }

  .swarm-name-pill {
    margin-left: 6px;
    padding: 0.5px 3.5px;
    font-size: 7.5px;
  }
}

/* Motion Sensitivity Accessibility */
@media (prefers-reduced-motion: reduce) {
  #swarm-overlay {
    display: none !important;
  }

  .swarm-pending,
  .swarm-building,
  .swarm-built {
    opacity: 1 !important;
    filter: none !important;
  }
}