/*
 * View-cube widget
 *
 * The wrapper is intentionally a generous square so the cube can rotate
 * without clipping at any angle. The 3D scene + cube live in their own
 * stacking context (.scene) so the corner pins, which sit in a separate
 * .pins layer, never get sucked into the perspective transform.
 */

:root {
  /* Half-side of the cube in pixels — must equal half of .cube width/height. */
}

.wrapper {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 130px;
  height: 130px;
  z-index: 10;
  user-select: none;
  /* Allow corner pins to extend slightly past the wrapper without clipping. */
  overflow: visible;
}

.scene {
  position: absolute;
  inset: 0;
  perspective: 600px;
  perspective-origin: 50% 50%;
  /* The 3D scene must not clip its children when rotation pushes them out
     of the box for a frame. */
  overflow: visible;
}

.cube {
  position: absolute;
  /* Centred 80×80 cube — half-side = 40 px. */
  width: 80px;
  height: 80px;
  top: 50%;
  left: 50%;
  margin-top: -40px;
  margin-left: -40px;
  transform-style: preserve-3d;
  transform-origin: 50% 50% 0;
  transform: rotateX(-26deg) rotateY(-32deg);
  will-change: transform;
}

.face {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(248, 250, 252, 0.96),
    rgba(226, 232, 240, 0.92)
  );
  border: 1px solid rgba(100, 116, 139, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  /* Hide the back side of every face so rotated faces don't z-fight with
     the face behind them. */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: background 160ms ease, color 160ms ease;
}

.face:hover {
  background: linear-gradient(
    135deg,
    rgba(219, 234, 254, 0.98),
    rgba(191, 219, 254, 0.96)
  );
  color: #1d4ed8;
}

/* Each face is pushed out by half the cube side (40 px). */
.faceTop {
  transform: rotateX(90deg) translateZ(40px);
}
.faceFront {
  transform: translateZ(40px);
}
.faceBack {
  transform: rotateY(180deg) translateZ(40px);
}
.faceRight {
  transform: rotateY(90deg) translateZ(40px);
}
.faceLeft {
  transform: rotateY(-90deg) translateZ(40px);
}
.faceBottom {
  /* Real face now — backface-visibility hides it unless the camera looks up
     at the cube, instead of the previous opacity:0 hack which left a
     z-fighting ghost behind. */
  transform: rotateX(-90deg) translateZ(40px);
  background: linear-gradient(
    135deg,
    rgba(241, 245, 249, 0.92),
    rgba(203, 213, 225, 0.88)
  );
  cursor: default;
}

/*
 * Corner pins live in their own non-3D layer so they're not affected by
 * the cube's perspective transform. Higher z-index than .scene keeps them
 * crisp on top regardless of which cube face is currently in front.
 */
.pins {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fbbf24, #d97706);
  border: 1.5px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  pointer-events: auto;
  transition: transform 160ms ease, box-shadow 160ms ease;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.corner:hover {
  transform: scale(1.18);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
}

.cornerNW {
  top: 4px;
  left: 4px;
}
.cornerNE {
  top: 4px;
  right: 4px;
}
.cornerSW {
  bottom: 4px;
  left: 4px;
}
.cornerSE {
  bottom: 4px;
  right: 4px;
}

.label {
  position: absolute;
  bottom: -16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: #64748b;
  font-weight: 500;
  pointer-events: none;
}
