/**
 * MagicBlog Theme Compatibility CSS
 * 
 * Fixes for popular WordPress themes to ensure perfect integration
 * 
 * @package Magic_Blog
 * @version 1.0.0
 */

/* ==========================================================================
   ASTRA THEME COMPATIBILITY
   ========================================================================== */

.theme-astra .magicblog-post-grid {
    /* Fix Astra's default grid conflicts */
    margin: 0 !important;
    padding: 0 !important;
}

.theme-astra .magicblog-post-grid .post-item {
    /* Ensure consistent spacing with Astra's content */
    margin-bottom: 2em;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.theme-astra .magicblog-rating .star {
    /* Fix star color inheritance from Astra */
    color: #fbbf24 !important;
    text-decoration: none;
}

.theme-astra .magicblog-engagement-buttons {
    /* Align with Astra's button styling */
    font-family: inherit;
    margin-top: 1.5em;
}

.theme-astra .magicblog-views-counter {
    /* Match Astra's meta styling */
    font-size: 0.9em;
    color: #757575;
    font-family: inherit;
}

/* ==========================================================================
   OCEANWP THEME COMPATIBILITY
   ========================================================================== */

.theme-oceanwp .magicblog-post-grid {
    /* Fix OceanWP's container conflicts */
    width: 100%;
    max-width: none;
}

.theme-oceanwp .magicblog-post-grid .post-item {
    /* Match OceanWP's card styling */
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 30px;
}

.theme-oceanwp .magicblog-post-slider {
    /* Fix OceanWP margin conflicts */
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.theme-oceanwp .magicblog-rating {
    /* Improve star visibility on OceanWP */
    background: rgba(255,255,255,0.9);
    padding: 8px 12px;
    border-radius: 4px;
    display: inline-block;
}

.theme-oceanwp .magicblog-carousel-container {
    /* Fix OceanWP's overflow issues */
    overflow: visible;
    position: relative;
}

/* ==========================================================================
   GENERATEPRESS THEME COMPATIBILITY
   ========================================================================== */

.theme-generatepress .magicblog-post-grid {
    /* Align with GeneratePress spacing */
    margin-bottom: 40px;
}

.theme-generatepress .magicblog-post-grid .post-item {
    /* Match GeneratePress article styling */
    margin-bottom: 2.5em;
    padding: 0;
    border: none;
}

.theme-generatepress .magicblog-post-grid .post-title {
    /* Inherit GeneratePress heading styles */
    font-family: inherit;
    font-weight: inherit;
    color: inherit;
    line-height: 1.3;
}

.theme-generatepress .magicblog-engagement-buttons button {
    /* Match GeneratePress button styling */
    border-radius: 3px;
    font-family: inherit;
    font-weight: normal;
}

.theme-generatepress .magicblog-views-counter {
    /* Align with GeneratePress meta */
    font-size: 85%;
    color: #666;
}

/* ==========================================================================
   KADENCE THEME COMPATIBILITY
   ========================================================================== */

.theme-kadence .magicblog-post-grid {
    /* Fix Kadence grid system conflicts */
    display: grid;
    gap: 2rem;
}

.theme-kadence .magicblog-post-grid .post-item {
    /* Match Kadence's modern card design */
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.theme-kadence .magicblog-post-grid .post-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.theme-kadence .magicblog-carousel-container {
    /* Fix Kadence carousel spacing */
    margin: 0 -15px;
}

.theme-kadence .magicblog-carousel-container .carousel-slide {
    padding: 0 15px;
}

.theme-kadence .magicblog-rating .star {
    /* Improve star sizing for Kadence */
    font-size: 1.2em;
    margin: 0 2px;
}

/* ==========================================================================
   TWENTY TWENTY-FOUR THEME COMPATIBILITY
   ========================================================================== */

.theme-twentytwentyfour .magicblog-post-grid {
    /* Align with Twenty Twenty-Four's modern styling */
    gap: clamp(1rem, 3vw, 2rem);
}

.theme-twentytwentyfour .magicblog-post-grid .post-item {
    /* Match block theme styling */
    background: var(--wp--preset--color--base, #fff);
    border: 1px solid var(--wp--preset--color--contrast-2, #e0e0e0);
    border-radius: 8px;
    padding: 1.5rem;
}

.theme-twentytwentyfour .magicblog-post-grid .post-title {
    /* Use theme typography */
    font-size: var(--wp--preset--font-size--large, 1.5rem);
    line-height: var(--wp--custom--line-height--heading, 1.3);
    color: var(--wp--preset--color--contrast, #000);
}

.theme-twentytwentyfour .magicblog-engagement-buttons {
    /* Modern button styling for block theme */
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.theme-twentytwentyfour .magicblog-engagement-buttons button {
    border-radius: 6px;
    border: 1px solid var(--wp--preset--color--contrast-3, #ccc);
    background: var(--wp--preset--color--base, #fff);
    color: var(--wp--preset--color--contrast, #000);
}

/* ==========================================================================
   UNIVERSAL RESPONSIVE FIXES
   ========================================================================== */

/* Mobile optimizations for all themes */
@media (max-width: 768px) {
    .magicblog-post-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .magicblog-post-slider .carousel-slide {
        padding: 0 10px;
    }
    
    .magicblog-engagement-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .magicblog-engagement-buttons button {
        width: 100%;
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .magicblog-rating {
        display: flex;
        justify-content: center;
        padding: 10px;
    }
    
    .magicblog-views-counter {
        text-align: center;
        padding: 8px;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .magicblog-post-grid[data-columns="3"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .magicblog-post-grid[data-columns="4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .magicblog-post-slider[data-slides="3"] .carousel-slide {
        width: 50% !important;
    }
}

/* ==========================================================================
   HIGH CONTRAST & ACCESSIBILITY FIXES
   ========================================================================== */

/* Ensure sufficient contrast for all themes */
@media (prefers-contrast: high) {
    .magicblog-rating .star {
        color: #000 !important;
        text-shadow: 1px 1px 0 #fff;
    }
    
    .magicblog-engagement-buttons button {
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }
    
    .magicblog-views-counter {
        color: #000 !important;
        font-weight: bold;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .magicblog-post-grid .post-item {
        background: #1a1a1a;
        border-color: #333;
        color: #fff;
    }
    
    .magicblog-engagement-buttons button {
        background: #333;
        border-color: #555;
        color: #fff;
    }
    
    .magicblog-views-counter {
        color: #ccc;
    }
}

/* ==========================================================================
   RTL (RIGHT-TO-LEFT) SUPPORT
   ========================================================================== */

[dir="rtl"] .magicblog-post-grid {
    direction: rtl;
}

[dir="rtl"] .magicblog-engagement-buttons {
    flex-direction: row-reverse;
}

[dir="rtl"] .magicblog-rating {
    direction: ltr; /* Stars should remain left-to-right */
}

[dir="rtl"] .magicblog-carousel-nav-prev {
    right: auto;
    left: 10px;
}

[dir="rtl"] .magicblog-carousel-nav-next {
    left: auto;
    right: 10px;
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* Use will-change for animations */
.magicblog-post-grid .post-item:hover,
.magicblog-carousel-slide,
.magicblog-rating .star:hover {
    will-change: transform;
}

/* Optimize font rendering */
.magicblog-post-grid,
.magicblog-engagement-buttons,
.magicblog-rating {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* GPU acceleration for smooth animations */
.magicblog-carousel-container,
.magicblog-post-grid .post-item {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .magicblog-engagement-buttons,
    .magicblog-carousel-nav,
    .magicblog-rating {
        display: none !important;
    }
    
    .magicblog-post-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .magicblog-post-grid .post-item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}