/* Livestreaming Button Styling */

.streaming-container {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 33%; /* container takes ~1/3 of card width */
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none; /* allow clicks to pass through except the link itself */
}

/* Make the livestream link render only the PNG without any extra oval/background */
a.livestreaming {
    display: inline-block;
    width: 33%; /* fill the container width (approx 1/3 of card) */
    max-width: 120px; /* cap size on large cards */
    height: auto;
    background-image: url('../images/livestreaming.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center right;
    text-indent: -9999px; /* hide any text */
    overflow: hidden;
    border: 0;
    box-shadow: none;
    background-color: transparent;
    pointer-events: auto; /* make the PNG itself clickable */
}

a.livestreaming img { display: none; }

a.livestreaming:hover { transform: none; opacity: 0.98; }
/* Movie Grid Layout Styles */

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 120px 20px 20px; /* Top padding for control center */
    max-width: 100vw;
    margin: 0 auto;
    min-height: 100vh;
}

/* Responsive Grid - 10, 5, or 2 movies per row filling whole screen */
@media (min-width: 1920px) {
    .movie-grid {
        grid-template-columns: repeat(10, 1fr);
        max-width: calc(100vw - 40px); /* Fill screen with padding */
        padding: 120px 20px 20px;
    }
}

@media (min-width: 1200px) and (max-width: 1919px) {
    .movie-grid {
        grid-template-columns: repeat(5, 1fr);
        max-width: calc(100vw - 40px); /* Fill screen with padding */
        padding: 120px 20px 20px;
    }
}

@media (max-width: 1199px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 120px 15px 15px;
    }
}

@media (max-width: 768px) {
    .movie-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 100px 10px 10px;
    }
}

/* Movie Card */
.movie-card {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    aspect-ratio: 2/3;
    box-shadow: var(--shadow);
    transform: translateZ(0); /* GPU acceleration */
    will-change: transform;
    contain: layout style paint;
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
}

.movie-card:hover {
    transform: translateY(-5px) scale(1.02) translateZ(0);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.movie-card:active {
    transform: scale(0.98) translateZ(0);
}

/* Movie Poster */
.movie-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.movie-card:hover .movie-poster {
    transform: scale(1.05);
}

/* Movie Info Overlay */
.movie-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 20px 15px 15px;
    transform: translateY(100%);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.movie-card:hover .movie-info {
    transform: translateY(0);
}

.movie-info-detailed {
    color: rgba(255, 255, 255, 0.95);
}

.movie-info-detailed .movie-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.movie-info-detailed .movie-meta span {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
}

.movie-overview-snippet {
    margin-top: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.4;
    max-height: 3.6em;
    overflow: hidden;
}

.movie-extra-line {
    margin-top: 6px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.movie-poster-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 2.5rem;
}

.movie-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 5px;
    line-height: 1.3;
    color: var(--text-primary);
}

.movie-year {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.movie-rating {
    display: flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--accent);
}

.movie-rating::before {
    content: '⭐';
    margin-right: 4px;
}

/* Loading Placeholder */
.movie-card.loading {
    background: var(--card-bg);
    position: relative;
    overflow: hidden;
}

.movie-card.loading::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%; }
}

/* Error State */
.movie-card.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px dashed var(--border);
    color: var(--text-secondary);
}

.movie-card.error::before {
    content: '🎬';
    font-size: 2rem;
    margin-bottom: 10px;
}

/* Infinite Scroll Loading */
.scroll-loading {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-secondary);
}

.scroll-loading::after {
    content: '';
    width: 30px;
    height: 30px;
    margin-left: 15px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* End of Results */
.end-of-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Movie Grid Animations - lightweight fade only */
.movie-card {
    opacity: 0;
    animation: fadeInCard 0.3s ease-out forwards;
}

.movie-card:nth-child(1) { animation-delay: 0.02s; }
.movie-card:nth-child(2) { animation-delay: 0.04s; }
.movie-card:nth-child(3) { animation-delay: 0.06s; }
.movie-card:nth-child(4) { animation-delay: 0.08s; }
.movie-card:nth-child(5) { animation-delay: 0.1s; }

@keyframes fadeInCard {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Special Layouts for Different Screen Sizes */
@media (min-width: 2560px) {
    .movie-grid {
        grid-template-columns: repeat(10, 1fr); /* Keep 10 per row even on very large screens */
        max-width: calc(100vw - 40px);
        padding: 120px 20px 20px;
    }
}

/* Ultra-wide displays */
@media (min-width: 3440px) {
    .movie-grid {
        grid-template-columns: repeat(12, 1fr); /* 12 per row on ultra-wide */
        max-width: calc(100vw - 40px);
    }
}

@media (max-width: 480px) {
    .movie-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 90px 8px 8px;
    }
    
    .movie-title {
        font-size: 0.9rem;
    }
    
    .movie-year, .movie-rating {
        font-size: 0.8rem;
    }
}