/* Accessible Audio Player Styles */

/* Audio Accordion Toggle */
.audio-accordion {
    display: block;
    margin: .5rem 0;
    background: none !important;
    background-color: transparent !important;
}

.audio-toggle {
    display: inline-block;
    width: auto;
    text-align: left;
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: var(--pc-link, #0d47a1);
    border: 1px solid var(--pc-link, #0d47a1);
    border-radius: 0.375rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.audio-toggle:hover {
    color: var(--pc-link-hover, #08306e);
    background-color: var(--pc-link, #0d47a1);
    color: #ffffff;
    border-color: var(--pc-link-hover, #08306e);
}

.audio-toggle:focus {
    outline: 2px solid var(--pc-link, #0d47a1);
    outline-offset: 2px;
}

.audio-toggle-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid currentColor;
    transition: transform 0.2s ease;
    vertical-align: middle;
    padding-left: .5rem;
}

.audio-toggle[aria-expanded="true"] .audio-toggle-icon {
    transform: rotate(90deg);
}

.audio-player-container {
    padding: .5rem;
    background-color: var(--bs-body-bg, #ffffff);
}

.audio-download {
    margin-top: 0.2rem;
    text-align: center;
    padding-top: 0.5rem;
}

.audio-download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    color: var(--pc-link, #0d47a1);
    text-decoration: none;
    border: 1px solid var(--pc-link, #0d47a1);
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.audio-download-link:hover {
    background-color: var(--pc-link, #0d47a1);
    color: #ffffff;
    text-decoration: none;
}

.download-icon {
    font-size: 0.75rem;
}

.audio-description {
    color: var(--bs-secondary, #6c757d);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .audio-accordion {
        background-color: #2d3748;
        border-color: #4a5568;
    }

    .audio-toggle {
        color: var(--pc-link, #2fa8ff);
    }

    .audio-toggle:hover {
        color: var(--pc-link-hover, #7bd3ff);
        background-color: #4a5568;
    }

    .audio-player-container {
        background-color: #1a202c;
        border-color: #4a5568;
    }

    .audio-description {
        color: #a0aec0;
    }
}

/* Audio Player Wrapper */
.audio-player-wrapper {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.25rem;
    margin: .2rem 0;
    font-family: system-ui, -apple-system, sans-serif;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.play-pause-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.play-pause-btn:hover {
    background: #0056b3;
    transform: scale(1.05);
}

.play-pause-btn:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.play-pause-btn:active {
    transform: scale(0.95);
}

.time-display {
    font-size: 0.9rem;
    color: #6c757d;
    min-width: 100px;
    font-variant-numeric: tabular-nums;
}

.progress-wrapper {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: height 0.2s ease;
}

.progress-bar:hover {
    height: 8px;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.progress-bar::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.progress-bar:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

.progress-bar::-webkit-slider-track {
    background: linear-gradient(to right, #007bff 0%, #007bff var(--progress, 0%), #e9ecef var(--progress, 0%), #e9ecef 100%);
    height: 6px;
    border-radius: 3px;
}

.progress-bar::-moz-range-track {
    background: #e9ecef;
    height: 6px;
    border-radius: 3px;
}

.progress-bar::-moz-range-progress {
    background: #007bff;
    height: 6px;
    border-radius: 3px;
}

.playback-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.speed-btn,
.rewind-btn,
.forward-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.speed-btn:hover,
.rewind-btn:hover,
.forward-btn:hover {
    background: #495057;
    transform: translateY(-1px);
}

.speed-btn:focus,
.rewind-btn:focus,
.forward-btn:focus {
    outline: 2px solid #495057;
    outline-offset: 2px;
}

.speed-btn:active,
.rewind-btn:active,
.forward-btn:active {
    transform: translateY(0);
}

.transcript-toggle {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.transcript-toggle:hover {
    background: #218838;
}

.transcript-toggle:focus {
    outline: 2px solid #218838;
    outline-offset: 2px;
}

.transcript-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.transcript-content {
    background: white;
    padding: 1.5rem;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

.transcript-content:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only content */
.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;
}

/* Responsive design */
@media (max-width: 768px) {
    .audio-player-wrapper {
        padding: 0.4rem;
        margin: 0.5rem 0;
    }

    .audio-controls {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.4rem;
        align-items: center;
    }

    .play-pause-btn {
        grid-row: 1 / 3;
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .progress-wrapper {
        grid-column: 2;
        grid-row: 1;
        min-width: auto;
        margin: 0;
    }

    .progress-bar {
        height: 6px;
        border-radius: 3px;
    }

    .progress-bar:hover {
        height: 6px;
    }

    .progress-bar::-webkit-slider-thumb {
        width: 16px;
        height: 16px;
    }

    .progress-bar::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }

    .time-display {
        grid-column: 2;
        grid-row: 2;
        font-size: 0.8rem;
        text-align: left;
        margin: 0;
        min-width: auto;
    }

    .playback-controls {
        grid-column: 3;
        grid-row: 1 / 3;
        flex-direction: column;
        gap: 0.25rem;
    }

    .speed-btn,
    .rewind-btn,
    .forward-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.8rem;
        padding: 0.25rem;
    }
}

/* Tablet responsive design */
@media (max-width: 992px) and (min-width: 769px) {
    .audio-controls {
        gap: 0.75rem;
    }

    .progress-wrapper {
        min-width: 150px;
    }

    .playback-controls {
        gap: 0.75rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .audio-player-wrapper {
        padding: 0.3rem;
        border-radius: 4px;
        margin: 0.4rem 0;
    }

    .audio-controls {
        gap: 0.3rem;
    }

    .play-pause-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .time-display {
        font-size: 0.75rem;
    }

    .speed-btn,
    .rewind-btn,
    .forward-btn {
        min-width: 24px;
        height: 24px;
        font-size: 0.7rem;
        padding: 0.2rem;
    }

    .playback-controls {
        gap: 0.2rem;
    }
}

/* Large screens optimization */
@media (min-width: 1200px) {
    .audio-controls {
        gap: 1.5rem;
    }

    .progress-wrapper {
        min-width: 300px;
    }

    .playback-controls {
        gap: 0.75rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .audio-player-wrapper {
        border: 2px solid;
        background: ButtonFace;
    }

    .play-pause-btn {
        background: ButtonText;
        color: ButtonFace;
        border: 2px solid;
    }

    .progress-bar::-webkit-slider-thumb {
        background: ButtonText;
        border: 2px solid ButtonFace;
    }

    .progress-bar::-moz-range-thumb {
        background: ButtonText;
        border: 2px solid ButtonFace;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .play-pause-btn,
    .speed-btn,
    .rewind-btn,
    .forward-btn,
    .transcript-toggle {
        transition: none;
    }

    .play-pause-btn:hover,
    .speed-btn:hover,
    .rewind-btn:hover,
    .forward-btn:hover {
        transform: none;
    }
}

/* Focus visible for better keyboard navigation */
.play-pause-btn:focus-visible,
.speed-btn:focus-visible,
.rewind-btn:focus-visible,
.forward-btn:focus-visible,
.transcript-toggle:focus-visible,
.progress-bar:focus-visible {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .audio-player-wrapper {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .time-display {
        color: #a0aec0;
    }

    .progress-bar {
        background: #4a5568;
    }

    .transcript-content {
        background: #1a202c;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* Video Accordion Styles */
.video-accordion {
    display: block;
    margin: 1rem 0;
    background: none !important;
    background-color: transparent !important;
}

.video-toggle {
    display: inline-block;
    width: auto;
    text-align: left;
    padding: 0.5rem 1rem;
    font-weight: 500;
    color: var(--pc-link, #0d47a1);
    border: 1px solid var(--pc-link, #0d47a1);
    border-radius: 0.375rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.video-toggle:hover {
    color: var(--pc-link-hover, #08306e);
    background-color: var(--pc-link, #0d47a1);
    color: #ffffff;
    border-color: var(--pc-link-hover, #08306e);
}

.video-toggle:focus {
    outline: 2px solid var(--pc-link, #0d47a1);
    outline-offset: 2px;
}

.video-toggle-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid currentColor;
    transition: transform 0.2s ease;
    vertical-align: middle;
    padding-left: .5rem;
}

.video-toggle[aria-expanded="true"] .video-toggle-icon {
    transform: rotate(90deg);
}

.video-player-container {
    padding: 1rem;
    background-color: var(--bs-body-bg, #ffffff);
}

/* Responsive YouTube Embed */
.youtube-embed {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

.generic-video-embed {
    padding: 1rem;
    text-align: center;
    border: 2px dashed var(--bs-border-color, #dee2e6);
    border-radius: 8px;
}

.generic-video-embed a {
    color: var(--pc-link, #0d47a1);
    text-decoration: none;
    font-weight: 500;
}

.generic-video-embed a:hover {
    color: var(--pc-link-hover, #08306e);
    text-decoration: underline;
}

/* Dark mode support for video */
@media (prefers-color-scheme: dark) {
    .video-accordion {
        background-color: #2d3748;
        border-color: #4a5568;
    }

    .video-toggle {
        color: var(--pc-link, #2fa8ff);
    }

    .video-toggle:hover {
        color: var(--pc-link-hover, #7bd3ff);
        background-color: #4a5568;
    }

    .video-player-container {
        background-color: #1a202c;
        border-color: #4a5568;
    }

    .generic-video-embed {
        border-color: #4a5568;
    }

    .generic-video-embed a {
        color: var(--pc-link, #2fa8ff);
    }

    .generic-video-embed a:hover {
        color: var(--pc-link-hover, #7bd3ff);
    }
}
