/* =========================================================
   BLOG — DETAIL (ARTICLE) PAGE
   ========================================================= */

.blog-page {
    --navy: #0F1B2E;
    --bg: #FFFFFF;
    --bg-soft: #F5F8F9;
    --teal: #1B8392;
    --teal-dark: #14606C;
    --teal-tint: #E5F4F5;
    --ink: #1B2430;
    --muted: #5B6773;
    --line: #E1E8EA;

    font-family: 'Inter', Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.blog-page h1,
.blog-page h2,
.blog-page h3,
.blog-page h4 {
    font-family: 'Space Grotesk', Arial, Helvetica, sans-serif;
}

.cat-pill {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--teal-tint);
    color: var(--teal-dark);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}


/* ---------------- BREADCRUMB ---------------- */

.article-breadcrumb {
    max-width: 960px;
    margin: 28px auto 0;
    padding: 0 20px;

    color: var(--muted);
    font-size: 0.86rem;
}

.article-breadcrumb a {
    color: var(--muted);
    text-decoration: none;
}

.article-breadcrumb a:hover {
    color: var(--teal-dark);
    text-decoration: underline;
}

.article-breadcrumb span.sep {
    margin: 0 6px;
    color: #B7C1C7;
}

.article-breadcrumb span.current {
    color: var(--ink);
    font-weight: 600;
}


/* ---------------- ARTICLE HEAD ---------------- */

.article-head {
    max-width: 960px;
    margin: 18px auto 0;
    padding: 0 20px;
    text-align: center;
}

.article-head h1 {
    margin: 12px 0 14px;
    font-size: clamp(1.7rem, 4vw, 2.5rem);
    line-height: 1.2;
    color: var(--navy);
}

.article-byline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    color: var(--muted);
    font-size: 0.9rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
}


/* ---------------- LAYOUT ---------------- */

.article-layout {
    max-width: 1020px;
    margin: 36px auto 0;
    padding: 0 20px;

    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    align-items: start;
}

/* Two-column layout when TOC is populated (JS toggles this class) */
.article-layout.has-toc {
    grid-template-columns: 200px 1fr;
}

/* Explicit placement — no reliance on auto-flow */
.article-layout.has-toc > .article-toc {
    grid-column: 1;
    grid-row: 1;
}

.article-layout.has-toc > .article-content {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

.article-layout:not(.has-toc) > .article-content {
    grid-column: 1 / -1;
    grid-row: 1;
    min-width: 0;
}

/* Keep the TOC sticky inside its own column */
.article-layout.has-toc > .article-toc {
    position: sticky;
    top: 84px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.article-toc {
    position: sticky;
    top: 84px;

    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-soft);
}

.article-toc h4 {
    margin: 0 0 10px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

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

.article-toc nav a {
    padding: 6px 8px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: none;
    line-height: 1.4;
}

.article-toc nav a.toc-sub {
    padding-left: 18px;
    font-size: 0.8rem;
}

.article-toc nav a:hover {
    color: var(--teal-dark);
    text-decoration: none;
}

.article-toc nav a.active {
    background: var(--teal-tint);
    color: var(--teal-dark);
    font-weight: 600;
}

.article-content {
    min-width: 0;
}

.article-figure {
    margin: 0 0 28px;
}

.article-figure img {
    width: 100%;
    border-radius: 14px;
    display: block;
}

.article-body {
    font-size: 1.02rem;
    line-height: 1.75;
    color: var(--ink);
}

.article-body h2 {
    margin: 34px 0 14px;
    font-size: 1.4rem;
    color: var(--navy);
    scroll-margin-top: 84px;
}

.article-body h3 {
    margin: 26px 0 12px;
    font-size: 1.15rem;
    color: var(--navy);
    scroll-margin-top: 84px;
}

.article-body p {
    margin: 0 0 16px;
}

.article-body ul,
.article-body ol {
    margin: 0 0 16px;
    padding-left: 22px;
}

.article-body img {
    max-width: 100%;
    border-radius: 10px;
}

.article-body a {
    color: var(--teal-dark);
    font-weight: 600;
}

.article-tags {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--line);

    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}


/* ---------------- RELATED ---------------- */

.related-section {
    max-width: 1020px;
    margin: 56px auto 0;
    padding: 40px 20px 64px;
    border-top: 1px solid var(--line);
}

.related-section h2 {
    margin: 0 0 20px;
    font-size: 1.3rem;
    color: var(--navy);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.blog-card {
    display: flex;
    flex-direction: column;

    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;

    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.blog-card:hover {
    box-shadow: 0 10px 24px rgba(15, 27, 46, 0.1);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.blog-card-media img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.blog-card-body {
    padding: 14px 16px 16px;
}

.blog-card-body h3 {
    margin: 8px 0 0;
    font-size: 0.95rem;
    line-height: 1.35;
    color: var(--navy);
}

.no-related {
    grid-column: 1 / -1;
    color: var(--muted);
    text-align: center;
    padding: 20px 0;
}

@media (max-width: 800px) {

    .article-layout {
        grid-template-columns: 1fr;
    }

    .article-toc {
        position: static;
        order: 2;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }
}
