/* Article / Project Detail Layout Refinements */

:root {
    --article-max-width: 1100px;
    --content-max-width: 720px;
    --sidebar-width: 240px;
    /* Reduced from 240px */
}

.article-container {
    padding-top: 0;
    /* Dynamic Clearance */
    padding-bottom: var(--space-64);
    max-width: 100%;
    /* Full width */
    width: 100%;
    margin: 0;
    padding-left: clamp(var(--space-16), 5vw, var(--space-40));
    padding-right: clamp(var(--space-16), 5vw, var(--space-40));
}

/* Back Link Styling */
.back-link-container {
    margin-bottom: var(--space-24);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s ease;
}

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

/* Article Hero / Header */
.article-header {
    margin-top: var(--space-32);
    /* Extra space after back-link */
    margin-bottom: var(--space-48);
    /* Reduced for more direct feel, but increasing gap below title */
    text-align: left;
}

.article-title {
    font-size: clamp(2.8rem, 8.5vw, 4.5rem);
    font-weight: 850;
    line-height: 0.95;
    margin-bottom: var(--space-64);
    /* Increased from var(--space-40) */
    color: var(--color-text);
    letter-spacing: -0.05em;
    text-wrap: balance;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-16);
    /* Increased from var(--space-12) */
    justify-content: flex-start;
    /* Explicit Left Align */
    margin-bottom: var(--space-48);
    /* Increased from var(--space-32) */
}

.article-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    font-size: 13px;
    color: var(--color-text-secondary);
    background: rgba(var(--color-slate-500-rgb), 0.1);
    padding: var(--space-6) var(--space-16);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    font-weight: 550;
    backdrop-filter: blur(8px);
}

.article-summary {
    font-size: clamp(1.2rem, 2.2vw, 1.4rem);
    line-height: 1.6;
    color: var(--color-text-secondary);
    max-width: 800px;
}

.article-tags {
    margin-top: var(--space-40);
    /* Adjusted spacing */
    margin-bottom: var(--space-24);
    display: flex;
    gap: var(--space-10);
    flex-wrap: wrap;
}

/* Layout Grid */
.article-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-16);
    /* Drastically reduced from 48px */
}

@media (min-width: 769px) {

    /* Synchronized with global breakpoint + 1px */
    .article-grid {
        grid-template-columns: var(--sidebar-width) 1fr;
        align-items: start;
        gap: var(--space-32);
    }

    .article-sidebar {
        padding-right: var(--space-24);
    }

    .article-sidebar::after {
        content: '';
        position: absolute;
        top: 5vh;
        /* Start slightly down */
        height: 70vh;
        /* Fixed height relative to viewport for the sticky container */
        right: 0;
        width: 1px;
        background: linear-gradient(to bottom,
                transparent,
                var(--color-primary),
                transparent);
        opacity: 0.3;
    }
}

/* Sidebar / TOC */
.article-sidebar {
    position: sticky;
    top: 100px;
    /* Increased to clear the fixed Back button */
    max-height: calc(100vh - 120px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding-left: clamp(var(--space-16), 3vw, var(--space-32));
}

/* Custom TOC scrollbar */
.toc-list::-webkit-scrollbar {
    width: 4px;
}

.toc-list::-webkit-scrollbar-track {
    background: transparent;
}

.toc-list::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: var(--radius-full);
    transition: background 0.3s ease;
}

.article-sidebar:hover .toc-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
}

@media (max-width: 768px) {
    .article-sidebar {
        position: static;
        max-height: none;
        overflow-y: visible;
        margin-top: var(--space-48);
        margin-bottom: var(--space-24);
        padding-bottom: var(--space-12);
        border-bottom: 1px solid var(--border-color);
    }
}

.sidebar-project-title {
    font-size: 16px;
    font-weight: 850;
    color: var(--color-text);
    margin-bottom: var(--space-16);
    opacity: 0;
    /* Hidden initially */
    transform: translateY(20px);
    /* Pushed down */
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.sidebar-project-title.visible {
    opacity: 0.95;
    transform: translateY(0);
}

.toc-title {
    font-size: 15px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-primary);
    margin-top: var(--space-10);
    margin-bottom: var(--space-10);
    opacity: 0.8;
    flex-shrink: 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    padding-right: var(--space-12);
    flex: 1;
    min-height: 0;
    overscroll-behavior: contain;
    /* Prevent parent scroll chaining */
}

@media (max-width: 768px) {
    .toc-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--space-8);
    }

    .toc-link {
        padding: var(--space-6) var(--space-14) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-full) !important;
        /* Pills look better */
        background: var(--color-surface);
    }
}

.toc-link {
    display: block;
    font-family: var(--font-family-base);
    /* Comfortaa */
    font-size: 15px;
    /* Increased */
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 6px 0 6px 12px;
    /* Reduced from 16px */
    border-left: 1px solid var(--color-border);
    /* Thinner border */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.4;
    position: relative;
    opacity: 0.7;
    letter-spacing: -0.02em;
}

.toc-link:hover {
    color: var(--color-primary);
    transform: translateX(4px);
    opacity: 1;
    border-left-color: var(--color-primary);
    background: linear-gradient(90deg, rgba(var(--color-primary-rgb), 0.05), transparent);
}

.toc-link.active {
    color: var(--color-primary);
    border-left: 3px solid var(--color-primary);
    font-weight: 700;
    opacity: 1;
    background: linear-gradient(90deg, rgba(var(--color-primary-rgb), 0.15), transparent);
    padding-left: 12px;
    /* Add visual spacing */
}

/* Removed redundant pseudo-element bar */

/* Content Typography */
.article-content {
    max-width: var(--content-max-width);
}

.article-content section {
    margin-bottom: var(--space-32);
    scroll-margin-top: 100px;
    /* For better jump navigation */
}

/* Revamped Article Headers */
.article-content h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    margin-top: var(--space-8);
    margin-bottom: var(--space-16);
    color: var(--color-text);
    position: relative;
    display: inline-block;
    padding-bottom: var(--space-8);
    background: linear-gradient(to right, #22d3ee, #2dd4bf);
    /* Cyan to Teal */
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(var(--color-primary-rgb), 0.3));
    border-bottom: 2px solid rgba(var(--color-primary-rgb), 0.3);
}

.article-content h3 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-top: var(--space-24);
    margin-bottom: var(--space-12);
    color: var(--color-text);
    border-left: 3px solid var(--color-primary);
    padding-left: var(--space-12);
}

.article-content strong {
    color: var(--color-primary);
    font-weight: 700;
    background: linear-gradient(120deg, rgba(var(--color-primary-rgb), 0.15), transparent);
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    text-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.4);
}

.article-content em {
    font-family: var(--font-family-serif);
    color: var(--color-text-secondary);
    font-style: italic;
    border-bottom: 1px dotted var(--color-primary);
}

.article-content mark {
    background: rgba(var(--color-warning-rgb), 0.15);
    color: var(--color-warning);
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    box-shadow: 0 0 10px rgba(var(--color-warning-rgb), 0.2);
}

.article-content p {
    font-size: clamp(1.15rem, 1.8vw, 1.3rem);
    line-height: 1.5;
    margin-bottom: var(--space-20);
    color: var(--color-text);
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
    /* Subtle pop */
}

/* Futuristic Lists */
.article-content ul {
    margin-bottom: var(--space-20);
    padding-left: var(--space-16);
}

.article-content li {
    margin-bottom: var(--space-8);
    padding-left: var(--space-24);
    position: relative;
    list-style: none;
}

.article-content li::before {
    content: '•';
    /* Bullet point */
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: bold;
    font-size: 1.5em;
    line-height: 1.1;
    top: -2px;
}

/* Glassmorphism Blockquote */
.article-content blockquote {
    position: relative;
    border-left: 2px solid var(--color-primary);
    padding: var(--space-24) var(--space-32);
    margin: var(--space-40) 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--color-text);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    /* Top/Right/Bottom subtle border */
    border-left-width: 4px;
    /* Strong left accent */
}

.article-content blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: 10px;
    font-size: 4rem;
    color: var(--color-primary);
    opacity: 0.2;
    font-family: serif;
    line-height: 1;
}

/* Links with Glow */
.article-content a {
    color: var(--color-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px rgba(var(--color-primary-rgb), 0.3);
}

.article-content a:hover {
    color: var(--color-primary-hover);
    border-bottom-color: var(--color-primary);
    text-shadow: 0 0 15px rgba(var(--color-primary-rgb), 0.6);
}

/* Image styling */
.article-content img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    margin-top: var(--space-16);
    margin-bottom: var(--space-32);
    box-shadow: var(--shadow-lg);
}

/* Code Snippets */
code {
    background: var(--color-secondary);
    color: var(--color-primary);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

pre {
    background: var(--color-surface);
    padding: var(--space-20);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    border: 1px solid var(--color-border);
    margin-bottom: var(--space-24);
}

pre code {
    background: transparent;
    padding: 0;
    color: var(--color-text);
}

/* Gallery Refinement */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-20);
    margin-top: var(--space-24);
}

.gallery-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-16);
    text-align: center;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), border-color 0.4s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-12);
}

.gallery-item:hover {
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.gallery-icon {
    font-size: 2rem;
}

.gallery-label {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-text-secondary);
}

/* Micro-animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-content section {
    animation: fadeIn var(--duration-normal) ease-out forwards;
}

/* Article Images & Figures */
.article-figure {
    margin: var(--space-48) auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-16);
    text-align: center;
}

/* Global Article Image Constraint */
.article-content img {
    max-width: 400px;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid var(--border-color);
    display: block;
    margin: var(--space-32) auto;
}

.article-content video {
    border-radius: var(--radius-lg);
    margin: var(--space-32) auto;
    display: block;
    box-shadow: var(--shadow-lg);
    max-width: 100%;
}

@media (hover: hover) {
    .article-content img:hover {
        transform: translateY(-5px);
        box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    }
}

.article-caption {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    max-width: 80%;
    line-height: 1.6;
    display: none;
}

/* Lightbox / Zoom Functionality */
.article-content img {
    cursor: zoom-in;
}

.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s, background 0.3s, backdrop-filter 0.3s;
    cursor: zoom-out;
}

.image-lightbox.active {
    opacity: 1;
    visibility: visible;
    background: rgba(0, 0, 0, 0.7);
    /* Deep dim */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Delay background and blur until after zoom (0.5s) */
    transition:
        opacity 0.1s ease,
        visibility 0s,
        background 0.6s ease 0.5s,
        backdrop-filter 0.6s ease 0.5s;
}

.lightbox-img {
    max-width: 95%;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.4);
    /* Start small/far */
    opacity: 0;
    transition: transform 0.4s ease-in, opacity 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.image-lightbox.active .lightbox-img {
    transform: scale(1);
    /* Zoom to user */
    opacity: 1;
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.3s;
}

.lightbox-caption {
    margin-top: var(--space-24);
    color: #ffffff;
    font-size: var(--font-size-md);
    font-weight: 500;
    text-align: center;
    max-width: 80%;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s, transform 0.4s;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.image-lightbox.active .lightbox-caption {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.5s ease 0.6s, transform 0.5s ease 0.6s;
    transition: opacity 0.5s ease 0.6s, transform 0.5s ease 0.6s;
    /* Appear after bg starts */
}

/* Markdown Table Styling */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-32) 0;
    font-size: 15px;
    background: rgba(var(--color-surface-rgb), 0.5);
    backdrop-filter: blur(5px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* For border-radius */
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.article-content th,
.article-content td {
    padding: var(--space-12) var(--space-16);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.article-content th {
    background: rgba(var(--color-primary-rgb), 0.1);
    color: var(--color-primary);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(var(--color-primary-rgb), 0.2);
}

.article-content tr:last-child td {
    border-bottom: none;
}

.article-content tr:hover td {
    background: rgba(var(--color-primary-rgb), 0.05);
}

/* Parallax Hero Styles - Jesko Style */
.parallax-hero {
    position: relative;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    height: 90vh;
    /* Taller hero */
    min-height: 500px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    /* Position content toward bottom */
    padding-bottom: 15vh;
    margin-bottom: var(--space-48);
    /* Initial State */
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transform-origin: center top;
    /* Scale from top */
    will-change: transform, border-radius, width;
}

.parallax-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120%;
    /* visual bleed for parallax */
    top: -10%;
    background-size: cover;
    background-position: center;
    /* background-attachment: fixed; Removed for smoother JS parallax */
    z-index: 1;
    filter: brightness(0.6) blur(0px);
    transition: filter 0.5s ease;
    will-change: transform;
}

.parallax-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.3) 60%, transparent 100%);
    z-index: 2;
}

.parallax-content {
    position: relative;
    z-index: 3;
    width: 100%;
    max-width: var(--article-max-width);
    margin: 0 auto;
    padding: 0 clamp(var(--space-16), 5vw, var(--space-40));
    opacity: 0.95;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

.parallax-hero .article-title {
    color: #ffffff;
    margin-bottom: var(--space-16);
    opacity: 0.95;
    font-size: clamp(2.5rem, 5vw, 4rem);
    /* Reduced size */
    text-wrap: balance;
    animation: fadeIn 0.8s ease-out forwards;
}

.parallax-hero .article-tagline {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(1rem, 2vw, 1.25rem);
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
    max-width: 600px;
    text-wrap: balance;
    animation: slideInFromLeft 0.8s ease-out 0.2s forwards;
    opacity: 0;
    transform: translateX(-3em);
    /* Start from under the first letter of title, not extreme edge */
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-3em);
        /* Relative offset, aligning with title's first letter */
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.parallax-hero .article-meta-item {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(4px);
}


/* Fixed Back Button Styling */
.back-link-container {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 1002;
    /* Above Hero (1000) and Nav (1000) */
    margin: 0;
    padding: 0;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(3, 7, 18, 0.85);
    /* Matches .header */
    backdrop-filter: blur(40px);
    padding: 10px 20px;
    border-radius: 99px;
    border: 1px solid rgba(226, 232, 240, 0.1);
    /* Matches var(--premium-border) */
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateX(-4px);
}

/* Ensure Body has padding/margin adjustments if needed, 
   but since Hero is fixed-like or growing, standard flow is fine.
   We just need to make sure the hero doesn't cover content abruptly.
*/

/* Project Card Link Wrapper */
.project-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
    /* Ensure it fills height if needed */
}

/* Style the "View Project" text which is now a span */
.project-info .project-link {
    color: var(--color-primary);
    font-weight: 500;
    margin-top: var(--space-8);
    display: inline-block;
    transition: transform 0.3s ease, color 0.3s ease;
}

.project-card-link:hover .project-link {
    color: var(--color-primary-hover);
    transform: translateX(4px);
}


/* ==================== Mobile Responsive Styles for Project Pages ==================== */
@media (max-width: 768px) {

    /* Prevent horizontal scrolling on mobile */
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Hero Section - Reduce height for mobile */
    .parallax-hero {
        height: 60vh;
        min-height: 350px;
        padding-bottom: 8vh;
        margin-bottom: var(--space-32);
    }

    /* Title - Scale down for mobile */
    .parallax-hero .article-title {
        font-size: clamp(1.75rem, 7vw, 2.5rem);
        line-height: 1.05;
        margin-bottom: var(--space-12);
    }

    /* Subtitle - Smaller animation offset and text size */
    .parallax-hero .article-tagline {
        font-size: clamp(0.9rem, 3.5vw, 1.1rem);
        max-width: 100%;
        transform: translateX(-1.5em);
        /* Reduced offset for mobile */
        animation: slideInFromLeftMobile 0.8s ease-out 0.2s forwards;
    }

    @keyframes slideInFromLeftMobile {
        from {
            opacity: 0;
            transform: translateX(-1.5em);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    /* Parallax content - More padding on sides */
    .parallax-content {
        padding: 0 var(--space-16);
    }

    /* Back button - Adjust position for mobile */
    .back-link-container {
        top: 1rem;
        left: 1rem;
    }

    .btn-back {
        padding: 8px 14px;
        font-size: 12px;
        gap: 6px;
    }

    .btn-back svg {
        width: 16px;
        height: 16px;
    }

    /* Article container - Less padding */
    .article-container {
        padding-left: var(--space-16);
        padding-right: var(--space-16);
        padding-bottom: var(--space-32);
        overflow-x: hidden;
        /* Prevent horizontal scroll */
    }

    /* Article content - Full width */
    .article-content {
        max-width: 100%;
        overflow-x: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Typography scaling for content */
    .article-content h2 {
        font-size: var(--font-size-xl);
        margin-top: var(--space-32);
        margin-bottom: var(--space-16);
    }

    .article-content h3 {
        font-size: var(--font-size-lg);
        margin-top: var(--space-24);
        margin-bottom: var(--space-12);
    }

    .article-content p {
        font-size: clamp(1rem, 4vw, 1.15rem);
        margin-bottom: var(--space-24);
        line-height: 1.7;
    }

    .article-content ul {
        padding-left: var(--space-8);
    }

    .article-content li {
        padding-left: var(--space-20);
        margin-bottom: var(--space-12);
    }

    /* Images - Constrain to screen width */
    .article-content img {
        max-width: 100%;
        max-height: 300px;
        margin: var(--space-24) auto;
    }

    .article-figure {
        margin: var(--space-32) auto;
    }

    .article-caption {
        font-size: 12px;
        max-width: 100%;
    }

    /* Blockquotes */
    .article-content blockquote {
        padding: var(--space-16) var(--space-20);
        margin: var(--space-24) 0;
        font-size: 1.05rem;
    }

    .article-content blockquote::before {
        font-size: 2.5rem;
        top: -5px;
        left: 5px;
    }

    /* Code blocks */
    pre {
        padding: var(--space-16);
        font-size: 0.85em;
    }

    /* Lightbox adjustments */
    .lightbox-img {
        max-width: 98%;
        max-height: 80vh;
    }

    .lightbox-caption {
        font-size: var(--font-size-sm);
        padding: 0 var(--space-16);
        max-width: 95%;
    }

    /* Hide sidebar project title on mobile since it's in hero */
    .sidebar-project-title {
        display: none;
    }

    /* TOC adjustments */
    .article-sidebar {
        margin-top: var(--space-32);
        padding-left: 0;
    }

    .toc-title {
        font-size: 13px;
        margin-bottom: var(--space-8);
    }

    .toc-link {
        font-size: 13px;
        border-left: none !important;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .parallax-hero {
        height: 50vh;
        min-height: 300px;
        padding-bottom: 6vh;
    }

    .parallax-hero .article-title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }

    .parallax-hero .article-tagline {
        font-size: 0.9rem;
        transform: translateX(-1em);
    }

    @keyframes slideInFromLeftMobile {
        from {
            opacity: 0;
            transform: translateX(-1em);
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .back-link-container {
        top: 0.75rem;
        left: 0.75rem;
    }

    .btn-back {
        padding: 6px 12px;
        font-size: 11px;
    }

    .article-content p {
        font-size: 1rem;
    }

    .article-content h2 {
        font-size: var(--font-size-lg);
    }

    .article-content h3 {
        font-size: var(--font-size-base);
    }

    /* Stack TOC pills */
    .toc-list {
        gap: var(--space-6);
    }

    .toc-link {
        padding: var(--space-4) var(--space-12) !important;
        font-size: 12px;
    }
}

/* Side-by-side Image Layout */
.article-content .image-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-16);
    margin: var(--space-16) 0;
    width: 100%;
}

.article-content .image-row img {
    margin: 0;
    max-width: 100%;
    /* Override the global 400px limit */
    flex: 1;
    /* Distribute space evenly */
    object-fit: cover;
    /* Fill the box, crop if necessary to remove black bars */
    height: 200px;
    /* Fixed height for consistent row */
    width: 100%;
    /* Force fill width */
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .article-content .image-row {
        flex-direction: column;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .article-content .image-row img,
    .article-content .image-row video {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 250px;
    }
}

/* Text and Media Side-by-Side Layout */
.article-content .text-media-row {
    display: flex;
    align-items: center;
    /* Vertically center */
    gap: var(--space-48);
    margin: var(--space-48) 0;
    width: 100%;
}

.article-content .text-media-row.reverse {
    flex-direction: row-reverse;
}

.article-content .text-media-row img {
    margin: 0;
    max-width: 350px;
    width: 40%;
    flex-shrink: 0;
}

.article-content .text-media-row .text-content {
    flex: 1;
    min-width: 0;
}

.article-content .text-media-row .text-content h2:first-child,
.article-content .text-media-row .text-content h3:first-child {
    margin-top: 0;
}

@media (max-width: 768px) {

    .article-content .text-media-row,
    .article-content .text-media-row.reverse {
        flex-direction: column;
        gap: var(--space-24);
    }

    .article-content .text-media-row img {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
}