/* Trending Clusters - Innovative UI Styles */

.trending-cluster {
    position: relative;
    overflow: hidden;
}

.trending-cluster::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.9;
    z-index: -1;
}

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

.cluster-header {
    position: relative;
    z-index: 1;
}

.cluster-header h3 {
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.primary-blog {
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

.primary-blog:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.related-article-card {
    transition: all 0.2s ease;
    cursor: pointer;
}

.related-article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    background: rgba(255,255,255,1) !important;
}

.trending-clusters-container {
    position: relative;
}

.cluster-item {
    margin-bottom: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .trending-cluster {
        margin-bottom: 1.5rem;
        border-radius: 12px !important;
    }
    
    .cluster-header {
        padding: 1rem !important;
    }
    
    .cluster-header h3 {
        font-size: 1.1rem !important;
        line-height: 1.3 !important;
    }
    
    .cluster-header .flex {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }
    
    .cluster-header .flex > div:last-child {
        align-self: flex-end !important;
    }
    
    .primary-blog {
        margin-bottom: 0.75rem !important;
    }
    
    .primary-blog .flex {
        flex-direction: column !important;
    }
    
    .primary-blog .flex > div:first-child {
        padding: 1rem !important;
    }
    
    .primary-blog .flex > div:last-child {
        width: 100% !important;
        height: 180px !important;
        margin-top: 0 !important;
        order: -1 !important;
    }
    
    .primary-blog h4 {
        font-size: 1rem !important;
        line-height: 1.3 !important;
    }
    
    .primary-blog p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }
    
    .related-articles {
        padding: 0 1rem 1rem 1rem !important;
    }
    
    .related-articles h5 {
        font-size: 0.9rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .related-articles .grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    .related-article-card .flex {
        padding: 0.75rem !important;
    }
    
    .related-article-card .flex > div:first-child {
        width: 60px !important;
        height: 45px !important;
        margin-right: 0.75rem !important;
    }
    
    .related-article-card h6 {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.25rem !important;
    }
    
    .related-article-card .flex > div:last-child .flex {
        gap: 0.25rem !important;
    }
    
    .related-article-card .flex > div:last-child .flex span {
        font-size: 0.65rem !important;
        padding: 0.15rem 0.4rem !important;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .trending-cluster {
        margin-bottom: 1rem;
        border-radius: 8px !important;
    }
    
    .cluster-header {
        padding: 0.75rem !important;
    }
    
    .cluster-header h3 {
        font-size: 1rem !important;
    }
    
    .cluster-header .flex > div:last-child span {
        font-size: 0.7rem !important;
        padding: 0.2rem 0.5rem !important;
    }
    
    .primary-blog .flex > div:first-child {
        padding: 0.75rem !important;
    }
    
    .primary-blog .flex > div:last-child {
        height: 150px !important;
    }
    
    .primary-blog h4 {
        font-size: 0.9rem !important;
    }
    
    .primary-blog p {
        font-size: 0.8rem !important;
    }
    
    .related-articles {
        padding: 0 0.75rem 0.75rem 0.75rem !important;
    }
    
    .related-article-card .flex {
        padding: 0.5rem !important;
    }
    
    .related-article-card .flex > div:first-child {
        width: 50px !important;
        height: 40px !important;
        margin-right: 0.5rem !important;
    }
    
    .related-article-card h6 {
        font-size: 0.75rem !important;
    }
}

/* Tablet landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .trending-cluster {
        margin-bottom: 1.75rem;
    }
    
    .cluster-header {
        padding: 1.25rem !important;
    }
    
    .primary-blog .flex > div:first-child {
        padding: 1.25rem !important;
    }
    
    .primary-blog .flex > div:last-child {
        width: 180px !important;
        height: 135px !important;
    }
    
    .related-articles .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .trending-cluster:hover {
        transform: none;
    }
    
    .primary-blog:hover {
        transform: none;
    }
    
    .related-article-card:hover {
        transform: none;
    }
    
    .related-article-card:active {
        transform: scale(0.98);
    }
    
    .primary-blog:active {
        transform: scale(0.99);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .trending-cluster {
        box-shadow: 0 5px 15px rgba(0,0,0,0.08) !important;
    }
    
    .primary-blog {
        box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
    }
}

/* Dynamic Cluster Styles for News Cards */
.news-card {
    position: relative;
    transition: all 0.3s ease;
}

.news-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.cluster-container {
    border-top: 1px solid #eee;
    margin-top: 1rem;
    padding-top: 1rem;
}

.cluster-loading {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.9rem;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.mini-cluster {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1rem;
    border-left: 4px solid #007bff;
    transition: all 0.3s ease;
}

.mini-cluster:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.related-article-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: #fff;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
}

.related-article-item:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #007bff;
}

.related-article-item:last-child {
    margin-bottom: 0;
}

.related-article-item img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 0.75rem;
}

.related-article-item h6 {
    margin: 0 0 0.25rem 0;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.3;
}

.related-article-item h6 a {
    text-decoration: none;
    color: inherit;
}

.related-article-item h6 a:hover {
    color: #007bff;
}

.no-cluster {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #dee2e6;
}

/* Mobile optimizations for dynamic clusters */
@media (max-width: 768px) {
    .cluster-container {
        margin-top: 0.75rem;
        padding-top: 0.75rem;
    }
    
    .mini-cluster {
        padding: 0.75rem;
    }
    
    .related-article-item {
        padding: 0.5rem;
    }
    
    .related-article-item img {
        width: 50px;
        height: 40px;
        margin-right: 0.5rem;
    }
    
    .related-article-item h6 {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .cluster-container {
        margin-top: 0.5rem;
        padding-top: 0.5rem;
    }
    
    .mini-cluster {
        padding: 0.5rem;
    }
    
    .related-article-item {
        padding: 0.4rem;
    }
    
    .related-article-item img {
        width: 45px;
        height: 35px;
        margin-right: 0.4rem;
    }
    
    .related-article-item h6 {
        font-size: 0.75rem;
    }
}

/* Animation for cluster appearance */
@keyframes clusterFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cluster-content {
    animation: clusterFadeIn 0.4s ease-out;
}

/* Touch device optimizations for dynamic clusters */
@media (hover: none) and (pointer: coarse) {
    .news-card:hover {
        transform: none;
    }
    
    .mini-cluster:hover {
        transform: none;
    }
    
    .related-article-item:hover {
        transform: none;
    }
    
    .related-article-item:active {
        transform: scale(0.98);
        background: #f0f8ff;
    }
}

/* Animation for cluster loading */
@keyframes clusterFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cluster-item {
    animation: clusterFadeIn 0.6s ease-out;
}

.cluster-item:nth-child(1) { animation-delay: 0.1s; }
.cluster-item:nth-child(2) { animation-delay: 0.2s; }
.cluster-item:nth-child(3) { animation-delay: 0.3s; }
.cluster-item:nth-child(4) { animation-delay: 0.4s; }
.cluster-item:nth-child(5) { animation-delay: 0.5s; }

/* Badge styles */
.badge-trending {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24) !important;
    color: white !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}

.badge-latest {
    background: linear-gradient(45deg, #4ecdc4, #44a08d) !important;
    color: white !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
}

.badge-category {
    background: linear-gradient(45deg, #a8edea, #fed6e3) !important;
    color: #333 !important;
    font-weight: 500 !important;
}

/* Featured badge enhancement */
.primary-blog .badge-trending {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24) !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Gradient text effect for cluster themes */
.cluster-header h3 {
    background: linear-gradient(45deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Enhanced hover effects */
.trending-cluster:hover .cluster-header h3 {
    background: linear-gradient(45deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Loading state */
.trending-clusters-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: #666;
    font-style: italic;
}

.trending-clusters-loading::before {
    content: '🔄';
    margin-right: 0.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}