/***************************************************
  blog-jukebox.css
  Jukebox-style three-panel blog layout
  Extends existing project-box styling for blog cards
****************************************************/

/* Prevent any scrolling on the blog page */
body:has(.blog-container) {
    overflow: hidden;
    height: 100vh;
}

html:has(.blog-container) {
    overflow: hidden;
    height: 100vh;
}

/* Fallback for browsers that don't support :has() */
@supports not (selector(:has(.blog-container))) {
    .blog-page body {
        overflow: hidden;
        height: 100vh;
    }
    
    .blog-page html {
        overflow: hidden;
        height: 100vh;
    }
}

/* =============================================================================
   BLOG CONTAINER & LAYOUT
   ============================================================================= */

/* Override main padding constraints for blog page */
.blog-container {
    width: 100%;
    max-width: 100vw; /* Ensure it doesn't exceed viewport width */
    margin: 0;
    padding: 0 1rem;
    box-sizing: border-box; /* Include padding in width calculation */
}

/* Override common.css main padding for blog */
main.blog-container {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden; /* Prevent all page scrolling */
    margin-top: 0; /* Remove margin-top to use absolute positioning */
    padding-top: calc(var(--header-height) + 1rem); /* Account for header + spacing */
    height: 100vh; /* Full viewport height */
    position: fixed; /* Fix to viewport */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Additional override for blog content width */
@media (min-width: 1470px) {
    .blog-container {
        padding: 0 2rem;
    }
    
    main.blog-container {
        padding-left: 2rem;
        padding-right: 2rem;
        padding-top: calc(var(--header-height) + 2rem); /* More breathing room on larger screens */
    }
    
    .blog-layout {
        grid-template-columns: 320px 1fr 320px;
        gap: 2rem;
    }
}

.blog-header {
    text-align: center;
    margin-bottom: 3rem;
}

.blog-header h1 {
    margin-bottom: 1rem;
}

.blog-header .blog-summary {
    max-width: 600px;
    margin: 0 auto;
}

/* Three-panel layout */
.blog-layout {
    display: grid;
    grid-template-columns: minmax(280px, 300px) 1fr minmax(280px, 300px);
    gap: 1.5rem;
    height: calc(100vh - var(--header-height) - 3rem); /* Fixed height relative to viewport */
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* =============================================================================
   LEFT PANEL: Blog Posts Grid
   ============================================================================= */

.blog-grid {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1.5rem;
    height: 100%; /* Use full available height */
    overflow-y: auto; /* Scrollable content */
    box-sizing: border-box;
}

.blog-grid h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.5rem;
}

.blog-posts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Blog thumbnail cards - adapted from project-box styling */
.blog-card {
    /* background-color removed to allow background images to show through */
    color: var(--color-text-primary);
    box-shadow: var(--box-shadow);
    padding: 1rem;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100px;
    position: relative;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    cursor: pointer;
    border: 2px solid transparent;
    /* Ensure background images work properly with clipping and overlay */
    background-attachment: local;
}

/* Background image is now set directly on .blog-card element via JavaScript */

.blog-card.active {
    border-color: var(--color-accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 8px var(--accent-glow);
}

.blog-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    border-radius: 10px;
    background-color: rgba(0, 0, 0, 0.85); /* Darkened by 15% */
    z-index: 1;
    transition: background-color 0.3s ease-in-out;
}

.blog-card:hover::before {
    background-color: rgba(0, 0, 0, 0.45); /* Darkened hover state */
}

/* Ensure preview images are more visible while maintaining overlay */
.blog-card.has-preview-image {
    /* Remove any background color that might interfere */
    background-color: transparent !important;
}

.blog-card.has-preview-image::before {
    background-color: rgba(0, 0, 0, 0.75); /* Darkened by 15% for preview images */
}

.blog-card.has-preview-image:hover::before {
    background-color: rgba(0, 0, 0, 0.45); /* Darkened hover state */
}

.blog-card:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 0 8px var(--accent-glow);
}

.blog-card-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    z-index: 2;
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.blog-card-thumbnail:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 8px var(--color-text-primary));
}

.blog-card-content {
    flex: 1;
    z-index: 2;
    position: relative;
    min-width: 0; /* Allows text truncation */
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0; /* Even padding top and bottom */
}

.blog-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0.15rem 0 0.05rem 0 !important; /* Further reduced for better balance with padding */
    color: var(--color-text-primary);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 0.1rem !important; /* Even tighter spacing with !important */
}

.blog-card-categories {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.blog-card-category {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    color: #ccc;
}

/* =============================================================================
   CENTER PANEL: Selected Post Content
   ============================================================================= */

.blog-content {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 2rem;
    height: 100%; /* Use full available height */
    overflow-y: auto; /* Scrollable content */
    box-sizing: border-box;
}

.blog-content-wrapper {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-message {
    text-align: center;
    color: #aaa;
    padding: 3rem 1rem;
    max-width: 600px;
    margin: 0 auto; /* Center the container horizontally */
}

.welcome-message p {
    text-align: center;
    max-width: 400px; /* Limit line length for better readability */
    margin: 0 auto; /* Center the paragraph horizontally */
}

.welcome-message h2 {
    color: var(--color-text-primary);
    margin-bottom: 1rem;
}

/* Selected post styling - extends existing .post styles */
.selected-post {
    width: 100%;
    max-width: 800px; /* Limit content width */
    margin: 0 auto; /* Center the content block */
}

.selected-post .post-thumbnail-content {
    margin: 0 auto 1.5rem auto;
    max-width: 800px; /* Allow thumbnail content to be larger for image grids */
}

.selected-post .post-thumbnail-content img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0 auto 1.5rem auto !important;
    display: block;
}

.selected-post .post-thumbnail-content .image-grid {
    margin: 0 auto 1.5rem auto !important; /* Center image-grid inside thumbnail content */
}

.selected-post .post-thumbnail-content .image-grid img {
    margin: 0; /* Remove individual margins for images in thumbnail grid */
}

.selected-post img {
    width: 100%;
    max-width: 600px; /* Limit maximum width */
    height: auto;
    border-radius: 8px;
    margin: 0 auto 1.5rem auto !important; /* Center the image horizontally - override any conflicts */
    display: block; /* Make it a block element for centering */
    cursor: pointer; /* Enable pointer cursor for hover */
    transition: transform 0.3s ease, filter 0.3s ease; /* Smooth hover transitions */
}

.selected-post video {
    width: 100%;
    max-width: 600px; /* Limit maximum width */
    height: auto;
    border-radius: 8px;
    margin: 0 auto 1.5rem auto !important; /* Center the video horizontally */
    display: block; /* Make it a block element for centering */
}

.selected-post img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 8px var(--color-text-primary));
}

/* Image grid support within selected posts */
.selected-post .image-grid {
    display: grid;
    gap: 10px;
    margin: 0 auto 1.5rem auto !important;
}

.selected-post .image-grid img {
    margin: 0; /* Remove individual image margins in grids */
    max-width: none; /* Remove max-width constraint in grids */
    width: 100%; /* Fill grid cell */
}

/* Apply the existing grid layouts */
.selected-post .image-grid.grid-1 {
    grid-template-columns: 1fr;
    max-width: 600px;
    margin: 0 auto 1.5rem auto !important;
}

.selected-post .image-grid.grid-2 {
    grid-template-columns: 1fr 1fr;
    max-width: 800px; /* Increase max-width for 2-image grids */
    margin: 0 auto 1.5rem auto !important;
}

.selected-post .image-grid.grid-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    grid-template-areas:
        "large large"
        "small1 small2";
    max-width: 600px;
    margin: 0 auto 1.5rem auto !important;
}

.selected-post .image-grid.grid-3 img:nth-child(1) {
    grid-area: large;
}

.selected-post .image-grid.grid-3 img:nth-child(2) {
    grid-area: small1;
}

.selected-post .image-grid.grid-3 img:nth-child(3) {
    grid-area: small2;
}

.selected-post .image-grid.grid-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    max-width: 600px;
    margin: 0 auto 1.5rem auto !important;
}

.selected-post .image-grid.grid-more {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    max-width: 800px;
    margin: 0 auto 1.5rem auto !important;
}

.selected-post h2 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--color-text-primary);
    text-align: center; /* Center the headline */
}

.selected-post time {
    display: block;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 1rem;
    text-align: center; /* Center the date */
}

.selected-post .post-categories {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center; /* Center the category tags */
}

.selected-post .category {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #ddd;
}

.selected-post p {
    font-size: var(--font-size-p);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.selected-post a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 700;
}

/* =============================================================================
   RIGHT PANEL: Categories & Navigation
   ============================================================================= */

.blog-navigation {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1.5rem;
    height: 100%; /* Use full available height */
    overflow-y: auto; /* Scrollable content */
    box-sizing: border-box;
}

.blog-navigation h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--color-text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 0.5rem;
    font-size: 1rem;
}

/* Category filter buttons */
.category-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.category-btn {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-primary);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    text-align: left;
}

.category-btn:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.category-btn.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--color-text-primary);
    font-weight: 600;
}

/* Pinned posts */
.pinned-posts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pinned-item {
    padding: 0.8rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.pinned-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateX(3px);
}

.pinned-item h4 {
    margin: 0 0 0.25rem 0;
    font-size: 0.85rem;
    color: var(--color-text-primary);
    line-height: 1.2;
}

.pinned-item .pinned-date {
    font-size: 0.75rem;
    color: #aaa;
}

/* =============================================================================
   ICON NAVIGATION (Below 1000px)
   ============================================================================= */

/* Hide text navigation and show icon navigation below 1000px */
@media (max-width: 1000px) {
    .blog-navigation {
        width: 60px;
        padding: 1rem 0.5rem;
        min-width: 60px;
    }
    
    .blog-layout {
        grid-template-columns: minmax(280px, 320px) 1fr 60px;
        gap: 1rem;
    }
    
    .blog-navigation h3 {
        display: none;
    }
    
    .category-filters {
        gap: 0.75rem;
        align-items: center;
    }
    
    .category-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        position: relative;
        overflow: visible;
    }
    
    .category-btn span {
        display: none;
    }
    
    /* Icon content for each category */
    .category-btn[data-category="all"]::before { content: "📄"; }
    .category-btn[data-category="game-development"]::before { content: "🎮"; }
    .category-btn[data-category="project-updates"]::before { content: "🔧"; }
    .category-btn[data-category="technology"]::before { content: "💻"; }
    .category-btn[data-category="game-reviews"]::before { content: "⭐"; }
    .category-btn[data-category="arts"]::before { content: "🎨"; }
    .category-btn[data-category="learning"]::before { content: "📚"; }
    

    
    .pinned-posts {
        display: none;
    }
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

/* Large screens (1200px and below) */
@media (max-width: 1200px) {
    .blog-container {
        padding: 0 1rem;
    }
    
    .blog-layout {
        grid-template-columns: minmax(220px, 250px) 1fr minmax(220px, 250px);
        gap: 1rem;
    }
    
    .blog-card {
        height: 90px;
        padding: 0.8rem;
    }
    
    .blog-card-thumbnail {
        width: 70px;
        height: 50px;
    }
}

/* Narrow screens (1000px and below) - ensure no overflow */
@media (max-width: 1000px) {
    .blog-layout {
        grid-template-columns: minmax(200px, 250px) 1fr 60px;
        gap: 0.75rem;
    }
    
    .blog-container {
        padding: 0 0.75rem;
    }
    
    main.blog-container {
        padding-top: calc(var(--header-height) + 1rem);
    }
    
    .blog-layout {
        height: calc(100vh - var(--header-height) - 2rem);
    }
}

/* Medium screens (800px and below) */
@media (max-width: 800px) {
    .blog-container {
        padding: 0 0.5rem;
    }
    
    main.blog-container {
        /* Match top spacing to grid gap for even spacing around categories */
        padding-top: calc(var(--header-height) + 0.75rem);
    }
    
    /* New mobile layout: categories at top, blog posts left, content right */
    .blog-layout {
        display: grid;
        grid-template-columns: 80px 1fr; /* Blog posts column + content area */
        grid-template-rows: auto 1fr; /* Categories row + main content */
        gap: 0.75rem;
        /* Reduce layout height slightly to create extra bottom gap on phones */
        height: calc(100vh - var(--header-height) - 2.5rem);
        grid-template-areas:
            "categories categories"
            "posts content";
    }
    
    /* Categories section - horizontal row at top */
    .blog-navigation {
        grid-area: categories;
        width: auto;
        height: auto;
        padding: 0.5rem; /* Slimmer categories bar */
        margin-bottom: 0;
        background-color: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
    }
    
    .blog-navigation h3 {
        display: none; /* Hide "Categories" title on mobile */
    }
    
    .category-filters {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        gap: 0.5rem;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.25rem 0;
        margin-bottom: 0;
    }
    
    .category-btn {
        width: 45px;
        height: 45px;
        min-width: 45px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
        position: relative;
        flex-shrink: 0;
    }
    
    .category-btn span {
        display: none; /* Hide text labels */
    }
    
    .category-btn::before {
        display: block; /* Show icons */
    }
    

    
    /* Blog posts - left column with image squares only */
    .blog-grid {
        grid-area: posts;
        padding: 0.5rem;
        width: 80px;
        min-width: 80px;
        background-color: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        height: 100%;
        overflow-y: auto;
    }
    
    .blog-grid h3 {
        display: none; /* Hide "Posts" title */
    }
    
    .blog-posts-container {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .blog-card {
        width: 100%;
        height: 70px; /* Smaller height to match reduced width */
        padding: 0;
        background: none;
        border: none;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
        cursor: pointer;
        transition: transform 0.2s ease;
    }
    
    .blog-card:hover {
        transform: scale(1.05);
    }
    
    .blog-card-content {
        display: none; /* Hide all text content */
    }
    
    .blog-card-thumbnail {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 8px;
        object-fit: cover;
    }
    
    .blog-card-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 8px;
    }
    
    /* Content area - right side */
    .blog-content {
        grid-area: content;
        height: 100%;
        min-height: 0;
        overflow-y: auto;
        background-color: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 10px;
        padding: 1.5rem;
    }
    
    /* Hide pinned posts on mobile */
    .pinned-posts {
        display: none;
    }
}


/* Small screens (600px and below) */
@media (max-width: 600px) {
    .blog-header {
        margin-bottom: 1.5rem;
    }
    
    .blog-container {
        padding: 0 0.25rem;
    }
    
    main.blog-container {
        /* Keep spacing consistent with smaller gaps */
        padding-top: calc(var(--header-height) + 0.5rem);
    }
    
    /* Adjust layout for very small screens */
    .blog-layout {
        grid-template-columns: 80px 1fr; /* Narrower blog posts column */
        gap: 0.5rem;
    }
    
    /* Smaller category buttons */
    .category-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        font-size: 1rem;
    }
    
    .category-filters {
        gap: 0.4rem;
    }
    
    .blog-navigation {
        padding: 0.5rem; /* Slimmer on very small screens */
    }
    
    /* Smaller blog post squares */
    .blog-grid {
        padding: 0.5rem;
        width: 80px;
        min-width: 80px;
    }
    
    .blog-card {
        height: 60px; /* Smaller squares for very small screens */
    }
    
    .blog-content {
        padding: 1rem;
    }
    

}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

.hidden {
    display: none !important;
}

.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Smooth scrolling for internal navigation */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar styling for panels */
.blog-grid::-webkit-scrollbar,
.blog-content::-webkit-scrollbar,
.blog-navigation::-webkit-scrollbar {
    width: 6px;
}

.blog-grid::-webkit-scrollbar-track,
.blog-content::-webkit-scrollbar-track,
.blog-navigation::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.blog-grid::-webkit-scrollbar-thumb,
.blog-content::-webkit-scrollbar-thumb,
.blog-navigation::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.blog-grid::-webkit-scrollbar-thumb:hover,
.blog-content::-webkit-scrollbar-thumb:hover,
.blog-navigation::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}