/* ==========================================================================
   Unfair Advantage — Spatial 3D Hub Stage & Analytic-Spring Dock Case
   ========================================================================== */

.instrument .stage-canvas {
  position: relative;
  isolation: isolate;
  perspective: 1180px;
  perspective-origin: 50% 44%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-height: 390px;
  padding: clamp(28px, 4.4vw, 64px) clamp(16px, 3vw, 48px);
  overflow: clip;
  background:
    radial-gradient(ellipse 68% 58% at 50% 42%, rgba(232, 17, 45, calc(0.06 + var(--active-ratio, 0.15) * 0.14)), transparent 68%),
    radial-gradient(ellipse 80% 70% at 50% 25%, rgba(44, 52, 72, 0.36) 0%, #0d1017 68%, #090b10 100%);
  transition: background 0.5s var(--sine);
}

/* Perspective Dot Floor Plane */
.stage-canvas::before {
  content: '';
  position: absolute;
  inset: -16% -14% -28%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(circle, rgba(164, 174, 196, 0.38) 1px, transparent 1.35px) 50% 50% / 22px 22px;
  opacity: 0.42;
  transform: rotateX(55deg) translateY(18%);
  mask-image: linear-gradient(transparent, #000 32%, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 88%, transparent);
}

.stage-canvas > .hub-window,
.stage-canvas > .hub-pill {
  grid-area: 1 / 1;
  min-width: 0;
  max-width: 100%;
  transform-origin: center;
  z-index: 1;
  background: transparent;
  box-shadow: none;
  border-color: transparent;
  backface-visibility: visible;
}

.stage-canvas > .hub-window.high-contrast {
  outline: 2px solid rgba(255, 255, 255, 0.55);
}

/* Continuous Enamel & Brushed Titanium Housing (Morphs Window <-> Pill) */
.dock-case {
  grid-area: 1 / 1;
  position: relative;
  place-self: center;
  max-width: 100%;
  pointer-events: none;
  transform-style: preserve-3d;
  border-radius: 26px;
  z-index: 0;
}

.dock-case i,
.dock-case b {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.dock-case i {
  transform: translateZ(-4px);
  background: #0c0e14;
  box-shadow:
    0 2px 0 #2b3140,
    0 5px 0 #181c26,
    0 9px 0 #07080c,
    0 26px 40px -12px rgba(0, 0, 0, 0.88),
    0 36px 70px -18px rgba(0, 0, 0, 0.78);
}

.dock-case b {
  background: linear-gradient(142deg, #1b202d 0%, #10131c 56%, #161a24 100%);
  border: 1px solid;
  border-color: rgba(255, 255, 255, 0.2) rgba(255, 255, 255, 0.09) rgba(255, 255, 255, 0.05) rgba(255, 255, 255, 0.13);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.hub-pill #hub-count {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  min-width: 26px;
  min-height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(180deg, #f31e38, #b60c22);
  box-shadow: inset 0 1px 0 rgba(255, 165, 175, 0.4), 0 0 14px rgba(232, 17, 45, 0.55);
}

.stage-canvas[data-hub-view='hub']:not([data-dock-running]) > .hub-pill,
.stage-canvas[data-hub-view='pill']:not([data-dock-running]) > .hub-window {
  visibility: hidden;
}

.stage-canvas > [inert] {
  pointer-events: none;
}

.stage-canvas:has(.hub-window[aria-hidden='true']) .hub-pill {
  cursor: pointer;
}

@media (min-width: 741px) and (prefers-reduced-motion: no-preference) {
  .stage-canvas > .hub-window {
    transform: rotateX(3.5deg) rotateY(-2deg);
  }
  .no-menu-motion .stage-canvas > .hub-window {
    transform: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .stage-canvas[data-dock-running] > .hub-window,
  .stage-canvas[data-dock-running] > .hub-pill {
    will-change: transform, opacity;
  }

  .hub-grid-enter .hub-card {
    animation: hub-card-seat 0.36s var(--ease) backwards;
    animation-delay: calc(min(var(--card-order, 0), 7) * 26ms);
  }

  .hub-grid-enter .hub-card::before {
    content: '';
    position: absolute;
    pointer-events: none;
    left: 14px;
    right: 14px;
    top: -1px;
    height: 1.5px;
    background: linear-gradient(90deg, transparent, var(--signal) 45%, #ffd6dc 52%, transparent);
    transform-origin: left;
    animation: edge-strike 0.34s var(--ease) calc(min(var(--card-order, 0), 6) * 22ms) both;
  }

  @keyframes hub-card-seat {
    from {
      opacity: 0;
      transform: translateY(10px) scale(0.985);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @keyframes edge-strike {
    0% { transform: scaleX(0); opacity: 0; }
    25% { opacity: 0.9; }
    100% { transform: scaleX(1); opacity: 0; }
  }

  @media (hover: hover) {
    .hub-card:hover {
      transform: translateY(-2px);
      box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 12px 24px -10px rgba(0, 0, 0, 0.85);
    }
    .hub-pill:not([inert]):hover img {
      transform: translateY(-1px) scale(1.04);
    }
    .hub-pill img {
      transition: transform 0.22s var(--ease);
    }
  }
}

@media (max-width: 740px) {
  .stage-canvas > .hub-window {
    transform: none;
  }
  .instrument .stage-canvas {
    min-height: 310px;
    padding: 24px 12px;
  }
}
