/* Masonry Layout CSS for Homepage Products */

.masonry-container {
    column-count: 4;
    column-gap: 20px;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 15px;
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: 20px;
    display: block;
    position: relative;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.masonry-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.masonry-item a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.masonry-item:hover img {
    transform: scale(1.05);
}

.masonry-item h3,
.masonry-item h4 {
    padding: 15px 15px 10px 15px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: #333;
    min-height: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.masonry-item h3 a,
.masonry-item h4 a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.masonry-item h3 a:hover,
.masonry-item h4 a:hover {
    color: #007bff;
}

.masonry-item .price {
    padding: 0 15px 15px 15px;
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #007bff;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .masonry-container {
        column-count: 3;
        column-gap: 15px;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    .masonry-container {
        column-count: 2;
        column-gap: 10px;
        padding: 0 5px;
    }
    
    .masonry-item h3,
    .masonry-item h4 {
        font-size: 13px;
        padding: 10px 10px 8px 10px;
    }
    
    .masonry-item .price {
        font-size: 13px;
        padding: 0 10px 10px 10px;
    }
}

@media (max-width: 480px) {
    .masonry-container {
        column-count: 1;
        column-gap: 10px;
        padding: 0 5px;
    }
    
    .masonry-item {
        margin-bottom: 15px;
    }
}

/* Loading animation for masonry items */
.masonry-item {
    animation: fadeInUp 0.6s ease-out;
    will-change: transform;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Optimize performance */
.masonry-container {
    will-change: auto;
    transform: translateZ(0);
}

/* Stagger animation for items */
.masonry-item:nth-child(1) { animation-delay: 0.1s; }
.masonry-item:nth-child(2) { animation-delay: 0.2s; }
.masonry-item:nth-child(3) { animation-delay: 0.3s; }
.masonry-item:nth-child(4) { animation-delay: 0.4s; }
.masonry-item:nth-child(5) { animation-delay: 0.5s; }
.masonry-item:nth-child(6) { animation-delay: 0.6s; }
.masonry-item:nth-child(7) { animation-delay: 0.7s; }
.masonry-item:nth-child(8) { animation-delay: 0.8s; }
.masonry-item:nth-child(9) { animation-delay: 0.9s; }
.masonry-item:nth-child(10) { animation-delay: 1.0s; }
.masonry-item:nth-child(11) { animation-delay: 1.1s; }
.masonry-item:nth-child(12) { animation-delay: 1.2s; }
.masonry-item:nth-child(13) { animation-delay: 1.3s; }
.masonry-item:nth-child(14) { animation-delay: 1.4s; }
.masonry-item:nth-child(15) { animation-delay: 1.5s; }
.masonry-item:nth-child(16) { animation-delay: 1.6s; }
.masonry-item:nth-child(17) { animation-delay: 1.7s; }
.masonry-item:nth-child(18) { animation-delay: 1.8s; }
.masonry-item:nth-child(19) { animation-delay: 1.9s; }
.masonry-item:nth-child(20) { animation-delay: 2.0s; }

/* Video Masonry Layout CSS */
.video-masonry-container {
    column-count: 3;
    column-gap: 20px;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 15px;
}

.video-masonry-item {
    break-inside: avoid;
    margin-bottom: 20px;
    display: block;
    position: relative;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.video-masonry-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.video-masonry-item .image {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    overflow: hidden;
}

.video-masonry-item .image a {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9;
}

.video-masonry-item .image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-masonry-item:hover .image img {
    transform: scale(1.08);
}

.video-masonry-item .image .video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.video-masonry-item .image .video-container.active {
    z-index: 10;
    opacity: 1;
    visibility: visible;
}

.video-masonry-item .image .video-container iframe,
.video-masonry-item .image .video-container object,
.video-masonry-item .image .video-container embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-masonry-item .info {
    padding: 15px;
}

.video-masonry-item .info h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-masonry-item .info h3 a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.video-masonry-item .info h3 a:hover {
    color: #007bff;
}

.video-masonry-item .info p.view {
    color: #666;
    font-size: 13px;
    margin: 0 0 5px 0;
}

.video-masonry-item .info p.user {
    color: #666;
    font-size: 13px;
    margin: 0 0 8px 0;
}

.video-masonry-item .info p.user i {
    margin-right: 5px;
    color: #007bff;
}

.video-masonry-item .info p.content {
    color: #999;
    font-size: 13px;
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Video Masonry Responsive Design */
@media (max-width: 1200px) {
    .video-masonry-container {
        column-count: 3;
        column-gap: 15px;
        padding: 0 10px;
    }
}

@media (max-width: 768px) {
    .video-masonry-container {
        column-count: 2;
        column-gap: 10px;
        padding: 0 5px;
    }
    
    .video-masonry-item .info {
        padding: 12px;
    }
    
    .video-masonry-item .info h3 {
        font-size: 14px;
    }
    
    .video-masonry-item .info p.view,
    .video-masonry-item .info p.user,
    .video-masonry-item .info p.content {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .video-masonry-container {
        column-count: 1;
        column-gap: 10px;
        padding: 0 5px;
    }
    
    .video-masonry-item {
        margin-bottom: 15px;
    }
    
    .video-masonry-item .info {
        padding: 10px;
    }
}

/* Video Masonry Animation */
.video-masonry-item {
    animation: fadeInUp 0.6s ease-out;
    will-change: transform;
}

/* Stagger animation for video items */
.video-masonry-item:nth-child(1) { animation-delay: 0.1s; }
.video-masonry-item:nth-child(2) { animation-delay: 0.2s; }
.video-masonry-item:nth-child(3) { animation-delay: 0.3s; }
.video-masonry-item:nth-child(4) { animation-delay: 0.4s; }
.video-masonry-item:nth-child(5) { animation-delay: 0.5s; }
.video-masonry-item:nth-child(6) { animation-delay: 0.6s; }
.video-masonry-item:nth-child(7) { animation-delay: 0.7s; }
.video-masonry-item:nth-child(8) { animation-delay: 0.8s; }
.video-masonry-item:nth-child(9) { animation-delay: 0.9s; }
.video-masonry-item:nth-child(10) { animation-delay: 1.0s; }
.video-masonry-item:nth-child(11) { animation-delay: 1.1s; }
.video-masonry-item:nth-child(12) { animation-delay: 1.2s; } 