/* Containers (global max-width retained) */
.blog-container, .container, .container-fluid {
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px;
}

/* Headings (global baseline) */
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    margin-top: 1.6rem;
    margin-bottom: .8rem;
    line-height: 1.25;
}

h1 {
    font-size: 2.1rem;
}

h2 {
    font-size: 1.6rem;
}

h3 {
    font-size: 1.25rem;
}

/* Cards */
.blog-card {
    background: var(--panel);
    border-radius: 12px;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

.blog-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}

.blog-card img {
    height: 200px;
    width: 100%;
    object-fit: cover;
    object-position: center;
}

.blog-card .card-title {
    font-size: 1.2rem;
    color: var(--text);
}

.blog-card .card-text {
    color: var(--muted);
}

/* Hero / cover */
.blog-hero {
    width: 100%;
    min-height: 320px;
    max-height: 420px;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.cover-image {
    width: 100%;
    max-width: 900px;
    height: 400px;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 12px;
    margin: 0 auto 24px auto;
    box-shadow: 0 8px 28px rgba(0, 0, 0, .35);
}

.blog-hero-content {
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .55) 80%);
    color: #fff;
    padding: 2rem;
    width: 100%;
    border-radius: 0 0 12px 12px;
}

/* Blog title block */
.blog-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Content panel */
.blog-content {
    background: var(--panel);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

.blog-content p {
    color: var(--text);
    margin: 0 0 1rem 0;
}

.blog-content .text-sm {
    color: var(--muted);
}

.blog-post img {
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.blog-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25);
}

/* Lists */
.list-unstyled {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.list-unstyled a {
    color: var(--accent-blue);
}

ol, ul {
    color: var(--text);
    margin: 0 0 1rem 1.25rem;
}

li, li::marker {
    color: var(--text);
}

/* Tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.25rem 0;
}

.blog-content table {
    font-size: .95rem;
    border: 1px solid var(--accent-border);
}

.blog-content th, .blog-content td {
    border: 1px solid var(--accent-border);
    padding: 10px 12px;
    text-align: left;
}

.blog-content th {
    background: var(--table-head);
    color: var(--text);
}

.blog-content tr:nth-child(even) {
    background: var(--table-row);
}

/* fallback */
th, td {
    border: 1px solid var(--accent-border);
    padding: 8px;
    text-align: left;
}

th {
    background: var(--table-head);
    color: var(--text);
}

.blog-content pre {
    background: var(--code-bg);
    color: var(--text);
    border: 1px solid var(--accent-border);
    max-width: 100%;
    overflow-x: auto;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .02);
}

.blog-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: .9em;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(255, 255, 255, .05);
    padding: .05rem .35rem;
    border-radius: 6px;
}

/* Sidebar (TOC + Machine Info) */
.col-md-4.blog-toc {
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    background: var(--panel-soft);
    color: var(--text);
    padding: 1rem;
    border-left: 4px solid var(--accent-blue);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
    max-height: 80vh;
    overflow-y: auto;
}

.blog-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.blog-toc li {
    margin: .35rem 0;
}

.blog-toc a {
    color: var(--accent-blue);
    font-weight: 500;
    text-decoration: none;
}

.blog-toc a:hover {
    color: var(--accent-green);
    text-decoration: underline;
}

/* Machine info */
.machine-info {
    background: #2a3343;
    color: var(--text);
    border-left: 4px solid var(--accent-green);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 14px;
    box-shadow: 0 1px 10px rgba(0, 0, 0, .18);
}

.machine-info h5 {
    margin: 0 0 .5rem 0;
    font-weight: 700;
    color: #fff;
}

.machine-info p {
    margin: .35rem 0;
    color: var(--text);
}

.machine-info a {
    color: var(--accent-blue);
    word-break: break-all;
}

.machine-info strong {
    color: #fff;
}

/* Buttons / badges */
.btn-bk, .btn-bk:hover {
    background: #000;
    color: #fff;
    border: 1px solid #111;
}

.badge.bg-secondary {
    background: #3a4760 !important;
    color: #e9f1f7 !important;
    font-weight: 500;
}

.sky-btn {
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--accent-border);
    padding: .5rem .9rem;
    border-radius: 10px;
    transition: background .18s, transform .18s, border-color .18s;
}

.sky-btn:hover {
    background: #2f3a4e;
    border-color: #4b627f;
    text-decoration: none;
    transform: translateY(-1px);
}

.social-share-inline {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin: .5rem 0 1rem 0;
}

.social-share-inline .btn {
    padding: .25rem .6rem;
    font-size: .85rem;
    border-radius: 8px;
}

/* Remove grey strip behind pagination */
.pagination-wrapper,
.card-footer:has(.pagination) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

/* Make pagination buttons match the dark theme */
.page-link {
    background: var(--panel-alt) !important;
    border: 1px solid var(--accent-border) !important;
    color: var(--text) !important;
    border-radius: 10px;
}

.page-link:hover {
    background: #2f3a4e !important;
    border-color: #4b627f !important;
    text-decoration: none;
}

.pagn-bg {
    background-color: #141B26 !important;
}

/* Winne the pooh */
.wtp-wrapper {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Comments */

.comments-wrap {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 992px) {
    .comments-wrap {
        grid-template-columns: 2fr 1fr;
    }
}

/* ========== List ========== */
.comments-list {
    display: grid;
    gap: .75rem;
}

.comments-list>* {
    background: var(--panel-soft);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    padding: .65rem;
}

/* ========== Form card ========== */
.comments-card {
    background: var(--panel);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
}

.comments-card .card-body {
    padding: 1rem;
}

/* ========== Form basics ========== */
.comment-form {
    display: grid;
    gap: .6rem;
    max-width: 520px;
}

.comment-form label {
    font-weight: 500;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    background: var(--panel-alt);
    color: var(--text);
    border: 1px solid var(--accent-border);
    border-radius: 8px;
    padding: .5rem .65rem;
}

.comment-form textarea {
    min-height: 84px;
    resize: vertical;
}

.comment-form .actions {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.comment-container {
    background: var(--panel-soft);
    border: 1px solid var(--accent-border);
    border-radius: 10px;
    padding: .65rem;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: .25rem;
}

.comment-author {
    font-weight: 600;
    color: var(--text);
}

.comment-date {
    font-size: 0.89em;
    color: var(--muted);
}

.comment-body {
    color: var(--text);
    white-space: pre-line;
    margin: 0;
}


/* ========== Captcha ========== */
.captcha-row {
    display: flex;
    justify-content: flex-start;
}

@media (min-width:768px) {
    .blog-page .row.justify-content-center {
        display: grid !important;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        /* 8/4 */
        column-gap: 20px;
        align-items: start;
    }

    .blog-page .col-md-8.blog-content,
    .blog-page .col-md-4.blog-toc {
        width: auto !important;
        max-width: none !important;
        flex: initial !important;
    }

    .blog-page .col-md-8.blog-content {
        min-width: 0;
    }

    /* allow long blocks to shrink */
    .blog-page .col-md-4.blog-toc {
        position: sticky;
        top: 1rem;
    }
}

/* Mobile stack */
@media (max-width:991.98px) {
    .blog-content {
        padding: 1rem;
    }

    .col-md-4.blog-toc {
        position: static;
        max-height: none;
        margin-top: 1rem;
    }
}

@media (max-width:575.98px) {
    h1 {
        font-size: 1.7rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    .cover-image {
        max-width: 100%;
        height: 250px;
    }
}

/* Slightly wider main content on md+ */
@media (min-width: 768px) {
    .blog-page .row.justify-content-center {
        /* from 2fr / 1fr (~66.7/33.3) to 2.25fr / 1fr (~69.2/30.8) */
        grid-template-columns: minmax(0, 2.25fr) minmax(0, 1fr);
    }
}

@media (min-width: 1400px) {
    .blog-page .row.justify-content-center {
        grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr);
    }
}

@media (max-width: 420px) {
    .captcha-row .captcha-wrap {
        transform: scale(.86);
        transform-origin: center top;
    }
}

/* ========== Scoped Bootstrap override for comments row ONLY ========== */
@media (min-width: 992px) {
    .comments-section .row.comments-wrap {
        display: grid;
        grid-template-columns: 2fr 1fr;
        column-gap: 1rem;
    }

    .comments-section .row.comments-wrap>.col-lg-8,
    .comments-section .row.comments-wrap>.col-lg-4 {
        width: auto;
        flex: 0 0 auto;
    }
}

/* ========== Mobile fit ========== */
@media (max-width: 991.98px) {
    .comments-card, .comment-form {
        max-width: 100%;
        margin: 0;
    }
}


/* Prevent TOC overlay on small screens */
@media (max-width: 991.98px) {
    .col-md-4.blog-toc {
        position: static !important;
        max-height: none !important;
        margin-top: 1rem !important;
        overflow: visible !important;
    }
}

/* XS phones: TOC styling */
@media (max-width: 575.98px) {
    .blog-content {
        padding: 1rem;
    }

    .cover-image {
        max-width: 100%;
        height: 250px;
    }

    .blog-toc {
        padding: .75rem;
        border-left: 0;
        border-top: 4px solid var(--accent-blue);
        border-radius: 10px;
    }
}

/* ========== Back to Top Button ========== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent-blue);
    color: var(--bg);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--accent-green);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.back-to-top:active {
    transform: translateY(-1px);
}

/* Mobile adjustments */
@media (max-width: 575.98px) {
    .back-to-top {
        width: 45px;
        height: 45px;
        bottom: 20px;
        right: 20px;
        font-size: 18px;
    }
}

/* ========== Image Lightbox ========== */
.image-lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: zoom-out;
    animation: fadeIn 0.2s ease-in-out;
}

.image-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lightbox-content {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    cursor: default;
    animation: zoomIn 0.2s ease-in-out;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    border-radius: 4px;
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
    z-index: 10000;
    -webkit-user-select: none;
    user-select: none;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: var(--accent-green);
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #f1f1f1;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 8px;
    max-width: 80%;
    text-align: center;
    font-size: 14px;
}

/* Make blog content images clickable */
.blog-content img {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.blog-content img:hover {
    opacity: 0.9;
}

/* Mobile optimizations */
@media (max-width: 575.98px) {
    .lightbox-close {
        top: 10px;
        right: 15px;
        font-size: 35px;
    }

    .lightbox-caption {
        font-size: 12px;
        padding: 8px 15px;
        bottom: 10px;
        max-width: 90%;
    }

    .lightbox-content {
        max-width: 98%;
        max-height: 98%;
    }
}