/* Speaker Selection Wheel */
.storyframe-speaker-wheel {
  position: fixed;
  z-index: 100002;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: sf-scale-in var(--sf-transition-slow) var(--sf-ease-spring);
}

/* Wheel items */
.speaker-wheel-item {
  position: absolute;
  width: 100px;
  height: 110px;
  left: -50px;
  top: -55px;
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: all var(--sf-transition-base) var(--sf-ease-out);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.speaker-wheel-item:hover {
  transform: translate(var(--hover-x, 0), var(--hover-y, 0)) scale(1.12);
  z-index: 10;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.6));
}

.speaker-wheel-item img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 4px solid rgba(94, 129, 172, 0.7);
  object-fit: cover;
  object-position: top center;
  background: linear-gradient(135deg, rgba(30, 35, 45, 0.9), rgba(20, 25, 35, 0.9));
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.1);
  transition: all var(--sf-transition-base);
}

.speaker-wheel-item.active {
  z-index: 50 !important;
  filter: drop-shadow(0 0 16px rgba(235, 203, 139, 0.6)) drop-shadow(0 6px 20px rgba(0, 0, 0, 0.6)) !important;
}

.speaker-wheel-item.active > * {
  transform: scale(1.12);
}

.speaker-wheel-item.active::after {
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #ebcb8b, #d4af69);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: rgba(30, 35, 45, 1);
  font-weight: bold;
  box-shadow:
    0 0 0 2px rgba(30, 35, 45, 0.9),
    0 0 12px rgba(235, 203, 139, 0.8);
  animation: badge-pop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 10;
}

.speaker-wheel-item.active img {
  border-color: #ebcb8b !important;
  border-width: 4px !important;
  box-shadow:
    0 0 0 2px rgba(235, 203, 139, 0.3),
    0 0 20px rgba(235, 203, 139, 0.5),
    inset 0 1px 4px rgba(255, 255, 255, 0.15) !important;
}

.speaker-wheel-item.active .speaker-label {
  border-color: rgba(235, 203, 139, 0.6) !important;
  color: #ebcb8b !important;
  font-weight: 800 !important;
  text-shadow:
    0 0 4px rgba(235, 203, 139, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.8) !important;
}

@keyframes badge-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.speaker-wheel-item:hover img {
  border-color: rgba(94, 129, 172, 1);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.3),
    0 0 28px rgba(94, 129, 172, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Prevent hover from overriding active state */
.speaker-wheel-item.active:hover {
  filter: drop-shadow(0 0 20px rgba(235, 203, 139, 0.8)) drop-shadow(0 8px 24px rgba(0, 0, 0, 0.7)) !important;
}

.speaker-wheel-item.active:hover > * {
  transform: scale(1.15);
}

.speaker-wheel-item.active:hover img {
  border-color: #ebcb8b !important;
  border-width: 5px !important;
}

.speaker-wheel-item .speaker-label {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-align: center;
  background: linear-gradient(135deg, rgba(30, 35, 45, 0.98), rgba(20, 25, 35, 0.98));
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(94, 129, 172, 0.4);
  white-space: normal;
  max-width: 200px;
  min-width: 80px;
  line-height: 1.2;
  word-wrap: break-word;
  word-break: break-word;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.speaker-wheel-item:hover .speaker-label {
  border-color: rgba(94, 129, 172, 0.6);
  background: linear-gradient(135deg, rgba(40, 45, 60, 0.98), rgba(30, 35, 50, 0.98));
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Center clear button */
.speaker-wheel-center {
  position: absolute;
  width: 70px;
  height: 70px;
  left: -35px;
  top: -35px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(191, 97, 106, 0.95), rgba(191, 97, 106, 0.75));
  border: 4px solid rgba(191, 97, 106, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
  transition: all var(--sf-transition-base);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
  overflow: hidden;
  z-index: 100;
}

/* Split button layout */
.speaker-wheel-center.split-button {
  flex-direction: row;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.speaker-wheel-center.split-button .center-half {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--sf-transition-base);
  position: relative;
}

.speaker-wheel-center.split-button .back-half {
  background: linear-gradient(135deg, rgba(94, 129, 172, 0.95), rgba(94, 129, 172, 0.75));
  border: 4px solid rgba(94, 129, 172, 0.6);
  border-radius: 50% 0 0 50%;
  border-right: 2px solid rgba(94, 129, 172, 0.6);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.speaker-wheel-center.split-button .clear-half {
  background: linear-gradient(135deg, rgba(191, 97, 106, 0.95), rgba(191, 97, 106, 0.75));
  border: 4px solid rgba(191, 97, 106, 0.6);
  border-radius: 0 50% 50% 0;
  border-left: 2px solid rgba(191, 97, 106, 0.6);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.speaker-wheel-center.split-button .back-half:hover {
  background: linear-gradient(135deg, rgba(94, 129, 172, 1), rgba(94, 129, 172, 0.85));
  border-color: rgba(94, 129, 172, 0.8);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.6),
    0 0 24px rgba(94, 129, 172, 0.7),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
  z-index: 10;
}

.speaker-wheel-center.split-button .clear-half:hover {
  background: linear-gradient(135deg, rgba(191, 97, 106, 1), rgba(191, 97, 106, 0.85));
  border-color: rgba(191, 97, 106, 0.8);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.6),
    0 0 24px rgba(191, 97, 106, 0.6),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
  z-index: 10;
}

.speaker-wheel-center:hover {
  transform: scale(1.08);
  background: linear-gradient(135deg, rgba(191, 97, 106, 1), rgba(191, 97, 106, 0.85));
  border-color: rgba(191, 97, 106, 0.8);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.6),
    0 0 24px rgba(191, 97, 106, 0.6),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.6));
}

.speaker-wheel-center:active {
  transform: scale(1.02);
}

.speaker-wheel-center i {
  font-size: 24px;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.speaker-wheel-center .center-label {
  font-size: 10px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Scene items styling */
.speaker-wheel-item.scene .scene-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(163, 190, 140, 0.5), rgba(143, 170, 120, 0.4)),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent);
  border: 3px solid rgba(163, 190, 140, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.4),
    0 4px 16px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  transition: all var(--sf-transition-base);
  position: relative;
  overflow: hidden;
}

.speaker-wheel-item.scene .scene-icon-wrapper::before {
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 8px,
    rgba(163, 190, 140, 0.08) 8px,
    rgba(163, 190, 140, 0.08) 16px
  );
  pointer-events: none;
  border-radius: 10px;
}

.speaker-wheel-item.scene .scene-icon-wrapper::after {
  top: 2px;
  left: 2px;
  right: 2px;
  height: 30%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.12), transparent);
  border-radius: 8px 8px 0 0;
  pointer-events: none;
}

.speaker-wheel-item.scene:hover .scene-icon-wrapper {
  border-color: rgba(163, 190, 140, 0.9);
  background:
    linear-gradient(135deg, rgba(163, 190, 140, 0.35), rgba(143, 170, 120, 0.3)),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.6),
    0 0 32px rgba(163, 190, 140, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transform: scale(1.05) translateY(-2px);
}

.speaker-wheel-item.scene .scene-icon {
  font-size: 32px;
  color: rgba(163, 190, 140, 1);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.7));
  z-index: 1;
  position: relative;
}

/* Back button styling */
.speaker-wheel-center.back-button {
  background: linear-gradient(135deg, rgba(94, 129, 172, 0.95), rgba(94, 129, 172, 0.75));
  border-color: rgba(94, 129, 172, 0.6);
}

.speaker-wheel-center.back-button:hover {
  background: linear-gradient(135deg, rgba(94, 129, 172, 1), rgba(94, 129, 172, 0.85));
  border-color: rgba(94, 129, 172, 0.8);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.6),
    0 0 24px rgba(94, 129, 172, 0.7),
    0 0 0 2px rgba(0, 0, 0, 0.3),
    inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

/* Handle many speakers - scale down if needed */
@media (max-height: 800px) {
  .storyframe-speaker-wheel {
    transform: translate(-50%, -50%) scale(0.85);
  }
}

/* Hidden name badge for speaker wheel */
.speaker-wheel-hidden-badge {
  position: absolute !important;
  top: 56px !important;
  left: auto !important;
  right: 14px !important;
  bottom: auto !important;
  font-size: 0.65em;
  background: rgba(0, 0, 0, 0.85);
  padding: 3px 5px;
  border-radius: 3px;
  color: #fff;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.speaker-wheel-item.name-hidden .speaker-label {
  font-style: italic;
  opacity: 0.8;
}
