/* ==========================================================================
   MULTIPLAYER CURSOR DESIGN-TOOL SWARM REBUILD (NATIVE SITE INTRO ENGINE)
   ========================================================================== */

/* 1. Blank canvas hold while React mounts (~80ms) so zero unbuilt flash occurs */
html.ds-initializing body > #root {
  opacity: 0 !important;
}

/* Disable native smooth-scroll fighting during 60fps programmatic auto-scroll tour */
html.ds-active {
  scroll-behavior: auto !important;
}

/* 2. Disable Framer entrance/whileInView offsets while Swarm measures & builds into exact boxes */
html.ds-active .hero-char,
html.ds-active .creativity-char,
html.ds-active .hero-portrait-enter,
html.ds-active .hero-intro,
html.ds-active .hero-side,
html.ds-active .brand-section,
html.ds-active .section-heading,
html.ds-active .portfolio-toolbar,
html.ds-active .project-card,
html.ds-active .creativity-stage,
html.ds-active .creativity-figure,
html.ds-active .recognition-intro,
html.ds-active .recognition-row,
html.ds-active .about-lead,
html.ds-active .education-panel,
html.ds-active .process-panel > div,
html.ds-active .process-row,
html.ds-active .quote-panel,
html.ds-active .experience-row,
html.ds-active .awards-panel,
html.ds-active .contact-intro,
html.ds-active .contact-links,
html.ds-active .contact-grid > div {
  transform: none !important;
}

/* Ensure Framer whileInView wrapper containers do not hide built children */
html.ds-active .section-heading,
html.ds-active .recognition-intro,
html.ds-active .about-lead,
html.ds-active .process-panel > div,
html.ds-active .contact-intro,
html.ds-active .contact-links,
html.ds-active .contact-grid > div,
html.ds-active .creativity-figure,
html.ds-active [data-ds-box="unbuilt"],
html.ds-active [data-ds-built="1"] {
  opacity: 1 !important;
}

/* 3. Unbuilt container boxes (hide background/border/shadow while allowing built children or empty box reveal) */
html.ds-active [data-ds-box="unbuilt"] {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.ds-active [data-ds-box="unbuilt"]::before,
html.ds-active [data-ds-box="unbuilt"]::after {
  opacity: 0 !important;
}

/* 4. Unbuilt leaf elements (text, media, buttons, icons) */
html.ds-active [data-ds-leaf="unbuilt"] {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Smooth fade-in when a box or leaf is built */
html.ds-active [data-ds-built="1"] {
  transition: opacity 0.30s ease, background-color 0.32s ease, border-color 0.32s ease, box-shadow 0.32s ease;
}

/* Keep user's own Glowing Dot cursor above everything */
#liquid-glass-cursor {
  z-index: 100020 !important;
}

/* 5. Isolated Design-Tool Overlay Root */
#ds-root {
  position: fixed;
  inset: 0;
  z-index: 99900;
  pointer-events: none;
  overflow: hidden;
  user-select: none;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, sans-serif;
  opacity: 1;
  transition: opacity 0.58s cubic-bezier(0.22, 1, 0.36, 1);
}

#ds-root.is-exiting {
  opacity: 0;
  pointer-events: none !important;
}

/* 6. Figma Top & Left Rulers (20px) */
.ds-ruler-corner {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  background: #14171f;
  border-right: 1px solid rgba(255, 255, 255, 0.11);
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  z-index: 99905;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.38);
  font-size: 8px;
  transform: translate3d(-22px, -22px, 0);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.ds-ruler-top {
  position: fixed;
  top: 0;
  left: 20px;
  right: 0;
  height: 20px;
  background: rgba(20, 23, 31, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  z-index: 99904;
  transform: translateY(-22px);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.ds-ruler-left {
  position: fixed;
  top: 20px;
  left: 0;
  bottom: 0;
  width: 20px;
  background: rgba(20, 23, 31, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px solid rgba(255, 255, 255, 0.11);
  z-index: 99904;
  transform: translateX(-22px);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

#ds-root.rulers-in .ds-ruler-corner,
#ds-root.rulers-in .ds-ruler-top,
#ds-root.rulers-in .ds-ruler-left {
  transform: translate3d(0, 0, 0);
}

.ds-ruler-top canvas,
.ds-ruler-left canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* 7. Gizmo & Cursor Stage Layers */
#ds-guides-layer,
#ds-gizmos-layer,
#ds-cursors-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

#ds-guides-layer { z-index: 99901; }
#ds-gizmos-layer { z-index: 99902; }
#ds-cursors-layer { z-index: 99906; }

/* Red Ruler Guides */
.ds-guide {
  position: absolute;
  background: rgba(242, 72, 34, 0.68);
  pointer-events: none;
  transition: opacity 0.35s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.ds-guide.is-v {
  top: 20px;
  bottom: 0;
  width: 1px;
}

.ds-guide.is-h {
  left: 20px;
  right: 0;
  height: 1px;
}

.ds-guide.is-snapping {
  background: #ff5630;
  box-shadow: 0 0 8px rgba(242, 72, 34, 0.85);
}

.ds-guide-tag {
  position: absolute;
  background: #F24822;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 2px;
  white-space: nowrap;
}

.ds-guide.is-v .ds-guide-tag {
  top: 6px;
  left: 4px;
}

.ds-guide.is-h .ds-guide-tag {
  left: 6px;
  top: 4px;
}

/* Figma Blue Selection / Drag Wireframe Box */
.ds-sel-box {
  position: absolute;
  border: 1.5px solid #0D99FF;
  box-sizing: border-box;
  pointer-events: none;
}

.ds-sel-box.is-placeholder {
  background: rgba(13, 153, 255, 0.055);
}

.ds-sel-box.is-media-ph {
  background: linear-gradient(135deg, rgba(130, 148, 175, 0.16) 0%, rgba(68, 82, 108, 0.12) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ds-media-icon {
  width: clamp(20px, 28%, 42px);
  height: clamp(20px, 28%, 42px);
  opacity: 0.62;
}

/* 4 White Corner Resize Handles */
.ds-handle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #ffffff;
  border: 1.5px solid #0D99FF;
  box-sizing: border-box;
}

.ds-handle.tl { top: -3.5px; left: -3.5px; }
.ds-handle.tr { top: -3.5px; right: -3.5px; }
.ds-handle.bl { bottom: -3.5px; left: -3.5px; }
.ds-handle.br { bottom: -3.5px; right: -3.5px; }

/* Live Blue W × H Size Pill Badge */
.ds-size-pill {
  position: absolute;
  left: 50%;
  top: calc(100% + 5px);
  transform: translateX(-50%);
  background: #0D99FF;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.15;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Live Typing Text Frame & Blinking Caret */
.ds-type-box {
  position: absolute;
  border: 1px solid rgba(13, 153, 255, 0.82);
  background: rgba(13, 153, 255, 0.03);
  box-sizing: border-box;
  pointer-events: none;
  overflow: visible;
}

.ds-type-content {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.ds-caret {
  display: inline-block;
  width: 2px;
  height: 0.96em;
  background: #0D99FF;
  margin-left: 1px;
  vertical-align: -0.08em;
  box-shadow: 0 0 6px rgba(13, 153, 255, 0.8);
  animation: dsCaretBlink 0.52s steps(1) infinite;
}

@keyframes dsCaretBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* Option-Drag Duplicate Ghost & Red Smart-Spacing Badges */
.ds-dup-master {
  position: absolute;
  border: 1px solid rgba(13, 153, 255, 0.72);
  box-sizing: border-box;
}

.ds-dup-ghost {
  position: absolute;
  border: 1.5px solid #F24822;
  background: rgba(242, 72, 34, 0.07);
  box-sizing: border-box;
}

.ds-dup-line {
  position: absolute;
  background: #F24822;
}

.ds-gap-pill {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #F24822;
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* Pen Tool SVG Overlay */
.ds-pen-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Multiplayer Cursor Agent */
.ds-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  will-change: transform;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.52));
  pointer-events: none;
}

.ds-cursor svg {
  width: 28px;
  height: 28px;
  overflow: visible;
  transition: transform 0.09s ease;
}

.ds-cursor.is-down svg {
  transform: scale(0.86);
}

/* Click Pulse Ring */
.ds-click-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  border-radius: 50%;
  border: 1.5px solid #0D99FF;
  pointer-events: none;
  animation: dsClickPulse 0.36s ease-out forwards;
}

@keyframes dsClickPulse {
  0% { transform: scale(0.35); opacity: 0.95; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* 8. Bottom Floating Dark Control Pill Dock (Matches Swarm Rebuild Toolbar) */
#ds-toolbar {
  position: fixed;
  left: 50%;
  bottom: clamp(14px, 2.5vh, 24px);
  transform: translateX(-50%);
  z-index: 99910;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 38px;
  padding: 0 13px;
  max-width: calc(100vw - 24px);
  border-radius: 999px;
  background: rgba(22, 24, 30, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.62), 0 2px 8px rgba(0, 0, 0, 0.4);
  color: #e6e9ef;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.ds-tb-avatars {
  display: flex;
  align-items: center;
  padding-left: 3px;
}

.ds-tb-av {
  width: 17px;
  height: 17px;
  margin-left: -4px;
  border-radius: 50%;
  border: 1.5px solid #16181e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 8.5px;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
}

.ds-tb-av:first-child {
  margin-left: 0;
}

.ds-tb-stat {
  color: rgba(230, 233, 239, 0.72);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.ds-tb-stat strong {
  color: #ffffff;
  font-weight: 700;
}

.ds-tb-track {
  width: clamp(48px, 8vw, 84px);
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  position: relative;
  flex-shrink: 0;
}

.ds-tb-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: #0D99FF;
}

.ds-tb-dot {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 6px rgba(13, 153, 255, 0.9);
  transform: translate(-50%, -50%);
}

.ds-tb-btn {
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: rgba(230, 233, 239, 0.85);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.ds-tb-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

.ds-tb-btn.is-active {
  background: rgba(13, 153, 255, 0.24);
  color: #66c2ff;
}

.ds-tb-close {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
}

@media (max-width: 640px) {
  #ds-toolbar {
    gap: 7px;
    height: 34px;
    padding: 0 10px;
    font-size: 10px;
  }
  .ds-tb-stat.hide-mob {
    display: none;
  }
  .ds-tb-track {
    width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #ds-root {
    display: none !important;
  }
}
