/* ================================================================
   CORTEX BLOG PUBLIC CSS - MASTER ISOLATION FILE
   ================================================================
   File     : /includes/cortex/blog/cortex-blog-public.css
   Purpose  : Complete CSS isolation for CORTEX blogs on BS3 sites.

   CRITICAL: All styles are SCOPED to blog containers to prevent
   leaking into the site's nav/footer.

   USAGE:
   - Copy this file to any site's /includes/cortex/blog/ folder
   - Link it in the blog page templates
   ================================================================ */


/* ================================================================
   SECTION 1: CSS ISOLATION RESET (SCOPED TO BLOG CONTAINERS)
   ================================================================ */

/* Define the blog font stack */
:root {
    --blog-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --blog-font-family-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --blog-color-text: #212529;
    --blog-color-text-muted: #6c757d;
    --blog-line-height: 1.6;
}

/* Master reset for all blog containers */
.blog-home-wrapper,
.blog-article-wrapper,
.blog-article-hero,
.blog-category-wrapper,
.blog-mobile-cat-bar {
    font-family: var(--blog-font-family) !important;
    font-size: 16px !important;
    line-height: var(--blog-line-height) !important;
    color: var(--blog-color-text) !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Reset box-sizing for all blog elements */
.blog-home-wrapper *,
.blog-home-wrapper *::before,
.blog-home-wrapper *::after,
.blog-article-wrapper *,
.blog-article-wrapper *::before,
.blog-article-wrapper *::after,
.blog-article-hero *,
.blog-article-hero *::before,
.blog-article-hero *::after,
.blog-category-wrapper *,
.blog-category-wrapper *::before,
.blog-category-wrapper *::after {
    box-sizing: border-box !important;
}


/* ================================================================
   SECTION 2: SCOPED TYPOGRAPHY RESETS
   ================================================================
   Only affects elements INSIDE blog containers.
   ================================================================ */

/* Headings */
.blog-home-wrapper h1,
.blog-home-wrapper h2,
.blog-home-wrapper h3,
.blog-home-wrapper h4,
.blog-home-wrapper h5,
.blog-home-wrapper h6,
.blog-article-wrapper h1,
.blog-article-wrapper h2,
.blog-article-wrapper h3,
.blog-article-wrapper h4,
.blog-article-wrapper h5,
.blog-article-wrapper h6,
.blog-article-hero h1,
.blog-category-wrapper h1,
.blog-category-wrapper h2 {
    font-family: var(--blog-font-family) !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    margin-top: 0 !important;
}

/* Paragraphs - SCOPED */
.blog-home-wrapper p,
.blog-article-wrapper p,
.blog-category-wrapper p {
    font-family: var(--blog-font-family) !important;
    line-height: var(--blog-line-height) !important;
    margin-top: 0 !important;
    margin-bottom: 1rem !important;
}

/* Lists - SCOPED */
.blog-home-wrapper ul,
.blog-home-wrapper ol,
.blog-article-wrapper ul,
.blog-article-wrapper ol,
.blog-category-wrapper ul,
.blog-category-wrapper ol {
    font-family: var(--blog-font-family) !important;
    margin-top: 0 !important;
    margin-bottom: 1rem !important;
    padding-left: 2rem !important;
}

/* Images - SCOPED */
.blog-home-wrapper img,
.blog-article-wrapper img,
.blog-article-hero img,
.blog-category-wrapper img {
    max-width: 100% !important;
    height: auto !important;
    vertical-align: middle !important;
}


/* ================================================================
   SECTION 3: FONT SIZE VARIABLES
   ================================================================ */

:root {
    /* Homepage */
    --blog-body-text:           16px;
    --blog-body-line:           26px;
    --blog-h1:                  22px;
    --blog-h2:                  28px;
    --blog-card-title:          36px;
    --blog-card-lead:           15px;
    --blog-hero-title:          42px;
    --blog-hero-lead:           18px;
    --blog-category-badge:      12px;
    --blog-date-time:           14px;
    --blog-read-more:           14px;
    --blog-author-name:         14px;
    --blog-author-date:         13px;

    /* Category Page */
    --blog-category-page-title: 28px;
    --blog-category-subhead:    14px;
    --blog-category-item-title: 18px;

    /* Article Page */
    --blog-article-title:       57px;
    --blog-article-category:    12px;
    --blog-article-date:        14px;
    --blog-article-author:      15px;

    /* Sidebar */
    --blog-sidebar-title:       20px;
    --blog-sidebar-pill:        13px;
    --blog-sidebar-count:       13px;
}

@media (max-width: 991px) {
    :root {
        --blog-h1: 36px;
        --blog-h2: 24px;
        --blog-card-title: 20px;
        --blog-hero-title: 28px;
        --blog-article-title: 36px;
    }
}

@media (max-width: 767px) {
    :root {
        --blog-body-text: 15px;
        --blog-h1: 28px;
        --blog-card-title: 18px;
        --blog-hero-title: 24px;
        --blog-article-title: 28px;
        --blog-category-badge: 11px;
    }
}

@media (max-width: 575px) {
    :root {
        --blog-body-text: 14px;
        --blog-h1: 24px;
        --blog-card-title: 16px;
        --blog-hero-title: 20px;
        --blog-article-title: 24px;
    }
}


/* ================================================================
   SECTION 4: APPLY FONT SIZES
   ================================================================ */

.blog-home-wrapper {
    font-size: var(--blog-body-text) !important;
    line-height: var(--blog-body-line) !important;
}

.blog-card-title {
    font-size: var(--blog-card-title) !important;
}

.blog-card-lead,
.blog-card-text {
    font-size: var(--blog-card-lead) !important;
}

.blog-hero-card .blog-card-title {
    font-size: var(--blog-hero-title) !important;
}

.blog-category-badge {
    font-size: var(--blog-category-badge) !important;
}

.blog-post-meta .blog-meta-item {
    font-size: var(--blog-date-time) !important;
}

.blog-readmore-link {
    font-size: var(--blog-read-more) !important;
}

.blog-author-name {
    font-size: var(--blog-author-name) !important;
}

.blog-author-date {
    font-size: var(--blog-author-date) !important;
}

.blog-sidebar-title {
    font-size: var(--blog-sidebar-title) !important;
}

.blog-article-title {
    font-size: var(--blog-article-title) !important;
}


/* ================================================================
   SECTION 5: BS5 CONTAINERS (SAFE - unique class name)
   ================================================================ */

.container-xl {
    width: 100%;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

@media (min-width: 1200px) {
    .container-xl {
        max-width: 1320px;
    }
}


/* ================================================================
   SECTION 6: FLEXBOX UTILITIES (SAFE - BS3 doesn't have these)
   ================================================================ */

.d-flex { display: flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline-flex { display: inline-flex !important; }

.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

.justify-content-start { justify-content: flex-start !important; }
.justify-content-end { justify-content: flex-end !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around { justify-content: space-around !important; }

.align-items-start { align-items: flex-start !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-center { align-items: center !important; }
.align-items-stretch { align-items: stretch !important; }

.align-self-start { align-self: flex-start !important; }
.align-self-center { align-self: center !important; }
.align-self-end { align-self: flex-end !important; }


/* ================================================================
   SECTION 7: GAP UTILITIES (SAFE - BS3 doesn't have these)
   ================================================================ */

.gap-0 { gap: 0 !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }
.gap-5 { gap: 3rem !important; }


/* ================================================================
   SECTION 8: GUTTER UTILITIES (g-* classes)
   ================================================================ */

.row.g-0 { margin-left: 0; margin-right: 0; }
.row.g-0 > * { padding-left: 0; padding-right: 0; }

.row.g-2 { margin-left: -0.25rem; margin-right: -0.25rem; }
.row.g-2 > * { padding-left: 0.25rem; padding-right: 0.25rem; margin-bottom: 0.5rem; }

.row.g-3 { margin-left: -0.5rem; margin-right: -0.5rem; }
.row.g-3 > * { padding-left: 0.5rem; padding-right: 0.5rem; margin-bottom: 1rem; }

.row.g-4 { margin-left: -0.75rem; margin-right: -0.75rem; }
.row.g-4 > * { padding-left: 0.75rem; padding-right: 0.75rem; margin-bottom: 1.5rem; }


/* ================================================================
   SECTION 9: SIZING UTILITIES
   ================================================================ */

.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }
.mw-100 { max-width: 100% !important; }


/* ================================================================
   SECTION 10: SPACING UTILITIES (BS5 naming - ms/me/ps/pe)
   ================================================================ */

/* Margins */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }
.mt-auto { margin-top: auto !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-auto { margin-left: auto !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-auto { margin-right: auto !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.my-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
.my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }

/* Paddings */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-3 { padding-top: 1rem !important; }
.pt-4 { padding-top: 1.5rem !important; }
.pt-5 { padding-top: 3rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-3 { padding-bottom: 1rem !important; }
.pb-4 { padding-bottom: 1.5rem !important; }
.pb-5 { padding-bottom: 3rem !important; }

.ps-0 { padding-left: 0 !important; }
.ps-3 { padding-left: 1rem !important; }

.pe-0 { padding-right: 0 !important; }
.pe-3 { padding-right: 1rem !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }


/* ================================================================
   SECTION 11: TEXT UTILITIES
   ================================================================ */

.text-start { text-align: left !important; }
.text-end { text-align: right !important; }
.text-center { text-align: center !important; }

.text-nowrap { white-space: nowrap !important; }
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fw-light { font-weight: 300 !important; }
.fw-normal { font-weight: 400 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-bold { font-weight: 700 !important; }

.fst-italic { font-style: italic !important; }

.text-decoration-none { text-decoration: none !important; }
.text-muted { color: #6c757d !important; }

.small { font-size: 0.875em !important; }

.lh-1 { line-height: 1 !important; }
.lh-sm { line-height: 1.25 !important; }


/* ================================================================
   SECTION 12: POSITION UTILITIES
   ================================================================ */

.position-static { position: static !important; }
.position-relative { position: relative !important; }
.position-absolute { position: absolute !important; }
.position-fixed { position: fixed !important; }
.position-sticky { position: sticky !important; }

.top-0 { top: 0 !important; }
.bottom-0 { bottom: 0 !important; }
.start-0 { left: 0 !important; }
.end-0 { right: 0 !important; }


/* ================================================================
   SECTION 13: BORDER UTILITIES
   ================================================================ */

.border { border: 1px solid #dee2e6 !important; }
.border-0 { border: 0 !important; }
.border-top { border-top: 1px solid #dee2e6 !important; }
.border-bottom { border-bottom: 1px solid #dee2e6 !important; }

.rounded { border-radius: 0.375rem !important; }
.rounded-0 { border-radius: 0 !important; }
.rounded-circle { border-radius: 50% !important; }
.rounded-pill { border-radius: 50rem !important; }


/* ================================================================
   SECTION 14: SHADOW / OVERFLOW / OPACITY
   ================================================================ */

.shadow-none { box-shadow: none !important; }
.shadow-sm { box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075) !important; }
.shadow { box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15) !important; }

.overflow-auto { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-visible { overflow: visible !important; }

.opacity-0 { opacity: 0 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-100 { opacity: 1 !important; }


/* ================================================================
   SECTION 15: STRETCHED LINK (for card clicks)
   ================================================================ */

.stretched-link::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    content: "";
}


/* ================================================================
   SECTION 16: LIST UTILITIES
   ================================================================ */

.list-unstyled {
    padding-left: 0;
    list-style: none;
}


/* ================================================================
   SECTION 17: RESPONSIVE DISPLAY
   ================================================================ */

@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }
}

@media (min-width: 1200px) {
    .d-xl-none { display: none !important; }
    .d-xl-block { display: block !important; }
    .d-xl-flex { display: flex !important; }
}


/* ================================================================
   SECTION 18: RESPONSIVE FLEX
   ================================================================ */

@media (min-width: 768px) {
    .flex-md-row { flex-direction: row !important; }
    .flex-md-column { flex-direction: column !important; }
}

@media (min-width: 992px) {
    .flex-lg-row { flex-direction: row !important; }
    .flex-lg-column { flex-direction: column !important; }
}


/* ================================================================
   SECTION 19: SCOPED CARD STYLES (BLOG ONLY)
   ================================================================
   These only apply inside blog containers.
   ================================================================ */

.blog-home-wrapper .card,
.blog-article-wrapper .card,
.blog-category-wrapper .card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    background-clip: border-box;
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
}

.blog-home-wrapper .card-body,
.blog-article-wrapper .card-body,
.blog-category-wrapper .card-body {
    flex: 1 1 auto;
    padding: 1rem;
}


/* ================================================================
   SECTION 20: SCOPED BUTTON STYLES (BLOG ONLY)
   ================================================================
   These only apply inside blog containers - won't affect nav.
   ================================================================ */

.blog-home-wrapper .btn,
.blog-article-wrapper .btn,
.blog-category-wrapper .btn {
    display: inline-block;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.blog-home-wrapper .btn-primary,
.blog-article-wrapper .btn-primary,
.blog-category-wrapper .btn-primary {
    color: #fff;
    background-color: var(--color-primary, var(--bs-primary, #0d6efd));
    border-color: var(--color-primary, var(--bs-primary, #0d6efd));
}


/* ================================================================
   SECTION 21: STICKY TOC POSITIONING
   ================================================================ */

.sectionList-stuck {
    top: 180px;
}

@media (max-width: 991.98px) {
    .sectionList-stuck-mobile {
        top: 97px;
    }
}


/* ================================================================
   SECTION 22: OBJECT FIT
   ================================================================ */

.object-fit-cover { object-fit: cover !important; }
.object-fit-contain { object-fit: contain !important; }


/* ================================================================
   END OF CORTEX BLOG PUBLIC CSS
   ================================================================ */
