/* --- Column Layout Styles --- */
.blog-column-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
}

.blog-column {
    flex: 1 1 300px;
    min-width: 0;
}

/* --- Carousel Engine Styles --- */
.carousel-container {
    position: relative;
    width: 100%;
    margin: 2.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
}

body.theme-light .carousel-container {
    background: rgba(0, 0, 0, 0.01);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

.carousel-track {
    display: grid;
    grid-template-columns: 100%;
    width: 100%;
    position: relative;
}

.carousel-slide {
    grid-area: 1 / 1 / 2 / 2;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
    padding: 2rem 2.5rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

.carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}

.carousel-slide > * {
    max-width: 100%;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    user-select: none;
}

body.theme-light .carousel-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
}

.carousel-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 1rem;
}

.next-btn {
    right: 1rem;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0 1.25rem;
    z-index: 10;
    position: relative;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

body.theme-light .carousel-dot {
    background: rgba(0, 0, 0, 0.15);
}

.carousel-dot.active {
    background: var(--accent-color);
    transform: scale(1.25);
    width: 18px;
    border-radius: 4px;
}

/* --- Image Optimization & Lightbox Styles --- */
.optimized-image-container {
    position: relative;
    margin: 2rem auto;
    max-width: 100%;
    text-align: center;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
}

.lazy-opt-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    transition: all 0.3s ease;
    cursor: zoom-in;
}

.lazy-opt-image:hover {
    transform: scale(1.005);
    border-color: var(--accent-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.image-caption {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

.zoom-prompt {
    display: inline-block;
    margin-top: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.65;
    transition: opacity 0.2s ease;
}

.optimized-image-container:hover .zoom-prompt {
    opacity: 0.9;
    color: var(--accent-color);
}

/* Zoomable Images cursor indicator */
.zoomable-image,
.blog-post-body img {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}
.zoomable-image:hover,
.blog-post-body img:hover {
    opacity: 0.95;
}

/* Lightbox Overlay */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%; /* not 100vw: that includes the scrollbar, shifting a centred fixed overlay */
    height: 100vh;
    height: 100dvh; /* fixed overlay: must cover exactly the visible viewport, so its close controls stay reachable when the mobile URL bar is shown */
    background: rgba(10, 10, 10, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: zoom-out;
}

.lightbox-overlay.active {
    opacity: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 6px;
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 12px 50px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.lightbox-overlay.active .lightbox-image {
    transform: scale(1);
}

.lightbox-caption {
    color: #eaeaea;
    margin-top: 1.25rem;
    font-size: 1rem;
    text-align: center;
    font-family: var(--font-title-sans), sans-serif;
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 0 0 12px rgba(0, 0, 0, 0.9);
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 2rem;
    color: #fff;
    font-size: 3rem;
    font-weight: 200;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    z-index: 2010;
    line-height: 1;
    user-select: none;
}

.lightbox-close:hover {
    color: var(--accent-color);
    transform: scale(1.1);
}

/* Carousel specific overrides to prevent vertical overflow and columns wrapping */
.carousel-slide .blog-column-list {
    flex-wrap: nowrap !important;
    gap: 1rem;
    margin: 1rem 0;
}

.carousel-slide .blog-column {
    flex: 1 1 50% !important;
}

.carousel-slide .optimized-image-container {
    margin: 0.5rem auto;
}

.carousel-slide img {
    max-height: 55vh !important;
    width: auto !important;
    object-fit: contain !important;
}

/* Table of Contents */
.table-of-contents {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    font-family: var(--font-title-sans), sans-serif;
}

.table-of-contents .toc-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-of-contents .toc-title::after {
    content: '▲';
    font-size: 0.75rem;
    transition: transform 0.25s ease;
    opacity: 0.7;
}

.table-of-contents.collapsed .toc-title::after {
    transform: rotate(180deg);
}

.table-of-contents.collapsed ul {
    display: none;
}

.table-of-contents.collapsed .toc-title {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.table-of-contents li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.table-of-contents li a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.table-of-contents li a:hover {
    color: var(--accent-color);
}

.table-of-contents .toc-depth-1 {
    font-weight: 500;
}

.table-of-contents .toc-depth-2 {
    padding-left: 1.25rem;
    font-size: 0.92rem;
}

.table-of-contents .toc-depth-3 {
    padding-left: 2.5rem;
    font-size: 0.88rem;
}

.table-of-contents .toc-depth-4 {
    padding-left: 3.75rem;
    font-size: 0.84rem;
}

/* Floating Table of Contents in the margin on wide screens */
@media (min-width: 1250px) {
    @keyframes slideInRight {
        from {
            opacity: 0;
            transform: translate3d(20px, 0, 0);
        }
        to {
            opacity: 1;
            transform: translate3d(0, 0, 0);
        }
    }

    @keyframes slideInLeft {
        from {
            opacity: 0;
            transform: translate3d(-20px, 0, 0);
        }
        to {
            opacity: 1;
            transform: translate3d(0, 0, 0);
        }
    }

    .table-of-contents.floating {
        position: fixed;
        top: 8.5rem;
        width: 280px; /* +1cm wider for standard HD/Desktop screens */
        max-height: 70vh;
        overflow-y: auto;
        z-index: 500;
        margin: 0;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 1.25rem;
        font-size: 0.82rem;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        transition: width 0.3s ease, padding 0.3s ease;
    }

    /* Even wider (+2cm) on 4K / Ultra-wide displays */
    @media (min-width: 2500px) {
        .table-of-contents.floating {
            width: 340px;
            padding: 1.5rem;
            font-size: 0.85rem;
        }
    }
    
    .table-of-contents.floating.pos-right {
        right: 2.5rem;
        left: auto;
        animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .table-of-contents.floating.pos-left {
        left: 2.5rem;
        right: auto;
        top: 16rem; /* Push down to avoid overlapping the Dial Nav on the top-left */
        animation: slideInLeft 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }
    
    .table-of-contents.floating .toc-title {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.35rem;
    }
    
    .table-of-contents.floating ul {
        max-height: calc(70vh - 4rem);
    }
    
    .table-of-contents.floating li {
        margin-bottom: 0.35rem;
    }
    
    .table-of-contents.floating .toc-depth-2 {
        padding-left: 0.75rem;
        font-size: 0.8rem;
    }
    
    .table-of-contents.floating .toc-depth-3 {
        padding-left: 1.5rem;
        font-size: 0.75rem;
    }
    
    .table-of-contents.floating .toc-depth-4 {
        padding-left: 2.25rem;
        font-size: 0.70rem;
    }
}

/* Table of Contents Position Controls styling */
.toc-pos-controls {
    display: none; /* Hide by default when inline */
    align-items: center;
    gap: 0.2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.15rem;
    margin-left: auto;
    margin-right: 0.5rem;
}

/* Show only when floating on wide screens */
.table-of-contents.floating .toc-pos-controls {
    display: inline-flex;
}

.theme-light .toc-pos-controls {
    background: rgba(0, 0, 0, 0.03);
}

.toc-pos-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
    padding: 0;
}

.toc-pos-btn:hover {
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.05);
}

.theme-light .toc-pos-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.toc-pos-btn.active {
    background: var(--accent-color) !important;
    color: var(--bg-color) !important;
}

.table-of-contents .toc-title::after {
    margin-left: 0;
}

/* ─── Mermaid Wrapper & Controls ─────────────────────────────────────── */
.mermaid-wrapper {
    position: relative;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    padding: 1.5rem;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.theme-light .mermaid-wrapper {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

/* Actions bar in Mermaid block */
.mermaid-actions {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    display: flex;
    gap: 0.5rem;
    z-index: 10;
}

.mermaid-action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.theme-light .mermaid-action-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text-muted);
}

.mermaid-action-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.theme-light .mermaid-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mermaid-action-btn.copied {
    background: var(--accent-color) !important;
    color: var(--bg-color) !important;
    border-color: var(--accent-color) !important;
}

/* Lightbox specific for Mermaid */
.mermaid-lightbox-overlay .mermaid {
    background: transparent !important;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.mermaid-lightbox-overlay .mermaid svg {
    max-width: 90vw !important;
    max-height: 85vh !important;
    width: auto !important;
    height: auto !important;
}

