/**
 * ElevenLabs Audio Native Player Styles
 *
 * SEO-optimized, accessible audio player wrapper for 2025
 * Follows WCAG 2.1 AA guidelines
 *
 * @package SportPersonalities
 * @since 3.2.0
 */

/* ==========================================================================
   Player Wrapper - Reserve Space to Prevent CLS
   ========================================================================== */

.sp-elevenlabs-audio-wrapper {
    min-height: 120px; /* Reserve space before load */
    contain: layout; /* CSS containment for performance */
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Header with icon and label */
.sp-elevenlabs-audio-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sp-elevenlabs-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #b60f0a 0%, #8b0000 100%);
    color: #fff;
    border-radius: 50%;
    flex-shrink: 0;
}

.sp-elevenlabs-icon svg {
    width: 18px;
    height: 18px;
}

.sp-elevenlabs-label {
    font-size: 1rem;
    font-weight: 600;
    color: #1a202c;
    letter-spacing: -0.01em;
}

/* Player Widget Container */
#elevenlabs-audionative-widget {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
}

#elevenlabs-audionative-widget a {
    color: #0066cc;
    text-decoration: none;
}

#elevenlabs-audionative-widget a:hover {
    text-decoration: underline;
}

/* Disclaimer */
.sp-elevenlabs-disclaimer {
    margin: 12px 0 0 0;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.sp-elevenlabs-disclaimer small {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-elevenlabs-disclaimer small::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2364748b'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
    background-size: contain;
    flex-shrink: 0;
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet */
@media (max-width: 768px) {
    .sp-elevenlabs-audio-wrapper {
        padding: 14px 16px;
        margin: 16px 0;
        border-radius: 10px;
    }

    .sp-elevenlabs-audio-header {
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 10px;
    }

    .sp-elevenlabs-icon {
        width: 32px;
        height: 32px;
    }

    .sp-elevenlabs-icon svg {
        width: 16px;
        height: 16px;
    }

    .sp-elevenlabs-label {
        font-size: 0.95rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .sp-elevenlabs-audio-wrapper {
        padding: 12px 14px;
        margin: 14px 0;
        border-radius: 8px;
        min-height: 100px;
    }

    .sp-elevenlabs-audio-header {
        gap: 8px;
    }

    .sp-elevenlabs-icon {
        width: 30px;
        height: 30px;
    }

    .sp-elevenlabs-icon svg {
        width: 14px;
        height: 14px;
    }

    .sp-elevenlabs-label {
        font-size: 0.9rem;
    }

    .sp-elevenlabs-disclaimer small {
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   Sport Article Variant (optional darker theme)
   ========================================================================== */

.sp-sport-article .sp-elevenlabs-audio-wrapper,
.sp-sport-layout-hub .sp-elevenlabs-audio-wrapper,
.sp-sport-layout-spoke .sp-elevenlabs-audio-wrapper,
.sp-sport-layout-deep_dive .sp-elevenlabs-audio-wrapper {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-color: #cbd5e0;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles for keyboard navigation */
.sp-elevenlabs-audio-wrapper:focus-within {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Screen reader only text */
.sp-elevenlabs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sp-elevenlabs-audio-wrapper {
        border-width: 2px;
        border-color: #000;
    }

    .sp-elevenlabs-icon {
        background: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sp-elevenlabs-audio-wrapper,
    .sp-elevenlabs-audio-wrapper * {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================================================
   Loading State
   ========================================================================== */

#elevenlabs-audionative-widget:empty::before,
#elevenlabs-audionative-widget:not(:has(iframe))::before {
    content: '';
    display: block;
    height: 60px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: sp-audio-loading 1.5s infinite;
    border-radius: 6px;
}

@keyframes sp-audio-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Hide loading animation once iframe loads */
#elevenlabs-audionative-widget:has(iframe)::before {
    display: none;
}

/* ==========================================================================
   Dark Mode Support (if theme supports it)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .sp-elevenlabs-audio-wrapper {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        border-color: #334155;
    }

    .sp-elevenlabs-label {
        color: #f1f5f9;
    }

    .sp-elevenlabs-disclaimer small {
        color: #94a3b8;
    }

    .sp-elevenlabs-disclaimer small::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
    }

    .sp-elevenlabs-audio-header {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .sp-elevenlabs-disclaimer {
        border-top-color: rgba(255, 255, 255, 0.1);
    }
}
