/* Merthopia Blog Preview Widget CSS */

.merthopia-react-blog-preview {
    --wpbp-gray-50: #f9fafb;
    --wpbp-gray-100: #f3f4f6;
    --wpbp-gray-200: #e5e7eb;
    --wpbp-gray-300: #d1d5db;
    --wpbp-gray-400: #9ca3af;
    --wpbp-gray-500: #6b7280;
    --wpbp-gray-600: #4b5563;
    --wpbp-gray-900: #111827;
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--wpbp-gray-900);
}

.merthopia-react-blog-preview * {
    box-sizing: border-box;
}

/* Skeleton Loading (Immediate Flash) */
@keyframes wpbp-spin { to { transform: rotate(360deg); } }
@keyframes wpbp-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.wp-skeleton {
    background: var(--wpbp-gray-50);
    border-radius: 12px;
    width: 100%;
}

.wp-skeleton-header {
    background: white;
    border-bottom: 1px solid var(--wpbp-gray-200);
    padding: 32px 24px;
}

.wp-skeleton-line {
    background: var(--wpbp-gray-100);
    border-radius: 6px;
    margin-bottom: 12px;
}
.wp-skeleton-line.short { height: 40px; width: max(120px, 30%); }
.wp-skeleton-line.long { height: 18px; width: max(280px, 60%); }

.wp-skeleton-tags { margin-top: 40px; display: flex; gap: 12px; }
.wp-skeleton-pill { height: 38px; width: 60px; background: var(--wpbp-gray-100); border-radius: 99px; }
.wp-skeleton-pill.w-large { width: 100px; }

.wp-skeleton-spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 0;
    gap: 20px;
}

.wp-spinner-init {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(0, 0, 0, 0.05);
    border-top-color: var(--wpbp-gray-400); /* Will be overridden by React inline block */
    border-radius: 50%;
    animation: wpbp-spin 0.8s linear infinite;
}

.wp-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 32px;
    padding: 0 24px 48px;
    opacity: 0.3;
}

.skeleton-card {
    height: 400px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--wpbp-gray-200);
    animation: wpbp-pulse 1.5s infinite ease-in-out;
}

/* React App CSS */
.wpbp-app-wrapper {
    background: var(--wpbp-gray-50);
    border-radius: 12px;
    border: 1px solid var(--wpbp-gray-200);
    overflow: hidden;
    opacity: 0;
    animation: wpbpFadeIn 0.3s ease-in forwards;
}

@keyframes wpbpFadeIn { to { opacity: 1; } }

.wpbp-header { background: white; border-bottom: 1px solid var(--wpbp-gray-200); }
.wpbp-container { padding: 32px 24px; }
@media (min-width: 768px) { .wpbp-container { padding: 40px; } }

.wpbp-header-top {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
@media (min-width: 768px) {
    .wpbp-header-top { flex-direction: row; justify-content: space-between; align-items: center; }
}

.wpbp-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}
@media (min-width: 768px) { .wpbp-title { font-size: 36px; } }

.wpbp-subtitle {
    margin: 0;
    color: var(--wpbp-gray-500);
    font-size: 14px;
}
@media (min-width: 768px) { .wpbp-subtitle { font-size: 16px; } }

.wpbp-search-container {
    position: relative;
    width: 100%;
}
@media (min-width: 768px) { .wpbp-search-container { width: 320px; } }

.wpbp-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wpbp-gray-400);
}

.wpbp-search-input {
    width: 100%;
    padding: 10px 16px 10px 44px !important;
    border: 1px solid var(--wpbp-gray-300);
    border-radius: 12px;
    background: var(--wpbp-gray-50);
    font-size: 14px;
    transition: all 0.2s;
}
.wpbp-search-input:focus {
    outline: none;
    background: white;
    border-color: var(--wpbp-gray-400);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.wpbp-header-bottom {
    margin-top: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.wpbp-categories {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none; /* Firefox */
}
.wpbp-categories::-webkit-scrollbar { display: none; }

.wpbp-cat-btn {
    padding: 8px 16px;
    border-radius: 99px;
    border: 1px solid var(--wpbp-gray-200);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.wpbp-cat-btn:hover:not(.wpbp-cat-active) { background: var(--wpbp-gray-100); }
.wpbp-cat-active { border-color: transparent; }

.wpbp-view-toggles {
    display: none;
    background: var(--wpbp-gray-100);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid var(--wpbp-gray-200);
    flex-shrink: 0;
}
@media (min-width: 640px) { .wpbp-view-toggles { display: flex; gap: 4px; } }

.wpbp-view-btn {
    padding: 6px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--wpbp-gray-500);
    cursor: pointer;
    transition: all 0.2s;
}
.wpbp-view-btn.wpbp-view-active {
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.wpbp-view-btn:hover:not(.wpbp-view-active) { color: var(--wpbp-gray-900); }

.wpbp-main { padding: 48px 24px; }
@media (min-width: 768px) { .wpbp-main { padding: 48px 40px; } }

.wpbp-loading, .wpbp-error, .wpbp-empty {
    text-align: center;
    padding: 80px 20px;
    background: white;
    border-radius: 24px;
    border: 1px solid var(--wpbp-gray-200);
}
.wpbp-error { color: #dc2626; font-weight: 500; }
.wpbp-empty h3 { margin: 0; font-size: 20px; font-weight: 700; }

.wpbp-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--wpbp-gray-100);
    border-radius: 50%;
    animation: wpbp-spin 0.8s linear infinite;
    margin: 0 auto;
}

.wpbp-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid var(--wpbp-gray-200);
    border-radius: 50%;
    animation: wpbp-spin 0.8s linear infinite;
}

/* Grids vs Lists */
.wpbp-posts-container { display: flex; flex-direction: column; gap: 32px; }
.wpbp-grid { 
    display: grid; 
    grid-template-columns: repeat(1, 1fr); 
    gap: 32px; 
}
@media (min-width: 768px) { .wpbp-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .wpbp-grid { grid-template-columns: repeat(3, 1fr); } }

.wpbp-card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--wpbp-gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}
.wpbp-card:hover {
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.wpbp-card-image {
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background-size: cover;
    background-position: center;
    background-color: var(--wpbp-gray-100);
    transition: transform 0.5s ease;
}
.wpbp-card:hover .wpbp-card-image { transform: scale(1.05); }

.wpbp-card-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 24px;
    z-index: 2;
    background: white;
}

.wpbp-list .wpbp-card { flex-direction: column; }
@media (min-width: 640px) {
    .wpbp-list .wpbp-card { flex-direction: row; }
    .wpbp-list .wpbp-card-image { 
        width: 40%; 
        padding-top: 0;
        min-height: 240px; 
    }
}

.wpbp-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--wpbp-gray-600);
    margin-bottom: 12px;
}
.wpbp-meta-item { display: flex; align-items: center; gap: 6px; }

.wpbp-card-title-link {
    text-decoration: none;
    color: var(--wpbp-gray-900);
    margin-bottom: 12px;
    display: block;
}
.wpbp-card-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}
.wpbp-card-title-link:hover .wpbp-card-title { color: inherit; opacity: 0.8; } /* Inherit accent color eventually if needed, simple opacity hover for now */

.wpbp-card-excerpt {
    font-size: 14px;
    line-height: 1.6;
    color: var(--wpbp-gray-600);
    margin: 0 0 24px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wpbp-card-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--wpbp-gray-100);
}

.wpbp-read-more {
    display: inline-flex;
    align-items: center;
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: filter 0.2s;
}
.wpbp-read-more:hover { filter: brightness(1.1); }
.wpbp-ml-2 { margin-left: 8px; }

.wpbp-load-more {
    display: flex;
    justify-content: center;
    margin-top: 48px;
}

.wpbp-btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: 2px solid;
    padding: 12px 32px;
    border-radius: 99px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}
.wpbp-btn-load-more:not(:disabled):hover {
    background-color: currentColor;
    color: white !important;
}

.wpbp-btn-load-more.wpbp-loading-more {
    border-color: var(--wpbp-gray-200) !important;
    color: var(--wpbp-gray-400) !important;
    background: var(--wpbp-gray-50);
    cursor: not-allowed;
}

.wpbp-icon-sm { width: 16px; height: 16px; }
.wpbp-icon-xs { width: 14px; height: 14px; }
