/**
 * Audio Embed Styles
 * Responsive styling for HTML5 audio players in article content
 *
 * Pattern: Mirrors youtube-embed.css architecture
 * Features: Responsive design, dark mode, accessibility, print styles
 */

/* ========================================
   Container Styles
   ======================================== */

.audio-embed-container {
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #f8fafc;
    overflow: hidden;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}

.audio-embed-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

/* ========================================
   Title Bar
   ======================================== */

.audio-embed-title {
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e293b;
    border-bottom: 1px solid #cbd5e1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.audio-embed-title::before {
    content: '🎵';
    font-size: 1rem;
}

/* ========================================
   Wrapper & Player
   ======================================== */

.audio-embed-wrapper {
    padding: 1rem;
    background: #ffffff;
}

.audio-embed-player {
    width: 100%;
    height: 40px;
    border-radius: 4px;
    outline: none;
    display: block;
    background: transparent;
}

/* Focus state for accessibility */
.audio-embed-player:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.audio-embed-player:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ========================================
   Loading & Error States
   ======================================== */

.audio-embed-container.loading .audio-embed-wrapper::before {
    content: 'Loading audio...';
    display: block;
    text-align: center;
    padding: 1rem;
    color: #64748b;
    font-size: 0.875rem;
}

.audio-embed-container.error .audio-embed-wrapper {
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.audio-embed-container.error .audio-embed-wrapper::before {
    content: '⚠️ Failed to load audio';
    display: block;
    text-align: center;
    padding: 1rem;
    color: #991b1b;
    font-size: 0.875rem;
}

/* ========================================
   Responsive Design - Tablet
   ======================================== */

@media (max-width: 768px) {
    .audio-embed-container {
        margin: 1.25rem 0;
        border-radius: 6px;
    }

    .audio-embed-title {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .audio-embed-wrapper {
        padding: 0.875rem;
    }
}

/* ========================================
   Responsive Design - Mobile
   ======================================== */

@media (max-width: 640px) {
    .audio-embed-container {
        margin: 1rem 0;
        border-radius: 6px;
    }

    .audio-embed-title {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .audio-embed-wrapper {
        padding: 0.75rem;
    }

    .audio-embed-player {
        height: 36px;
    }
}

/* ========================================
   Dark Mode Support
   ======================================== */

@media (prefers-color-scheme: dark) {
    .audio-embed-container {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .audio-embed-container:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .audio-embed-title {
        background: linear-gradient(135deg, #374151 0%, #4b5563 100%);
        color: #f3f4f6;
        border-bottom-color: #4b5563;
    }

    .audio-embed-wrapper {
        background: #111827;
    }

    .audio-embed-container.loading .audio-embed-wrapper::before {
        color: #9ca3af;
    }

    .audio-embed-container.error .audio-embed-wrapper {
        background: #7f1d1d;
        border-color: #991b1b;
    }

    .audio-embed-container.error .audio-embed-wrapper::before {
        color: #fecaca;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .audio-embed-player {
        display: none;
    }

    .audio-embed-container {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .audio-embed-container::after {
        content: 'Audio URL: ' attr(data-original-url);
        display: block;
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
        color: #000;
        background: #f5f5f5;
        border-top: 1px solid #ddd;
        word-break: break-all;
    }

    .audio-embed-title {
        background: #e5e5e5 !important;
        color: #000 !important;
    }
}

/* ========================================
   Accessibility - Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .audio-embed-container {
        transition: none;
    }

    .audio-embed-container:hover {
        transform: none;
    }
}

/* ========================================
   High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
    .audio-embed-container {
        border: 2px solid currentColor;
    }

    .audio-embed-title {
        border-bottom: 2px solid currentColor;
    }

    .audio-embed-player:focus {
        outline: 3px solid currentColor;
        outline-offset: 3px;
    }
}

/* ========================================
   Browser-Specific Styling
   ======================================== */

/* Chrome, Safari, Edge */
.audio-embed-player::-webkit-media-controls-panel {
    background-color: #f1f5f9;
}

.audio-embed-player::-webkit-media-controls-play-button,
.audio-embed-player::-webkit-media-controls-mute-button {
    background-color: #3b82f6;
    border-radius: 50%;
}

/* Firefox */
.audio-embed-player::-moz-range-thumb {
    background-color: #3b82f6;
}

/* Dark mode browser controls */
@media (prefers-color-scheme: dark) {
    .audio-embed-player::-webkit-media-controls-panel {
        background-color: #1e293b;
    }
}

/* ========================================
   Prose Container Integration
   ======================================== */

.prose .audio-embed-container {
    max-width: 100%;
}

.prose .audio-embed-container:first-child {
    margin-top: 0;
}

.prose .audio-embed-container:last-child {
    margin-bottom: 0;
}

/* ========================================
   Utility Classes
   ======================================== */

.audio-embed-container.compact {
    margin: 0.75rem 0;
}

.audio-embed-container.compact .audio-embed-title {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
}

.audio-embed-container.compact .audio-embed-wrapper {
    padding: 0.5rem;
}

.audio-embed-container.no-title .audio-embed-title {
    display: none;
}

.audio-embed-container.full-width {
    margin-left: 0;
    margin-right: 0;
    border-radius: 0;
}
