/* Article Page Specific Styles - Rewritten */

:root {
    --article-primary-color: var(--g-blog-accent, #007bff); /* Blue for links and accents */
    --article-primary-hover-color: var(--g-blog-accent-hover, #0056b3); /* Darker blue for hover states */
    --article-text-color: #212529; /* Dark grey for main text */
    --article-text-muted-color: #6c757d; /* Lighter grey for meta text, borders */
    --article-background-color: #ffffff; /* White background for the article card */
    --article-page-background-color: #f4f6f8; /* Light grey for the page background */
    --article-border-color: #dee2e6; /* Light border color */
    --article-code-background-color: #f8f9fa; /* Background for inline code */
    --article-code-text-color: #e83e8c; /* Pinkish color for inline code text */
    --article-pre-background-color: #282c34; /* Dark background for code blocks */
    --article-pre-text-color: #abb2bf; /* Light text for code blocks */
    --article-tag-background-color: #e9ecef;
    --article-tag-text-color: #495057;

    --article-font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --article-font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --article-font-size-base: 1rem; /* Approx 16px */
    --article-font-size-lg: 1.25rem;
    --article-font-size-sm: 0.875rem;
    --article-font-size-xs: 0.75rem;

    --article-line-height-base: 1.65;
    --article-line-height-heading: 1.3;

    --article-border-radius: 0.3rem;
    --article-box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --article-content-max-width: 720px; /* Max width for the article content area */
    --article-page-max-width: 1200px; /* Increased max width for sidebar layout */
    --sidebar-width: 280px; /* Width of the sidebar */
}

body.article-view { /* Add a class to body on article.php for specific targeting */
    background-color: var(--article-page-background-color);
    color: var(--article-text-color);
    font-family: var(--article-font-family-sans-serif);
    line-height: var(--article-line-height-base);
    margin: 0;
    padding: 0;
}

.article-page-wrapper {
    max-width: var(--article-page-max-width);
    margin: 2rem auto;
    padding: 0 1rem;
    display: flex; /* Enable flexbox */
    gap: 2rem; /* Space between sidebar and content */
}

.blog-sidebar { /* Assuming this class is used in blog_sidebar_menu.php */
    flex: 0 0 var(--sidebar-width); /* Sidebar width, don't grow or shrink */
    /* Add any specific sidebar styling here, e.g., background, padding */
    /* background-color: #f9f9f9; */
    /* padding: 1rem; */
    /* border-right: 1px solid var(--article-border-color); */
}

.article-container { /* This is the main content area */
    background-color: var(--article-background-color);
    border: 1px solid var(--article-border-color);
    border-radius: var(--article-border-radius);
    box-shadow: var(--article-box-shadow);
    /* max-width: var(--article-content-max-width); REMOVED - flex item will control width */
    flex-grow: 1; /* Allow content to take remaining space */
    margin: 0; /* Reset margin as flex handles spacing */
    padding: 2rem; /* Increased padding */
    min-width: 0; /* Important for flex items to shrink properly */
}

/* Article Controls: Meta Info & Language Switcher */
.article-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--article-border-color);
    padding-bottom: 1rem;
}

.article-meta-inline {
    font-size: var(--article-font-size-sm);
    color: var(--article-text-muted-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.8rem; /* row-gap column-gap */
}

.article-meta-item {
    /* Base styling for all meta items */
}

.article-meta-inline a,
.article-meta-inline .article-subcategory-name { /* Assuming .article-subcategory-name is a span if not a link */
    color: var(--article-text-muted-color);
    text-decoration: none;
}

.article-meta-inline a:hover {
    color: var(--article-primary-color);
    text-decoration: underline;
}

/* Removed unused .article-meta-inline .article-tag-link rule */

.meta-separator {
    color: var(--article-text-muted-color);
    margin: 0 0.2rem;
    user-select: none;
}

.language-switcher {
    position: relative;
}

.language-switcher label.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.language-switcher select {
    padding: 0.4em 2em 0.4em 0.6em;
    font-size: var(--article-font-size-sm);
    border: 1px solid var(--article-border-color);
    border-radius: var(--article-border-radius);
    background-color: var(--article-background-color);
    color: var(--article-text-color);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23333333' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5em center;
    background-size: 0.8em;
    line-height: 1.3;
    transition: border-color 0.2s ease;
}

.language-switcher select:hover {
    border-color: var(--article-primary-color);
}

.language-switcher select:focus {
    outline: none;
    border-color: var(--article-primary-hover-color);
    box-shadow: 0 0 0 0.2rem rgba(var(--article-primary-color), 0.25);
}

/* Article Header: Title and Main Tags */
.article-header-main {
    margin-bottom: 2rem;
    display: flex; /* Stack title and tags horizontally */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    align-items: flex-start; /* Align items to the start of the cross axis */
    gap: 1rem; /* Space between title and tags block */
}

.article-title-main {
    font-size: 2.5rem; /* Adjusted for better balance */
    color: var(--article-text-color);
    font-weight: 700;
    margin: 0; /* Remove default margins, flex gap will handle spacing */
    line-height: var(--article-line-height-heading);
    flex-grow: 1; /* Allow title to take available space */
}

.article-header-main .article-tags-wrapper {
    margin-top: 0; /* Remove top margin, alignment handled by flex */
    flex-shrink: 0; /* Prevent tags from shrinking too much */
}

.article-header-main .article-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    list-style: none;
    margin: 0; /* Ensure no default margin */
}

.article-header-main .article-tags-wrapper .article-tags-list .article-tag-item { /* Increased specificity */
    display: inline-flex; /* Use flexbox for centering content */
    align-items: center; /* Vertically center content */
    background-color: rgba(56, 142, 60, 0.7) !important; /* Green background with !important */
    color: #ffffff !important; /* White text with !important */
    padding: 0.3em 0.7em; /* Adjusted padding for chip feel */
    border: 1px solid rgba(56, 142, 60, 0.7); /* Green border */
    border-radius: 16px; /* More rounded for chip style */
    text-decoration: none;
    font-size: var(--article-font-size-xs);
    line-height: 1.4;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08); /* Subtle shadow for chip */
}

.article-header-main .article-tags-wrapper .article-tags-list .article-tag-item:hover { /* Increased specificity */
    background-color: rgba(56, 142, 60, 0.9) !important; /* Darker green on hover with !important */
    color: #fff !important;
    border-color: rgba(56, 142, 60, 0.9) !important; /* Darker green border on hover */
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.article-header-main .article-tags-wrapper .article-tags-list li.active a.article-tag-item {
    background-color: var(--blog-accent-green-700) !important;
    color: #ffffff !important;
    border-color: var(--blog-accent-green-700) !important;
    font-weight: 600 !important;
}

/* Featured Image */
.article-image-wrapper-16-9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
    overflow: hidden;
    margin-bottom: 2rem;
    background-color: var(--article-page-background-color); /* Placeholder background */
    border-radius: var(--article-border-radius);
}

.article-image-wrapper-16-9 .article-image-featured {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Article Body Content */
.article-body-content {
    font-size: var(--article-font-size-base);
    line-height: var(--article-line-height-base);
}

.article-body-content h1, /* Assuming H1 might be used in body, though title is separate */
.article-body-content h2,
.article-body-content h3,
.article-body-content h4,
.article-body-content h5,
.article-body-content h6 {
    color: var(--article-text-color);
    margin-top: 2em;
    margin-bottom: 0.8em;
    font-weight: 600;
    line-height: var(--article-line-height-heading);
}

.article-body-content h1 { font-size: 2rem; }
.article-body-content h2 { font-size: 1.75rem; }
.article-body-content h3 { font-size: 1.5rem; }
.article-body-content h4 { font-size: 1.25rem; }
.article-body-content h5 { font-size: 1.1rem; }
.article-body-content h6 { font-size: 1rem; font-weight: bold; }

.article-body-content p {
    margin-bottom: 1.25em;
}

.article-body-content a {
    color: var(--article-primary-color);
    text-decoration: none; /* Underline on hover for cleaner look */
    transition: color 0.2s ease;
}

.article-body-content a:hover {
    color: var(--article-primary-hover-color);
    text-decoration: underline;
}

.article-body-content ul,
.article-body-content ol {
    margin-bottom: 1.25em;
    padding-left: 1.5em; /* Standard indent */
}

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

.article-body-content blockquote {
    border-left: 4px solid var(--article-primary-color);
    padding: 0.75em 1.25em;
    margin: 1.5em 0;
    font-style: italic;
    color: var(--article-text-muted-color);
    background-color: var(--article-page-background-color); /* Slight tint */
    border-radius: 0 var(--article-border-radius) var(--article-border-radius) 0;
}

.article-body-content blockquote p:last-child {
    margin-bottom: 0;
}

.article-body-content img { /* Images within the article body */
    max-width: 100%;
    height: auto;
    border-radius: var(--article-border-radius);
    margin: 1.5em auto;
    display: block;
    box-shadow: var(--article-box-shadow);
}

.article-body-content hr {
    border: 0;
    border-top: 1px solid var(--article-border-color);
    margin: 2.5em 0;
}

.article-body-content table {
    width: 100%;
    margin-bottom: 1.5em;
    border-collapse: collapse;
    font-size: var(--article-font-size-sm);
    border: 1px solid var(--article-border-color);
}

.article-body-content th,
.article-body-content td {
    border: 1px solid var(--article-border-color);
    padding: 0.6em 0.8em;
    text-align: left;
    vertical-align: top;
}

.article-body-content th {
    background-color: var(--article-page-background-color);
    font-weight: 600;
    color: var(--article-text-color);
}

.article-body-content tr:nth-child(even) td {
    background-color: #fbfcfd; /* Very subtle striping */
}

.article-body-content pre {
    background-color: var(--article-pre-background-color);
    color: var(--article-pre-text-color);
    padding: 1em;
    border-radius: var(--article-border-radius);
    overflow-x: auto;
    font-family: var(--article-font-family-monospace);
    font-size: 0.9em;
    line-height: 1.5;
    margin: 1.5em 0;
    white-space: pre;
}

.article-body-content code { /* Inline code */
    background-color: var(--article-code-background-color);
    color: var(--article-code-text-color);
    padding: 0.2em 0.4em;
    border-radius: 0.2rem;
    font-size: 0.9em; /* Relative to surrounding text */
    font-family: var(--article-font-family-monospace);
}

.article-body-content pre code { /* Reset for code inside pre */
    background-color: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit; /* Inherit from pre */
    font-family: inherit; /* Inherit from pre */
}

/* Responsive Adjustments */
@media (max-width: 992px) { /* Adjusted breakpoint for sidebar stacking */
    .article-page-wrapper {
        flex-direction: column; /* Stack sidebar and content */
        gap: 1.5rem;
    }

    .blog-sidebar {
        flex: 0 0 auto; /* Reset flex basis */
        width: 100%; /* Full width when stacked */
        margin-bottom: 1.5rem; /* Space below sidebar when stacked */
        /* border-right: none; */ /* Remove border if it was added */
        /* border-bottom: 1px solid var(--article-border-color); */ /* Optional: add a bottom border */
    }

    .article-container {
        max-width: none; /* Allow full width within its parent */
        margin: 0 auto; /* Center if page-wrapper has padding */
    }
}


@media (max-width: 768px) {
    .article-page-wrapper {
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
        /* flex-direction: column; is inherited */
    }

    .article-container {
        padding: 1.5rem;
    }

    .article-header-main {
        flex-direction: column; /* Stack title and tags vertically on smaller screens */
        align-items: flex-start;
    }

    .article-title-main {
        font-size: 2rem; /* Slightly smaller on tablets */
        margin-bottom: 0.75rem; /* Add back margin when stacked vertically */
    }

    .article-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .article-meta-inline {
        font-size: var(--article-font-size-xs);
        width: 100%;
    }

    .language-switcher {
        width: auto; /* Allow natural width or 100% if desired */
        align-self: flex-start;
    }

    .language-switcher select {
        font-size: var(--article-font-size-xs);
    }

    .article-body-content {
        font-size: 0.95rem;
    }
    .article-body-content h1 { font-size: 1.8rem; }
    .article-body-content h2 { font-size: 1.6rem; }
    .article-body-content h3 { font-size: 1.4rem; }
}

@media (max-width: 576px) {
    .article-page-wrapper {
        margin-top: 1rem;
        padding: 0; /* Full width for container on small screens */
    }

    .article-container {
        padding: 1rem;
        border-radius: 0; /* Full width, no side borders */
        border-left: none;
        border-right: none;
        box-shadow: none;
    }

    /* .article-header-main flex-direction: column is inherited from 768px breakpoint */

    .article-title-main {
        font-size: 1.75rem; /* Smaller on mobile */
    }

    .article-meta-inline {
        gap: 0.3rem 0.6rem;
    }

    .article-meta-inline .article-tag-link {
        font-size: 0.85em;
        padding: 0.15em 0.4em;
    }

    .article-header-main .article-tags-wrapper .article-tags-list .article-tag-item { /* Increased specificity */
        font-size: var(--article-font-size-xs);
        padding: 0.3em 0.6em; /* Adjusted padding for smaller screens */
    }

    .article-body-content {
        font-size: 0.9rem;
    }
    .article-body-content h1 { font-size: 1.6rem; }
    .article-body-content h2 { font-size: 1.45rem; }
    .article-body-content h3 { font-size: 1.3rem; }
    .article-body-content table {
        font-size: var(--article-font-size-xs); /* Make table text smaller */
    }
    .article-body-content pre {
        font-size: 0.85em;
    }
}