
/* Smart Post Grid CSS - Version 2.0 */
.smart-post-grid-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.smart-post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 768px) {
    .smart-post-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

.smart-post-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    margin: 0;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.smart-post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.12);
}

/* Smart image solution - maintains aspect ratio */
.post-card-inner {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 180px;
}

@media (max-width: 640px) {
    .post-card-inner {
        flex-direction: column;
        min-height: auto;
    }
}

.post-image-container {
    flex: 0 0 40%;
    min-width: 0;
    position: relative;
    overflow: hidden;
}

.post-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 180px;
}

.image-link {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.smart-post-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Maintain aspect ratio on mobile */
@media (max-width: 640px) {
    .post-image-container {
        flex: none;
        height: 220px;
    }
    
    .post-image-wrapper {
        height: 100%;
        min-height: 220px;
    }
    
    .smart-post-image {
        object-fit: cover;
        height: 100%;
    }
}

/* On larger screens, use contain for full image display */
@media (min-width: 1024px) {
    .smart-post-image {
        object-fit: contain;
        object-position: left center;
        padding: 10px;
        background: #f8f9fa;
    }
    
    .default-image {
        object-fit: cover;
    }
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, transparent 30%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.smart-post-card:hover .image-overlay {
    opacity: 1;
}

.smart-post-card:hover .smart-post-image {
    transform: scale(1.05);
}

.post-content-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.post-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    flex: 1;
}

.post-title {
    margin: 0 0 12px 0;
    font-size: 1.15rem;
    line-height: 1.4;
    font-weight: 600;
    color: #1a1a1a;
}

.post-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
    display: block;
}

.post-title a:hover {
    color: #2563eb;
}

.post-excerpt {
    margin: 0 0 15px 0;
    flex-grow: 0;
}

.post-excerpt p {
    margin: 0;
    color: #4b5563;
    font-size: 0.9rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.read-more-btn {
    margin-top: auto;
    padding-top: 10px;
}

.btn-read-more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #2563eb;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-read-more:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.btn-read-more:active {
    transform: translateY(0);
}

.btn-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.btn-read-more:hover .btn-arrow {
    transform: translateX(3px);
}

.no-posts-found {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    margin: 20px 0;
}

/* Loading animation */
.smart-post-grid {
    animation: smartFadeIn 0.5s ease-out;
}

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

/* Responsive image sizes with srcset */
@media (max-width: 480px) {
    .smart-post-grid-container {
        padding: 0 12px;
    }
    
    .smart-post-grid {
        gap: 12px;
    }
    
    .post-content {
        padding: 16px;
    }
    
    .post-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .post-excerpt p {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .post-image-container {
        height: 200px;
    }
    
    .post-image-wrapper {
        min-height: 200px;
    }
}

/* Tablet optimization */
@media (min-width: 641px) and (max-width: 1024px) {
    .smart-post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .post-image-container {
        flex: 0 0 180px;
    }
    
    .smart-post-image {
        object-fit: cover;
    }
}

/* Desktop optimization */
@media (min-width: 1025px) {
    .smart-post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
    
    .post-card-inner {
        min-height: 200px;
    }
    
    .post-image-container {
        flex: 0 0 200px;
    }
}

/* Accessibility improvements */
.smart-post-card:focus-within {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .smart-post-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .smart-post-card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .btn-read-more {
        display: none !important;
    }
}
