/* Update background and layout */
.blog-body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.blog-body .top-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 40px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.blog-body .top-footer div {
    display: flex;
    align-items: center;
}

.blog-body .nav-links {
    display: flex;
    align-items: center;
}

/* Keep logo aligned with Home (no extra horizontal margin) */
.blog-body .header-left .logo-link {
    margin: 0;
}

.blog-body .header-left strong {
    font-size: 1.5em;
    color: var(--heading-color);
}


.blog-body .nav-links .nav-text {
    margin: 0 10px;
}

.blog-body .top-footer.header-hidden {
    transform: translateY(-100%);
}

.back-button {
    color: var(--text-primary);
    font-size: 1.2em;
    text-decoration: none;
    transition: all 0.3s ease;
    display: none;
    align-items: center;
    gap: 8px;
}

.back-button:hover {
    color: var(--text-secondary);
    opacity: 0.7;
    /* Add opacity for dimming effect */
}

.back-button i {
    transition: opacity 0.3s ease;
    /* Smooth transition for icon */
}

.back-button:hover i {
    opacity: 0.7;
    /* Dim the icon on hover */
}

.back-button .hover-text {
    font-size: 0.9em;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: normal;
    color: var(--text-secondary);
}

.back-button:hover .hover-text {
    opacity: 1;
    /* Show the text on hover */
}

.blog-body .logo-link {
    font-size: inherit;
    font-weight: 500;
    color: var(--heading-color);
    text-decoration: none;
    /* Remove underline */
    transition: opacity 0.2s ease;
    /* Smooth hover effect */
}

.blog-body .logo-link:hover {
    opacity: 0.8;
    /* Subtle hover effect */
}

.blog-body .nav-links .nav-text {
    color: var(--text-primary);
}

.blog-body .nav-links .nav-text.active {
    color: var(--heading-color);
    font-weight: 600;
}

/* Match active mobile icon tone with main pages */
.blog-body .nav-links .nav-icon.active {
    color: var(--heading-color);
    opacity: 1 !important;
}

.blog-body .back-button.is-visible {
    display: flex;
}

.blog-post .top-footer .logo-link {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

/* Hide mobile line break on desktop */
.mobile-break {
    display: none;
}

.placeholder {
    display: none;
}

.blog-wrapper {
    max-width: 1200px;
    margin: 220px auto 0;
    padding: 20px 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Blog content area */
.blog-content {
    width: 100%;
    max-width: 900px;
}

/* Header row with Posts title and view toggle */
.blog-header-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
}

.blog-header-row h1 {
    margin: 0;
}

/* Blog Controls Container */
.blog-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Control Buttons - Shared pill style for Search, Filter */
.search-btn,
.filter-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 22px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-btn:hover,
.filter-btn:hover {
    color: var(--text-primary);
}

.search-btn i,
.filter-btn i {
    font-size: 0.9em;
}

.filter-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* Filter Panel */
.filter-panel {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    margin-top: 8px;
    width: 100%;
}

.filter-panel.active {
    display: flex;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-label {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.filter-select {
    font-size: 0.75em;
    padding: 2px 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: color 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
    padding-right: 12px;
}

.filter-select:hover,
.filter-select:focus {
    color: var(--text-primary);
}

/* View Toggle - Segmented Pill Style */
.view-toggle {
    display: flex;
    background: var(--bg-hover);
    border-radius: 25px;
    padding: 3px;
    gap: 0;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 22px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.toggle-btn i {
    font-size: 0.9em;
}

/* Blog Grid - Base styles */
.blog-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* List View (Default) - With preview */
.blog-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.blog-grid.list-view .blog-post {
    width: fit-content;
    max-width: 100%;
    background: transparent;
    padding: 16px 12px;
    border-radius: 8px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.blog-grid.list-view .blog-post:hover {
    background-color: var(--bg-hover);
}

/* Content wrapper for title and preview */
.blog-grid.list-view .blog-post .post-content {
    flex: 1;
    min-width: 0;
}

.blog-grid.list-view .blog-post h2 {
    font-size: 1.15em;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--heading-color);
}

/* Preview text */
.blog-grid.list-view .blog-post .preview {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* List view metadata - pill style like grid view */
.blog-grid.list-view .blog-post .metadata {
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    flex-shrink: 0;
    margin-left: 24px;
    white-space: nowrap;
}

/* Grid View */
.blog-grid.grid-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    justify-items: start;
    /* Align to left like list view */
}

.blog-grid.grid-view .blog-post {
    width: 100%;
    max-width: 280px;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    color: inherit;
    text-decoration: none;
}

/* Hide post-content wrapper and preview in grid view */
.blog-grid.grid-view .blog-post .post-content {
    display: contents;
    /* Removes wrapper, keeps h2 */
}

.blog-grid.grid-view .blog-post .preview {
    display: none;
}

.blog-grid.grid-view .blog-post:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow-color);
}

/* Cover image - Grid view only */
.blog-grid.grid-view .blog-post .cover-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 0 -20px;
    width: calc(100% + 40px);
}

/* Card content wrapper in grid view */
.blog-grid.grid-view .blog-post .card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin: 0 -20px 0 -20px;
    /* No top margin, extend divider to full width */
    padding-left: 20px;
    padding-right: 20px;
}

.blog-grid.grid-view .blog-post h2 {
    font-size: 1.05em;
    margin: 0 0 10px 0;
    color: var(--heading-color);
    line-height: 1.4;
}

/* Hide cover image and card-content wrapper in list view */
.blog-grid.list-view .blog-post .cover-image {
    display: none;
}

.blog-grid.list-view .blog-post .card-content {
    display: contents;
    /* Remove wrapper, keep children */
}

/* Blog post base styles (shared) */
.blog-post {
    text-decoration: none;
    color: inherit;
}

.blog-post:hover {
    text-decoration: none;
}

.blog-post h2 {
    color: var(--heading-color);
    text-decoration: none;
}

.post-meta {
    color: #666666;
    font-size: 0.9em;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.post-meta span {
    position: relative;
}

.post-meta span:not(:first-child)::before {
    content: "•";
    position: absolute;
    left: -10px;
}

.excerpt {
    color: #444444;
    line-height: 1.6;
}

.read-more {
    color: #333333;
    text-decoration: none;
}

/* Scrollbar styling */
.middle {
    height: calc(100vh - 160px);
    overflow-y: auto;
}

.middle::-webkit-scrollbar {
    width: 6px;
}

.middle::-webkit-scrollbar-track {
    background: transparent;
}

.middle::-webkit-scrollbar-thumb {
    background: #cccccc;
}

@media (max-width: 768px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }

    .blog-content h1 {
        font-size: 2em;
    }

    /* Reduce wrapper margin and padding on mobile */
    .blog-wrapper {
        margin: 80px auto 60px;
        /* Top for header, bottom for fixed footer */
        padding: 20px 20px;
    }

    /* List view: stack title/preview and date vertically */
    .blog-grid.list-view .blog-post {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px 10px;
    }

    .blog-grid.list-view .blog-post .metadata {
        margin-left: 0;
    }

    /* Keep Posts and toggle on same row on mobile */
    .blog-header-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .blog-header-row h1 {
        font-size: 1.5em;
    }

    .view-toggle {
        flex-shrink: 0;
    }

    /* Grid view: single column */
    .blog-grid.grid-view {
        grid-template-columns: 1fr;
        justify-items: stretch;
    }

    .blog-grid.grid-view .blog-post {
        max-width: 100%;
    }

    /* Hide back arrow on mobile */
    .blog-body .back-button {
        display: none !important;
    }

    /* Match Home header layout on mobile */
    .blog-body .top-footer {
        padding: 15px 20px;
    }

    /* Single-line title on mobile */
    .blog-post .top-footer .logo-link {
        position: static;
        transform: none;
        white-space: nowrap;
    }
}

/* Bottom footer styling */
.bottom-footer {
    background: var(--bg-secondary);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 40px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Mobile override for footer - must come after .bottom-footer definition */
@media (max-width: 768px) {

    /* Make footer relative like other pages (matches responsive.css) */
    .bottom-footer {
        padding: 15px 20px;
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
    }

    /* Fix empty space below footer on mobile */
    .blog-body {
        overflow-y: auto !important;
        min-height: 100svh !important;
        display: flex !important;
        flex-direction: column !important;
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Middle section should not have fixed margin on mobile */
    .blog-body .blog-wrapper {
        flex: 1 0 auto;
    }

    .blog-body .social-links {
        margin-right: -20px;
        padding-right: 20px;
    }
}

@media (max-width: 480px) {
    .bottom-footer {
        padding: 10px 16px;
    }

    /* Match Home footer height (2-row icon grid on mobile) */
    .blog-body .bottom-footer {
        min-height: 76px;
    }

    /* Align 2 icons to the right like Home's 3-column grid */
    .blog-body .social-icons-row > a:nth-child(1) {
        grid-column: 2;
    }

    .blog-body .social-icons-row > a:nth-child(2) {
        grid-column: 3;
    }
}

.social-icons-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-right: 0;
    /* Remove any right margin */
    padding-right: 0;
    /* Remove any right padding */
}

.blog-body .social-icons-main {
    display: none !important;
}

.blog-body .social-icons-blog {
    display: flex;
}

.blog-body .copyright-main {
    display: block;
}

.blog-body .copyright-blog {
    display: none;
}

/* Remove blog-platforms specific styles */
.blog-platforms {
    display: none;
}

/* Update the circle base styling */
.circle {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 30px;
    height: 30px;
    background-color: var(--icon-bg);
    border-radius: 50%;
    transition: all 0.3s ease;
    color: var(--icon-color);
    text-decoration: none;
}

/* Platform-specific gradients */
.circle.medium:hover {
    background: linear-gradient(135deg, #12100E, #333333);
    color: white;
    transform: translateY(-2px);
}

.circle.substack:hover {
    background: linear-gradient(135deg, #FF6719, #FF4000);
    color: white;
    transform: translateY(-2px);
}

/* Update text colors to be more gray */
.blog-platforms strong {
    color: #333333;
}

.copyright {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Back to left alignment */
    gap: 5px;
}

.copyright strong {
    color: var(--heading-color);
}

.copyright span {
    color: var(--text-secondary);
}

/* Language tag styling */
.tag {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.85em;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #f0f0f0;
    color: #666666;
}

.tag.polish {
    background-color: #f5f5f5;
    color: #555555;
}

/* Remove underline from links */
.blog-grid a {
    text-decoration: none;
}

/* Update social icons grid for blog environment */
.blog-platforms .social-icons {
    display: flex;
    /* Change from grid to flex */
    gap: 12px;
    /* Keep the same gap */
    align-items: center;
}


/* Theme toggle button styles */
.blog-body .theme-toggle-container {
    position: relative;
    padding-left: 28px;
    margin-left: 10px;
}

.blog-body .theme-toggle-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    width: 1px;
    background-color: var(--border-color);
}

.theme-toggle {
    position: relative;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 0;
    font-size: 1.2em;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0;
    transition: opacity 0.2s ease;
}

.blog-body .theme-toggle::before {
    content: none;
}

.theme-toggle:hover {
    opacity: 0.8;
}

/* Blog specific footer styles */
.blog-body .bottom-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.blog-body .copyright {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

.blog-body .social-links {
    display: flex;
    justify-content: flex-end;
    margin-right: -20px;
    padding-right: 20px;
}

.metadata {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: bold;
    width: fit-content;
    user-select: text;
    /* Make text selectable */
    pointer-events: none;
    /* Prevent link behavior */
    color: var(--text-primary);
}

.metadata span {
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    color: inherit;
    /* Keep the text color */
}

.metadata .dot {
    margin: 0 4px;
    color: var(--text-primary);
}

.circle.substack {
    margin-right: 0;
    /* Remove any right margin */
    padding-right: 0;
    /* Remove any right padding */
}

/* Search overlay */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    /* Dimmed background */
    backdrop-filter: blur(5px);
    /* Blur effect */
    -webkit-backdrop-filter: blur(5px);
    /* For Safari */
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: all 0.3s ease;
}

.search-overlay.active {
    display: block;
    opacity: 1;
}

.search-overlay.active .search-container {
    transform: translateY(0);
}

.search-results {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    padding: 0 10px;
    min-height: 0;
    /* Remove minimum height */
    display: none;
    /* Hide when empty */
}

.search-results:not(:empty) {
    display: block;
    /* Show only when there are results */
    margin-top: 10px;
    /* Add some space between search input and results */
}

/* Adjust container padding when empty */
.search-container {
    max-width: 600px;
    margin: 100px auto 0;
    background: var(--bg-secondary);
    /* Use theme variable */
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 10px;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 0;
    padding: 5px 10px;
    height: 30px;
    /* Reduced from 40px to 30px */
    position: relative;
}

.search-input-group {
    display: flex;
    align-items: center;
    /* Center vertically */
    flex: 1;
    position: relative;
}

.search-input-group::before {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #999;
    /* Match the color of placeholder and X icon */
    font-size: 0.9em;
    margin-right: 8px;
    display: flex;
    align-items: center;
    height: 30px;
}

#searchInput {
    flex: 1;
    width: calc(100% - 40px);
    padding: 0 0 0 25px;
    font-size: 1.1em;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    /* Use theme variable */
    margin: 2px 0 0 0;
    /* Add tiny top margin */
    height: 30px;
    line-height: 30px;
}

/* Add search icon */
.search-header::before {
    content: '\f002';
    /* FontAwesome search icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 0.9em;
    z-index: 1;
}

#searchInput::placeholder {
    color: #999;
    /* Keep this color */
}

.close-search {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.1em;
    color: #999;
    /* Keep this color */
    cursor: pointer;
    transition: color 0.2s ease;
}

/* Search results styling */
.search-result-item {
    display: block;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: var(--bg-hover);
    /* Use theme variable */
}

.search-result-item h3 {
    margin: 0 0 5px 0;
    color: var(--heading-color);
    /* Use theme variable */
    font-size: 1.1em;
}

.search-result-metadata {
    font-size: 0.85em;
    color: var(--text-secondary);
    /* Use theme variable */
}
