/* ==========================================================================
   MASTER BLOG STYLESHEET (css-blog.css)
   Organized: Single Post Layout, Comments, RTL, and Archive Grids
   ========================================================================== */

/* ==========================================================================
   1. SINGLE POST - LAYOUT OVERRIDES & ANIMATIONS
   ========================================================================== */

/* Aggressive Layout Overrides (Destroy Sidebars, Stray Meta, & Duplicate Images) */
.single-post .site.grid-container { max-width: 1440px !important; width: 100% !important; } 
.single-post .site-main { margin: 0 !important; }
.single-post .inside-article { padding: 0 !important; background: transparent !important; box-shadow: none !important; }

/* Hide all default theme elements we are replacing */
.single-post #left-sidebar, 
.single-post #right-sidebar, 
.single-post .keyhub-mobile-filter-btn,
.single-post header.entry-header, 
.single-post footer.entry-meta,
.single-post .cat-links,
.single-post .tags-links,
.single-post .featured-image, /* Kills the duplicate top image */
.single-post .page-header-image-single { /* Fallback for GeneratePress image wrappers */
    display: none !important; 
}

.single-post #primary { width: 100% !important; float: none !important; }

/* Animations */
@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   2. SINGLE POST - MASTER GRID & HEADER
   ========================================================================== */

/* The Main Grid (ENGLISH: Content Left, TOC Right) */
.kh-blog-master-grid {
    max-width: 1440px !important; /* Expanded for full width */
    margin: 50px auto 80px auto !important;
    padding: 0 40px !important;
    display: grid !important;
    grid-template-columns: 1fr 350px !important; /* Slightly wider TOC to balance the page */
    gap: 80px !important; /* Wider gap for breathability */
    align-items: start !important;
}

/* Reorder DOM elements via CSS to match the grid columns */
.kh-blog-main-content { order: 1 !important; }
.kh-blog-toc-sidebar { order: 2 !important; }

/* Header (Title, Date, Image) */
.kh-blog-main-title {
    font-size: 42px !important;
    font-weight: 900 !important;
    color: #2c3e50 !important;
    margin: 0 0 20px 0 !important;
    line-height: 1.2 !important;
    animation: slideUpFade 0.6s ease forwards;
}

.kh-blog-meta {
    margin-bottom: 35px !important;
    animation: slideUpFade 0.6s ease 0.1s forwards;
    opacity: 0;
}

.kh-date-badge {
    background: #f4f7f0 !important;
    color: #8db73b !important;
    padding: 6px 14px !important;
    border-radius: 6px !important;
    font-weight: 800 !important;
    font-size: 14px !important;
    display: inline-block !important;
}

.kh-blog-hero-img {
    width: 100% !important;
    margin-bottom: 50px !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    box-shadow: 0 15px 40px rgba(0,0,0,0.08) !important;
    border: 1px solid #eeeeee !important;
    animation: slideUpFade 0.6s ease 0.2s forwards;
    opacity: 0;
}
.kh-blog-hero-img img { width: 100% !important; height: auto !important; display: block !important; }


/* ==========================================================================
   3. SINGLE POST - STICKY TABLE OF CONTENTS
   ========================================================================== */

.kh-blog-toc-sidebar { position: relative !important; height: 100% !important; animation: slideUpFade 0.6s ease 0.3s forwards; opacity: 0; }
.kh-toc-sticky-box {
    position: sticky !important;
    top: 120px !important;
    background: #ffffff !important;
    border: 1px solid #eeeeee !important;
    border-top: 4px solid #8db73b !important;
    border-radius: 12px !important;
    padding: 30px 25px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03) !important;
}
.kh-toc-title { font-size: 18px !important; font-weight: 900 !important; color: #222 !important; margin: 0 0 20px 0 !important; text-transform: uppercase !important; }
.kh-toc-list { list-style: none !important; margin: 0 !important; padding: 0 !important; border-top: 1px solid #eee !important; padding-top: 15px !important; }
.kh-toc-list li { margin-bottom: 12px !important; }
.kh-toc-link { font-size: 14px !important; font-weight: 600 !important; color: #666 !important; text-decoration: none !important; transition: all 0.3s ease !important; display: block !important; line-height: 1.5 !important; }
.kh-toc-link:hover { color: #8db73b !important; transform: translateX(5px) !important; }


/* ==========================================================================
   4. SINGLE POST - TYPOGRAPHY & BRANDING
   ========================================================================== */

.kh-blog-main-content { background: transparent !important; padding: 0 !important; animation: slideUpFade 0.6s ease 0.3s forwards; opacity: 0; }

.kh-blog-main-content h2.kh-blog-h2 {
    font-size: 28px !important;
    font-weight: 900 !important;
    color: #2c3e50 !important;
    margin: 60px 0 25px 0 !important;
    padding-left: 18px !important;
    border-left: 5px solid #8db73b !important;
    line-height: 1.3 !important;
}
.kh-blog-main-content h2.kh-blog-h2:first-of-type { margin-top: 0 !important; }

.kh-blog-main-content h3, .kh-blog-main-content h4 { font-weight: 800 !important; color: #222 !important; margin: 30px 0 15px 0 !important; }

.kh-blog-main-content p { font-size: 17px !important; color: #4b5563 !important; line-height: 1.9 !important; margin-bottom: 25px !important; }
.kh-blog-main-content strong { color: #2c3e50 !important; font-weight: 800 !important; }
.kh-blog-main-content ul, .kh-blog-main-content ol { margin: 0 0 25px 20px !important; padding: 0 !important; }
.kh-blog-main-content li { font-size: 17px !important; color: #4b5563 !important; line-height: 1.9 !important; margin-bottom: 12px !important; }

.kh-blog-main-content figure.wp-block-image { margin: 40px 0 !important; text-align: center !important; }
.kh-blog-main-content .wp-block-image img { border-radius: 12px !important; box-shadow: 0 5px 25px rgba(0,0,0,0.06) !important; border: 1px solid #eeeeee !important; }


/* ==========================================================================
   5. SINGLE POST - COMMENTS SECTION
   ========================================================================== */

.comments-area {
    margin-top: 60px !important;
    padding-top: 50px !important;
    border-top: 2px dashed #eeeeee !important;
    animation: slideUpFade 0.6s ease 0.5s forwards;
    opacity: 0;
}
.comments-area .comments-title, .comments-area #reply-title {
    font-size: 24px !important;
    font-weight: 900 !important;
    color: #2c3e50 !important;
    margin-bottom: 20px !important;
    display: block !important;
}
.comments-area a { color: #8db73b !important; font-weight: 700 !important; text-decoration: none !important; }
#commentform textarea {
    width: 100% !important;
    border: 2px solid #eeeeee !important;
    border-radius: 12px !important;
    padding: 15px !important;
    font-family: inherit !important;
    font-size: 16px !important;
    transition: border-color 0.3s ease !important;
    background: #fdfdfd !important;
    box-sizing: border-box !important;
}
#commentform textarea:focus { border-color: #8db73b !important; outline: none !important; background: #ffffff !important; }
#commentform .submit {
    background: #8db73b !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    font-size: 16px !important;
    border-radius: 8px !important;
    padding: 15px 40px !important;
    border: none !important;
    margin-top: 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}
#commentform .submit:hover {
    background: #7ca332 !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 20px rgba(141, 183, 59, 0.3) !important;
}


/* ==========================================================================
   6. SINGLE POST - RTL (ARABIC) & MOBILE LOGIC
   ========================================================================== */

/* Arabic: TOC Left, Content Right */
html[dir="rtl"] .kh-blog-master-grid { grid-template-columns: 350px 1fr !important; }
html[dir="rtl"] .kh-blog-toc-sidebar { order: 1 !important; }
html[dir="rtl"] .kh-blog-main-content { order: 2 !important; }

/* Flip the Header Accent Line for Arabic */
html[dir="rtl"] .kh-blog-main-content h2.kh-blog-h2 {
    padding-left: 0 !important;
    padding-right: 18px !important;
    border-left: none !important;
    border-right: 5px solid #8db73b !important;
}

@media (max-width: 992px) {
    /* Mobile: Stack items vertically */
    .kh-blog-master-grid, html[dir="rtl"] .kh-blog-master-grid { grid-template-columns: 1fr !important; gap: 40px !important; }
    
    /* Mobile: Always force TOC to top, Content underneath */
    .kh-blog-toc-sidebar, html[dir="rtl"] .kh-blog-toc-sidebar { order: 1 !important; }
    .kh-blog-main-content, html[dir="rtl"] .kh-blog-main-content { order: 2 !important; }

    .kh-toc-sticky-box { position: static !important; margin-bottom: 20px !important; }
    .kh-blog-main-title { font-size: 32px !important; }
}

/* Supplemental RTL Adjustments */
html[dir="rtl"] .kh-blog-master-grid { 
    grid-template-columns: 1fr 350px !important; 
    direction: rtl !important;
}

html[dir="rtl"] .kh-blog-main-content { 
    order: 1 !important; 
    text-align: right !important;
}

html[dir="rtl"] .kh-blog-toc-sidebar { 
    order: 2 !important; 
    text-align: right !important;
}

html[dir="rtl"] .kh-blog-main-title,
html[dir="rtl"] .kh-blog-meta {
    text-align: right !important;
}

html[dir="rtl"] .kh-blog-main-content h2.kh-blog-h2 {
    padding-left: 0 !important;
    padding-right: 18px !important;
    border-left: none !important;
    border-right: 5px solid #8db73b !important;
    text-align: right !important;
}

html[dir="rtl"] .kh-blog-main-content ul, 
html[dir="rtl"] .kh-blog-main-content ol {
    margin: 0 20px 25px 0 !important;
}

@media (max-width: 992px) {
    .kh-blog-master-grid, 
    html[dir="rtl"] .kh-blog-master-grid { 
        grid-template-columns: 1fr !important; 
        gap: 40px !important; 
    }
    
    .kh-blog-toc-sidebar, 
    html[dir="rtl"] .kh-blog-toc-sidebar { 
        order: 1 !important; 
    }
    
    .kh-blog-main-content, 
    html[dir="rtl"] .kh-blog-main-content { 
        order: 2 !important; 
    }

    .kh-toc-sticky-box { 
        position: static !important; 
        margin-bottom: 20px !important; 
    }
}


/* ==========================================================================
   7. BLOG ARCHIVE - FULL WIDTH GRID
   ========================================================================== */

/* Disable Sidebar, Filters & Force 3 Columns (STRICTLY NON-SHOP) */
.blog #left-sidebar, .archive:not(.woocommerce-page) #left-sidebar,
.blog #right-sidebar, .archive:not(.woocommerce-page) #right-sidebar,
.blog .keyhub-mobile-filter-btn, .archive:not(.woocommerce-page) .keyhub-mobile-filter-btn {
    display: none !important;
}

.blog #primary, .archive:not(.woocommerce-page) #primary {
    width: 100% !important; /* Expands content to full width */
    float: none !important;
}

.blog .site-main, .archive:not(.woocommerce-page) .site-main {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* Forces 3 articles per row */
    gap: 30px !important;
}

/* Mobile override: stack into 1 column on phones */
@media (max-width: 768px) {
    .blog .site-main, .archive:not(.woocommerce-page) .site-main {
        grid-template-columns: 1fr !important;
    }
}


/* ==========================================================================
   8. BLOG ARCHIVE - CARDS & EQUAL HEIGHTS
   ========================================================================== */

.blog .site-main article,
.archive .site-main article {
    height: 100% !important;
    background: #fff !important; 
    border: 1px solid #eee !important; 
    border-radius: 16px !important;
    overflow: hidden !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03) !important;
}

/* Flexbox magic to control inner elements */
.blog .site-main article .inside-article,
.archive .site-main article .inside-article {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    padding: 0 !important;
}

/* Force the image to the very top */
.blog .site-main article .post-image,
.archive .site-main article .post-image {
    order: -1 !important; 
    margin: 0 !important;
}

.blog .site-main article .post-image img,
.archive .site-main article .post-image img {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
    object-fit: cover !important;
    border-radius: 16px 16px 0 0 !important;
}

.blog .site-main article .entry-header,
.archive .site-main article .entry-header {
    padding: 25px 25px 0 25px !important;
}

.blog .site-main article .entry-title,
.archive .site-main article .entry-title {
    font-size: 19px !important; 
    font-weight: 900 !important; 
    margin: 0 0 10px 0 !important; 
    line-height: 1.4 !important;
}

/* Force the text summary area to grow, pushing the 'Read More' to the bottom */
.blog .site-main article .entry-summary,
.archive .site-main article .entry-summary {
    padding: 15px 25px 25px 25px !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

.blog .site-main article .entry-summary p:last-of-type,
.archive .site-main article .entry-summary .read-more-container {
    margin-top: auto !important; /* Aligns 'Read More' links */
    padding-top: 15px !important;
}

.blog .site-main article .read-more,
.archive .site-main article .read-more {
    color: #8db73b !important; 
    font-weight: 800 !important;
}

/* Hide "General" meta footer */
.blog .site-main article footer.entry-meta,
.archive .site-main article footer.entry-meta {
    display: none !important;
}


/* ==========================================================================
   9. BLOG ARCHIVE - GAP REDUCTION & CLEANUP
   ========================================================================== */

/* Reduce the gap under the date/meta */
.blog .site-main article .entry-header,
.archive .site-main article .entry-header {
    margin-bottom: 0 !important;
    padding-bottom: 10px !important; 
}

.blog .site-main article .entry-summary,
.archive .site-main article .entry-summary {
    padding-top: 0 !important; 
}

/* Remove the default invisible top margin on the excerpt text */
.blog .site-main article .entry-summary p:first-of-type,
.archive .site-main article .entry-summary p:first-child {
    margin-top: 0 !important; 
}

/* Hide the "by [author]" text */
.blog .site-main article .entry-meta .byline,
.archive .site-main article .entry-meta .byline {
    display: none !important;
}


/* ==========================================================================
   10. BLOG ARCHIVE - FINAL ALIGNMENT TWEAKS
   ========================================================================== */

/* Kill invisible default margin below Date */
.blog .site-main article .entry-header .entry-meta,
.archive .site-main article .entry-header .entry-meta {
    margin-bottom: 0 !important; 
}

/* Set bottom padding to perfectly match top padding */
.blog .site-main article .entry-header,
.archive .site-main article .entry-header {
    padding-bottom: 25px !important; 
}

/* Ensure text box stays flush */
.blog .site-main article .entry-summary,
.archive .site-main article .entry-summary {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Force all titles to take up the exact same amount of space (up to 3 lines) */
.blog .site-main article .entry-title,
.archive .site-main article .entry-title {
    min-height: 85px !important; 
    margin-bottom: 10px !important; 
    display: block !important;
}