/* Video Components */
.video-container {
    position: relative;
    width: 100%;
    height: auto; /* Allow height to be determined by content */
    overflow: hidden;
    border-radius: var(--radius);
    /* background: var(--card-bg); Shows while loading or if iframe has no background */
    box-shadow: var(--shadow);
    min-height: 315px; /* Ensure minimum height for video player visibility */
}

.video-container:hover {
    box-shadow: var(--shadow-md), var(--glow-sm);
}

.video-container iframe {
    display: block; /* Make it a block element in normal flow */
    width: 100%;    /* Take full width of parent */
    max-width: 100%; /* Prevent overflow */
    height: auto;   /* Works with aspect-ratio */
    aspect-ratio: 16/9; /* Default aspect ratio to prevent collapse */
    border: none;   /* Good practice */
    margin: 0;      /* Reset margin */
    max-height: 90vh; /* Constrain video height to 90% of viewport height */
    min-height: 315px; /* Ensure minimum height for Google indexing */
}

/* YouTube Facade specific styles - for the initial placeholder */
/* This applies *before* the click, when the div has both .video-container and .youtube-facade */
.video-container.youtube-facade {
    padding-bottom: 56.25%; /* 16:9 aspect ratio for the facade image */
    height: 0; /* Required for the padding-bottom trick */
    background: var(--bg-secondary); /* Facade specific background */
}

/* Ensure the thumbnail image within the facade fills the 16:9 space */
.video-container.youtube-facade .youtube-facade-thumbnail {
    position: absolute; /* Positioned within .video-container.youtube-facade */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Fills the 16:9 area defined by padding-bottom */
    object-fit: cover;
}

.video-container.youtube-facade .youtube-facade-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10; /* Ensure it's above the thumbnail */
}

/* Homepage Featured Video - Enforce 16:9 aspect ratio */
.featured-video .video-player .video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.featured-video .video-player .video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    aspect-ratio: unset;
}

/* Front Page Video List */
.video-list {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.video-info {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.featured-video {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.video-item-small {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    background: var(--bg-secondary);
    margin-bottom: 0.75rem;
}

.video-item-small:last-child {
    margin-bottom: 0;
}

.video-item-small:hover {
    background: var(--border-color);
}

.video-image {
    position: relative;
    width: 120px;
    height: 68px; /* 16:9 aspect ratio */
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}

.video-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}

.video-image:hover img {
    opacity: 0.9;
}

.video-image::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.5rem;
    opacity: 0;
    transition: opacity 0.2s;
    text-shadow: var(--glow-sm);
}

.video-image:hover::after {
    opacity: 0.9;
}

.video-image .duration {
    position: absolute;
    bottom: 0.25rem;
    right: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    z-index: 2;
}

.video-content-small {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.video-content-small h4 {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-content-small h4 a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.video-content-small h4 a:hover {
    color: var(--primary-color);
}

.video-content-small time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Video Cards (for single page) */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.video-card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.video-card:hover {
    box-shadow: var(--shadow-md), var(--glow-sm);
    transform: translateY(-2px);
}

.video-card .video-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    overflow: hidden;
    background: var(--card-bg);
}

.video-card .video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.video-card .video-thumbnail::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 2.5rem;
    opacity: 0;
    transition: opacity 0.3s;
    text-shadow: var(--glow-sm);
}

.video-card:hover .video-thumbnail::after {
    opacity: 0.9;
}

.video-card:hover .video-thumbnail img {
    opacity: 0.8;
}

.video-card .duration {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 2;
}

.video-card-content {
    padding: 1rem;
}

.video-card-content h3 {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.video-card-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.video-card-link {
    text-decoration: none;
    color: inherit;
}

/* Single Video Page */
.video-article {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.video-player-container {
    margin-bottom: 2rem;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-secondary);
}

.video-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.video-meta .duration {
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
}

.video-meta .categories {
    display: flex;
    gap: 0.5rem;
}

.video-meta .category {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.video-meta .category:hover {
    color: var(--primary-color);
}

.video-description {
    line-height: 1.6;
    color: var(--text-primary);
}

.video-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.video-tags .tag {
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.video-tags .tag:hover {
    background: var(--primary-color);
    color: var(--text-primary);
}

/* Video Section Layout */
.video-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.related-videos {
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.related-videos h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .video-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .video-article {
        padding: 1rem;
    }

    .video-meta {
        flex-wrap: wrap;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }

    /* Related videos on single page - mobile optimization */
    .related-videos .video-grid {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .related-videos .video-card {
        border: none;
        border-radius: var(--radius-sm);
        background: var(--card-bg);
        overflow: hidden;
        box-shadow: none;
        transition: background-color 0.2s ease;
        transform: none;
    }

    .related-videos .video-card:hover {
        background: var(--border-color);
        transform: none;
        box-shadow: none;
    }

    .related-videos .video-card-link {
        display: flex;
        gap: 1rem;
        align-items: center;
        padding: 0.75rem;
    }

    .related-videos .video-thumbnail {
        flex-shrink: 0;
        width: 120px;
        height: 68px; /* 16:9 on 120px width */
        padding-bottom: 0; /* Override padding-bottom trick */
        border-radius: var(--radius-sm);
    }
    
    .related-videos .video-thumbnail::after {
        display: none; /* Hide big play button for compact view */
    }
    
    .related-videos .video-card-content {
        padding: 0;
        flex: 1;
        min-width: 0; /* for text truncation */
    }

    .related-videos .video-card-content h3 {
        font-size: 0.875rem;
        line-height: 1.4;
        margin-bottom: 0;
        color: var(--text-color); /* Match .video-content-small h4 a color */
        display: -webkit-box;
        -webkit-line-clamp: 2; /* Limit to 2 lines */
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .related-videos .video-card:hover .video-card-content h3 {
        color: var(--primary-color); /* Match .video-content-small h4 a:hover color */
    }

    .related-videos .video-card-content p {
        display: none; /* Hide description on mobile for compact view */
    }

    .related-videos .video-card .duration {
        bottom: 0.25rem;
        right: 0.25rem;
        padding: 0.125rem 0.375rem;
        font-size: 0.75rem;
    }

    .video-item-small {
        padding: 0.5rem;
    }

    .video-image {
        width: 100px;
        height: 56px;
    }
}

/* YouTube Facade Styles */
.youtube-facade { /* This class is added to .video-container for YouTube videos */
    cursor: pointer;
    /* This class is now primarily a marker, specific aspect ratio is handled by .video-container.youtube-facade */
}

.youtube-facade-thumbnail {
    /* This is now styled under .video-container.youtube-facade .youtube-facade-thumbnail */
    /* Styles here might become redundant or need to be harmonized if they differ */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 0; 
    transition: opacity 0.3s ease-out;
}

.youtube-facade-play-icon {
    /* This is now styled under .video-container.youtube-facade .youtube-facade-play-icon */
    /* Styles here might become redundant or need to be harmonized */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px; 
    height: 48px; 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path fill="rgba(30,30,30,0.8)" d="M66.52,7.74c-0.78-2.93-2.49-5.41-5.42-6.19C55.79,.13,34,0,34,0S12.21,.13,6.9,1.55 C3.97,2.33,2.27,4.81,1.48,7.74C0.06,13.05,0,24,0,24s0.06,10.95,1.48,16.26c0.78,2.93,2.49,5.41,5.42,6.19 C12.21,47.87,34,48,34,48s21.79-0.13,27.1-1.55c2.93-0.78,4.64-3.26,5.42-6.19C67.94,34.95,68,24,68,24S67.94,13.05,66.52,7.74z"/><path fill="%23fff" d="M 45,24 27,14 27,34"/></svg>');
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1; 
    z-index: 10; 
}

.youtube-facade:hover .youtube-facade-play-icon {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 1;
}

/* X/Twitter video container on single video page - max height constraint */
/* .video-player-container is from single.html, .x-video-container is the .video-container for Twitter */
.video-player-container .x-video-container {
    max-height: 90vh; /* Constrain the container's height */
    overflow-y: auto; /* Allow internal scrolling if Twitter content overflows and doesn't resize */
}

/* Attempt to remove any border from the iframe generated by Twitter within the x-video-container */
.video-player-container .x-video-container iframe {
    border: none !important; 
} 