/**
 * DeTube Dark - Related Videos Section Styles
 * Optimized for single line titles and 6-video grid
 */

/* =============================================================================
   Related Videos Section
   ============================================================================= */

.related-videos-section {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}


/* =============================================================================
   Related Videos Grid - Perfect 6 Videos Layout
   ============================================================================= */

.related-videos-grid {
    display: grid;
    gap: 20px;
    max-width: none;
    /* Ensure proper grid item placement */
    justify-items: stretch;
    align-items: stretch;
}

/* Ẩn thẻ qua class — JS điều khiển (không dùng nth-child cố định) */
.related-video-card.hidden-video {
    display: none !important;
}

/* Desktop (legacy — single-refined overrides in single-page.css) */
@media (min-width: 1024px) {
    body:not(.single-refined) .related-videos-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 1200px;
        margin: 0 auto;
        gap: 20px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .related-videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

@media (max-width: 767px) {
    .related-videos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

/* =============================================================================
   Related Video Cards
   ============================================================================= */

.related-video-card {
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-lg, 14px);
    overflow: hidden;
    transition: all 0.3s ease;
}

.related-video-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.related-video-card .thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.related-video-card .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-video-card:hover .thumb img {
    transform: scale(1.05);
}

/* =============================================================================
   Related Video Titles - Single Line Only
   ============================================================================= */

.related-video-title {
    padding: 12px 15px;
    margin: 0;
}

.related-video-title a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.3;
    
    /* Single line title with ellipsis */
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Fallback for non-webkit browsers */
    white-space: nowrap;
    max-width: 100%;
}

@media (hover: hover) and (pointer: fine) {
    .related-video-title a:hover {
        color: var(--accent-color);
    }
}

.related-video-title a {
    transition: color 0.2s ease;
}

/* =============================================================================
   No Related Videos Message
   ============================================================================= */

.no-related-videos {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.no-related-videos p {
    color: var(--muted);
    font-size: 1rem;
    margin: 0;
    font-style: italic;
}

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

.related-videos-loading {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.related-videos-loading .skeleton {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.related-videos-loading .skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* =============================================================================
   Mobile Optimizations
   ============================================================================= */

@media (max-width: 768px) {
    .related-videos-section {
        margin-top: 30px;
        padding: 15px 0;
    }
    
    .related-videos-section .section-title {
        font-size: 1.3rem;
        margin-bottom: 15px;
    }
    
    .related-video-title {
        padding: 8px 10px;
    }
    
    .related-video-title a {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    
    .related-video-card .thumb .overlay-badge {
        font-size: 0.65rem;
        padding: 3px 6px;
    }
}

/* =============================================================================
   Dark Theme Enhancements
   ============================================================================= */

@media (prefers-color-scheme: dark) {
    .related-video-card {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.08);
    }
    
    .related-video-card:hover {
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.15);
    }
    
    .no-related-videos {
        background: rgba(255, 255, 255, 0.03);
        border-color: rgba(255, 255, 255, 0.08);
    }
}

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

.related-video-card:focus-within {
    outline: none;
}

.related-video-title a:focus {
    outline: none;
}

.related-video-title a:focus-visible {
    color: var(--accent-color);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .related-video-card,
    .related-video-card .thumb img,
    .related-video-title a {
        transition: none;
    }
    
    .related-video-card:hover {
        transform: none;
    }
    
    .related-video-card:hover .thumb img {
        transform: none;
    }
    
    @keyframes shimmer {
        0%, 100% { opacity: 0.5; }
        50% { opacity: 1; }
    }
}