/**
 * 🎯 Radial Menu Styles
 * Interactive circular menu with drag-to-select functionality
 */

/* Menu Toggle Button */
#radialMenuBtn {
  position: fixed;
  top: 10px;
  left: 10px; /* Primary navigation - profile button hidden */
  padding: 10px 15px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-weight: bold;
  font-size: 1em;
  cursor: pointer;
  z-index: 10002; /* Higher than notifications (10001) */
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  pointer-events: auto; /* Ensure clickable */
}

#radialMenuBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
}

/* Emote Toggle Button */
#emoteToggleBtn {
  position: fixed;
  top: 55px; /* Below radial menu button */
  left: 10px;
  padding: 10px 15px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-weight: bold;
  font-size: 1.2em;
  cursor: pointer;
  z-index: 10002; /* Higher than notifications (10001) */
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  pointer-events: auto; /* Ensure clickable */
}

#emoteToggleBtn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.5);
}

/* Radial Menu Overlay */
.radial-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.radial-menu-overlay.active {
  display: flex;
  opacity: 1;
}

/* Menu Container */
.radial-menu-container {
  position: relative;
  width: 500px;
  height: 500px;
  user-select: none;
  -webkit-user-select: none;
}

/* Center Circle */
.radial-menu-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 40px rgba(102, 126, 234, 0.6),
              0 0 0 4px rgba(255, 255, 255, 0.1);
  z-index: 10;
  cursor: grab;
  transition: all 0.3s ease;
}

.radial-menu-center.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 12px 50px rgba(102, 126, 234, 0.8),
              0 0 0 6px rgba(255, 255, 255, 0.2);
}

.center-icon {
  font-size: 2.5em;
  margin-bottom: 5px;
}

.center-label {
  font-size: 0.9em;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Menu Segments Container */
.radial-menu-segments {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5; /* Below center circle */
}

/* Individual Segments */
.radial-segment {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  opacity: 0; /* Start hidden to prevent flash */
}

/* Position segments in a circle using transform */
.radial-segment[data-angle="0"] {
  transform: translate(0, -200px);
}

.radial-segment[data-angle="45"] {
  transform: translate(141px, -141px);
}

.radial-segment[data-angle="90"] {
  transform: translate(200px, 0);
}

.radial-segment[data-angle="135"] {
  transform: translate(141px, 141px);
}

.radial-segment[data-angle="180"] {
  transform: translate(0, 200px);
}

.radial-segment[data-angle="225"] {
  transform: translate(-141px, 141px);
}

.radial-segment[data-angle="270"] {
  transform: translate(-200px, 0);
}

.radial-segment[data-angle="315"] {
  transform: translate(-141px, -141px);
}

/* Segment Content */
.segment-content {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transform: scale(0); /* Start scaled down */
  opacity: 0; /* Start invisible */
}

.segment-icon {
  font-size: 2em;
  transition: transform 0.3s ease;
}

.segment-label {
  font-size: 0.75em;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

/* Hover State */
.radial-segment:hover .segment-content {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.5), rgba(118, 75, 162, 0.5));
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(102, 126, 234, 0.5);
}

.radial-segment:hover .segment-icon {
  transform: scale(1.2);
}

/* Active/Highlighted State (when dragging over) */
.radial-segment.highlighted .segment-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.2);
  box-shadow: 0 0 40px rgba(102, 126, 234, 0.8),
              0 0 0 4px rgba(255, 255, 255, 0.3);
}

.radial-segment.highlighted .segment-icon {
  transform: scale(1.3);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
}

.radial-segment.highlighted .segment-label {
  color: white;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

/* Instructions */
.radial-instructions {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9em;
  font-weight: 500;
  text-align: center;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.7;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
  }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .radial-menu-container {
    width: 350px;
    height: 350px;
  }

  .radial-menu-center {
    width: 90px;
    height: 90px;
  }

  .center-icon {
    font-size: 2em;
  }

  .center-label {
    font-size: 0.75em;
  }

  .radial-segment {
    width: 80px;
    height: 80px;
    margin: -40px 0 0 -40px;
  }

  /* Adjust positions for smaller circle */
  .radial-segment[data-angle="0"] {
    transform: translate(0, -140px);
  }

  .radial-segment[data-angle="45"] {
    transform: translate(99px, -99px);
  }

  .radial-segment[data-angle="90"] {
    transform: translate(140px, 0);
  }

  .radial-segment[data-angle="135"] {
    transform: translate(99px, 99px);
  }

  .radial-segment[data-angle="180"] {
    transform: translate(0, 140px);
  }

  .radial-segment[data-angle="225"] {
    transform: translate(-99px, 99px);
  }

  .radial-segment[data-angle="270"] {
    transform: translate(-140px, 0);
  }

  .radial-segment[data-angle="315"] {
    transform: translate(-99px, -99px);
  }

  .segment-icon {
    font-size: 1.5em;
  }

  .segment-label {
    font-size: 0.65em;
  }

  #radialMenuBtn {
    left: 10px;
    font-size: 0.9em;
    padding: 8px 12px;
  }

  #emoteToggleBtn {
    top: 50px;
    left: 10px;
    font-size: 1em;
    padding: 8px 12px;
  }
}

/* Animation on open */
@keyframes segmentFadeIn {
  from {
    opacity: 0;
    transform: scale(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Apply animation to segment content, not the segment itself */
.radial-menu-overlay.active .radial-segment {
  opacity: 1; /* Make segment visible */
}

.radial-menu-overlay.active .segment-content {
  animation: segmentFadeIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  /* Explicitly set final state for mobile browsers */
  opacity: 1;
  transform: scale(1);
}

/* Stagger animations for each segment */
.radial-menu-overlay.active .radial-segment:nth-child(1) .segment-content { animation-delay: 0.05s; }
.radial-menu-overlay.active .radial-segment:nth-child(2) .segment-content { animation-delay: 0.1s; }
.radial-menu-overlay.active .radial-segment:nth-child(3) .segment-content { animation-delay: 0.15s; }
.radial-menu-overlay.active .radial-segment:nth-child(4) .segment-content { animation-delay: 0.2s; }
.radial-menu-overlay.active .radial-segment:nth-child(5) .segment-content { animation-delay: 0.25s; }
.radial-menu-overlay.active .radial-segment:nth-child(6) .segment-content { animation-delay: 0.3s; }
.radial-menu-overlay.active .radial-segment:nth-child(7) .segment-content { animation-delay: 0.35s; }
.radial-menu-overlay.active .radial-segment:nth-child(8) .segment-content { animation-delay: 0.4s; }

/* ===== CHILD MENU SYSTEM ===== */

/* Child Menu Container */
.radial-child-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  background: linear-gradient(135deg, rgba(20, 20, 30, 0.95), rgba(30, 30, 45, 0.95));
  border: 2px solid rgba(102, 126, 234, 0.6);
  border-radius: 16px;
  padding: 20px;
  min-width: 250px;
  z-index: 15; /* Above segments, below center when dragging */
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
}

.radial-child-menu.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Child Menu Header */
.child-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 12px;
  border-bottom: 2px solid rgba(102, 126, 234, 0.3);
}

.child-menu-icon {
  font-size: 2em;
}

.child-menu-title {
  font-size: 1.1em;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Child Menu Options */
.child-menu-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.child-menu-option {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
  border: 2px solid rgba(102, 126, 234, 0.3);
  border-radius: 10px;
  color: white;
  font-weight: 600;
  font-size: 0.95em;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.child-menu-option:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.5), rgba(118, 75, 162, 0.5));
  border-color: rgba(102, 126, 234, 0.8);
  transform: translateX(5px);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.child-menu-option:active {
  transform: translateX(5px) scale(0.98);
}

.child-option-icon {
  font-size: 1.3em;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .radial-child-menu {
    min-width: 220px;
    padding: 15px;
  }

  .child-menu-title {
    font-size: 1em;
  }

  .child-menu-option {
    padding: 10px 14px;
    font-size: 0.85em;
  }
}
