/**
 * Custom Post Grid Stylesheet
 * Premium, clean, responsive grid layout and card design
 */

:root {
    --cpg-primary-color: #6366f1; /* Indigo */
    --cpg-primary-hover: #4f46e5;
    --cpg-text-main: #1f2937; /* Dark slate */
    --cpg-text-muted: #6b7280; /* Gray */
    --cpg-bg-card: #ffffff;
    --cpg-border-color: rgba(229, 231, 235, 0.8);
    --cpg-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --cpg-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --cpg-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --cpg-radius: 12px;
    --cpg-transition-speed: 0.3s;
}

/* Grid Layouts using CSS Grid with auto-fit fallback */
.custom-post-grid {
    display: grid;
    gap: 18px;
    width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); /* Fallback: automatically fit columns if class mismatches */
}

/* Equal Heights setup for child items */
.custom-post-grid * {
    box-sizing: border-box;
}

/* Desktop-First Columns configuration */
.custom-post-grid-cols-1 {
    grid-template-columns: 1fr;
}

.custom-post-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.custom-post-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.custom-post-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive adjustments using Max-Width */
@media (max-width: 900px) {
    .custom-post-grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 680px) {
    .custom-post-grid-cols-3,
    .custom-post-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .custom-post-grid-cols-2,
    .custom-post-grid-cols-3,
    .custom-post-grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

/* Card Styling */
.custom-post-grid-item {
    background: var(--cpg-bg-card);
    border: 1px solid var(--cpg-border-color);
    border-radius: var(--cpg-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: var(--cpg-shadow-sm);
    transition: transform var(--cpg-transition-speed) cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow var(--cpg-transition-speed) ease,
                border-color var(--cpg-transition-speed) ease;
}

/* Zoom Hover Effect on Card */
.custom-post-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--cpg-shadow-hover);
    border-color: rgba(99, 102, 241, 0.3);
}

/* Thumbnail wrapper */
.custom-post-grid-image {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
    background-color: #f3f4f6;
}

.custom-post-grid-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.custom-post-grid-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-post-grid-item:hover .custom-post-grid-thumbnail {
    transform: scale(1.05);
}

/* Card Body */
.custom-post-grid-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Pushes the footer button container to the bottom */
}

/* Post Title */
.custom-post-grid-title {
    margin: 0 0 10px 0;
    font-size: 1.15rem;
    line-height: 1.4;
    font-weight: 600;
}

.custom-post-grid-title a {
    color: var(--cpg-text-main);
    text-decoration: none;
    transition: color var(--cpg-transition-speed) ease;
}

.custom-post-grid-title a:hover {
    color: var(--cpg-primary-color);
}

/* Categories / Terms List */
.custom-post-grid-terms {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.custom-post-grid-terms a {
    color: #c2410c; /* Warm orange-red/rust */
    text-decoration: none;
    transition: color var(--cpg-transition-speed) ease;
}

.custom-post-grid-terms a:hover {
    color: #9a3412;
}

/* Excerpt text */
.custom-post-grid-excerpt {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--cpg-text-muted);
    margin-bottom: 12px;
    flex-grow: 1; /* Fills remaining space, ensuring height uniformity */
}

/* Card Footer (Date container) */
.custom-post-grid-footer {
    margin-top: auto; /* Forces date to the absolute bottom of the card body */
    padding-top: 0;
}

/* Date Styling */
.custom-post-grid-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--cpg-text-main);
}

/* No posts found styling */
.custom-post-grid-no-posts {
    padding: 30px;
    background: rgba(243, 244, 246, 0.5);
    border: 1px dashed var(--cpg-border-color);
    border-radius: var(--cpg-radius);
    text-align: center;
    color: var(--cpg-text-muted);
    font-style: italic;
    width: 100%;
}
