/* File: css/components/blog.css */

/*
 * ============================================
 *  BLOG STYLES
 * ============================================
 *
 * Styles for:
 * 1. Blog listing page (search, post cards grid)
 * 2. Single post page (article typography, progress bar)
 * 3. Share buttons
 * 4. Author bio
 * 5. Related posts
 * 6. Table of contents
 */


/* ==========================================
   1. BLOG SEARCH BAR
   ========================================== */

.blog-search {
    max-width: 500px;
    margin: 0 auto var(--space-xl);
    position: relative;
}

.blog-search__input {
    width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-family: var(--font-primary);
    transition: all var(--transition-fast);
}

.blog-search__input::placeholder {
    color: var(--text-secondary);
}

.blog-search__input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(100, 255, 218, 0.1);
}

[data-theme="light"] .blog-search__input:focus {
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.blog-search__icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

.blog-search__clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.blog-search__clear.visible {
    display: flex;
}

.blog-search__clear:hover {
    color: var(--accent-primary);
}

/* Search results count */
.blog-search__results {
    text-align: center;
    font-size: var(--fs-sm);
    font-family: var(--font-mono);
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    display: none;
}

.blog-search__results.visible {
    display: block;
}

.blog-search__results-count {
    color: var(--accent-primary);
    font-weight: 700;
}


/* ==========================================
   2. BLOG POST CARDS (listing page)
   ========================================== */

.blog-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xl);
}

@media (max-width: 768px) {
    .blog-grid {
        grid-template-columns: 1fr;
    }
}

/* Featured post (first post, larger) */
.blog-post-card--featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0;
}

.blog-post-card--featured .card__image-wrapper {
    height: 100%;
    min-height: 280px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.blog-post-card--featured .card__body {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.blog-post-card--featured .card__title {
    font-size: var(--fs-xl);
}

@media (max-width: 768px) {
    .blog-post-card--featured {
        grid-template-columns: 1fr;
    }

    .blog-post-card--featured .card__image-wrapper {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        min-height: 200px;
    }
}

/* Reading time badge */
.blog-post-card__reading-time {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* Tags on blog cards */
.blog-post-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

.blog-post-card__tag {
    padding: 2px 8px;
    background: rgba(100, 255, 218, 0.06);
    border: 1px solid rgba(100, 255, 218, 0.12);
    color: var(--accent-primary);
    font-size: 0.65rem;
    font-family: var(--font-mono);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-post-card__tag:hover {
    background: rgba(100, 255, 218, 0.12);
}

[data-theme="light"] .blog-post-card__tag {
    background: rgba(0, 102, 204, 0.04);
    border-color: rgba(0, 102, 204, 0.1);
}


/* ==========================================
   3. READING PROGRESS BAR
   ========================================== */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--accent-gradient);
    z-index: calc(var(--z-sticky) + 10);
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}


/* ==========================================
   4. SINGLE POST — ARTICLE LAYOUT
   ========================================== */

.post-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: var(--space-3xl);
    align-items: start;
}

@media (max-width: 1024px) {
    .post-layout {
        grid-template-columns: 1fr;
    }
}

/* ---- Post Header ---- */
.post-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto var(--space-3xl);
}

.post-header__category {
    display: inline-block;
    padding: var(--space-xs) var(--space-md);
    background: rgba(100, 255, 218, 0.1);
    border: 1px solid rgba(100, 255, 218, 0.2);
    color: var(--accent-primary);
    font-size: var(--fs-xs);
    font-family: var(--font-mono);
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-lg);
}

[data-theme="light"] .post-header__category {
    background: rgba(0, 102, 204, 0.06);
    border-color: rgba(0, 102, 204, 0.15);
}

.post-header__title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: var(--space-lg);
    color: var(--text-heading);
}

.post-header__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.post-header__meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.post-header__meta-divider {
    opacity: 0.3;
}

/* Featured image */
.post-featured-image {
    width: 100%;
    max-height: 500px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-3xl);
}

.post-featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-featured-image__placeholder {
    width: 100%;
    height: 300px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}


/* ---- Article Content ---- */
.post-content {
    max-width: 720px;
}

/* Typography for article content */
.post-content h2 {
    font-size: var(--fs-2xl);
    margin-top: var(--space-3xl);
    margin-bottom: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
    scroll-margin-top: calc(var(--header-height) + var(--space-lg));
}

.post-content h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.post-content h3 {
    font-size: var(--fs-xl);
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-md);
    scroll-margin-top: calc(var(--header-height) + var(--space-lg));
}

.post-content p {
    font-size: var(--fs-md);
    line-height: 1.9;
    margin-bottom: var(--space-lg);
    color: var(--text-primary);
}

.post-content a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(100, 255, 218, 0.3);
    transition: text-decoration-color var(--transition-fast);
}

.post-content a:hover {
    text-decoration-color: var(--accent-primary);
}

.post-content strong {
    color: var(--text-heading);
    font-weight: 600;
}

.post-content ul,
.post-content ol {
    margin-bottom: var(--space-lg);
    padding-left: var(--space-xl);
}

.post-content li {
    font-size: var(--fs-md);
    line-height: 1.8;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.post-content ul li {
    list-style-type: disc;
}

.post-content ol li {
    list-style-type: decimal;
}

.post-content ul li::marker,
.post-content ol li::marker {
    color: var(--accent-primary);
}

/* Blockquotes */
.post-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: var(--space-md) var(--space-xl);
    margin: var(--space-xl) 0;
    background: rgba(100, 255, 218, 0.03);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
}

[data-theme="light"] .post-content blockquote {
    background: rgba(0, 102, 204, 0.03);
}

.post-content blockquote p {
    margin-bottom: 0;
    color: var(--text-primary);
}

/* Code blocks */
.post-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    padding: 2px 6px;
    background: var(--code-bg);
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
}

.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin: var(--space-xl) 0;
    overflow-x: auto;
    font-size: var(--fs-sm);
    line-height: 1.7;
}

.post-content pre code {
    padding: 0;
    background: none;
    border-radius: 0;
    color: var(--text-primary);
}

/* Images in posts */
.post-content img {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin: var(--space-xl) 0;
}

.post-content figure {
    margin: var(--space-xl) 0;
}

.post-content figcaption {
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: var(--space-sm);
    font-style: italic;
}

/* Horizontal rule */
.post-content hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: var(--space-3xl) 0;
}


/* ==========================================
   5. TABLE OF CONTENTS (sidebar)
   ========================================== */

.toc {
    position: sticky;
    top: calc(var(--header-height) + var(--space-xl));
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    max-height: calc(100vh - var(--header-height) - var(--space-3xl));
    overflow-y: auto;
}

.toc__title {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-mono);
}

.toc__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.toc__link {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
    display: block;
    line-height: 1.5;
}

.toc__link:hover {
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    background: rgba(100, 255, 218, 0.05);
}

.toc__link.active {
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

.toc__link--h3 {
    padding-left: var(--space-xl);
    font-size: var(--fs-xs);
}

@media (max-width: 1024px) {
    .toc {
        display: none;
    }
}


/* ==========================================
   6. SHARE BUTTONS
   ========================================== */

.share-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin: var(--space-2xl) 0;
    flex-wrap: wrap;
}

.share-bar__label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-heading);
    font-family: var(--font-mono);
}

.share-bar__buttons {
    display: flex;
    gap: var(--space-sm);
}

.share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.share-btn--copied {
    background: #22c55e;
    color: #ffffff;
    border-color: #22c55e;
}


/* ==========================================
   7. AUTHOR BIO
   ========================================== */

.author-bio {
    display: flex;
    gap: var(--space-xl);
    padding: var(--space-xl);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin: var(--space-3xl) 0;
}

.author-bio__avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--text-on-accent);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.author-bio__name {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: var(--space-xs);
}

.author-bio__role {
    font-size: var(--fs-sm);
    color: var(--accent-primary);
    font-family: var(--font-mono);
    margin-bottom: var(--space-sm);
}

.author-bio__text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: 1.7;
}

@media (max-width: 640px) {
    .author-bio {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}


/* ==========================================
   8. POST NAVIGATION (prev/next)
   ========================================== */

.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin: var(--space-3xl) 0;
}

.post-nav__item {
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: all var(--transition-base);
}

.post-nav__item:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.post-nav__item--next {
    text-align: right;
}

.post-nav__label {
    font-size: var(--fs-xs);
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.post-nav__item--next .post-nav__label {
    justify-content: flex-end;
}

.post-nav__title {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--text-heading);
    line-height: 1.4;
}

@media (max-width: 640px) {
    .post-nav {
        grid-template-columns: 1fr;
    }
}


/* ==========================================
   9. NO RESULTS STATE
   ========================================== */

.blog-no-results {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    display: none;
}

.blog-no-results.visible {
    display: block;
}

.blog-no-results__icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
    display: block;
}

.blog-no-results__title {
    font-size: var(--fs-xl);
    color: var(--text-heading);
    margin-bottom: var(--space-sm);
}

.blog-no-results__text {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}