/**
 * Text Flyout Button Styles
 * Provides styling for the flyout button component with smooth animations
 */

.text-flyout-container {
  // Base container styles
  position: relative;
  display: inline-block;
  
  .text-flyout-trigger {
    // Button base styles
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.25rem;
    border: none;
    cursor: pointer;
    user-select: none;
    
    // Smooth transitions
    transition: all 0.2s ease-in-out;
    
    // Hover state
    // &:hover {
    //   transform: translateY(-1px);
    //   box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    // }
    
    // Active state
    &:active {
      transform: translateY(0);
    }
    
    // Focus state for accessibility
    &:focus {
      outline: 2px solid transparent;
      outline-offset: 2px;
      box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
    }
    
    // Arrow icon
    svg {
      transition: transform 0.2s ease-in-out;
      margin-left: 0.5rem;
    }
    
    // Active state arrow rotation
    &.active svg {
      transform: rotate(90deg);
    }
  }
  
  .text-flyout-panel {
    // Panel positioning and base styles
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    padding: 1rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    min-width: 20rem;
    max-width: 28rem;
    
    // Animation properties
    transform-origin: top left;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    // Right-side positioning when flyout would overflow viewport
    &.flyout-right {
      left: auto;
      right: 0;
      transform-origin: top right;
    }
    
    // Left-side positioning (default)
    &.flyout-left {
      left: 0;
      right: auto;
      transform-origin: top left;
    }
    
    // Hidden state
    transform: scale(0);
    opacity: 0;
    
    // Visible state
    &.scale-100 {
      transform: scale(1);
    }
    
    &.opacity-100 {
      opacity: 1;
    }
    
    // Content styling
    .text-flyout-content {
      color: #374151;
      line-height: 1.625;
      
      // Typography styles for content
      p {
        margin-bottom: 0.75rem;
        
        &:last-child {
          margin-bottom: 0;
        }
      }
      
      ul, ol {
        margin-bottom: 0.75rem;
        padding-left: 1.5rem;
      }
      
      li {
        margin-bottom: 0.25rem;
      }
      
      strong {
        font-weight: 600;
      }
      
      a {
        color: #2563eb;
        text-decoration: underline;
        
        &:hover {
          color: #1d4ed8;
        }
      }
    }
    
    // Close button
    .text-flyout-close {
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
      width: 1.5rem;
      height: 1.5rem;
      display: flex;
      align-items: center;
      justify-content: center;
      border: none;
      background: transparent;
      border-radius: 50%;
      cursor: pointer;
      color: #6b7280;
      transition: all 0.15s ease-in-out;
      
      &:hover {
        background-color: #f3f4f6;
        color: #374151;
      }
      
      &:focus {
        outline: 2px solid transparent;
        outline-offset: 2px;
        background-color: #f3f4f6;
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
      }
      
      svg {
        width: 1rem;
        height: 1rem;
      }
    }
  }
}

// Responsive adjustments
@media (max-width: 640px) {
  .text-flyout-container {
    .text-flyout-panel {
      // Center positioning on mobile regardless of orientation
      left: 50% !important;
      right: auto !important;
      transform-origin: top center !important;
      
      &.scale-0 {
        transform: translateX(-50%) scaleX(0);
      }
      
      &.scale-100 {
        transform: translateX(-50%) scaleX(1);
      }
      
      // Adjust width for mobile
      min-width: 90vw;
      max-width: 90vw;
    }
  }
}

// High contrast mode support
@media (prefers-contrast: high) {
  .text-flyout-container {
    .text-flyout-trigger {
      border: 2px solid;
    }
    
    .text-flyout-panel {
      border: 2px solid;
    }
  }
}

// Reduced motion support
@media (prefers-reduced-motion: reduce) {
  .text-flyout-container {
    .text-flyout-trigger,
    .text-flyout-trigger svg,
    .text-flyout-panel,
    .text-flyout-close {
      transition: none;
    }
  }
}