/*
 * Styles for the Single Blog Post Template (single.php)
 * VERSION 5.0: Fixed Sticky Sidebar (Final)
 */

/* ==========================================================================
   1. LAYOUT CONTAINERS
   ========================================================================== */

/* A. Default Layout with Sidebar */
.py-blog-container { 
    display: flex; 
    gap: 40px; 
    margin-top: 30px; 
    margin-bottom: 30px;
    /* Critical: Ensures sidebar doesn't stretch to full height of post */
    align-items: flex-start; 
    position: relative;
    overflow: visible !important; /* Ensure no overflow hides sticky */
}

.py-blog-container .blog-post-full { 
    flex: 1; 
    min-width: 0; /* Prevents flex item from overflowing */
    width: 100%; /* Ensure it takes available space */
}

/* 
 * STICKY SIDEBAR FIX 
 */
.sidebar-sticky-wrapper {
    width: 300px; 
    flex-shrink: 0;
    /* Sticky Positioning */
    position: -webkit-sticky;
    position: sticky;
    
    /* UPDATED: Reduced top gap because header is no longer sticky */
    top: 20px; 
    
    z-index: 99;
    height: auto; 
    align-self: flex-start;
}

/* Adjust top offset if admin bar is showing */
body.admin-bar .sidebar-sticky-wrapper {
    top: 52px; /* 20px + 32px (Admin Bar) */
}


/* The actual sidebar inside the wrapper */
.py-blog-container .blog-sidebar { 
    width: 100%; 
}


/* B. True Full-Width Layout (No Container, No Sidebar) - DESKTOP ONLY */
.py-single-post-container-full { 
    max-width: 100% !important; 
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.py-single-post-container-full .blog-post-full {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 60px 0;
    background: var(--py-card-bg);
    position: relative;
}

.py-single-post-container-full .blog-post-full > article {
    max-width: min(100%, 1400px);
    margin: 0 auto;
    padding: 0 40px;
}

/* ==========================================================================
   2. FULL WIDTH SPECIFIC ELEMENTS (DESKTOP)
   ========================================================================== */

.py-single-post-container-full .blog-breadcrumbs-wrapper {
    max-width: min(100%, 1400px);
    margin: 0 auto 20px auto;
    padding: 0 40px;
}

.py-single-post-container-full .entry-header {
    max-width: min(100%, 1400px);
    margin: 0 auto 30px auto;
    padding: 0 40px 20px 40px;
    border-bottom: 1px solid var(--py-border-color);
}

.py-single-post-container-full .post-thumbnail {
    max-width: 100vw;
    width: 100vw;
    margin: 40px calc(-50vw + 50%);
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    position: relative;
    left: 0;
    right: 0;
}

.py-single-post-container-full .post-thumbnail img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: cover;
    object-position: center;
    display: block;
}

.py-single-post-container-full .entry-content {
    padding: 0;
    color: var(--py-text-color);
}

.py-single-post-container-full .entry-footer,
.py-single-post-container-full .author-box,
.py-single-post-container-full .post-navigation {
    max-width: min(100%, 1400px);
    margin-left: auto;
    margin-right: auto;
    padding: 0 40px;
}

.py-single-post-container-full .author-box {
    background: #f9fafb;
    padding: 30px 40px;
    border-radius: var(--py-border-radius);
    margin-top: 50px;
    border: 1px solid var(--py-border-color);
}

.py-single-post-container-full .post-navigation {
    padding: 30px 40px 0 40px;
    border-top: 1px solid var(--py-border-color);
}

.py-single-post-container-full .comments-area {
    max-width: min(100%, 1400px);
    margin: 0 auto;
    padding: 40px;
    border-top: 1px solid var(--py-border-color);
}

/* ==========================================================================
   3. COMMON STYLES (Both Layouts)
   ========================================================================== */

.blog-post-full { 
    background: transparent; 
    padding: 0; 
    border-radius: 0; 
    box-shadow: none; 
}

.entry-title { 
    font-size: 2.5rem; 
    line-height: 1.2;
    margin-bottom: 15px;
    color: var(--py-secondary-color);
}

.entry-meta { 
    display: flex; 
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.entry-meta .meta-author a {
    font-weight: 600;
    color: var(--py-secondary-color);
}

.entry-meta .meta-author a:hover {
    color: var(--py-primary-color);
}

.entry-meta .meta-separator {
    color: #ccc;
}

.entry-meta .meta-date {
    color: var(--py-text-light);
}

.post-thumbnail { 
    margin-top: 40px;
    margin-bottom: 40px; 
    border-radius: var(--py-border-radius); 
    overflow: hidden; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.post-thumbnail img { 
    width: 100%; 
    height: auto; 
    display: block; 
}

/* Content styles */
.entry-content p { margin-bottom: 1.5em; }
.entry-content h2 { margin-top: 1.5em; font-size: 1.8rem; }
.entry-content h3 { margin-top: 1.5em; font-size: 1.5rem; }
.entry-content ul, .entry-content ol { margin-bottom: 1.5em; padding-left: 1.5em; }
.entry-content li { margin-bottom: 0.5em; }

.entry-footer {
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid var(--py-border-color);
}

.post-tags .tag-links {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.post-tags .tag-links a {
    background-color: #f1f3f5;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.9rem;
    color: var(--py-text-color);
    font-weight: 500;
    transition: all 0.2s ease;
}
.post-tags .tag-links a:hover {
    background-color: var(--py-primary-color);
    color: #fff;
}

.author-box { 
    display: flex; 
    gap: 25px; 
    background: #f9fafb;
    padding: 30px; 
    border-radius: var(--py-border-radius); 
    margin-top: 50px; 
    align-items: center; 
    border: 1px solid var(--py-border-color); 
}

.author-avatar img { 
    border-radius: 50%; 
    width: 80px;
    height: 80px;
}

.author-info h4 { 
    margin: 0 0 8px; 
    font-size: 1.3rem;
    font-weight: 700;
}
.author-info p {
    margin: 0;
    font-size: 1rem;
    color: var(--py-text-light); 
    line-height: 1.6;
}

.post-navigation { 
    display: flex; 
    justify-content: space-between; 
    margin-top: 40px; 
    padding-top: 30px; 
    border-top: 1px solid var(--py-border-color); 
}

.post-navigation a { 
    font-weight: 600; 
    color: var(--py-secondary-color); 
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px;
    border: 1px solid var(--py-border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.post-navigation a:hover {
    border-color: var(--py-primary-color);
    color: var(--py-primary-color);
    background: #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Sidebar Widgets (Only for non-full width) */
.py-blog-container .blog-sidebar .widget {
    background: var(--py-card-bg);
    padding: 20px;
    border-radius: var(--py-border-radius);
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.py-blog-container .blog-sidebar .widget h3.widget-title {
    font-size: 1.2rem;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--py-border-color);
    padding-bottom: 10px;
}
.py-blog-container .blog-sidebar .widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.py-blog-container .blog-sidebar .widget ul li {
    margin-bottom: 10px;
}
.py-blog-container .blog-sidebar .widget ul li a {
    color: var(--py-text-color);
}
.py-blog-container .blog-sidebar .widget ul li a:hover {
    color: var(--py-primary-color);
}

/* ==========================================================================
   4. RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 992px) {
    .py-blog-container { 
        flex-direction: column; 
        gap: 30px;
    }
    
    /* Reset sticky on mobile */
    .sidebar-sticky-wrapper { 
        width: 100%; 
        position: static;
        height: auto;
    }
    
    .py-blog-container .blog-sidebar { 
        width: 100%; 
    }
    
    .py-single-post-container-full .blog-post-full {
        padding: 40px 0;
    }
    
    .py-single-post-container-full .blog-post-full > article,
    .py-single-post-container-full .blog-breadcrumbs-wrapper,
    .py-single-post-container-full .entry-header,
    .py-single-post-container-full .entry-footer,
    .py-single-post-container-full .author-box,
    .py-single-post-container-full .post-navigation,
    .py-single-post-container-full .comments-area {
        padding: 0 30px;
    }
    
    .py-single-post-container-full .entry-content {
        padding: 0;
    }
}

@media (max-width: 768px) {
    .py-blog-container {
        margin: 20px auto;
    }
    
    .entry-title { 
        font-size: 1.8rem; 
    }
    
    .entry-content {
        font-size: 1.05rem;
    }
    
    .author-box {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .post-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .post-navigation a {
        width: 100%;
        justify-content: center;
    }
    
    .py-single-post-container-full {
        margin: 20px auto !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .py-single-post-container-full .blog-post-full {
        padding: 0;
    }
    
    .py-single-post-container-full .blog-post-full > article,
    .py-single-post-container-full .blog-breadcrumbs-wrapper,
    .py-single-post-container-full .entry-header,
    .py-single-post-container-full .entry-footer,
    .py-single-post-container-full .author-box,
    .py-single-post-container-full .post-navigation,
    .py-single-post-container-full .comments-area {
        padding: 0; 
    }
    
    .py-single-post-container-full .post-thumbnail {
        margin: 20px 0 30px 0;
        width: 100%;
        max-width: 100%;
        border-radius: var(--py-border-radius);
        box-shadow: 0 3px 10px rgba(0,0,0,0.08);
        left: auto;
        right: auto;
    }
    
    .py-single-post-container-full .post-thumbnail img {
        max-height: 60vh;
    }
    
    .py-single-post-container-full .author-box {
        padding: 20px;
    }
    
    .py-single-post-container-full .post-navigation {
        padding: 20px 0 0 0;
    }
}

/* ==========================================================================
   5. RELATED POSTS SECTION (After Content)
   ========================================================================== */
.related-posts-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--py-border-color);
}

.related-posts-title {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: 30px;
}

/* NEW: Custom, compact grid for related posts (2 columns on desktop) */
.related-posts-grid {
    display: grid;
    /* Desktop: 2 columns, each min 200px wide */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px; /* Reduced gap */
}

/* FIX: Ensure thumbnail container uses the same aspect ratio logic */
.related-posts-grid .py-blog-post-thumbnail {
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    position: relative;
    background: #f0f0f0;
}

.related-posts-grid .py-blog-post-thumbnail img,
.related-posts-grid .py-blog-post-thumbnail-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-posts-grid .py-blog-post-card {
    height: 100%;
    min-height: auto; /* Reset min-height */
}

.related-posts-grid .py-blog-post-content {
    padding: 10px; /* Reduced padding */
}

.related-posts-grid .py-blog-post-title {
    font-size: 0.9rem; /* Smaller font size */
    -webkit-line-clamp: 3; /* Allow 3 lines */
}

.related-posts-grid .py-blog-post-meta {
    font-size: 0.75rem; /* Very small meta font */
}


/* ==========================================================================
   6. STICKY SIDEBAR & WIDGET STYLES
   ========================================================================== */

/* Custom Related Posts Widget Styling */
.widget_priceyoo_related_posts_widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget_priceyoo_related_posts_widget li {
    margin-bottom: 15px;
}

.widget_priceyoo_related_posts_widget li a {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
}

.widget_priceyoo_related_posts_widget .widget-post-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
}

.widget_priceyoo_related_posts_widget .widget-post-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.widget_priceyoo_related_posts_widget .widget-post-title {
    font-weight: 600;
    color: var(--py-secondary-color);
    line-height: 1.4;
    font-size: 0.9rem;
}

.widget_priceyoo_related_posts_widget li a:hover .widget-post-title {
    color: var(--py-primary-color);
}

/* Mobile adjustment for related posts grid */
@media (max-width: 768px) {
    .related-posts-grid {
        grid-template-columns: repeat(2, 1fr); 
        gap: 15px;
    }
    
    .related-posts-grid .py-blog-post-title {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
    }
    
    .related-posts-grid .py-blog-post-content {
        padding: 8px;
    }
}