/**
 * Video Block Styles
 * WCAG 2.1 AA compliant video player and controls
 * Uses design system variables from theme-consolidated.css
 *
 * Supports:
 * - Embedded videos (YouTube, Vimeo, etc.)
 * - Uploaded videos (HTML5 player)
 * - Responsive 16:9 aspect ratio
 * - Accessibility badges (CC, AD, Transcript)
 * - Related materials section
 * - Dark mode support
 * - Print styles
 */

/* ==========================================================================
   Video Block Container
   ========================================================================== */

.video-block-container {
    margin: 2rem auto;
    max-width: 100%;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Fix sub-pixel rendering artifacts at rounded corners */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ==========================================================================
   Video Player Wrapper (16:9 Aspect Ratio)
   ========================================================================== */

.video-block-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
    background: transparent;
    border-radius: 4px;
    overflow: hidden;
    /* Fix sub-pixel rendering artifacts at rounded corners */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Responsive 16:9 aspect ratio for embeds */
.video-embed-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-embed-container iframe,
.video-embed-container object,
.video-embed-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* HTML5 video player */
.video-player {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block;
    background: var(--ucb-black);
    object-fit: contain;
}

.video-player:focus {
    outline: 3px solid var(--ucb-gold);
    outline-offset: 2px;
}

/* ==========================================================================
   Accessibility Indicators (CC, AD, Transcript Badges)
   ========================================================================== */

.video-accessibility-info {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.video-accessibility-info:empty {
    display: none;
    margin-bottom: 0;
}

.accessibility-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    /* Fix sub-pixel rendering artifacts at rounded corners */
    transform: translateZ(0);
    backface-visibility: hidden;
    cursor: help;
    transition: transform 0.2s ease;
}

.accessibility-badge:hover,
.accessibility-badge:focus {
    transform: translateY(-1px);
}

.accessibility-badge--cc {
    background: var(--ucb-gold);
    color: var(--ucb-black);
}

.accessibility-badge--ad {
    background: var(--success-color, #28a745);
    color: white;
}

.accessibility-badge--transcript {
    background: var(--info-color, #17a2b8);
    color: white;
}

/* ==========================================================================
   Video Caption Section (similar to figure captions)
   ========================================================================== */

.video-caption-section {
    padding: 0.5rem 0 0;
    color: var(--text-secondary);
}

.video-caption-section .video-number {
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 0.25rem;
}

.video-caption-section .video-title {
    display: inline;
    color: var(--text-secondary);
    margin: 0;
}

.video-caption-section .video-duration {
    display: inline;
    margin-left: 0.25rem;
}

.video-caption-section .video-caption {
    display: inline;
    color: var(--text-secondary);
}

.video-caption-section .video-caption p {
    display: inline;
    margin: 0;
    padding: 0;
}

.video-caption-section .video-caption p + p {
    display: block;
    margin-top: 0.5rem;
}

/* ==========================================================================
   Transcript Link
   ========================================================================== */

.video-transcript-link {
    margin-bottom: 1rem;
}

/* Base .btn already has text-decoration: none */
/* Underline on hover removed - use .btn-outline-* for link-like buttons */

/* ==========================================================================
   Related Materials Section
   ========================================================================== */

.video-related-materials {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #dee2e6);
}

.related-materials-toggle {
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0.5rem 0;
    user-select: none;
    list-style: none; /* Remove default marker */
}

.related-materials-toggle::-webkit-details-marker {
    display: none; /* Hide default arrow in WebKit */
}

.related-materials-toggle::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    color: var(--ucb-gold);
}

.video-related-materials[open] .related-materials-toggle::before {
    transform: rotate(90deg);
}

.related-materials-toggle:hover,
.related-materials-toggle:focus {
    color: var(--ucb-gold);
    outline: 2px solid var(--ucb-gold);
    outline-offset: 2px;
}

.related-materials-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
}

.related-material-item {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 4px;
    border-left: 3px solid var(--ucb-gold);
    transition: background-color 0.2s ease;
}

.related-material-item:hover {
    background: var(--bg-hover, rgba(207, 184, 124, 0.1));
}

.related-material-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

.related-material-link:hover,
.related-material-link:focus {
    color: var(--ucb-gold);
    text-decoration: underline;
}

.material-type-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.material-file-info {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* ==========================================================================
   Noscript Fallback
   ========================================================================== */

.video-fallback {
    background: var(--bg-warning, #fff3cd);
    border: 1px solid var(--border-warning, #ffc107);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
}

.video-fallback p {
    margin: 0.5rem 0;
}

.video-fallback a {
    color: var(--ucb-gold);
    font-weight: 600;
}

/* Hide fallback by default (show only in noscript) */
noscript .video-fallback {
    display: block;
}

/* ==========================================================================
   Dark Mode Overrides
   ========================================================================== */

[data-theme="dark"] .video-block-container {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .related-material-item {
    background: var(--bg-primary);
}

[data-theme="dark"] .video-fallback {
    background: rgba(255, 243, 205, 0.1);
    border-color: var(--ucb-gold);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .video-block-container {
        padding: 1rem;
        margin: 1.5rem auto;
    }

    .video-caption-section {
        font-size: 0.9rem;
    }

    .accessibility-badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.4rem;
    }

    .related-material-link {
        flex-wrap: wrap;
    }

    .material-file-info {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .video-block-container {
        padding: 0.75rem;
        border-radius: 4px;
    }

    .video-caption-section {
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .video-block-wrapper {
        display: none !important;
    }

    .video-accessibility-info {
        display: none !important;
    }

    .related-materials-toggle::before {
        content: '' !important;
    }

    .video-related-materials[open] {
        border: 1px solid #000;
        padding: 0.5rem;
    }

    .video-fallback {
        display: block !important;
        page-break-inside: avoid;
    }

    .related-materials-list {
        page-break-inside: avoid;
    }
}

/* ==========================================================================
   Focus and Keyboard Navigation
   ========================================================================== */

.video-block-container:focus-within {
    box-shadow: 0 0 0 3px rgba(207, 184, 124, 0.3);
}

.video-block-container a:focus,
.video-block-container button:focus,
.video-block-container summary:focus {
    outline: 2px solid var(--ucb-gold);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .video-block-container {
        border: 2px solid currentColor;
    }

    .accessibility-badge {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .accessibility-badge,
    .related-materials-toggle::before {
        transition: none;
    }
}
