/* --- Article Header --- */
.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    gap: 1rem;
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: bold;
    white-space: nowrap;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.2s;
}

.back-link:hover {
    background: var(--accent-faded);
    border-color: var(--accent);
}

/* --- Author Card --- */
.author-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.author-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--sidebar-bg);
}

.author-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.author-name {
    font-weight: bold;
    color: var(--text);
    font-size: 1rem;
}

.commit-date {
    font-size: 0.75rem;
    color: var(--secondary);
    margin-top: 4px;
}

/* --- Responsive Adjustments --- */
@media (max-width: 650px) {
    .article-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem 0;
    }

    .back-link {
        order: -1; /* Moves "Back to Home" to the top */
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    
    .author-card {
        width: 100%;
    }
}

/* --- Content / Typography Optimization --- */
.prose {
    line-height: 1.7;
    font-size: 1.05rem;
}

/* Ensure code blocks don't break mobile layout */
.prose pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 1rem;
    border-radius: 8px;
    margin: 1.5rem 0;
    position: relative;
    /* Custom scrollbar for terminal feel */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

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

/* Loading States */
.skeleton-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--border);
    animation: pulse 1.5s infinite;
}

.skeleton-text {
    width: 120px;
    height: 12px;
    background: var(--border);
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

/* --- Global Reset for the Log Viewer --- */
/* 1. The Container: Matches your main page width */
.log-container {
    max-width: 900px;  /* Optimal reading width */
    width: 90%;
    margin: 3rem auto; /* Large top/bottom margin to show shader */
    padding: 3rem;
    border-radius: 20px;
    background-color: color-mix(in srgb, var(--bg), transparent 10%);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    box-sizing: border-box;
    display: block; /* Ensure it's not a grid */
}

/* 2. The Header: Spans the full width of the container */
.article-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 3rem;
}

/* 3. The Content: This is what we constrain for readability */
.prose {
    width: 100%;
    max-width: 100%; /* Prose now just fills its container */
}

/* 4. Desktop Code Blocks: Let them be slightly wider than the text */
@media (max-width: 950px) {
    .log-container {
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding: 1.5rem;
    }
}

/* 5. Mobile Adjustments (The "Lag & Scroll" Fixes) */
@media (max-width: 950px) {
    :root {
        font-size: 14px; /* Scaled down text for mobile */
    }

    .log-container {
        width: 100%;
        padding: 0 1.2rem;
    }

    .prose {
        max-width: 100%; /* Use full width on mobile */
        font-size: 1rem;
    }

    /* Reset the Desktop "pop out" for mobile */
    @media (min-width: 0px) {
        .prose pre {
            width: 100% !important;
            margin-left: 0 !important;
            white-space: pre-wrap; /* Wrap code on small screens */
            word-break: break-all;
        }
    }
    
    .article-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .back-link {
        width: 100%;
        text-align: center;
        order: -1;
    }
}

/* Ensure the sidebar toggle stays above everything */
.sidebar-toggle {
    z-index: 2000;
}

/* Ensure the shader canvas stays in the background */
#bg-canvas {
    z-index: -1;
}

/* Make links in the sidebar navigate back to index correctly */
.side-nav-links a {
    cursor: pointer;
}

.explanation-section {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--accent-faded);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
}

.explanation-section h2 {
    margin-top: 0;
    color: var(--accent);
    font-size: 1.4rem;
    text-transform: uppercase;
}

.explanation-section h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.explanation-section ul {
    padding-left: 1.2rem;
}

.explanation-section li {
    margin-bottom: 0.8rem;
    list-style-type: "󰄬 "; /* Nerd Font Check */
}

/* --- Prism Highlighting Fixes --- */

/* Ensure the background matches your theme but allows Prism colors to show */
.prose pre[class*="language-"] {
    background: var(--code-bg) !important;
    border: 1px solid var(--border);
    margin: 2rem 0;
    padding: 1.2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Make sure the text color doesn't override the tokens */
.prose code[class*="language-"],
.prose pre[class*="language-"] {
    font-family: 'JetBrainsMono NF', monospace !important;
    text-shadow: none !important; /* Prism themes often add shadows we don't want */
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Adjust Prism "Tomorrow" theme tokens to be more vibrant on your dark bg */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #7285b7; }
.token.punctuation { color: #a8b1c1; }
.token.namespace { opacity: .7; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #ff9f43; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #10b981; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: var(--accent); }
.token.atrule, .token.attr-value, .token.keyword { color: #bd93f9; }
.token.function, .token.class-name { color: #38bdf8; }
.token.regex, .token.important, .token.variable { color: #feca57; }

/* --- Author Link Interactivity --- */
.author-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none; /* Remove underline */
    color: inherit; /* Keep text colors from theme */
    padding: 6px 12px;
    margin-left: -12px; /* Pull back to align with text */
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.author-link:hover {
    background: var(--accent-faded);
    border-color: var(--border);
    transform: translateY(-2px);
}

.author-link:hover .author-avatar {
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-faded);
}

.author-link:hover .author-name {
    color: var(--accent);
}

/* Ensure avatar still looks right inside the link */
.author-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--border);
    transition: border-color 0.2s;
}

/* Mirror index.html license button style */
#licenseBtn.nav-item {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 12px 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

#licenseBtn.nav-item:hover {
    background: var(--sidebar-bg);
    color: var(--accent);
    padding-left: 2rem;
}