/* css/blog-post.css */
/* Refined Blog Post Styles (Assumes cms-base.css is loaded) */
/* Incorporates fixes for Share dropdown */

/* --- Use CMS Base Variables --- */
/* Variables like --primary-color are inherited via cms-base.css */

/* Base styling for blog post container */
.blog-post .container {
    max-width: 800px; /* Optimized line length */
}

/* Navigation */
.blog-nav {
    background-color: var(--bg-color);
    padding: var(--cms-spacing-unit) 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 1000; /* Ensure nav stays above content */
    border-bottom: 1px solid var(--border-color);
}

.blog-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px; /* Allow nav to span wider */
    margin: 0 auto;
    padding: 0 var(--cms-spacing-unit);
}

.nav-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    transition: var(--cms-transition);
    font-family: var(--cms-font-sans);
}

.nav-back:hover {
    color: var(--secondary-color);
    opacity: 0.8;
}

/* --- Recommendation: Fix Share Button/Dropdown Styling (Copied from paper.css fix) --- */
.nav-share {
    position: relative; /* Needed for absolute positioning of dropdown */
}

.share-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    color: var(--primary-color);
    transition: var(--cms-transition);
    font-family: var(--cms-font-sans);
    font-size: 0.9rem; /* Ensure consistent size */
}

.share-button i {
    font-size: 0.9em; /* Adjust icon size relative to button text */
}

.share-button:hover {
    background-color: var(--section-bg-color); /* Use theme variable */
    border-color: var(--primary-color);
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 8px); /* Position below the button with a gap */
    right: 0;
    background-color: var(--bg-color); /* Use theme background */
    box-shadow: var(--shadow-medium); /* Use theme shadow */
    border-radius: var(--cms-radius);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    width: max-content; /* Adjust width based on content */
    min-width: 160px; /* Minimum width */
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 0.25rem;
    z-index: 1010; /* Ensure it's above other elements */
}

.share-dropdown.active {
    display: flex; /* Show when active class is added by JS */
}

.share-link {
    padding: 0.6rem 1rem; /* Adjust padding for better click area */
    text-decoration: none;
    color: var(--text-color); /* Use theme text color */
    border-radius: calc(var(--cms-radius) / 2);
    transition: var(--cms-transition);
    font-size: 0.9rem;
    font-family: var(--cms-font-sans);
    display: flex; /* Align icon and text if icons are added */
    align-items: center;
    gap: 0.5rem;
}

.share-link:hover {
    background-color: var(--section-bg-color); /* Use theme variable */
    color: var(--primary-color);
}
/* --- End Share Button Fix --- */

/* Header Styles */
.post-header {
    text-align: center;
    margin-bottom: calc(var(--cms-spacing-unit) * 3);
    padding-bottom: var(--cms-spacing-unit);
}

.post-header h1 {
    font-size: 2.6rem;
    color: var(--primary-color);
    margin-bottom: var(--cms-spacing-unit);
    line-height: 1.2;
    font-family: var(--cms-font-heading); /* Ensure heading font */
}

.post-meta {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    color: var(--light-text-color);
    font-size: 0.9rem;
    margin-bottom: var(--cms-spacing-unit);
    font-family: var(--cms-font-sans);
}

.post-meta span { display: flex; align-items: center; gap: 0.4rem; }
.post-meta span:not(:first-child)::before { content: '|'; color: var(--border-color); margin-right: 1.5rem; display: inline-block; }
.post-meta .post-topic { font-weight: 600; color: var(--secondary-color); }

/* Table of Contents */
.table-of-contents {
    background-color: var(--section-bg-color);
    border-radius: var(--cms-radius);
    padding: 1.5rem 2rem;
    margin: calc(var(--cms-spacing-unit) * 2) auto;
    max-width: 700px;
    border: 1px solid var(--border-color);
    box-shadow: none;
    text-align: left;
}

.table-of-contents h3 { margin-bottom: 1rem; color: var(--primary-color); font-family: var(--cms-font-heading); font-size: 1.2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.table-of-contents ul { list-style: none; padding: 0; margin: 0; }
.table-of-contents li { margin-bottom: 0.5rem; font-size: 0.95rem; }
.table-of-contents a { text-decoration: none; color: var(--text-color); transition: var(--cms-transition); display: inline-block; padding: 0.25rem 0; position: relative; }
.table-of-contents a:hover { color: var(--secondary-color); transform: translateX(3px); }
.table-of-contents a.active { color: var(--secondary-color); font-weight: 600; }
.table-of-contents a.active::before { content: ''; position: absolute; left: -1rem; top: 50%; transform: translateY(-50%); width: 4px; height: 80%; background-color: var(--secondary-color); border-radius: 2px; }
.toc-sub-item { margin-left: 1.5rem; padding-left: 0.5rem; border-left: 1px solid var(--border-color); margin-top: 0.25rem; margin-bottom: 0.25rem; }

/* Content Styles */
.post-content { margin-bottom: calc(var(--cms-spacing-unit) * 3); }
.post-content h2, .post-content h3, .post-content h4, .post-content h5, .post-content h6 { color: var(--primary-color); font-family: var(--cms-font-heading); margin-top: calc(var(--cms-spacing-unit) * 2.5); margin-bottom: calc(var(--cms-spacing-unit) * 1.2); line-height: 1.3; scroll-margin-top: 80px; }
.post-content h2 { font-size: 1.8rem; border-bottom: 2px solid var(--secondary-color); padding-bottom: 0.5rem; color: var(--primary-color); }
.post-content h3 { font-size: 1.5rem; color: var(--text-color); }
.post-content h4 { font-size: 1.2rem; font-weight: 600; }
.post-content p { margin-bottom: var(--cms-spacing-unit); font-size: 1.05rem; color: var(--text-color); max-width: 65ch; font-family: var(--cms-font-body); }
.post-content p strong { color: var(--primary-color); font-weight: 600; }
.post-content a { color: var(--secondary-color); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.post-content a:hover { color: var(--primary-color); text-decoration-thickness: 2px; }
.post-content ul, .post-content ol { margin: var(--cms-spacing-unit) 0; padding-left: calc(var(--cms-spacing-unit) * 1.5); max-width: 65ch; }
.post-content li { margin-bottom: calc(var(--cms-spacing-unit) * 0.5); padding-left: 0.5rem; }
.post-content p:first-child::first-letter, .post-content li > p:first-child::first-letter { float: left; font-size: 1.5em; line-height: 1; margin-right: 0.5rem; margin-top: 0.1em; }
hr { border: none; height: 1px; background-color: var(--border-color); margin: calc(var(--cms-spacing-unit) * 3) auto; width: 60%; }

/* Footer Styles */
.post-footer { margin-top: calc(var(--cms-spacing-unit) * 3); padding-top: calc(var(--cms-spacing-unit) * 2); border-top: 1px solid var(--border-color); }
.post-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: calc(var(--cms-spacing-unit) * 2); }
.post-tag { display: inline-block; padding: 0.4rem 1rem; background-color: var(--section-bg-color); border: 1px solid var(--border-color); border-radius: 20px; color: var(--text-color); text-decoration: none; transition: var(--cms-transition); font-size: 0.85rem; font-family: var(--cms-font-sans); }
.post-tag:hover { background-color: var(--secondary-color); border-color: var(--secondary-color); color: var(--bg-color); transform: translateY(-2px); }
.author-section { background-color: var(--section-bg-color); border-radius: var(--cms-radius); padding: calc(var(--cms-spacing-unit) * 1.5); margin-bottom: calc(var(--cms-spacing-unit) * 2); border: 1px solid var(--border-color); box-shadow: none; }
.author-info { display: flex; align-items: center; gap: 1.5rem; }
.author-image { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color); }
.author-bio h3 { color: var(--primary-color); margin-bottom: 0.25rem; font-family: var(--cms-font-heading); font-size: 1.1rem; }
.author-bio p { color: var(--light-text-color); font-size: 0.9rem; margin-bottom: 0; }
.post-cta { text-align: center; padding: calc(var(--cms-spacing-unit) * 2); background-color: var(--primary-color); color: var(--bg-color); border-radius: var(--cms-radius); margin-top: calc(var(--cms-spacing-unit) * 2); }
.post-cta h3 { font-size: 1.6rem; color: var(--bg-color); margin-bottom: 0.75rem; }
.post-cta p { color: rgba(255, 255, 255, 0.8); font-size: 1rem; margin-bottom: 1.5rem; max-width: 100%; }
.cta-button { display: inline-block; padding: 0.8rem 1.8rem; background-color: var(--accent-color); color: var(--primary-color); border-radius: 30px; text-decoration: none; font-weight: 600; transition: var(--cms-transition); font-family: var(--cms-font-heading); border: none; }
.cta-button:hover { background-color: #e6ae06; transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); }
.post-navigation { margin-top: calc(var(--cms-spacing-unit) * 2); }
.post-nav-links { display: flex; justify-content: space-between; gap: 1rem; }
.post-nav-links a { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: var(--text-color); font-weight: 600; transition: var(--cms-transition); padding: 0.5rem 1rem; border: 1px solid var(--border-color); border-radius: var(--cms-radius); font-family: var(--cms-font-sans); }
.post-nav-links a:hover { color: var(--secondary-color); background-color: var(--section-bg-color); border-color: var(--secondary-color); }
.post-nav-links .prev::before { content: '←'; margin-right: 0.3em; }
.post-nav-links .next::after { content: '→'; margin-left: 0.3em; }

/* Blockquotes */
blockquote { border-left: 4px solid var(--secondary-color); padding: 1rem 1.5rem; background-color: var(--section-bg-color); margin: calc(var(--cms-spacing-unit) * 1.5) 0; font-style: normal; position: relative; font-family: var(--cms-font-serif); color: var(--text-color); border-radius: 0 var(--cms-radius) var(--cms-radius) 0; }
blockquote p { margin-bottom: 0.5rem; }
blockquote p:last-child { margin-bottom: 0; }

/* Image styles */
.post-content figure { margin: calc(var(--cms-spacing-unit) * 2) 0; text-align: center; }
.post-content img { max-width: 100%; height: auto; border-radius: var(--cms-radius); margin: 0 auto; display: block; border: 1px solid var(--border-color); box-shadow: var(--shadow-soft); }
figcaption.image-caption { text-align: center; font-size: 0.9rem; color: var(--light-text-color); margin-top: 0.75rem; font-style: italic; }

/* Reading progress bar */
.reading-progress { position: fixed; top: 0; left: 0; width: 100%; height: 4px; background-color: transparent; z-index: 1001; pointer-events: none; }
.reading-progress-bar { height: 100%; background: linear-gradient(to right, var(--secondary-color), var(--accent-color)); width: 0%; transition: width 0.2s ease-out; border-radius: 0 2px 2px 0; }

/* Table styling */
.table-container { overflow-x: auto; margin: calc(var(--cms-spacing-unit) * 1.5) 0; border: 1px solid var(--border-color); border-radius: var(--cms-radius); }
.post-content table { width: 100%; border-collapse: collapse; margin: 0; font-size: 0.95rem; }
.post-content thead { background-color: var(--section-bg-color); border-bottom: 2px solid var(--border-color); }
.post-content th, .post-content td { padding: 0.8rem 1rem; text-align: left; border: none; border-bottom: 1px solid var(--border-color); vertical-align: top; }
.post-content th { font-weight: 600; color: var(--primary-color); }
.post-content tbody tr:last-child td { border-bottom: none; }
.post-content tbody tr:hover { background-color: var(--section-bg-color); }

/* Responsive design */
@media (max-width: 768px) {
    .blog-post .container { padding: 0 calc(var(--cms-spacing-unit) * 0.75); }
    .post-header h1 { font-size: 2rem; }
    .post-meta { gap: 0.5rem; flex-direction: column; align-items: center; }
    .post-meta span:not(:first-child)::before { display: none; }
    .post-content h2 { font-size: 1.6rem; }
    .post-content h3 { font-size: 1.3rem; }
    .post-content p, .post-content ul, .post-content ol { font-size: 1rem; max-width: none; }
    .author-info { flex-direction: column; text-align: center; gap: 1rem; }
    .post-nav-links { flex-direction: column; gap: 0.5rem; }
    .post-nav-links a { justify-content: center; }
    .table-container { border-radius: 4px; }
    .post-content th, .post-content td { padding: 0.6rem 0.8rem; font-size: 0.9rem; }
}

/* Print styles */
@media print {
    .blog-nav, .post-cta, .post-navigation, .post-footer, .reading-progress, .page-controls-fixed, .table-of-contents, .author-section { display: none; }
    body { color: #000; background: #fff; }
    .blog-post { padding: 0; }
    .blog-post .container { max-width: 100%; padding: 0; }
    .post-header h1, .post-content h2, .post-content h3, .post-content h4 { color: #000; border: none; }
    a { text-decoration: none; color: #000; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
    blockquote { border-left: 2px solid #ccc; background: #f9f9f9; padding: 0.5rem 1rem; page-break-inside: avoid; }
    pre, code { font-family: monospace; background: #eee; border: 1px solid #ddd; page-break-inside: avoid; white-space: pre-wrap; word-wrap: break-word; }
    img { max-width: 100% !important; page-break-inside: avoid; }
    table { page-break-inside: avoid; }
    thead { display: table-header-group; }
}

/* Animation */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.post-header, .post-content > *, .post-footer > * { animation: fadeInUp 0.5s ease-out forwards; opacity: 0; }
.post-content > *:nth-child(1) { animation-delay: 0.1s; }
.post-content > *:nth-child(2) { animation-delay: 0.15s; }
.post-content > *:nth-child(3) { animation-delay: 0.2s; }
