/* ========================================
   ARTICLE LAYOUT STYLES
   Full-Width Header + 3-Column Body: Blank | Article | TOC
   ======================================== */

/* ========== FULL-WIDTH HEADER SECTION ========== */

.article-header-wrapper {
    max-width: 1200px;
    margin: 0 auto 4rem auto;
    padding: 0 20px;
    text-align: center;
}

/* 1. Hero Image - Full Width, Full Resolution */
.article-hero-image {
    width: 100%;
    margin-bottom: 2.5rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.article-hero-image img {
    width: 100%;
    height: auto;
    display: block;
    /* No max-width or height constraints - uses full resolution */
}

/* 2. Title - Full Width, Centered */
.article-title-main {
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    text-align: center;
}

/* 3. Author and Date - Full Width, Centered */
.article-byline {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.author-name {
    font-weight: 600;
    color: var(--text-primary);
}

.metadata-separator {
    color: var(--text-tertiary);
}

.article-byline time {
    color: var(--text-secondary);
}

.freshness-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-left: 0.5rem;
}

.freshness-badge.fresh {
    background: #d4edda;
    color: #155724;
}

.freshness-badge.aging {
    background: #fff3cd;
    color: #856404;
}

.freshness-badge.stale {
    background: #f8d7da;
    color: #721c24;
}

/* 4. Tags - Full Width, Centered */
.article-tags-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.article-tag {
    background: var(--accent-color, #33bdef);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.article-tag:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* 5. Share Links - Full Width, Centered, Single Line */
.article-share-header {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0;
    padding-bottom: 2.5rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: nowrap;
    /* Keep all buttons on one line */
}

.share-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    /* Prevent buttons from shrinking */
}

.share-button:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(51, 189, 239, 0.3);
}

.share-button svg {
    width: 20px;
    height: 20px;
}

/* ========== 3-COLUMN BODY LAYOUT ========== */

.article-body-wrapper {
    display: grid;
    grid-template-columns: 1fr minmax(0, 800px) 300px;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 20px 40px 20px;
    /* Added top padding for spacing after header */
}

/* Main Article Content Column */
.article-content-column {
    min-width: 0;
    /* Prevents grid blowout */
}

/* Article Text Content */
.article-text {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 3rem;
    text-align: left;
    /* Reset text alignment for article content */
}

.article-text h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem 0;
    color: var(--text-primary);
}

.article-text h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    color: var(--text-primary);
}

.article-text h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--text-primary);
}

.article-text p {
    margin: 0 0 1.5rem 0;
}

.article-text a {
    color: var(--accent-color);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.article-text a:hover {
    color: var(--accent-hover);
}

.article-text ul,
.article-text ol {
    margin: 0 0 1.5rem 0;
    padding-left: 2rem;
}

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

.article-text img.blogpic {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 2rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-text blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

.article-text code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.article-text pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    margin: 2rem 0;
}

.article-text pre code {
    background: none;
    padding: 0;
}

.article-text hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 2.5rem 0;
}

.article-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
}

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

.article-text th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

/* Right Sidebar: Table of Contents */
.article-toc-column {
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

/* Comments Section */
.comments-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--border-color);
}

.comments-section h3 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.comments-placeholder {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    color: var(--text-secondary);
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 1200px) {
    .article-body-wrapper {
        grid-template-columns: 1fr minmax(0, 700px) 250px;
        gap: 30px;
    }

    .article-title-main {
        font-size: 2.25rem;
    }
}

@media (max-width: 1024px) {
    .article-body-wrapper {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 2rem 20px 40px 20px;
    }

    .article-spacer-left {
        display: none;
    }

    .article-toc-column {
        position: relative;
        top: 0;
        max-height: none;
        margin-top: 2rem;
        padding: 1.5rem;
        background: var(--bg-secondary);
        border-radius: 12px;
    }

    .article-title-main {
        font-size: 2rem;
    }

    .article-text {
        font-size: 1.0625rem;
    }
}

@media (max-width: 768px) {
    .article-header-wrapper {
        padding: 0 15px;
    }

    .article-body-wrapper {
        padding: 2rem 15px 30px 15px;
    }

    .article-title-main {
        font-size: 1.75rem;
    }

    .article-text {
        font-size: 1rem;
    }

    .article-share-header {
        flex-wrap: wrap;
        /* Allow wrapping on very small screens */
        justify-content: center;
    }

    .share-button {
        width: 40px;
        height: 40px;
    }

    .article-hero-image {
        margin-bottom: 1.5rem;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .article-title-main {
        font-size: 1.5rem;
    }

    .article-byline {
        font-size: 0.95rem;
    }

    .article-tags-header {
        gap: 0.4rem;
    }

    .article-tag {
        font-size: 0.85rem;
        padding: 5px 12px;
    }

    .share-button {
        width: 38px;
        height: 38px;
    }
}

/* ========== PRINT STYLES ========== */

@media print {
    .article-body-wrapper {
        grid-template-columns: 1fr;
    }

    .article-spacer-left,
    .article-toc-column,
    .article-share-header,
    .comments-section {
        display: none;
    }

    .article-header-wrapper {
        margin-bottom: 2rem;
    }
}

/* ========== FOOTER SECTION (Bio & Related Posts) ========== */
.article-footer-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 4rem 20px;
}

.related-posts {
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
    padding-top: 3rem;
}

.related-posts-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.related-post-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.related-post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.related-post-image {
    aspect-ratio: 16/9;
    overflow: hidden;
}

.related-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.related-post-card:hover .related-post-image img {
    transform: scale(1.05);
}

.related-post-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.related-post-title {
    font-size: 1.25rem;
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}

.related-post-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.related-post-title a:hover {
    color: var(--accent-color);
}

.related-post-excerpt {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.related-post-meta {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    display: flex;
    justify-content: space-between;
    margin-top: auto;
}

@media (max-width: 900px) {
    .related-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .related-posts-grid {
        grid-template-columns: 1fr;
    }
}