/* ============================================================
   FLYHOST BLOG — Theme-aware styles
   Uses site CSS variables so dark/light theme works automatically
   ============================================================ */

/* ── Page wrapper ── */
.blog-page { background: var(--dark); min-height: 60vh; }

/* ── Hero ── */
.blog-hero {
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-3) 100%);
    border-bottom: 1px solid var(--border);
    padding: 56px 0 38px;
}
.blog-hero h1  { color: var(--text-primary); font-size: 2.2rem; font-weight: 800; margin-bottom: 10px; }
.blog-hero p   { color: var(--text-secondary); font-size: 1rem; max-width: 520px; }
.blog-hero .blog-crumb { font-size: .82rem; color: var(--text-muted); margin-bottom: 10px; }
.blog-hero .blog-crumb a { color: var(--text-secondary); }
.blog-hero .blog-crumb .cur { color: var(--primary-light); }
.blog-hero .blog-post-count { color: var(--text-muted); font-size: .82rem; margin-top: 8px; }

/* ── Breadcrumb bar (post page) ── */
.blog-breadcrumb-bar {
    background: var(--dark-2);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    font-size: .82rem;
    color: var(--text-muted);
}
.blog-breadcrumb-bar a   { color: var(--text-secondary); }
.blog-breadcrumb-bar .cur{ color: var(--primary-light); }

/* ── Section ── */
.blog-section { padding: 46px 0 60px; background: var(--dark); }

/* ── Grid ── */
.blog-layout   { display: grid; grid-template-columns: 1fr 280px; gap: 32px; align-items: start; }
.blog-layout > * { min-width: 0; } /* prevent grid blowout from wide code blocks */
.blog-grid     { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; margin-bottom: 28px; }

/* ── Post card ── */
.blog-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    overflow: hidden;
    transition: transform .22s, border-color .22s, box-shadow .22s;
}
.blog-card:hover {
    transform: translateY(-4px);
    border-color: rgba(108,99,255,.45);
    box-shadow: var(--shadow-md);
}
.blog-card-img { width: 100%; height: 180px; object-fit: cover; display: block; }
.blog-card-placeholder {
    width: 100%; height: 140px;
    background: linear-gradient(135deg, var(--dark-3), var(--dark-4));
    display: flex; align-items: center; justify-content: center;
}
.blog-card-placeholder i { font-size: 2rem; color: var(--border); }
.blog-card-body { padding: 18px; }
.blog-cat-badge {
    display: inline-block;
    background: rgba(108,99,255,.14);
    color: var(--primary-light);
    font-size: .72rem; font-weight: 600;
    padding: 3px 9px; border-radius: 20px; margin-bottom: 10px;
    text-decoration: none;
}
.blog-cat-badge:hover { background: rgba(108,99,255,.25); }
.blog-card-title {
    font-size: 1rem; font-weight: 700; margin-bottom: 8px; line-height: 1.4;
}
.blog-card-title a { color: var(--text-primary); }
.blog-card-title a:hover { color: var(--primary); }
.blog-card-excerpt { color: var(--text-secondary); font-size: .85rem; line-height: 1.55; margin-bottom: 14px; }
.blog-card-meta { display: flex; align-items: center; justify-content: space-between; font-size: .78rem; color: var(--text-muted); flex-wrap: wrap; gap: 6px; }

/* ── Empty state ── */
.blog-empty { text-align: center; padding: 60px 20px; }
.blog-empty i    { font-size: 3rem; color: var(--border); margin-bottom: 16px; display: block; }
.blog-empty h2   { font-size: 1.2rem; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.blog-empty p    { color: var(--text-muted); }

/* ── Pagination ── */
.blog-pagination { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.blog-page-btn {
    padding: 8px 16px; border-radius: 8px;
    font-size: .88rem; font-weight: 500;
    background: var(--card-bg); color: var(--text-secondary);
    border: 1px solid var(--border); text-decoration: none;
    transition: all .2s;
}
.blog-page-btn:hover { border-color: var(--primary); color: var(--primary-light); text-decoration: none; }
.blog-page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.blog-page-ellipsis { border-color: transparent; background: transparent; cursor: default; pointer-events: none; }

/* ── Sidebar ── */
.blog-sidebar-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}
.blog-sidebar-title {
    font-size: .95rem; font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.blog-cat-list   { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.blog-cat-row    { display: flex; align-items: center; justify-content: space-between; }
.blog-cat-link   { color: var(--text-secondary); font-size: .88rem; text-decoration: none; transition: color .2s; }
.blog-cat-link:hover  { color: var(--primary); }
.blog-cat-link.active { color: var(--primary); font-weight: 700; }
.blog-count-pill {
    background: var(--dark-3);
    color: var(--text-muted);
    font-size: .7rem; padding: 2px 8px; border-radius: 20px;
}

/* Recent posts in sidebar */
.blog-recent-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.blog-recent-row  { display: flex; gap: 10px; align-items: center; }
.blog-recent-thumb {
    width: 48px; height: 48px; border-radius: 6px;
    object-fit: cover; flex-shrink: 0;
}
.blog-recent-thumb-ph {
    width: 48px; height: 48px; border-radius: 6px; flex-shrink: 0;
    background: var(--dark-3); display: flex; align-items: center; justify-content: center;
}
.blog-recent-thumb-ph i { color: var(--border); font-size: .9rem; }
.blog-recent-title { color: var(--text-primary); font-size: .83rem; font-weight: 500; line-height: 1.35; display: block; margin-bottom: 2px; text-decoration: none; }
.blog-recent-title:hover { color: var(--primary); }
.blog-recent-date { color: var(--text-muted); font-size: .72rem; }

/* CTA box */
.blog-cta-box {
    background: linear-gradient(135deg, var(--dark-3), var(--dark-4));
    border: 1px solid rgba(108,99,255,.25);
    border-radius: 12px; padding: 22px; text-align: center;
}
.blog-cta-box i    { font-size: 1.8rem; color: var(--primary); margin-bottom: 10px; display: block; }
.blog-cta-box h4   { font-size: .95rem; margin-bottom: 6px; color: var(--text-primary); }
.blog-cta-box p    { color: var(--text-secondary); font-size: .8rem; margin-bottom: 14px; }
.blog-cta-btn {
    display: block; padding: 10px;
    background: linear-gradient(135deg, #6c63ff, #a855f7);
    color: #fff; border-radius: 8px; font-size: .85rem;
    font-weight: 600; text-decoration: none; transition: opacity .2s;
}
.blog-cta-btn:hover { opacity: .88; color: #fff; text-decoration: none; }

/* ── Single post ── */
.blog-article-img { width: 100%; max-height: 420px; object-fit: cover; border-radius: 14px; margin-bottom: 28px; display: block; }
.blog-post-title  { font-size: 1.9rem; font-weight: 800; line-height: 1.3; margin-bottom: 16px; color: var(--text-primary); }
.blog-post-meta   { display: flex; align-items: center; gap: 18px; color: var(--text-muted); font-size: .83rem; flex-wrap: wrap; }
.blog-post-meta i { color: var(--primary); margin-right: 4px; }

/* ── Blog content typography ── */
.blog-content { line-height: 1.85; font-size: 1rem; color: var(--text-secondary); }
.blog-content h1,
.blog-content h2,
.blog-content h3,
.blog-content h4   { color: var(--text-primary); margin: 1.6em 0 .6em; font-weight: 700; }
.blog-content h2   { font-size: 1.4rem; }
.blog-content h3   { font-size: 1.15rem; }
.blog-content p    { margin-bottom: 1.1em; }
.blog-content a    { color: var(--primary-light); text-decoration: underline; }
.blog-content a:hover { color: var(--primary); }
.blog-content ul,
.blog-content ol   { margin: 0 0 1.1em 1.5em; }
.blog-content li   { margin-bottom: .4em; }
.blog-content img  { max-width: 100%; border-radius: 8px; margin: 1em 0; }
.blog-content hr   { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.blog-content blockquote {
    border-left: 4px solid var(--primary);
    padding: 12px 20px;
    background: var(--dark-3);
    border-radius: 0 8px 8px 0;
    margin: 1.5em 0;
    color: var(--text-secondary);
    font-style: italic;
}
.blog-content table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: .9rem; }
.blog-content th { background: var(--dark-3); padding: 10px 14px; text-align: left; color: var(--text-primary); }
.blog-content td { padding: 9px 14px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.blog-content code {
    background: var(--dark-3); padding: 2px 6px; border-radius: 4px;
    font-size: .88em; color: var(--primary-light);
    font-family: 'Courier New', Consolas, monospace;
}
.blog-content pre {
    background: var(--dark-2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 16px;
    overflow-x: auto; overflow-y: auto;
    max-height: 420px;
    margin: 1.5em 0; font-size: .88rem; line-height: 1.7;
}
.blog-content pre code { background: none; padding: 0; color: var(--text-secondary); }

/* ── Enhanced code blocks (inserted from editor) ── */
/* ── IDE-style code blocks ── */
.fh-code-block {
    background: #1e1e2e;
    border: 1px solid #313155;
    border-radius: 10px;
    overflow: hidden;
    margin: 1.6em 0;
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Courier New',Consolas,monospace;
    box-shadow: 0 4px 24px rgba(0,0,0,.35);
    max-width: 100%;
}
.fh-code-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 14px;
    background: #181825;
    border-bottom: 1px solid #313155;
    gap: 10px;
}
/* traffic-light dots */
.fh-code-header::before {
    content: '';
    display: inline-block;
    width: 48px; height: 12px; flex-shrink: 0;
    background:
        radial-gradient(circle, #ff5f57 5px, transparent 5px) 0 50%,
        radial-gradient(circle, #ffbd2e 5px, transparent 5px) 18px 50%,
        radial-gradient(circle, #28c840 5px, transparent 5px) 36px 50%;
    background-repeat: no-repeat;
}
.fh-code-lang {
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: #a6adc8;
    background: rgba(255,255,255,.06);
    padding: 2px 9px; border-radius: 20px;
    flex: 1; text-align: center;
}
.fh-copy-btn {
    display: flex; align-items: center; gap: 5px;
    font-size: .73rem; font-weight: 600;
    color: #6c7086;
    background: rgba(255,255,255,.05);
    border: 1px solid #313155;
    border-radius: 6px; padding: 4px 10px;
    cursor: pointer; transition: all .2s; font-family: inherit;
    flex-shrink: 0;
}
.fh-copy-btn:hover { color: #cdd6f4; border-color: #6c63ff; background: rgba(108,99,255,.15); }
.fh-copy-btn.copied { color: #a6e3a1; border-color: #a6e3a1; }
.fh-code-pre {
    padding: 10px 20px; margin: 0;
    overflow-x: auto;
    max-height: 480px;
    font-size: .86rem; line-height: 1.75;
    white-space: pre; background: #1e1e2e;
    tab-size: 4; -moz-tab-size: 4;
    /* custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: #45475a #1e1e2e;
}
.fh-code-pre::-webkit-scrollbar { height: 6px; width: 6px; }
.fh-code-pre::-webkit-scrollbar-track { background: #1e1e2e; }
.fh-code-pre::-webkit-scrollbar-thumb { background: #45475a; border-radius: 3px; }
.fh-code-pre code {
    background: none !important; padding: 0 !important;
    font-size: inherit; font-family: inherit;
    color: #cdd6f4; /* fallback before hljs loads */
}
/* Override hljs container background — we control it */
.fh-code-pre .hljs { background: transparent !important; padding: 0 !important; }

/* ── Share box ── */
.blog-share-box {
    margin-top: 36px; padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
}
.blog-share-box p { font-size: .85rem; color: var(--text-muted); margin-bottom: 12px; font-weight: 600; }
.blog-share-btns  { display: flex; gap: 10px; flex-wrap: wrap; }
.blog-share-wa    { padding: 8px 16px; background: rgba(37,211,102,.12);  color: #25d366; border: 1px solid rgba(37,211,102,.3);  border-radius: 8px; font-size: .83rem; text-decoration: none; transition: background .2s; }
.blog-share-tw    { padding: 8px 16px; background: rgba(29,161,242,.12);  color: #1da1f2; border: 1px solid rgba(29,161,242,.3);  border-radius: 8px; font-size: .83rem; text-decoration: none; transition: background .2s; }
.blog-share-fb    { padding: 8px 16px; background: rgba(24,119,242,.12);  color: #1877f2; border: 1px solid rgba(24,119,242,.3);  border-radius: 8px; font-size: .83rem; text-decoration: none; transition: background .2s; }
.blog-share-li    { padding: 8px 16px; background: rgba(10,102,194,.12);  color: #0a66c2; border: 1px solid rgba(10,102,194,.3);  border-radius: 8px; font-size: .83rem; text-decoration: none; transition: background .2s; }
.blog-share-wa:hover,.blog-share-tw:hover,.blog-share-fb:hover,.blog-share-li:hover { opacity: .82; text-decoration: none; }

/* ── Light-mode specific fixes ── */
/* ── Light mode — general content ── */
body.light-mode .blog-content blockquote { background: #eef0f8; color: #3a3a5c; }
body.light-mode .blog-content th         { background: #eef0f8; }
/* inline code only (not inside fh-code-block) */
body.light-mode .blog-content code:not(.hljs)               { background: #eef0f8; color: #5a52d5; }
body.light-mode .blog-content pre:not(.fh-code-pre)         { background: #f4f5fb; border-color: rgba(0,0,0,.08); color: #1a1a2e; }
body.light-mode .blog-content pre:not(.fh-code-pre) code    { color: #1a1a2e; }

/* ── Light mode — IDE code blocks stay dark always ── */
body.light-mode .fh-code-block,
body.light-mode .blog-content .fh-code-block { background: #1e1e2e !important; border-color: #313155 !important; box-shadow: 0 4px 24px rgba(0,0,0,.18); }
body.light-mode .fh-code-header,
body.light-mode .blog-content .fh-code-header { background: #181825 !important; border-color: #313155 !important; }
body.light-mode .fh-code-pre,
body.light-mode .blog-content .fh-code-pre,
body.light-mode .blog-content pre.fh-code-pre { background: #1e1e2e !important; color: #cdd6f4 !important; border: none !important; border-radius: 0 !important; }
body.light-mode .fh-code-pre code,
body.light-mode .blog-content .fh-code-pre code { background: transparent !important; color: inherit !important; }
body.light-mode .fh-copy-btn             { background: rgba(255,255,255,.07) !important; color: #6c7086 !important; border-color: #313155 !important; }
body.light-mode .fh-copy-btn:hover       { color: #cdd6f4 !important; border-color: #6c63ff !important; background: rgba(108,99,255,.15) !important; }
body.light-mode .fh-code-lang            { background: rgba(255,255,255,.06) !important; color: #a6adc8 !important; }
body.light-mode .blog-count-pill         { background: #dde0ee; color: #4a4a6a; }
body.light-mode .blog-cta-box            { background: linear-gradient(135deg,#eef0f8,#e4e7f1); border-color: rgba(90,82,213,.2); }

/* ── Ads ── */
.blog-sidebar-ad-box { padding: 10px !important; text-align: center; }
.blog-ad { display: block; }
.blog-ad-link { display: block; }
.blog-ad img { max-width: 100%; border-radius: 6px; display: block; margin: 0 auto; }
.blog-ad--mid_post {
    margin: 28px 0;
    padding: 10px;
    background: var(--dark-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
}
.blog-ad--mid_post img { max-width: 100%; border-radius: 6px; margin: 0 auto; }
.blog-ad-track { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── Hero search bar (mobile only — hidden on desktop) ── */
.blog-hero-search-wrap {
    display: none;
}
@media (max-width: 900px) {
    .blog-hero-search-wrap { display: block; }
}

/* shared wrap styles */
.blog-hero-search-wrap {
    position: relative;
    max-width: 480px;
    margin-top: 22px;
}
.blog-hero-search-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .9rem; pointer-events: none; z-index: 1;
}
.blog-hero-search-input {
    padding-left: 38px !important;
    background: rgba(255,255,255,.06) !important;
    border-color: rgba(255,255,255,.12) !important;
    font-size: .95rem !important;
}
.blog-hero-search-input:focus {
    background: var(--dark-3) !important;
    border-color: var(--primary) !important;
}
body.light-mode .blog-hero-search-input {
    background: rgba(0,0,0,.05) !important;
    border-color: rgba(0,0,0,.1) !important;
}
body.light-mode .blog-hero-search-input:focus {
    background: #fff !important;
}

/* mobile-only search above post article */
.blog-post-mobile-search {
    display: none;
    margin-bottom: 22px;
}
.blog-post-mobile-search .blog-hero-search-wrap {
    max-width: 100%;
    margin-top: 0;
}

/* ── Live Search ── */
.blog-search-wrap {
    position: relative;
}
.blog-search-input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    background: var(--dark-3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.blog-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,.15);
}
.blog-search-input::placeholder { color: var(--text-muted); }

/* spinner ring */
.blog-search-spinner {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    display: none;
    animation: blog-spin .6s linear infinite;
}
.blog-search-spinner.active { display: block; }
@keyframes blog-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* dropdown panel */
.blog-search-dropdown {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
    overflow: hidden;
    z-index: 999;
    display: none;
    max-height: 420px;
    overflow-y: auto;
}
.blog-search-dropdown.open { display: block; }

/* individual result row */
.bsr-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px;
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
    cursor: pointer;
}
.bsr-item:last-child { border-bottom: none; }
.bsr-item:hover, .bsr-item.focused {
    background: rgba(108,99,255,.1);
    text-decoration: none;
}
.bsr-thumb {
    width: 52px; height: 52px; border-radius: 7px;
    object-fit: cover; flex-shrink: 0;
}
.bsr-thumb-ph {
    width: 52px; height: 52px; border-radius: 7px; flex-shrink: 0;
    background: var(--dark-3);
    display: flex; align-items: center; justify-content: center;
}
.bsr-thumb-ph i { color: var(--border); font-size: 1rem; }
.bsr-body { flex: 1; min-width: 0; }
.bsr-title {
    font-size: .88rem; font-weight: 600;
    color: var(--text-primary); line-height: 1.35;
    margin-bottom: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bsr-excerpt {
    font-size: .78rem; color: var(--text-muted);
    line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.bsr-meta {
    display: flex; align-items: center; gap: 8px; margin-top: 5px;
}
.bsr-cat {
    font-size: .68rem; font-weight: 600;
    background: rgba(108,99,255,.14); color: var(--primary-light);
    padding: 1px 7px; border-radius: 20px;
}
.bsr-date { font-size: .68rem; color: var(--text-muted); }

/* no-results & footer */
.bsr-empty {
    padding: 20px 16px; text-align: center;
    color: var(--text-muted); font-size: .85rem;
}
.bsr-empty i { display: block; font-size: 1.4rem; margin-bottom: 6px; color: var(--border); }
.bsr-footer {
    padding: 9px 14px; text-align: center;
    border-top: 1px solid var(--border);
    font-size: .78rem; color: var(--text-muted);
}
.bsr-footer a { color: var(--primary-light); text-decoration: none; font-weight: 600; }
.bsr-footer a:hover { text-decoration: underline; }

/* highlight matched text */
.bsr-highlight { color: var(--primary-light); font-weight: 700; }

/* light mode adjustments */
body.light-mode .blog-search-input { background: #eef0f8; border-color: rgba(0,0,0,.12); }
body.light-mode .blog-search-dropdown { box-shadow: 0 12px 40px rgba(0,0,0,.15); }
body.light-mode .bsr-thumb-ph { background: #dde0ee; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .blog-layout { grid-template-columns: 1fr; }
    /* sidebar search hidden on mobile — hero / post-top search covers it */
    .blog-sidebar-search-only { display: none; }
    /* post page: show the mobile search bar above the article */
    .blog-post-mobile-search { display: block; }
    /* hero search: expand to fill available width */
    .blog-hero-search-wrap { max-width: 100%; }
}
@media (max-width: 600px) {
    .blog-grid { grid-template-columns: 1fr; }
    .blog-hero h1 { font-size: 1.6rem; }
    .blog-post-title { font-size: 1.4rem; }
    .fh-code-pre { font-size: .78rem; padding: 8px 12px; }
    .fh-code-header { padding: 8px 10px; }
}
