/* Snippets Page Styles */

/* Intro section */
.snippets-intro {
    margin: 40px 0;
    text-align: left;
}

.snippets-intro h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: 400;
}

.snippets-intro p {
    color: #666;
    font-size: 1.1rem;
    line-height: 1.5;
    font-weight: 300;
}

/* Grid Layout */
.snippets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 60px;
    margin-bottom: 60px;
}

/* Snippet Item */
.snippet-item {
    aspect-ratio: 1/1;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background-color: #222; /* Darker background for items still loading */
}

/* Style for when first frame is loaded */
.snippet-item.first-frame-loaded {
    background-color: #f5f5f5;
}

.snippet-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Video styling */
.snippet-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(100%) brightness(0.35);
    transition: filter 0.4s ease;
}

/* Hovering/Playing state */
.snippet-item:hover .snippet-video,
.snippet-item.playing .snippet-video {
    filter: grayscale(0%) brightness(1);
}

/* Loading state */
.snippet-item.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: snippet-loader 0.8s linear infinite;
    z-index: 2;
}

/* Hide the loading indicator once we have a frame */
.snippet-item.first-frame-loaded.loading::before {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #000;
}

@keyframes snippet-loader {
    to { transform: rotate(360deg); }
}

/* Entry animation for items */
.snippet-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fade-in 0.5s ease forwards;
}

@keyframes fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered loading for items */
.snippets-grid {
    --stagger-delay: 100ms;
}

.snippet-item:nth-child(1) { animation-delay: calc(var(--stagger-delay) * 1); }
.snippet-item:nth-child(2) { animation-delay: calc(var(--stagger-delay) * 2); }
.snippet-item:nth-child(3) { animation-delay: calc(var(--stagger-delay) * 3); }
.snippet-item:nth-child(4) { animation-delay: calc(var(--stagger-delay) * 4); }
.snippet-item:nth-child(5) { animation-delay: calc(var(--stagger-delay) * 5); }
.snippet-item:nth-child(6) { animation-delay: calc(var(--stagger-delay) * 6); }
.snippet-item:nth-child(7) { animation-delay: calc(var(--stagger-delay) * 7); }
.snippet-item:nth-child(8) { animation-delay: calc(var(--stagger-delay) * 8); }
.snippet-item:nth-child(9) { animation-delay: calc(var(--stagger-delay) * 9); }
.snippet-item:nth-child(10) { animation-delay: calc(var(--stagger-delay) * 10); }
.snippet-item:nth-child(11) { animation-delay: calc(var(--stagger-delay) * 11); }
.snippet-item:nth-child(12) { animation-delay: calc(var(--stagger-delay) * 12); }
.snippet-item:nth-child(13) { animation-delay: calc(var(--stagger-delay) * 13); }
/* Additional items will fade in without delay */

/* Responsive adjustments */
@media (max-width: 992px) {
    .snippets-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .snippets-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .snippets-intro {
        margin: 30px 0;
    }
    
    .snippets-intro h1 {
        font-size: 1.3rem;
    }
    
    .snippets-intro p {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .snippets-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}