/* ============================================================
   MicFi Blog — responsive stylesheet (X-inspired compact)
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --bg: #ffffff;
    --bg-card: #f8f9fa;
    --bg-surface: #f1f3f5;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #64748b;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --accent: #7c3aed;
    --accent-light: #8b5cf6;
    --accent-glow: rgba(124, 58, 237, 0.12);
    --gradient: linear-gradient(135deg, #7c3aed, #a855f7);
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius: 10px;
    --radius-sm: 8px;
    --max-width: 1200px;
    --header-h: 56px;
    --prose-size: 16px;
    --prose-line: 1.7;
}

[data-theme="dark"] {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-surface: #1a1a25;
    --text: #f1f1f4;
    --text-secondary: #a1a1aa;
    --text-muted: #9ca3af;
    --border: #27272a;
    --border-light: #1e1e28;
    --accent: #a78bfa;
    --accent-light: #c4b5fd;
    --accent-glow: rgba(167, 139, 250, 0.1);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-light); }
img { max-width: 100%; height: auto; display: block; }

/* --- Layout --- */
.blog-container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* --- Header --- */
.blog-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}
.blog-header-inner {
    max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    height: var(--header-h);
}
.blog-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.blog-logo-text {
    font-size: 13px; font-weight: 600;
    padding: 3px 10px; border-radius: 20px;
    background: var(--accent-glow); color: var(--accent);
}
.blog-header-actions { display: flex; gap: 6px; }
.blog-theme-toggle {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .2s; font-size: 14px;
}
.blog-theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* --- Hero --- */
.blog-hero {
    padding: 36px 0 24px;
    text-align: center;
    background: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
}
.blog-hero-compact { padding: 24px 0 18px; }
.blog-hero-title {
    font-size: clamp(24px, 4vw, 36px); font-weight: 800;
    letter-spacing: -0.03em; margin-bottom: 6px;
    background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.blog-hero-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 14px; }

/* --- Search --- */
.blog-search-form { max-width: 520px; margin: 0 auto; }
.blog-search-wrap {
    display: flex; align-items: center; gap: 0;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
    transition: border-color .2s, box-shadow .2s;
}
.blog-search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.blog-search-icon { padding-left: 10px; color: var(--text-muted); font-size: 14px; }
.blog-search-input {
    flex: 1; padding: 7px 10px; border: none; background: transparent;
    font-size: 14px; color: var(--text); outline: none; font-family: inherit;
}
.blog-search-input::placeholder { color: var(--text-muted); }
.blog-search-btn {
    padding: 7px 14px; border: none; background: var(--gradient);
    color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
    font-family: inherit; white-space: nowrap;
    transition: opacity .2s;
}
.blog-search-btn:hover { opacity: .9; }

/* --- Category Pills --- */
.blog-category-pills {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 20px; justify-content: center;
}
.blog-pill {
    padding: 6px 14px; border-radius: 20px;
    font-size: 12px; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); transition: all .2s;
    display: inline-flex; align-items: center; gap: 5px;
}
.blog-pill:hover { border-color: var(--accent); color: var(--accent); }
.blog-pill.active {
    background: var(--gradient); color: #fff; border-color: transparent;
}
.blog-pill-count { font-size: 11px; opacity: .7; }

/* --- Grid --- */
.blog-section { padding: 20px 0 32px; }
.blog-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* --- Card --- */
.blog-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: transform .25s, box-shadow .25s, border-color .25s;
    display: flex; flex-direction: column;
}
.blog-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.blog-card-image-wrap {
    position: relative; display: block; aspect-ratio: 16/9; overflow: hidden;
    background: var(--bg-surface);
}
.blog-card-image {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform .4s;
}
.blog-card:hover .blog-card-image { transform: scale(1.05); }
.blog-card-placeholder {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: var(--text-muted); background: var(--bg-surface);
}
.blog-card-badge {
    position: absolute; top: 10px; left: 10px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    background: var(--gradient); color: #fff;
}
.blog-card-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.blog-card-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; font-size: 11px; color: var(--text-muted); }
.blog-card-dot { opacity: .5; }
.blog-card-reading { display: inline-flex; align-items: center; gap: 3px; }
.blog-card-title { font-size: 15px; font-weight: 700; line-height: 1.35; margin-bottom: 4px; }
.blog-card-title a { color: var(--text); }
.blog-card-title a:hover { color: var(--accent); }
.blog-card-excerpt {
    font-size: 13px; color: var(--text-secondary); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 10px; flex: 1;
}
.blog-card-footer { display: flex; align-items: center; justify-content: space-between; }
.blog-card-read-more {
    font-size: 12px; font-weight: 600; color: var(--accent);
    display: inline-flex; align-items: center; gap: 3px;
    transition: gap .2s;
}
.blog-card:hover .blog-card-read-more { gap: 6px; }
.blog-card-likes { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }
.blog-card-likes i { color: #ef4444; font-size: 11px; }

/* --- Search results info --- */
.blog-search-results-info { margin-bottom: 16px; font-size: 14px; color: var(--text-secondary); }
.blog-results-count { color: var(--text-muted); font-size: 12px; }

/* --- Pagination --- */
.blog-pagination {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-top: 32px;
}
.blog-pagination-btn {
    padding: 8px 16px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text); transition: all .2s;
    display: inline-flex; align-items: center; gap: 5px;
}
.blog-pagination-btn:hover { border-color: var(--accent); color: var(--accent); }
.blog-pagination-info { font-size: 13px; color: var(--text-muted); }

/* --- Empty state --- */
.blog-empty {
    grid-column: 1 / -1; text-align: center; padding: 60px 16px;
    color: var(--text-muted);
}
.blog-empty i { font-size: 40px; margin-bottom: 12px; display: block; }
.blog-empty h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 6px; }

/* ============================================================
   DETAIL PAGE
   ============================================================ */
.blog-article { padding: 36px 0 40px; }
.blog-article-hero { max-width: 720px; margin: 0 auto; overflow: hidden; border-radius: var(--radius); }
.blog-article-hero-img { width: 100%; height: auto; }
.blog-article-layout {
    display: grid; grid-template-columns: 1fr 260px; gap: 32px;
    padding-top: 28px; align-items: start;
}
.blog-article-main { min-width: 0; overflow: hidden; }

/* Header */
.blog-article-header { margin-bottom: 20px; }
.blog-article-category {
    display: inline-block; padding: 3px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    background: var(--gradient); color: #fff; margin-bottom: 12px;
}
.blog-article-title {
    font-size: clamp(22px, 3.5vw, 32px); font-weight: 800;
    line-height: 1.2; letter-spacing: -0.02em; margin-bottom: 12px;
}
.blog-article-meta {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    font-size: 13px; color: var(--text-muted);
}
.blog-meta-brand { font-weight: 600; color: var(--accent); }
.blog-meta-sep { opacity: .4; }

/* Share */
.blog-article-share {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.blog-share-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.blog-share-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-secondary); font-size: 14px;
    cursor: pointer; transition: all .2s;
}
.blog-share-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.blog-share-x:hover { color: #1d9bf0; border-color: #1d9bf0; }
.blog-share-fb:hover { color: #1877f2; border-color: #1877f2; }
.blog-share-copy:hover { color: var(--accent); }
.blog-share-wa:hover { color: #25d366; border-color: #25d366; }

/* Prose content */
.blog-prose { font-size: var(--prose-size); line-height: var(--prose-line); color: var(--text); }
.blog-prose h2 { font-size: 20px; font-weight: 700; margin: 28px 0 12px; letter-spacing: -0.01em; scroll-margin-top: 70px; }
.blog-prose h3 { font-size: 18px; font-weight: 600; margin: 24px 0 10px; scroll-margin-top: 70px; }
.blog-prose p { margin-bottom: 16px; }
.blog-prose ul, .blog-prose ol { margin-bottom: 16px; padding-left: 20px; }
.blog-prose li { margin-bottom: 6px; }
.blog-prose blockquote {
    border-left: 3px solid var(--accent); padding: 12px 16px;
    margin: 20px 0; background: var(--accent-glow);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic; color: var(--text-secondary);
}
.blog-prose pre {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px;
    overflow-x: auto; font-size: 13px; margin: 20px 0;
}
.blog-prose code {
    background: var(--bg-surface); padding: 2px 5px; border-radius: 4px;
    font-size: 0.9em;
}
.blog-prose pre code { background: none; padding: 0; }
.blog-prose img, .blog-prose video {
    max-width: 100% !important; height: auto !important; display: block;
    border-radius: var(--radius); margin: 20px auto;
}
.blog-prose iframe { max-width: 100%; display: block; margin: 20px auto; }
.blog-prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.blog-prose a:hover { color: var(--accent-light); }

/* Embeds */
.blog-embed { margin: 20px 0; border-radius: var(--radius); overflow: hidden; }
.blog-embed-youtube { position: relative; padding-bottom: 56.25%; }
.blog-embed-youtube iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.blog-embed-twitter { margin: 20px 0; }

/* Article actions */
.blog-article-actions {
    display: flex; gap: 10px; margin: 20px 0;
    padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.blog-bookmark-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px;
    font-size: 13px; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; transition: all .2s;
    font-family: inherit;
}
.blog-bookmark-btn:hover { border-color: var(--accent); color: var(--accent); }
.blog-bookmark-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* ============================================================
   COMMENTS
   ============================================================ */
.blog-comments { margin: 20px 0; }
.blog-section-title {
    font-size: 16px; font-weight: 700; margin-bottom: 16px;
    display: flex; align-items: center; gap: 6px;
}
.blog-comment-count {
    font-size: 11px; font-weight: 600;
    background: var(--accent-glow); color: var(--accent);
    padding: 2px 8px; border-radius: 20px;
}

/* Comment form */
.blog-comment-form { margin-bottom: 14px; }
.blog-comment-form-fields { display: flex; flex-direction: column; gap: 10px; }
.blog-comment-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.blog-comment-field { display: flex; flex-direction: column; gap: 0; }
.blog-input, .blog-textarea {
    width: 100%; padding: 10px 14px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text); font-size: 13px; font-family: inherit;
    transition: border-color .2s, box-shadow .2s; outline: none;
}
.blog-input:focus, .blog-textarea:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
.blog-textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.blog-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 10px 20px; border-radius: 8px;
    font-size: 13px; font-weight: 600;
    border: none; cursor: pointer; transition: all .2s;
    font-family: inherit;
}
.blog-btn-primary { background: var(--gradient); color: #fff; }
.blog-btn-primary:hover { opacity: .9; transform: translateY(-1px); }
.blog-btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 6px; }
.blog-btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.blog-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Comments list */
.blog-comments-list { display: flex; flex-direction: column; gap: 12px; }
.blog-no-comments { text-align: center; color: var(--text-muted); padding: 24px 0; font-size: 14px; }

.blog-comment-item { display: flex; gap: 12px; }
.blog-comment-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--gradient); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.blog-comment-body { flex: 1; min-width: 0; }
.blog-comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.blog-comment-author { font-size: 13px; font-weight: 600; }
.blog-comment-time { font-size: 11px; color: var(--text-muted); }
.blog-comment-text { font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.blog-comment-reply-btn {
    font-size: 11px; color: var(--text-muted); background: none; border: none;
    cursor: pointer; margin-top: 4px; display: inline-flex; align-items: center; gap: 3px;
    font-family: inherit; padding: 2px 0;
}
.blog-comment-reply-btn:hover { color: var(--accent); }
.blog-comment-reply { padding-left: 46px; }
.blog-reply-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.blog-reply-actions { display: flex; gap: 6px; }

/* ============================================================
   RELATED POSTS
   ============================================================ */
.blog-related { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ============================================================
   NEWSLETTER
   ============================================================ */
.blog-newsletter { margin: 16px 0; }
.blog-newsletter-inner {
    padding: 14px 16px; border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(168,85,247,0.08));
    border: 1px solid rgba(124,58,237,0.15);
    text-align: center;
}
.blog-newsletter-icon { font-size: 20px; color: var(--accent); margin-bottom: 4px; }
.blog-newsletter-title { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.blog-newsletter-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; max-width: 400px; margin-left: auto; margin-right: auto; }
.blog-newsletter-form { max-width: 420px; margin: 0 auto; }
.blog-newsletter-row { display: flex; gap: 8px; }
.newsletter-input { flex: 1; }
.blog-newsletter-btn { white-space: nowrap; }

/* ============================================================
   TABLE OF CONTENTS (Sidebar)
   ============================================================ */
.blog-article-sidebar {
    position: sticky; top: calc(var(--header-h) + 16px);
}
.blog-toc { margin-bottom: 24px; }
.blog-toc-details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
.blog-toc-title {
    font-size: 13px; font-weight: 600; padding: 12px 14px;
    cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
    color: var(--text);
}
.blog-toc-title::-webkit-details-marker { display: none; }
.blog-toc-title::after { content: '\F282'; font-family: 'bootstrap-icons'; margin-left: auto; font-size: 11px; color: var(--text-muted); transition: transform .2s; }
details[open] > .blog-toc-title::after { transform: rotate(180deg); }
.toc-nav { padding: 2px 14px 12px; }
.toc-list { list-style: none; }
.toc-list li { margin-bottom: 1px; }
.toc-link {
    display: block; padding: 4px 8px; border-radius: 5px;
    font-size: 12px; color: var(--text-secondary); transition: all .2s;
}
.toc-link:hover { color: var(--accent); background: var(--accent-glow); }
.toc-link.active { color: var(--accent); background: var(--accent-glow); font-weight: 500; }
.toc-indent { padding-left: 16px; }

/* ============================================================
   FOOTER
   ============================================================ */
.blog-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    background: var(--bg-surface);
}
.blog-footer-inner {
    max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.blog-footer-brand { display: flex; align-items: center; justify-content: center; }
.blog-footer-nav {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.blog-footer-nav a {
    font-size: 12px; font-weight: 500; color: #475569; transition: color .2s;
    display: inline-flex; align-items: center;
}
.blog-footer-nav a:hover { color: var(--accent); }
.blog-footer-nav a i { font-size: 14px; }
.blog-footer-sep { color: #94a3b8; font-size: 12px; user-select: none; }
.blog-footer-copy { font-size: 12px; color: #475569; text-align: center; }

[data-theme="dark"] .blog-footer-nav a { color: #cbd5e1; }
[data-theme="dark"] .blog-footer-nav a:hover { color: var(--accent); }
[data-theme="dark"] .blog-footer-sep { color: #475569; }
[data-theme="dark"] .blog-footer-copy { color: #cbd5e1; }

/* ============================================================
   RESPONSIVE — Tablet (<=1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .blog-article-layout { grid-template-columns: 1fr; }
    .blog-article-sidebar { display: none; }
    .blog-grid { grid-template-columns: repeat(2, 1fr); }
    .blog-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVE — Mobile (<=640px)
   ============================================================ */
@media (max-width: 640px) {
    :root { --header-h: 50px; }
    .blog-header-inner { padding: 0 14px; }
    .blog-container { padding: 0 14px; }
    .blog-hero { padding: 20px 0 14px; }
    .blog-hero-compact { padding: 16px 0 12px; }
    .blog-section { padding: 20px 0 28px; }

    .blog-grid { grid-template-columns: 1fr; gap: 12px; }
    .blog-grid-3 { grid-template-columns: 1fr; }

    .blog-card-body { padding: 12px; }
    .blog-card-title { font-size: 14px; }

    .blog-article-hero-img { width: 100%; height: auto; }
    .blog-article-title { font-size: 20px; }
    .blog-article-meta { font-size: 12px; }

    .blog-article-share { gap: 6px; margin-bottom: 16px; padding-bottom: 12px; }
    .blog-share-btn { width: 30px; height: 30px; font-size: 13px; }

    .blog-prose { font-size: 15px; }
    .blog-prose h2 { font-size: 18px; }
    .blog-prose h3 { font-size: 16px; }

    .blog-comment-form-row { grid-template-columns: 1fr; }
    .blog-comment-reply { padding-left: 0; }

    .blog-category-pills { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
    .blog-pill { flex-shrink: 0; }

    .blog-search-wrap { gap: 6px; }

    .blog-newsletter-inner { padding: 14px 12px; }
    .blog-newsletter-row { flex-direction: column; align-items: center; }
    .blog-newsletter-form { width: 100%; }
    .blog-newsletter-btn { width: 100%; justify-content: center; }

    .blog-comment-form .blog-btn { width: 100%; justify-content: center; }

    .blog-article-actions { justify-content: center; }
    .blog-bookmark-btn { width: 100%; justify-content: center; }

    .blog-reply-actions { justify-content: center; }
    .blog-reply-actions .blog-btn { flex: 1; }
}

@media (max-width: 400px) {
    .blog-hero-title { font-size: 22px; }
    .blog-search-icon { display: none; }
    .blog-search-wrap { gap: 0; }
    .blog-search-input { padding: 7px 10px; }
    .blog-search-btn { padding: 7px 12px; }
    .blog-input, .blog-textarea { padding: 8px 12px; }
    .blog-reply-actions { flex-direction: column; }
    .blog-reply-actions .blog-btn { width: 100%; justify-content: center; }
}
