/* ==========================================================================
   Blog posts (body.page-blog). Loaded after refresh.css.
   Shared layout, tables, callouts and buttons live in refresh.css and
   blog-fixes.css; this file only adds the post-specific parts. Where a rule
   has to beat a legacy !important rule in blog-fixes.css it says so.
   ========================================================================== */

/* ---- 1. Banner: title, dek, byline -------------------------------------- */

/* The banner spacer is already invisible (height 0 in refresh.css) but its
   120px flex gap left an empty band under the breadcrumb. */
.page-blog .banner-layout > .spacer {
    display: none;
}

.page-blog .banner-layout .title-heading {
    max-width: 1000px;
    margin-inline: auto;
    text-wrap: balance;
}

.page-blog .post-dek {
    max-width: 760px;
    margin: 0 auto;
    font-size: var(--fs-md);
    line-height: 1.55;
    color: var(--text-color);
}

.page-blog .post-byline {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 12px;
    max-width: 760px;
    margin: 0 auto;
    font-size: var(--fs-sm);
    line-height: 1.55;
    color: var(--text-color);
}
.page-blog .post-byline a {
    color: var(--text-color-2);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--accent-color);
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}
.page-blog .post-byline a:hover,
.page-blog .post-byline a:focus-visible {
    color: var(--accent-text);
}
.page-blog .post-byline time {
    white-space: nowrap;
}

/* Phones: the post name always wrapped under "Home / Insights /", leaving a
   dangling slash at the end of the first line. Give it its own line instead. */
@media (max-width: 575.98px) {
    .page-blog nav.breadcrumb > :is(.separator, .separator-link):nth-last-child(2) {
        display: none;
    }
    .page-blog nav.breadcrumb > :is(.current, .current-page) {
        flex-basis: 100%;
        text-align: center;
    }
}

/* ---- 2. Reading layout --------------------------------------------------- */

/* Single-column posts: keep the line length readable on wide screens. */
.page-blog .row.row-cols-1 > .col > article.blog-content {
    max-width: 820px;
    margin-inline: auto;
}

/* Posts without a hero image get the same card and type scale that
   blog-fixes.css gives the others (its rules key on main .post-image). */
.page-blog .card.blog-content {
    padding: clamp(20px, 4vw, 34px) clamp(16px, 4vw, 34px) 40px;
}
body.page-blog:not(:has(main .post-image)) .post-main > .d-flex.flex-column {
    padding: clamp(20px, 4vw, 32px) clamp(16px, 4vw, 32px);
    border-radius: 12px;
    background: rgba(15, 15, 15, 0.6);
    border: 1px solid rgba(139, 92, 246, 0.1);
}
[data-theme="light"] body.page-blog:not(:has(main .post-image)) .post-main > .d-flex.flex-column {
    background: #FFFFFF;
    border-color: rgba(0, 0, 0, 0.08);
}
/* On phones these posts sat inside a 16px section padding plus the 12px
   container padding, which left 262-270px for text at 360px. A 16px edge
   (as on the hero-image posts) gives about 294px. */
@media (max-width: 575.98px) {
    body.page-blog:not(:has(main .post-image)) main > .section {
        padding-inline: 4px;
    }
}
body.page-blog:not(:has(main .post-image)) .post-main h2 {
    font-size: 1.875rem;
    line-height: 1.3;
    margin: 2rem 0 1rem;
    font-weight: 600;
    text-align: left;
}
body.page-blog:not(:has(main .post-image)) .post-main h3 {
    font-size: 1.5rem;
    line-height: 1.4;
    margin: 1.5rem 0 0.75rem;
    font-weight: 600;
    text-align: left;
}
body.page-blog:not(:has(main .post-image)) .post-main h4 {
    font-size: 1.25rem;
    line-height: 1.4;
    margin: 1.25rem 0 0.5rem;
    font-weight: 600;
}
body.page-blog:not(:has(main .post-image)) .post-main :is(p, li) {
    font-size: 1rem;
    line-height: 1.7;
}
body.page-blog:not(:has(main .post-image)) .post-main p {
    margin-bottom: 1.25rem;
}
body.page-blog:not(:has(main .post-image)) .post-main :is(ul, ol) {
    margin: 1rem 0 1.5rem;
    padding-left: 1.6rem;
}
body.page-blog:not(:has(main .post-image)) .post-main li {
    margin-bottom: 0.5rem;
}
html:not([data-theme="light"]) body.page-blog:not(:has(main .post-image)) .post-main h2 { color: #FFFFFF; }
html:not([data-theme="light"]) body.page-blog:not(:has(main .post-image)) .post-main h3 { color: #E5E7EB; }
html:not([data-theme="light"]) body.page-blog:not(:has(main .post-image)) .post-main :is(p, li) { color: #E5E7EB; }
html:not([data-theme="light"]) body.page-blog:not(:has(main .post-image)) .post-main strong { color: #FFFFFF; }
@media (max-width: 768px) {
    body.page-blog:not(:has(main .post-image)) .post-main h2 { font-size: 1.5rem; }
    body.page-blog:not(:has(main .post-image)) .post-main h3 { font-size: 1.25rem; }
}

/* Links in the article body (inline colours were removed from the posts). */
.page-blog :is(.post-main, article.blog-content) a:not(.btn):not(.sidebar-blog-item) {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}
html:not([data-theme="light"]) .page-blog :is(.post-main, article.blog-content) a:not(.btn):not(.sidebar-blog-item) {
    color: #C4B5FD;
}
.page-blog :is(.post-main, article.blog-content) a:not(.btn):not(.sidebar-blog-item):hover {
    color: var(--text-color-2);
}

/* Hero image inside single-column posts */
.page-blog article.blog-content .post-image {
    margin-bottom: var(--space-6);
}
.page-blog article.blog-content .post-image img {
    border-radius: 10px;
}

/* ---- 3. Callouts, quick answers, code ------------------------------------ */

.page-blog .callout > :first-child {
    margin-top: 0 !important; /* beats blog-fixes.css heading margins */
}
.page-blog .callout :is(h4, h5) {
    margin-top: 1rem;
}
.page-blog .callout .callout {
    margin: 1rem 0 0;
}

/* "Quick answer" box: a short title line, not a full-size heading.
   Selector weight beats the !important heading sizes in blog-fixes.css. */
body.page-blog main .post-answer .post-answer-title.post-answer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 0.6rem !important;
    font-size: 1.125rem !important;
    line-height: 1.4 !important;
    font-weight: 700 !important;
    color: var(--text-color-2);
}
html:not([data-theme="light"]) body.page-blog main .post-answer .post-answer-title.post-answer-title {
    color: #FFFFFF !important;
}
.page-blog .post-answer .post-answer-title i {
    color: var(--accent-color);
}
body.page-blog main .post-answer.post-answer :is(ul, ol) {
    margin: 0 !important;
    padding-left: 1.25rem !important;
}
body.page-blog main .post-answer.post-answer li:last-child {
    margin-bottom: 0 !important;
}

.page-blog .post-code {
    margin: 0.5rem 0 0;
    padding: 14px 16px;
    overflow-x: auto;
    border-radius: 8px;
    background: #0F172A;
    color: #E5E7EB;
    font-size: 0.875rem;
    line-height: 1.6;
}
.page-blog .post-code code {
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    color: inherit !important;
    white-space: pre;
}

/* ---- 4. Tables ------------------------------------------------------------ */

.page-blog .table-scroll {
    border-radius: 10px;
}
.page-blog .table-scroll > table {
    margin-bottom: 0;
}
.page-blog .table-scroll tr.table-total > td {
    font-weight: 700;
}
.page-blog .table-scroll tr.table-highlight-ok > td {
    background: rgba(16, 185, 129, 0.14);
}
.page-blog .table-scroll tr.table-highlight-warn > td {
    background: rgba(245, 158, 11, 0.14);
}
/* blog-fixes.css paints dark-mode rows with !important; these keep the highlight. */
html:not([data-theme="light"]) body.page-blog main .col.col-xl-8 .table-scroll table tbody tr.table-highlight-ok > td {
    background: rgba(16, 185, 129, 0.18) !important;
}
html:not([data-theme="light"]) body.page-blog main .col.col-xl-8 .table-scroll table tbody tr.table-highlight-warn > td {
    background: rgba(245, 158, 11, 0.18) !important;
}
/* Wide tables keep readable columns on phones and scroll sideways instead. */
@media (max-width: 575.98px) {
    .page-blog .table-scroll > table:has(tr > :nth-child(4)) {
        min-width: 560px;
    }
}

/* ---- 5. Figures, series card, related list ------------------------------- */

.page-blog .post-figure {
    margin: var(--space-5) 0 var(--space-6);
}
.page-blog .post-figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .page-blog .post-figure img {
    border-color: rgba(0, 0, 0, 0.08);
}
.page-blog .post-figure figcaption {
    margin-top: 8px;
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-color);
}

.page-blog .post-series {
    padding: 18px 22px;
    margin: 26px 0;
}
body.page-blog main .post-series .post-series-title {
    margin: 0 0 8px !important;
}
body.page-blog main .post-series ol {
    margin: 0 !important;
    padding-left: 20px !important;
}

.page-blog .post-further h2 {
    margin-top: 0 !important;
}

/* Static "Related Articles" list in the sidebar card (same item design as
   the "More From Our Blog" list in refresh.css 15.6). */
.page-blog .post-related-list {
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}
.page-blog .post-related-list > li {
    margin: 0;
}
.page-blog .post-related-list > li:last-child .sidebar-blog-item {
    margin-bottom: 0;
}
.page-blog .card.recent-post {
    align-items: stretch;
}
.page-blog .card.recent-post > h4 {
    width: 100%;
    margin: 0 0 4px;
    padding-bottom: 12px;
    border-bottom: 2px solid #8B5CF6;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-align: left;
}
html:not([data-theme="light"]) .page-blog .card.recent-post > h4 {
    color: #FFFFFF;
}
/* js/blog-related-posts.js now lists five posts, which fit without the
   560px inner scroll box from blog-fixes.css: no cut-off last item and no
   scroll area nested inside the page. */
.page-blog .card.recent-post .sidebar-posts-container {
    max-height: none;
    overflow: visible;
    padding-right: 0;
    scrollbar-gutter: auto;
}
/* The card's 30px gap already spaces the list, the divider and the second
   list; stacked margins added up to 74px above the divider. */
.page-blog .card.recent-post .blog-sidebar-section,
.page-blog .card.recent-post .sidebar-divider,
.page-blog .card.recent-post .sidebar-posts-container > .sidebar-blog-item:last-child {
    margin-bottom: 0;
}
.page-blog .card.recent-post .sidebar-divider {
    margin-top: 0;
}
/* On posts with a hero image the desktop sidebar is a fixed 320px column
   (blog-fixes.css), which left about 100px for each title. Smaller
   thumbnails and no excerpt give the title room for three full lines. */
@media (min-width: 1200px) {
    body.page-blog:has(main .post-image) .post-sidebar .sidebar-blog-item {
        gap: 10px;
        padding: 10px;
    }
    body.page-blog:has(main .post-image) .post-sidebar .sidebar-blog-image {
        flex-basis: 56px;
        width: 56px;
        height: 56px;
    }
    body.page-blog:has(main .post-image) .post-sidebar .sidebar-blog-title {
        -webkit-line-clamp: 3;
    }
    body.page-blog:has(main .post-image) .post-sidebar .sidebar-blog-excerpt {
        display: none;
    }
}

/* Sidebar CTA: the background photo stays visible at the top, and the overlay
   is nearly opaque by the time the text starts (30px padding + 100px spacer +
   30px gap = 160px), so the text stays readable over the bright and busy parts
   of the image. The stop is in px so taller banners keep the same cover. */
html:not([data-theme="light"]) .page-blog .cta-service-banner::before {
    background-image: linear-gradient(180deg, rgba(4, 4, 4, 0.25) 0, rgba(4, 4, 4, 0.82) 150px, rgba(4, 4, 4, 0.95) 100%);
}
[data-theme="light"] .page-blog .cta-service-banner::before {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0, rgba(255, 255, 255, 0.92) 150px, rgba(255, 255, 255, 0.97) 100%);
    opacity: 1;
}
.page-blog .cta-service-banner .title-heading {
    font-size: var(--fs-h4);
    line-height: 1.3;
}
.page-blog .cta-service-banner p {
    margin: 0;
}

/* ---- 6. End of post: CTA, FAQ, author ------------------------------------ */

.page-blog .post-cta {
    margin: var(--space-6) 0;
    padding: clamp(20px, 4vw, 28px);
    border: 1px solid rgba(200, 42, 239, 0.35);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(200, 42, 239, 0.10) 0%, rgba(200, 42, 239, 0.02) 100%);
}
[data-theme="light"] .page-blog .post-cta {
    border-color: rgba(155, 31, 192, 0.25);
    background: #FBF5FD;
}
body.page-blog main .post-cta > p {
    margin: 0 0 var(--space-4) !important;
}
.page-blog .post-cta .btn-row {
    margin: 0;
}

.page-blog .post-faq {
    margin-top: var(--space-7);
    padding-top: var(--space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}
[data-theme="light"] .page-blog .post-faq {
    border-top-color: rgba(0, 0, 0, 0.10);
}
body.page-blog main .post-faq > h2 {
    margin-top: 0 !important;
}

.page-blog .post-author {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin: var(--space-6) 0 0;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
}
[data-theme="light"] .page-blog .post-author {
    border-color: rgba(0, 0, 0, 0.08);
    background: #FFFFFF;
}
.page-blog .post-author img {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}
.page-blog .post-author-text {
    min-width: 0;
}
body.page-blog main .post-author.post-author p {
    margin: 0 0 6px !important;
    font-size: var(--fs-sm) !important;
    line-height: 1.6 !important;
}
body.page-blog main .post-author.post-author p:last-child {
    margin-bottom: 0 !important;
}
body.page-blog main .post-author.post-author .post-author-name {
    font-size: var(--fs-base) !important;
    font-weight: 700;
    color: var(--text-color-2) !important;
}
