/* Styles for the Blogs & Walkthroughs page */

.blog-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    margin-top: 0px;
    position: relative; /* Needed for positioning context */
}

.blog-header {
    text-align: center;
    margin-bottom: 25px;
    padding: 20px 10px; /* Increased padding */
    /* border-radius: 12px; */
    text-wrap: wrap;

    /* --- STICKY HEADER STYLES --- */
    position: sticky;
    top: 50px; /* Distance from the top of the viewport */
    z-index: 10;
    background-color: var(--primary-bg); /* Match page background to hide content underneath */
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); /* Add shadow for depth */
}

/* --- FADE/MASK EFFECT --- */
/* This pseudo-element creates the gradient that hides the cards as they scroll up */
.blog-header::after {
    content: '';
    position: absolute;
    bottom: -50px; /* Position it just below the header */
    left: 0;
    width: 100%;
    height: 50px;
    background: linear-gradient(to bottom, var(--primary-bg), transparent);
    pointer-events: none; /* Allows clicks to pass through */
}


.blog-header h1 {
    /* Reusing the gradient text effect from the main logo */
    font-family: 'Orbitron', sans-serif;
    font-size: 2;
    background: linear-gradient(90deg, var(--highlight-accent), var(--primary-accent), var(--secondary-accent), var(--highlight-accent));
    background-size: 400% 400%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
    text-wrap: wrap;
}

.blog-header p {
    font-size: 1em;
    color: var(--secondary-accent);
    margin-top: 10px;
    margin-bottom: 0;
}

.blog-grid {
    /* Add top margin to prevent the first row from being hidden by the sticky header */
    margin-top: 20px;
    display: grid;
    /* This creates a responsive grid that shows 1, 2, or 3 columns depending on screen width */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.blog-card {
    /* Adapting the .feature-card style for blog posts */
    background-color: var(--secondary-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.blog-card-image {
    width: 100%;
    height: 180px;
    object-fit: cover; /* Ensures the image covers the area without distortion */
}

/* --- BLOG CARD PREVIEW STYLES --- */

.blog-card .card-main-title {
    font-size: 1.1em;
    font-weight: bold;
    margin: 20px 20px 15px 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--secondary-accent);
}

.card-preview-grid {
    margin: 0 20px 20px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--primary-bg); /* Darker background for contrast */
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Make the grid fill the card height */
}

.card-preview-grid .blog-card-image {
    height: auto; /* Make the image shorter for the preview */
    object-fit: cover;
    border-bottom: 1px solid var(--border-color);
}

.card-preview-text {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Allow content to grow and push meta to bottom */
}

.card-preview-text h3 {
    font-size: 1em; /* Smaller title for the preview */
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.card-preview-text p {
    font-size: 0.85em; /* Smaller excerpt text */
    margin: 0;
    line-height: 1.4;
    color: var(--text-color);
    flex-grow: 1; /* Pushes the meta info down */
}

.card-preview-text .card-meta {
    font-size: 0.8em;
    color: var(--secondary-accent);
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}


/* --- SINGLE POST PAGE STYLES --- */

.post-container {
    max-width: 830px; /* --- CHANGED: Increased from 750px to fill more space --- */
    margin: 0; /* Let the flex container handle centering */
    padding: 20px;
    background-color: var(--secondary-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.post-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.post-tag {
    display: inline-block;
    padding: 4px 12px;
    background-color: var(--primary-accent);
    color: white;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: bold;
    margin-bottom: 15px;
}

.post-header h1 {
    font-size: 2.2em;
    color: var(--text-color);
    margin: 0 0 10px 0;
}

.post-meta {
    font-size: 0.9em;
    color: var(--secondary-accent);
    margin-bottom: 30px;
}

.post-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 12px;
}

.post-body {
    font-size: 1.1em;
    line-height: 1.7;
}

.post-body h2 {
    color: var(--secondary-accent);
    margin-top: 40px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.post-body p {
    margin-bottom: 20px;
}

.post-body code {
    background-color: var(--tertiary-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
}

.back-link {
    display: inline-block;
    margin-top: 40px;
    padding: 10px 20px;
    font-size: 16px;
    text-decoration: none;
    border-radius: 8px;
    background-image: linear-gradient(to right, var(--primary-accent), var(--secondary-accent));
    color: white;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-weight: 500;
}

.back-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* --- TABLE OF CONTENTS SIDEBAR --- */

/* New layout container for post pages */
.blog-layout-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    max-width: 1100px;
    margin: 0;
    padding: 0px;
}

.toc-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 120px;
    align-self: flex-start;
    
    /* --- NEW: Make the sidebar a flex container and constrain its height --- */
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 140px); /* Adjusts to viewport height, leaving space top/bottom */
}

.toc-sidebar h3 {
    font-size: 1em;
    font-weight: bold;
    color: var(--secondary-accent);
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; /* --- NEW: Prevents the title from shrinking or scrolling --- */
}

.toc-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;

    /* --- NEW: Allow the list to scroll and hide the scrollbar --- */
    overflow-y: auto;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* --- NEW: Hide scrollbar for Chrome, Safari, and Opera --- */
.toc-sidebar ul::-webkit-scrollbar {
    display: none;
}

.toc-sidebar li {
    margin-bottom: 10px;
}

.toc-sidebar li.anim-element.visible {
    animation: slide-in-from-left 0.5s ease-out forwards;
}

.toc-sidebar a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9em;
    padding: 4px 0 4px 10px;
    display: block;
    border-left: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.toc-sidebar a:hover {
    color: var(--primary-accent);
    border-left-color: var(--primary-accent);
}

.toc-sidebar a.active {
    color: var(--highlight-accent);
    border-left-color: var(--highlight-accent);
    transform: translateX(5px);
    font-weight: bold;
}

/* Hide sidebar on smaller screens */
@media (max-width: 1024px) {
    .toc-sidebar {
        display: none;
    }
}
