/* ============================================
   PRIORITY 2: DESIGN & UX ENHANCEMENTS
   Related Posts, Table of Contents, Enhanced Search
   ============================================ */

/* ============================================
   SKIP LINK - ACCESSIBILITY
   ============================================ */

/* Hide skip link visually but keep it accessible for keyboard users */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #33bdef;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-weight: 600;
    z-index: 1000;
    transition: top 0.3s ease;
}

/* Show skip link when focused (keyboard navigation) */
.skip-link:focus {
    top: 0;
}

/* ============================================
   MAIN CONTAINER & LAYOUT FLUSH
   ============================================ */

/* Ensure the main container spans the full width to allow for full-width backgrounds */
body .main-container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Remove any default top margin to be flush with header */
    margin-top: 0;
}

/* The content area wraps the actual content. 
   We let it span full width so inner sections can decide their own constraints. */
body .content-area {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
}

/* Constrain specific inner sections to a reasonable max-width for readability */
body .maingroupdiv,
body .split-container,
body .blog-grid,
body .article-with-toc,
body .articlesection {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    width: 100%;
}

/* Ensure the hero section background spans full width */
body .maindiv {
    width: 100%;
    max-width: 100%;
    background: linear-gradient(135deg, #f0f5fa 0%, #e3f2fd 100%);
    padding-bottom: 2rem;
    /* Add some breathing room at the bottom */
}

/* Ensure the feature section background spans full width */
body .featurediv {
    width: 100%;
    max-width: 100%;
    background-color: #ffffff;
    /* Explicit white background */
}

/* Adjust header spacing if needed */
body header {
    margin-bottom: 0;
    position: relative;
    z-index: 100;
}

/* Refine Article Page Layout */
body .article_bodydiv {
    margin: 0 auto;
    /* max-width: 68ch is already set in enhancements.css */
}

/* Fix for specific sections to ensure they don't overflow or look weird */
body .split-container {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Refine spacing for a "flush" look */
body .spacediv20 {
    height: 2rem;
    /* Standardize spacer */
}

/* ============================================
   RELATED POSTS MODULE
   ============================================ */

.related-posts {
    max-width: 1200px;
    margin: 4rem auto 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.related-posts-title {
    text-align: center;
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 2rem;
    position: relative;
    padding-bottom: 1rem;
}

.related-posts-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, #33bdef 0%, #019ad2 100%);
    border-radius: 2px;
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.related-post-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid #e1e5e9;
    display: flex;
    flex-direction: column;
}

.related-post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(51, 189, 239, 0.2);
    border-color: #33bdef;
}

.related-post-image {
    height: 200px;
    overflow: hidden;
    background: #f0f0f0;
}

.related-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-post-card:hover .related-post-image img {
    transform: scale(1.1);
}

.related-post-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.related-post-title {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    line-height: 1.4;
}

.related-post-title a {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.3s ease;
}

.related-post-title a:hover {
    color: #33bdef;
}

.related-post-excerpt {
    color: #666;
    line-height: 1.6;
    margin: 0 0 1rem 0;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #888;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
}

.related-post-date,
.related-post-reading-time {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.related-post-reading-time::before {
    content: '📖';
    font-size: 0.9rem;
}

/* ============================================
   ARTICLE LAYOUT WITH TOC
   ============================================ */

.article-with-toc {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

.article-main-content {
    min-width: 0;
    /* Prevents grid blowout */
}

.article-toc-sidebar {
    position: relative;
}

/* Mobile: Stack TOC above content */
@media (max-width: 1024px) {
    .article-with-toc {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }

    .article-toc-sidebar {
        order: -1;
        /* Move TOC above content on mobile */
    }

    .related-posts {
        margin: 2rem 0;
        padding: 1.5rem;
    }

    .related-posts-title {
        font-size: 1.5rem;
    }

    .related-posts-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .related-post-image {
        height: 180px;
    }
}

/* ============================================
   ENHANCED SEARCH WITH PREVIEWS
   ============================================ */

.search-results-enhanced {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 600px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
    cursor: pointer;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f0f0f0;
}

.search-result-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-title {
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    line-height: 1.3;
}

.search-result-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.search-result-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.search-result-tag {
    background: #e8f7fc;
    color: #33bdef;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.search-results-group {
    margin-bottom: 1.5rem;
}

.search-results-group-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 2px solid #33bdef;
    margin: 0;
}

.search-no-results {
    padding: 2rem;
    text-align: center;
    color: #666;
}

.search-no-results-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.search-no-results-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.search-no-results-suggestion {
    font-size: 0.9rem;
    color: #888;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .search-result-item {
        flex-direction: column;
    }

    .search-result-thumbnail {
        width: 100%;
        height: 150px;
    }

    .search-result-meta {
        font-size: 0.8rem;
    }
}

/* Smooth scrolling for all anchor links */
html {
    scroll-behavior: smooth;
}

/* Offset for fixed header when jumping to anchors */
:target {
    scroll-margin-top: 100px;
}

/* ============================================
   SECTION EMPTY STATE
   Used for tab content that has no items
   ============================================ */

.section-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: #f8f9fa;
    border-radius: 12px;
    color: #6c757d;
    font-size: 1.1rem;
    border: 2px dashed #e9ecef;
    margin: 1rem 0;
}