/**
 * Single Post Template - Premium CSS
 * Mobile-first responsive design with advanced features
 */

/*--------------------------------------------------------------
# CSS Variables
--------------------------------------------------------------*/
:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-white: #ffffff;
    --bg-gray-50: #f9fafb;
    --bg-gray-100: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.3s ease;
}

/*--------------------------------------------------------------
# Reading Progress Bar
--------------------------------------------------------------*/
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--bg-gray-100);
    z-index: 9999;
}

.reading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.1s ease;
}

/*--------------------------------------------------------------
# Container Utilities
--------------------------------------------------------------*/
.container-narrow {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px;
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/*--------------------------------------------------------------
# Back Button
--------------------------------------------------------------*/
.post-back-button {
    padding: 24px 0 16px;
    background: var(--bg-white);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
}

.back-link:hover {
    background: var(--bg-white);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateX(-4px);
}

.back-link svg {
    stroke: currentColor;
}

/*--------------------------------------------------------------
# Post Header
--------------------------------------------------------------*/
.post-header {
    padding: 32px 0 40px;
    background: var(--bg-white);
}

.post-category-wrapper {
    margin-bottom: 16px;
}

.post-category-badge {
    display: inline-flex;
    padding: 8px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
}

.post-category-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.post-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 800;
    line-height: 1.2;
    margin: 0 0 32px;
    color: var(--text-primary);
}

/*--------------------------------------------------------------
# Post Meta Bar
--------------------------------------------------------------*/
.post-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.post-meta-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.author-avatar-small {
    flex-shrink: 0;
}

.avatar-img {
    border-radius: 50%;
    display: block;
    border: 2px solid var(--border-color);
}

.post-meta-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.author-name-link {
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 15px;
    transition: color 0.3s ease;
}

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

.post-meta-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.meta-separator {
    opacity: 0.5;
}

.reading-time,
.word-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

.reading-time svg,
.word-count svg {
    stroke: var(--text-muted);
    flex-shrink: 0;
}

/*--------------------------------------------------------------
# Share Buttons
--------------------------------------------------------------*/
.post-share-buttons {
    position: relative;
    display: flex;
    align-items: center;
}

.share-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.share-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.share-button-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
}

.share-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 8px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 100;
}

.share-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.share-option:hover {
    background: var(--bg-gray-50);
}

.share-option svg {
    flex-shrink: 0;
}

.share-option.twitter:hover { color: #1da1f2; }
.share-option.linkedin:hover { color: #0077b5; }
.share-option.facebook:hover { color: #1877f2; }
.share-option.copy-link:hover { color: var(--primary-color); }

/*--------------------------------------------------------------
# Featured Image
--------------------------------------------------------------*/
.post-featured-image {
    padding: 40px 0 64px;
    background: var(--bg-white);
}

.featured-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/*--------------------------------------------------------------
# Post Content Layout
--------------------------------------------------------------*/
.post-content-wrapper {
    padding: 0 0 80px;
    background: var(--bg-gray-50);
}

.post-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 48px;
    align-items: start;
}

/*--------------------------------------------------------------
# Main Content
--------------------------------------------------------------*/
.post-content {
    background: var(--bg-white);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.entry-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5 {
    margin: 48px 0 24px;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
    scroll-margin-top: 100px;
}

.entry-content h2 { font-size: 2rem; }
.entry-content h3 { font-size: 1.5rem; }
.entry-content h4 { font-size: 1.25rem; }
.entry-content h5 { font-size: 1.125rem; }

.entry-content p {
    margin-bottom: 24px;
}

.entry-content a {
    color: var(--primary-color);
    text-decoration: underline;
    transition: color 0.3s ease;
}

.entry-content a:hover {
    color: var(--primary-dark);
}

.entry-content ul,
.entry-content ol {
    margin-bottom: 24px;
    padding-left: 32px;
}

.entry-content li {
    margin-bottom: 12px;
}

.entry-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 32px 0;
    box-shadow: var(--shadow-sm);
}

.entry-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 24px;
    margin: 32px 0;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 1.25rem;
    line-height: 1.6;
}

.entry-content code {
    background: var(--bg-gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    color: var(--text-primary);
}

.entry-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 24px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 32px 0;
}

.entry-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 1rem;
}

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

.entry-content th {
    background: var(--bg-gray-50);
    font-weight: 700;
}

/*--------------------------------------------------------------
# Tags
--------------------------------------------------------------*/
.post-tags {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.tags-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.tags-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag-item {
    padding: 8px 16px;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.tag-item:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/*--------------------------------------------------------------
# Author Card
--------------------------------------------------------------*/
.author-card {
    margin-top: 48px;
    padding: 32px;
    background: linear-gradient(135deg, var(--bg-gray-50) 0%, var(--bg-gray-100) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.author-card-header {
    display: flex;
    gap: 24px;
    align-items: start;
}

.author-avatar-large {
    flex-shrink: 0;
}

.avatar-img-large {
    border-radius: 50%;
    display: block;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.author-card-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.author-card-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 12px;
    transition: color 0.3s ease;
}

.author-card-name:hover {
    color: var(--primary-color);
}

.author-card-bio {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.author-card-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.author-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 14px;
}

.author-card-link {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s ease;
}

.author-card-link:hover {
    color: var(--primary-dark);
}

/*--------------------------------------------------------------
# Post Navigation
--------------------------------------------------------------*/
.post-navigation {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    padding: 24px;
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item:hover {
    background: var(--bg-white);
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.nav-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.nav-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.nav-next {
    text-align: right;
}

.nav-next .nav-label {
    justify-content: flex-end;
}

/*--------------------------------------------------------------
# Related Posts
--------------------------------------------------------------*/
.related-posts-section {
    margin-top: 64px;
}

.related-posts-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.related-posts-title svg {
    stroke: var(--primary-color);
    flex-shrink: 0;
}

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

.related-post-card {
    background: var(--bg-gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.related-post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.related-post-thumb {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    background: var(--bg-gray-100);
}

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

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

.related-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.related-post-card:hover .related-overlay {
    opacity: 1;
}

.read-badge {
    padding: 8px 16px;
    background: white;
    border-radius: var(--radius-full);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 14px;
}

.related-post-content {
    padding: 20px;
}

.related-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 12px;
}

.related-post-title {
    margin: 0 0 12px;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

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

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

.related-post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/*--------------------------------------------------------------
# Sidebar
--------------------------------------------------------------*/
.post-sidebar {
    position: relative;
}

.sidebar-sticky {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/*--------------------------------------------------------------
# Table of Contents Widget
--------------------------------------------------------------*/
.toc-widget {
    background: var(--bg-white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.toc-widget-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 16px;
    color: var(--text-primary);
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toc-nav a {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.toc-nav a:hover {
    background: var(--bg-gray-50);
    color: var(--primary-color);
}

.toc-nav a.active {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
    font-weight: 600;
}

.toc-nav a.toc-h3 {
    padding-left: 24px;
    font-size: 13px;
}

/*--------------------------------------------------------------
# Progress Widget
--------------------------------------------------------------*/
.progress-widget {
    background: var(--bg-white);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.progress-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.progress-percentage {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.25rem;
}

.progress-widget-bar {
    height: 8px;
    background: var(--bg-gray-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-widget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.3s ease;
}

/*--------------------------------------------------------------
# Sidebar CTA
--------------------------------------------------------------*/
.sidebar-cta {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    padding: 32px;
    border-radius: var(--radius-lg);
    text-align: center;
    color: white;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.cta-icon {
    width: 64px;
    height: 64px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.cta-icon svg {
    stroke: white;
}

.cta-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: white;
}

.cta-text {
    margin: 0 0 20px;
    opacity: 0.95;
    line-height: 1.5;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: white;
    color: var(--primary-color);
    border-radius: var(--radius-full);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: var(--transition);
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/*--------------------------------------------------------------
# Comments Wrapper
--------------------------------------------------------------*/
.comments-wrapper {
    margin-top: 64px;
    padding-top: 48px;
    border-top: 1px solid var(--border-color);
}

/*--------------------------------------------------------------
# Responsive Design
--------------------------------------------------------------*/

/* Large Desktop */
@media (max-width: 1280px) {
    .post-layout {
        gap: 32px;
    }
    
    .post-sidebar {
        width: 280px;
    }
}

/* Tablet */
@media (max-width: 1024px) {
    .post-layout {
        grid-template-columns: 1fr;
    }
    
    .post-sidebar {
        display: none;
    }
    
    .post-content {
        padding: 32px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .container-narrow,
    .container-wide {
        padding: 0 20px;
    }
    
    .post-title {
        font-size: 2rem;
        margin-bottom: 24px;
    }
    
    .post-meta-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }
    
    .post-share-buttons {
        width: 100%;
    }
    
    .share-button {
        width: 100%;
        justify-content: center;
    }
    
    .share-dropdown {
        left: 0;
        right: 0;
        width: 100%;
    }
    
    .post-content {
        padding: 24px 20px;
    }
    
    .entry-content {
        font-size: 1rem;
    }
    
    .entry-content h2 { font-size: 1.5rem; }
    .entry-content h3 { font-size: 1.25rem; }
    .entry-content h4 { font-size: 1.125rem; }
    
    .author-card {
        padding: 24px 20px;
    }
    
    .author-card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .post-navigation {
        grid-template-columns: 1fr;
    }
    
    .nav-next {
        text-align: left;
    }
    
    .nav-next .nav-label {
        justify-content: flex-start;
    }
    
    .related-posts-grid {
        grid-template-columns: 1fr;
    }
    
    .post-tags {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .post-title {
        font-size: 1.75rem;
    }
    
    .post-meta-stats {
        flex-wrap: wrap;
    }
    
    .word-count {
        display: none;
    }
}

/*--------------------------------------------------------------
# Animations
--------------------------------------------------------------*/
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-content,
.post-sidebar {
    animation: fadeIn 0.6s ease;
}

/*--------------------------------------------------------------
# Print Styles
--------------------------------------------------------------*/
@media print {
    .reading-progress-bar,
    .post-back-button,
    .post-share-buttons,
    .post-navigation,
    .related-posts-section,
    .post-sidebar,
    .comments-wrapper {
        display: none;
    }
    
    .post-content {
        box-shadow: none;
    }
}
