/* ==========================================================================
   Blog design system  (Phase 4)
   Scoped under .blog-scope so it never affects the rest of the LMS.
   Typography, spacing, colour and interaction rules shared by the blog
   listing and article templates.
   ========================================================================== */

.blog-scope {
    /* 8px spacing base + brand-compatible tokens */
    --bl-space: 8px;
    --bl-radius: 14px;
    --bl-surface: #ffffff;
    --bl-surface-muted: #f6f8fb;
    --bl-border: #e6eaf0;
    --bl-border-strong: #cfd8e6;
    --bl-text: #1f2733;
    --bl-text-muted: #5b6776;
    --bl-accent: var(--brand-primary, #5A5FCF);
    color: var(--bl-text);
}

/* ---- Typography -------------------------------------------------------- */
.blog-scope .bl-body {
    font-size: 17px;
    line-height: 1.75;
    color: var(--bl-text);
}
/* Contain floated (text-wrapped) in-content images so they don't spill past the body */
.blog-scope .bl-body::after { content: ""; display: block; clear: both; }
.blog-scope .bl-body img[style*="float"] { max-width: 60%; }
.blog-scope .bl-body p { margin-bottom: calc(var(--bl-space) * 2.5); }
.blog-scope .bl-body h2 {
    font-size: 1.6rem;
    font-weight: 500;
    line-height: 1.35;
    margin: calc(var(--bl-space) * 4.5) 0 calc(var(--bl-space) * 2);
    scroll-margin-top: 90px; /* so TOC anchor jumps clear the sticky header */
}
.blog-scope .bl-body h3 {
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.4;
    margin: calc(var(--bl-space) * 3.5) 0 var(--bl-space);
}
.blog-scope .bl-body ul,
.blog-scope .bl-body ol { margin-bottom: calc(var(--bl-space) * 2.5); padding-left: 1.4rem; }
.blog-scope .bl-body li { margin-bottom: var(--bl-space); }
.blog-scope .bl-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: calc(var(--bl-space) * 2) 0 var(--bl-space);
}
.blog-scope .bl-body figure { margin: calc(var(--bl-space) * 3) 0; }
.blog-scope .bl-body figcaption,
.blog-scope .bl-caption {
    font-size: 13px;
    color: var(--bl-text-muted);
    text-align: center;
    margin-top: var(--bl-space);
}

/* Pull quote: left accent, larger italic, indented */
.blog-scope .bl-body blockquote {
    border-left: 4px solid var(--bl-accent);
    background: var(--bl-surface-muted);
    margin: calc(var(--bl-space) * 3) 0;
    padding: calc(var(--bl-space) * 2) calc(var(--bl-space) * 3);
    font-size: 1.2rem;
    font-style: italic;
    line-height: 1.6;
    color: var(--bl-text);
    border-radius: 0 8px 8px 0;
}

/* Code blocks (subject-relevant for a learning platform) */
.blog-scope .bl-body pre {
    background: #0f1b2d;
    color: #e6edf6;
    padding: calc(var(--bl-space) * 2);
    border-radius: 10px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.6;
    margin: calc(var(--bl-space) * 2.5) 0;
}
.blog-scope .bl-body :not(pre) > code {
    background: var(--bl-surface-muted);
    border: 1px solid var(--bl-border);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.9em;
}

/* ---- Category pills ---------------------------------------------------- */
.blog-scope .bl-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    /* colour is applied inline per category; this is a neutral fallback */
    background: rgba(90, 95, 207, 0.12);
    color: var(--bl-accent);
}
.blog-scope a.bl-pill:hover,
.blog-scope a.bl-pill:focus-visible { filter: brightness(0.95); }

.blog-scope .bl-tag {
    display: inline-block;
    padding: 3px 10px;
    margin: 0 6px 6px 0;
    border-radius: 999px;
    background: var(--bl-surface-muted);
    border: 1px solid var(--bl-border);
    color: var(--bl-text-muted);
    font-size: 12px;
    text-decoration: none;
}
.blog-scope a.bl-tag:hover,
.blog-scope a.bl-tag:focus-visible { border-color: var(--bl-border-strong); color: var(--bl-text); }

/* ---- Meta row (avatar + author + date + read time) -------------------- */
.blog-scope .bl-meta { display: flex; align-items: center; gap: calc(var(--bl-space) * 1.5); flex-wrap: wrap; }
.blog-scope .bl-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bl-accent); color: #fff; font-weight: 500; font-size: 15px;
}
.blog-scope .bl-meta small,
.blog-scope .bl-meta .bl-dot { color: var(--bl-text-muted); font-size: 13px; }
.blog-scope .bl-dot { opacity: 0.6; }

/* ---- Cards (PostCard) ------------------------------------------------- */
.blog-scope .bl-card {
    display: flex; flex-direction: column;
    height: 100%;
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius);
    overflow: hidden;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}
.blog-scope .bl-card:hover,
.blog-scope .bl-card:focus-within {
    border-color: var(--bl-accent);
    background: var(--bl-surface-muted);
}
.blog-scope .bl-card-thumb {
    height: 170px; width: 100%; object-fit: cover; display: block;
}
.blog-scope .bl-card-thumb--placeholder {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.6rem;
}
.blog-scope .bl-card-body { padding: calc(var(--bl-space) * 2); display: flex; flex-direction: column; gap: var(--bl-space); }
.blog-scope .bl-card-title {
    font-size: 1.05rem; font-weight: 500; line-height: 1.4; margin: 0;
}
.blog-scope .bl-card-title a { color: var(--bl-text); text-decoration: none; }
.blog-scope .bl-card-title a:hover { color: var(--bl-accent); }
.blog-scope .bl-card-excerpt { color: var(--bl-text-muted); font-size: 14px; margin: 0; }

/* ---- Surfaces / sections --------------------------------------------- */
.blog-scope .bl-surface {
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: var(--bl-radius);
}
.blog-scope .bl-surface-muted {
    background: var(--bl-surface-muted);
    border-radius: var(--bl-radius);
}

/* ---- Zone 1: blog sub-navigation ------------------------------------- */
.blog-scope .bl-subnav {
    position: sticky; top: 0; z-index: 20;
    background: var(--bl-surface);
    border-bottom: 1px solid var(--bl-border);
}
.blog-scope .bl-subnav-inner {
    display: flex; align-items: center; gap: calc(var(--bl-space) * 2);
    padding: calc(var(--bl-space) * 1.5) 0;
}
.blog-scope .bl-subnav-brand { font-weight: 500; color: var(--bl-text); text-decoration: none; white-space: nowrap; }
.blog-scope .bl-subnav-links {
    display: flex; gap: calc(var(--bl-space) * 0.5); overflow-x: auto;
    flex: 1; scrollbar-width: thin;
}
.blog-scope .bl-subnav-links a {
    padding: 6px 12px; border-radius: 999px; white-space: nowrap;
    color: var(--bl-text-muted); text-decoration: none; font-size: 14px;
}
.blog-scope .bl-subnav-links a:hover { background: var(--bl-surface-muted); color: var(--bl-text); }
.blog-scope .bl-subnav-links a.active { background: var(--bl-accent); color: #fff; }

/* ---- Zone 4: Table of contents --------------------------------------- */
.blog-scope .bl-toc { position: sticky; top: 80px; }
.blog-scope .bl-toc-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--bl-border); }
.blog-scope .bl-toc-list a {
    display: block; padding: 6px 14px; margin-left: -2px;
    border-left: 2px solid transparent;
    color: var(--bl-text-muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.blog-scope .bl-toc-list a:hover { color: var(--bl-text); }
.blog-scope .bl-toc-list a.active { color: var(--bl-accent); border-left-color: var(--bl-accent); font-weight: 500; }

/* ---- Zone 6: mid-post CTA & newsletter ------------------------------- */
.blog-scope .bl-cta {
    background: var(--bl-surface-muted);
    border-radius: var(--bl-radius);
    padding: calc(var(--bl-space) * 3);
    margin: calc(var(--bl-space) * 4) 0;
}
.blog-scope .bl-cta h3 { font-size: 1.15rem; font-weight: 500; margin-bottom: var(--bl-space); }
.blog-scope .bl-cta p { color: var(--bl-text-muted); margin-bottom: calc(var(--bl-space) * 2); }

.blog-scope .bl-newsletter-banner {
    background: linear-gradient(135deg, var(--brand-primary, #5A5FCF) 0%, var(--brand-secondary, #2a7bd8) 100%);
    color: #fff;
    border-radius: 18px;
    padding: calc(var(--bl-space) * 4);
}
.blog-scope .bl-newsletter-banner .form-control { border: none; }

/* ---- Zone 7: author bio ---------------------------------------------- */
.blog-scope .bl-author {
    display: flex; gap: calc(var(--bl-space) * 2); align-items: flex-start;
    background: var(--bl-surface-muted);
    border-radius: var(--bl-radius);
    padding: calc(var(--bl-space) * 2.5);
}
.blog-scope .bl-author .bl-avatar { width: 56px; height: 56px; font-size: 20px; }
.blog-scope .bl-author-name { font-weight: 500; margin: 0; }
.blog-scope .bl-author-bio { color: var(--bl-text-muted); font-size: 14px; margin: 4px 0 0; }

/* ---- Zone 9: blog footer --------------------------------------------- */
.blog-scope .bl-footer {
    background: var(--bl-surface-muted);
    border-top: 1px solid var(--bl-border);
    margin-top: calc(var(--bl-space) * 5);
    padding: calc(var(--bl-space) * 4) 0;
}
.blog-scope .bl-footer h4 { font-size: 14px; font-weight: 500; margin-bottom: calc(var(--bl-space) * 1.5); }
.blog-scope .bl-footer a { color: var(--bl-text-muted); text-decoration: none; display: block; padding: 3px 0; font-size: 14px; }
.blog-scope .bl-footer a:hover { color: var(--bl-accent); }
.blog-scope .bl-social a { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; align-items: center; justify-content: center; background: var(--bl-surface); border: 1px solid var(--bl-border); margin-right: 6px; }

/* ---- Focus visibility (accessibility) -------------------------------- */
.blog-scope a:focus-visible,
.blog-scope button:focus-visible,
.blog-scope .bl-card:focus-within {
    outline: 2px solid var(--bl-accent);
    outline-offset: 2px;
}

/* ---- Hero featured post ---------------------------------------------- */
.blog-scope .bl-hero {
    display: grid; grid-template-columns: 1.1fr 1fr; gap: 0;
    background: var(--bl-surface);
    border: 1px solid var(--bl-border);
    border-radius: 18px; overflow: hidden;
}
.blog-scope .bl-hero-media { min-height: 280px; background-size: cover; background-position: center; }
.blog-scope .bl-hero-media--placeholder { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 2.5rem; }
.blog-scope .bl-hero-body { padding: calc(var(--bl-space) * 4); display: flex; flex-direction: column; justify-content: center; gap: calc(var(--bl-space) * 1.5); }
.blog-scope .bl-hero-title { font-size: 1.9rem; font-weight: 500; line-height: 1.3; margin: 0; }
.blog-scope .bl-hero-title a { color: var(--bl-text); text-decoration: none; }
.blog-scope .bl-hero-title a:hover { color: var(--bl-accent); }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 991px) {
    .blog-scope .bl-toc { position: static; }
}
@media (max-width: 767px) {
    .blog-scope .bl-hero { grid-template-columns: 1fr; }
    .blog-scope .bl-hero-media { min-height: 180px; }
    .blog-scope .bl-body { font-size: 16px; }
    .blog-scope .bl-hero-title { font-size: 1.5rem; }
}
