/*
 * Snippets Page Styles
 * Clean masonry grid with refined interactions
 */

/* Snippets Wrapper */
.snippets-wrapper {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--page-padding);
}

/* Page Header */
.snippets-header {
    padding: var(--space-3xl) 0 var(--space-xl);
    text-align: left;
}

.snippets-header h1 {
    font-size: var(--text-section);
    font-weight: 400;
    margin-bottom: var(--space-sm);
    letter-spacing: -0.02em;
}

.snippets-header p {
    color: var(--color-text-secondary);
    font-size: var(--text-lg);
    line-height: 1.5;
    max-width: 600px;
}

/* Masonry Grid Layout */
.snippets-grid {
    column-count: 4;
    column-gap: 24px;
    padding: var(--space-xl) 0 var(--space-4xl);
}

/* Snippet Item */
.snippet-item {
    break-inside: avoid;
    margin-bottom: 24px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background-color: var(--color-surface);
    border-radius: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease, box-shadow var(--duration-medium);
}

.snippet-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.snippet-item:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* Featured items */
.snippet-item.featured {
    transform: scale(1);
}

.snippet-item.featured.visible {
    transform: scale(1.01);
}

/* First frame loaded state */
.snippet-item.first-frame-loaded {
    background-color: var(--color-surface);
}

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

/* Video Styling */
.snippet-video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    filter: grayscale(100%) brightness(0.4);
    transition: filter 0.5s ease;
}

/* Hover/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: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--color-text-muted);
    border-radius: 50%;
    animation: snippet-loader 0.8s linear infinite;
    z-index: 2;
}

.snippet-item.first-frame-loaded.loading::before {
    border: 2px solid rgba(0, 0, 0, 0.05);
    border-top-color: var(--color-text-secondary);
}

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

/* Play indicator overlay */
.snippet-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--duration-medium), transform var(--duration-medium);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%231a1a1a'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px;
}

.snippet-item:hover::after {
    opacity: 1;
    transform: scale(1);
}

.snippet-item.playing::after {
    opacity: 0;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 1200px) {
    .snippets-grid {
        column-count: 3;
        column-gap: 20px;
    }
}

@media (max-width: 992px) {
    .snippets-grid {
        column-count: 3;
        column-gap: 16px;
    }

    .snippet-item {
        margin-bottom: 16px;
    }

    .snippets-header {
        padding: var(--space-2xl) 0 var(--space-lg);
    }
}

@media (max-width: 768px) {
    .snippets-grid {
        column-count: 2;
        column-gap: 12px;
        padding: var(--space-lg) 0 var(--space-3xl);
    }

    .snippet-item {
        margin-bottom: 12px;
        border-radius: 6px;
    }

    .snippets-header h1 {
        font-size: var(--text-lg);
    }

    .snippets-header p {
        font-size: var(--text-base);
    }

    /* Hide play indicator on mobile */
    .snippet-item::after {
        display: none;
    }
}

@media (max-width: 480px) {
    .snippets-grid {
        column-count: 1;
        column-gap: 0;
    }

    .snippet-item {
        margin-bottom: 16px;
    }

    .snippets-header {
        padding: var(--space-xl) 0 var(--space-md);
    }
}
