/*
     * The sticky full-bleed bar itself is defined once in base.html's
     * shared .blog-breadcrumb rule; the inner row's width comes from the
     * site's shared 1400px .container, same as every other page.
     */

    /* Article Hero */
    .article-hero {
        margin-bottom: var(--hero-gap);
        border-bottom: 1px solid var(--border);
        padding-bottom: var(--content-gap-top);
    }
    
    .article-category {
        font-family: var(--font-mono);
        font-size: 0.72rem;
        text-transform: uppercase;
        color: var(--primary);
        font-weight: 600;
        letter-spacing: 0.1em;
        margin-bottom: 1rem;
        display: inline-block;
    }

    .article-title {
        font-family: var(--font-heading);
        font-size: clamp(2rem, 5vw, 3rem);
        font-weight: 800;
        line-height: 1.15;
        letter-spacing: -0.02em;
        color: var(--text-primary);
        margin-bottom: 1.5rem;
    }

    .article-meta {
        display: flex;
        gap: 1.5rem;
        color: var(--gray);
        font-size: 0.88rem;
        align-items: center;
        flex-wrap: wrap;
    }
    
    .article-meta-item {
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }

    .article-featured-image-wrapper {
        border-radius: 20px;
        overflow: hidden;
        border: 1px solid var(--border);
        margin-bottom: 3.5rem;
        background: var(--bg-secondary);
    }
    
    .article-featured-image {
        width: 100%;
        height: auto;
        display: block;
        max-height: 480px;
        object-fit: cover;
    }

    /* Core Post Detail Layout */
    .article-layout {
        display: grid;
        grid-template-columns: 240px 1fr 280px;
        gap: 4rem;
        align-items: start;
    }

    /* Pin each column explicitly so a hidden sibling (e.g. the TOC on
       posts with no headings) can't shift the others into its track. */
    .article-layout > .toc-sidebar {
        grid-column: 1;
    }
    .article-layout > .article-body {
        grid-column: 2;
        min-width: 0;
    }
    .article-layout > .aside-widget-sidebar {
        grid-column: 3;
    }

    /* Aside widget sidebar */
    .aside-widget-sidebar {
        position: sticky;
        top: 6rem;
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    @media (max-width: 1200px) {
        .article-layout {
            grid-template-columns: 200px 1fr;
            gap: 2.5rem;
        }
        .aside-widget-sidebar {
            display: none;
        }
    }

    @media (max-width: 900px) {
        .article-layout {
            grid-template-columns: 1fr;
            gap: 2rem;
        }
        .toc-sidebar {
            display: none;
        }
        .article-layout > .article-body {
            grid-column: 1;
        }
    }

    /* Table of Contents (TOC) Sidebar */
    .toc-sidebar {
        position: sticky;
        top: 6rem;
        padding-right: 1rem;
    }

    .toc-title {
        font-family: var(--font-heading);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-primary);
        font-weight: 700;
        margin-bottom: 1rem;
    }

    .toc-list {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        border-left: 1px solid var(--border);
    }

    .toc-item {
        margin: 0.25rem 0;
        transition: all 0.2s ease;
    }

    .toc-h2 {
        padding-left: 0.75rem;
        border-left: 2px solid transparent;
        margin-left: -1px;
    }

    .toc-h2 .toc-link {
        font-weight: 600;
        font-size: 0.85rem;
    }

    .toc-h3 {
        padding-left: 1.75rem;
        border-left: 1px solid transparent;
        margin-left: -1px;
    }

    .toc-h3 .toc-link {
        font-size: 0.78rem;
        color: var(--text-secondary);
    }

    .toc-h4 {
        padding-left: 2.75rem;
        border-left: 1px solid transparent;
        margin-left: -1px;
    }

    .toc-h4 .toc-link {
        font-size: 0.72rem;
        color: var(--gray);
    }

    .toc-link {
        color: var(--text-secondary);
        text-decoration: none;
        transition: color 0.2s;
        display: block;
        line-height: 1.4;
    }

    .toc-link:hover {
        color: var(--primary);
    }

    .toc-link.active {
        color: var(--primary);
        font-weight: 700;
    }

    .toc-item:has(.toc-link.active) {
        border-left-color: var(--primary);
    }

    /* Article Body Typography & Style */
    .article-body {
        font-size: 1.05rem;
        line-height: 1.75;
        color: var(--text-primary);
        overflow-wrap: break-word;
    }

    .article-body h2 {
        font-family: var(--font-heading);
        font-size: 1.6rem;
        font-weight: 700;
        letter-spacing: -0.02em;
        margin: 2.5rem 0 1rem;
        color: var(--text-primary);
        scroll-margin-top: 6rem;
    }

    .article-body h3 {
        font-family: var(--font-heading);
        font-size: 1.25rem;
        font-weight: 700;
        letter-spacing: -0.01em;
        margin: 2rem 0 0.75rem;
        color: var(--text-primary);
        scroll-margin-top: 6rem;
    }

    .article-body p {
        margin-bottom: 1.25rem;
        color: var(--text-secondary);
    }

    .article-body a {
        color: var(--primary);
        text-decoration: none;
        font-weight: 500;
        border-bottom: 1px dashed var(--primary);
        transition: color 0.2s, border-color 0.2s;
    }

    .article-body a:hover {
        color: var(--primary-dark);
        border-bottom-style: solid;
    }

    .article-body ul, .article-body ol {
        margin: 1.25rem 0;
        padding-left: 1.75rem;
        color: var(--text-secondary);
    }

    .article-body li {
        margin-bottom: 0.5rem;
    }

    .article-body blockquote {
        border-left: 3px solid var(--primary);
        background: var(--bg-secondary);
        padding: 1.25rem 1.5rem;
        border-radius: 0 12px 12px 0;
        font-style: italic;
        margin: 2rem 0;
        color: var(--text-secondary);
    }

    /* Images inside content */
    .article-body img {
        max-width: 100%;
        height: auto;
        border-radius: 12px;
        border: 1px solid var(--border);
        margin: 2.5rem 0;
    }

    .article-body iframe,
    .article-body embed,
    .article-body video,
    .article-body figure {
        max-width: 100%;
    }

    /* Custom tables */
    .article-body table {
        width: 100%;
        table-layout: fixed;
        border-collapse: collapse;
        margin: 2rem 0;
        font-size: 0.9rem;
    }

    .article-body th {
        background: var(--bg-tertiary);
        color: var(--text-primary);
        font-weight: 700;
        padding: 0.75rem 1rem;
        border: 1px solid var(--border);
        text-align: left;
    }

    .article-body td {
        padding: 0.75rem 1rem;
        border: 1px solid var(--border);
        color: var(--text-secondary);
        overflow-wrap: break-word;
    }

    .article-body tr:nth-child(even) {
        background: rgba(255, 255, 255, 0.01);
    }

    /* Code highlights */
    .article-body code {
        font-family: var(--font-mono);
        font-size: 0.85rem;
        background: var(--bg-secondary);
        color: var(--primary);
        border: 1px solid var(--border);
        padding: 0.15rem 0.35rem;
        border-radius: 6px;
    }

    /* Pre container wrapper */
    .code-wrapper {
        position: relative;
        margin: 2rem 0;
        border-radius: 12px;
        border: 1px solid var(--border);
        background: #0f172a;
        overflow: hidden;
    }

    .code-wrapper pre {
        margin: 0;
        padding: 1.25rem;
        overflow-x: auto;
        background: transparent;
    }

    .code-wrapper pre code {
        background: transparent;
        border: none;
        padding: 0;
        color: #e2e8f0;
        font-family: var(--font-mono);
        font-size: 0.82rem;
    }

    .copy-code-btn {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: #94a3b8;
        padding: 0.3rem 0.6rem;
        border-radius: 6px;
        font-size: 0.72rem;
        font-family: var(--font-heading);
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        user-select: none;
    }

    .copy-code-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        color: #f8fafc;
        border-color: rgba(255, 255, 255, 0.2);
    }

    .copy-code-btn.copied {
        background: rgba(34, 197, 94, 0.2);
        color: #4ade80;
        border-color: rgba(34, 197, 94, 0.3);
    }

    .sidebar-widget {
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 16px;
        padding: 1.5rem;
    }

    .widget-title {
        font-family: var(--font-heading);
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-primary);
        font-weight: 700;
        margin-bottom: 1rem;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.5rem;
    }

    .sidebar-stock-list {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .sidebar-stock-item {
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.75rem;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
    }

    .sidebar-stock-item:last-child {
        border: none;
        padding-bottom: 0;
    }

    .stock-item-country {
        font-weight: 700;
        font-size: 0.88rem;
        display: flex;
        align-items: center;
        gap: 0.35rem;
    }

    .stock-item-meta {
        font-size: 0.75rem;
        color: var(--gray);
    }

    .stock-item-price {
        font-size: 0.95rem;
        font-weight: 800;
        color: var(--primary);
        margin-top: 0.25rem;
    }

    /* Related articles */
    .related-section {
        margin-top: var(--section-gap-lg);
        padding-top: var(--section-padding);
        border-top: 1px solid var(--border);
    }

    .related-section-title {
        font-family: var(--font-heading);
        font-size: 1.35rem;
        font-weight: 700;
        margin-bottom: 2rem;
        color: var(--text-primary);
        letter-spacing: -0.02em;
    }

    .related-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 2rem;
    }

    .related-card {
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 16px;
        overflow: hidden;
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        text-decoration: none;
        color: inherit;
        display: flex;
        flex-direction: column;
    }

    .related-card:hover {
        transform: translateY(-2px);
        border-color: var(--primary);
        box-shadow: var(--card-shadow);
    }

    .related-image-wrapper {
        height: 160px;
        width: 100%;
        background: var(--bg-tertiary);
        border-bottom: 1px solid var(--border);
        overflow: hidden;
    }

    .related-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .related-image-placeholder {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--primary);
    }

    .related-card-body {
        padding: 1.25rem;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .related-card-title {
        font-family: var(--font-heading);
        font-weight: 700;
        font-size: 1rem;
        line-height: 1.4;
        color: var(--text-primary);
    }

    .related-card-excerpt {
        font-size: 0.8rem;
        color: var(--text-secondary);
        line-height: 1.5;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
