/* ═══════════════════════════════════════════════════════════
   TEXT-TO-SPEECH BUTTON STYLES
   ═══════════════════════════════════════════════════════════ */

.text-to-speech-btn {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #3A7BD5 0%, #2563EB 100%);
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(58, 123, 213, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
    font-size: 22px;
}

.text-to-speech-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 8px 24px rgba(58, 123, 213, 0.6);
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

.text-to-speech-btn:active {
    transform: translateY(-2px) scale(1.02);
}

.text-to-speech-btn.speaking {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.text-to-speech-btn.speaking:hover {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 4px 24px rgba(239, 68, 68, 0.8);
    }
}

.text-to-speech-btn i {
    transition: all 0.3s ease;
}

.text-to-speech-btn.speaking i {
    animation: shake 0.5s ease-in-out infinite;
}

@keyframes shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

/* Tooltip */
.text-to-speech-btn::before {
    content: attr(title);
    position: absolute;
    right: 70px;
    background: #1F2937;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.text-to-speech-btn::after {
    content: '';
    position: absolute;
    right: 60px;
    border: 6px solid transparent;
    border-left-color: #1F2937;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.text-to-speech-btn:hover::before,
.text-to-speech-btn:hover::after {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .text-to-speech-btn {
        bottom: 80px;
        right: 20px;
        width: 52px;
        height: 52px;
        font-size: 20px;
        /* Ensure button is tappable on mobile */
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .text-to-speech-btn::before {
        display: none;
    }
    
    .text-to-speech-btn::after {
        display: none;
    }
    
    /* Increase touch target for better mobile UX */
    .text-to-speech-btn::after {
        content: '';
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
        display: block;
    }
}

@media (max-width: 480px) {
    .text-to-speech-btn {
        bottom: 70px;
        right: 15px;
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

/* Adjust position when scroll-up arrow is visible */
.scroll-up-arrow.show ~ .text-to-speech-btn {
    bottom: 160px;
}

@media (max-width: 768px) {
    .scroll-up-arrow.show ~ .text-to-speech-btn {
        bottom: 140px;
    }
}
