/* ============================================================
   blog.css — modern blog redesign (listing + article)
   Loaded after style.css. Uses CSS custom properties.
   ============================================================ */

/* ---------- Hero ---------- */
.blog-hero {
    padding: clamp(2.5rem, 5vw, 4rem) 0;
}

.blog-hero .container {
    position: relative;
    z-index: 1;
}

.blog-hero .btn-primary,
.blog-hero .btn-primary:hover,
.blog-hero .btn-primary:focus {
    color: #fff;
}

.blog-hero h1 {
    font-weight: 800;
    letter-spacing: -0.02em;
}

/* ---------- Category chip bar & Mobile Swipe Track ---------- */
.category-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    margin-bottom: 1.25rem;
    padding-bottom: 4px;
}
.category-scroll-container::-webkit-scrollbar { display: none; }
.category-chip-track {
    display: inline-flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    align-items: center;
}
.chip-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    padding: 0.45rem 1rem;
    min-height: 44px; /* Touch target accessibility (WCAG 2.2 AA) */
    border-radius: 9999px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-body-bg, #fff);
    color: #334155;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.chip-item .chip-badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
    transition: background-color 0.2s ease;
}
.chip-item:hover {
    border-color: var(--bs-primary, #0d6efd);
    color: var(--bs-primary, #0d6efd);
    transform: translateY(-1px);
}
.chip-item.active {
    background: var(--bs-primary, #0d6efd);
    border-color: var(--bs-primary, #0d6efd);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
}
.chip-item.active .chip-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* ---------- Post cards ---------- */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 1.4rem;
}

.blog-card-v2 {
    display: flex;
    flex-direction: column;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.blog-card-v2:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    border-color: rgba(13, 110, 253, 0.3);
}

.blog-card-v2.featured {
    grid-column: 1 / -1;
}

.card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #e7f1ff 0%, #b6d4fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.featured .card-thumb {
    aspect-ratio: 21 / 9;
}

.card-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .45s ease;
}

.blog-card-v2:hover .card-thumb img {
    transform: scale(1.05);
}

.card-thumb .thumb-initial {
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    font-weight: 800;
    color: var(--bs-primary, #0d6efd);
    opacity: .55;
    user-select: none;
}

.card-thumb-wrap .thumb-cat {
    position: absolute;
    top: .8rem;
    inset-inline-start: .8rem;
    z-index: 1;
}

.card-thumb-wrap {
    position: relative;
}

.blog-card-body {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 1.15rem 1.25rem 1.25rem;
}

.blog-card-v2.featured .blog-card-body {
    padding: clamp(1.15rem, 3vw, 1.75rem);
}

.blog-card-title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 .55rem;
    color: var(--bs-body-color, #212529);
    transition: color 0.2s ease;
}

.featured .blog-card-title {
    font-size: 1.5rem;
}

.blog-card-v2:hover .blog-card-title {
    color: var(--bs-primary, #0d6efd);
}

.blog-card-excerpt {
    font-size: 0.875rem;
    color: var(--bs-secondary-color, #6c757d);
    line-height: 1.6;
    margin: 0 0 1rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.featured .blog-card-excerpt {
    -webkit-line-clamp: 2;
    font-size: 1rem;
}

.blog-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem .55rem;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
}

.blog-card-meta .dot::before {
    content: '·';
    font-weight: 700;
}

.read-more-link {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bs-primary, #0d6efd);
    margin-top: .85rem;
}

.read-more-link i {
    transition: transform 0.2s ease;
}

.blog-card-v2:hover .read-more-link i {
    transform: translateX(4px);
}

/* ---------- Sidebar ---------- */
.blog-sidebar-sticky {
    position: sticky;
    top: 90px;
}

@media (max-width: 991.98px) {
    .blog-sidebar-sticky {
        position: static;
    }
}

/* ---------- Pagination ---------- */
.blog-pagination {
    display: flex;
    justify-content: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.blog-pagination a,
.blog-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 .75rem;
    border-radius: 10px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    background: var(--bs-body-bg, #fff);
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.blog-pagination a:hover {
    border-color: var(--bs-primary, #0d6efd);
    color: var(--bs-primary, #0d6efd);
}

.blog-pagination .current {
    background: var(--bs-primary, #0d6efd);
    border-color: var(--bs-primary, #0d6efd);
    color: #fff;
}

.blog-pagination .ellipsis {
    border: none;
    background: transparent;
    min-width: auto;
    padding: 0 .2rem;
}

/* ---------- Empty state ---------- */
.blog-empty {
    text-align: center;
    padding: 3.5rem 1rem;
    border: 1px dashed var(--bs-border-color, #dee2e6);
    border-radius: 14px;
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.blog-empty i {
    font-size: 2.4rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* ---------- Article page ---------- */
.article-header-block {
    margin-bottom: 1.5rem;
}

.article-header-block h1 {
    font-size: clamp(1.55rem, 3.4vw, 2.2rem);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.015em;
    color: var(--bs-body-color, #212529);
    margin-bottom: .9rem;
}

.article-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem 1rem;
}

.article-content {
    max-width: 72ch;
    font-size: 1.05rem;
    line-height: 1.8;
}

.article-content h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 2.2rem;
    margin-bottom: .7rem;
    padding-bottom: .35rem;
    border-bottom: 2px solid rgba(13, 110, 253, 0.2);
    scroll-margin-top: 90px;
}

.article-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-top: 1.7rem;
    margin-bottom: .5rem;
    scroll-margin-top: 90px;
}

.article-content img {
    border-radius: 10px;
    height: auto;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.3rem 0;
    font-size: 0.875rem;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.article-content th,
.article-content td {
    border: 1px solid var(--bs-border-color, #dee2e6);
    padding: .55rem .8rem;
    text-align: start;
    vertical-align: top;
}

.article-content th {
    background: rgba(13, 110, 253, 0.05);
    font-weight: 700;
}

.article-lead {
    font-size: 1.12rem;
    line-height: 1.65;
    color: var(--bs-secondary-color, #6c757d);
    border-inline-start: 3px solid var(--bs-primary, #0d6efd);
    padding-inline-start: 1rem;
    margin-bottom: 1.75rem;
}

/* Table of contents (sidebar) */
.toc-widget .toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: toc;
}

.toc-widget .toc-list a {
    display: block;
    padding: .4rem 0;
    font-size: 0.875rem;
    color: var(--bs-secondary-color, #6c757d);
    text-decoration: none;
    line-height: 1.45;
    border-bottom: 1px dashed var(--bs-border-color, #dee2e6);
    transition: color 0.2s ease, padding-inline-start 0.2s ease;
}

.toc-widget .toc-list a::before {
    counter-increment: toc;
    content: counter(toc) '. ';
    color: var(--bs-primary, #0d6efd);
    font-weight: 700;
}

.toc-widget .toc-list a:hover {
    color: var(--bs-primary, #0d6efd);
    padding-inline-start: .3rem;
}

.toc-widget .toc-list li:last-child a {
    border-bottom: none;
}

/* Reading progress bar */
#readingProgress {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--bs-primary, #0d6efd), #0dcaf0);
    z-index: 1080;
    transition: width .1s linear;
    pointer-events: none;
}

/* Author box */
.author-box {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
}

.author-avatar {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bs-primary, #0d6efd), #0a58ca);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
}

/* Executive Key Takeaways Hero Box */
.executive-summary-box {
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.04) 0%, rgba(13, 110, 253, 0.09) 100%);
    border-left: 5px solid var(--bs-primary, #0d6efd) !important;
    border-radius: 12px;
    padding: 1.35rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.06);
}

.executive-summary-box ul {
    margin-bottom: 0;
    padding-left: 1.25rem;
}

.executive-summary-box li {
    font-size: 0.95rem;
    line-height: 1.65;
    color: #334155;
    margin-bottom: 0.35rem;
}

.executive-summary-box li:last-child {
    margin-bottom: 0;
}

/* Article Author Credential Ribbon (E-E-A-T) */
.article-author-ribbon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.author-mini-avatar {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Mobile Collapsible TOC */
.mobile-toc-accordion .accordion-button {
    padding: 0.85rem 1.15rem;
    font-size: 0.95rem;
    font-weight: 700;
    background-color: #f8fafc;
    border-radius: 10px !important;
}

.mobile-toc-accordion .accordion-button:not(.collapsed) {
    background-color: #e0f2fe;
    color: #0369a1;
}

.mobile-toc-list a {
    display: block;
    padding: 0.35rem 0;
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px dashed #e2e8f0;
    transition: color 0.15s ease, padding-left 0.15s ease;
}

.mobile-toc-list a:hover {
    color: var(--bs-primary, #0d6efd);
    padding-left: 0.25rem;
}

.mobile-toc-list li:last-child a {
    border-bottom: none;
}

/* Mobile Bottom Sticky Conversion Dock */
.mobile-reading-dock {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

/* Code & Table Horizontal Scroll Touch Signaling */
.article-content pre,
.article-content .table-responsive {
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

/* Related cards */
.related-card-v2 {
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.related-card-v2:hover {
    transform: translateY(-3px);
    border-color: rgba(13, 110, 253, 0.3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.related-card-v2 a.rel-title {
    color: var(--bs-body-color, #212529);
    text-decoration: none;
    transition: color 0.2s ease;
}

.related-card-v2:hover a.rel-title {
    color: var(--bs-primary, #0d6efd);
}

/* Mobile LTR enforcement for all blog cards */
@media (max-width: 991.98px) {
    .blog-card-v2,
    .blog-card-body,
    .related-card-v2,
    .article-content,
    .article-content p,
    .article-content ul,
    .article-content ol,
    .article-content li,
    .article-content blockquote,
    .article-lead,
    .blog-takeaways,
    .customs-alert,
    .software-pitch-cta,
    .mirsal-tool-cta,
    .cbm-tool-cta {
        direction: ltr !important;
        text-align: left !important;
    }
}

/* Accessibility: reduced motion */
@media (prefers-reduced-motion: reduce) {
    .blog-card-v2,
    .blog-card-v2:hover,
    .card-thumb img,
    .blog-card-v2:hover .card-thumb img,
    .related-card-v2,
    .related-card-v2:hover,
    .read-more-link i,
    #readingProgress {
        transition: none;
        transform: none;
    }
}
