/* ========================================
   BLOGS PAGE STYLES
   ======================================== */

.blogs-hero {
    padding: var(--spacing-4xl) 0 var(--spacing-3xl);
    text-align: center;
}

.blogs-hero h1 {
    font-size: 48px;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

.blogs-grid-container {
    padding: var(--spacing-3xl) 0 var(--spacing-6xl);
}

.blog-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: var(--spacing-lg);
}



.blog-card {
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    overflow: hidden;
    transition: all var(--transition-smooth);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    box-shadow: var(--shadow-ambient);
}

.blog-card::after {
    content: '';
    position: absolute;
    inset: 8px;
    /* replaces top/right/bottom/left */
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity var(--transition-base);
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='6' height='6' fill='%23fc6721'%3E%3Cpath d='M7 0h2v16H7z'/%3E%3Cpath d='M0 7h16v2H0z'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='6' height='6' fill='%23fc6721'%3E%3Cpath d='M7 0h2v16H7z'/%3E%3Cpath d='M0 7h16v2H0z'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='6' height='6' fill='%23fc6721'%3E%3Cpath d='M7 0h2v16H7z'/%3E%3Cpath d='M0 7h16v2H0z'/%3E%3C/svg%3E"),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='6' height='6' fill='%23fc6721'%3E%3Cpath d='M7 0h2v16H7z'/%3E%3Cpath d='M0 7h16v2H0z'/%3E%3C/svg%3E");
    background-position: top left, top right, bottom left, bottom right;
    background-repeat: no-repeat;
}

.blog-card:hover::after {
    opacity: 1;
}

.blog-card:hover {
    box-shadow: var(--shadow-ambient);
    border-color: var(--primary-color);
}

.card-placeholder {
    background: var(--bg-subtle);
    border: 1px dashed var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    min-height: 300px;
}

.blog-card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-subtle);
    overflow: hidden;
}

.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

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

.blog-card-content {
    padding: var(--spacing-xl);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.blog-card-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--spacing-sm);
}

.blog-card-tag.solid {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
    width: fit-content;
}

.blog-card h3 {
    font-size: 22px;
    margin-bottom: var(--spacing-md);
    line-height: 1.3;
}

.blog-card p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
}

/* ========================================
   SINGLE BLOG POST STYLES
   ======================================== */

.blog-post-content {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--spacing-4xl) var(--spacing-lg);
}

.blog-post-header {
    text-align: center;
    margin-bottom: var(--spacing-4xl);
}

.blog-post-header .tag {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: var(--spacing-md);
    display: block;
}

.blog-post-header h1 {
    font-size: 52px;
    line-height: 1.1;
    margin-bottom: var(--spacing-lg);
}

.blog-post-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

.blog-main-image {
    width: 100%;
    height: auto;
    border-radius: 0;
    margin-bottom: var(--spacing-4xl);
    box-shadow: var(--shadow-md);
}

.blog-body {
    font-size: 18px;
    line-height: 1.8;
    color: var(--text-primary);
}

.blog-body h2 {
    font-size: 32px;
    margin: var(--spacing-3xl) 0 var(--spacing-lg);
}

.blog-body h3 {
    font-size: 24px;
    margin: var(--spacing-2xl) 0 var(--spacing-md);
}

.blog-body p {
    margin-bottom: var(--spacing-lg);
}

.blog-body ul,
.blog-body ol {
    margin-bottom: var(--spacing-xl);
    padding-left: var(--spacing-xl);
}

.blog-body li {
    margin-bottom: var(--spacing-sm);
}

/* Internal Visuals */
.blog-visual {
    margin: var(--spacing-3xl) 0;
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    border-radius: 0;
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-sm);
}

.blog-visual-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: center;
}

.blog-visual-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    text-align: center;
}

.chart-wrapper {
    width: 100%;
    height: 340px;
    /* Adjusted to fit chart + labels */
    position: relative;
    padding: 8px 16px 36px 56px;
    /* Padding for axis labels - slightly larger than D3 margins */
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .chart-wrapper {
        height: 320px;
        padding: 12px 8px 30px 24px;
    }

    .axis-label.y {
        left: -35px;
        font-size: 9px;
    }

    .axis-label.x {
        bottom: -20px;
        font-size: 9px;
    }

    /* Blog body: scale prose down slightly on mobile */
    .blog-body {
        font-size: 16px;
    }

    .blog-body h2 {
        font-size: clamp(22px, 6vw, 28px);
        margin: var(--spacing-2xl) 0 var(--spacing-md);
    }

    .blog-body h3 {
        font-size: clamp(18px, 5vw, 22px);
    }

    /* Bar chart label: fixed 140px overflows at 320px — reduce and allow ellipsis */
    .h-bar-label {
        width: 90px;
        font-size: 11px;
    }

    /* Blog post content: tighten horizontal padding */
    .blog-post-content {
        padding: var(--spacing-3xl) var(--spacing-md);
    }
}

.blog-image-wrapper {
    margin: var(--spacing-3xl) 0;
}

.blog-image-wrapper img {
    width: 100%;
    height: auto;
    border-radius: 0;
    border: 1px dashed var(--border-light);
}

/* Continue Reading Section */
.continue-reading {
    margin: var(--spacing-4xl) 0;
    padding-top: var(--spacing-2xl);
    border-top: 1px dashed var(--border-light);
}

.continue-reading-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}

.continue-reading-card {
    display: flex;
    gap: var(--spacing-lg);
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    padding: var(--spacing-lg);
    transition: all var(--transition-smooth);
}

.continue-reading-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-ambient);
}

.continue-reading-image {
    flex-shrink: 0;
    width: 180px;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-subtle);
    overflow: hidden;
}

.continue-reading-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.continue-reading-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.continue-reading-tag {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-color);
    margin-bottom: var(--spacing-xs);
}

.continue-reading-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 var(--spacing-xs) 0;
    line-height: 1.3;
}

.continue-reading-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .continue-reading-card {
        flex-direction: column;
    }
    .continue-reading-image {
        width: 100%;
    }
}

/* Horizontal Bar Chart (Top 10) */
.horizontal-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.h-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.h-bar-label {
    width: 140px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.h-bar-container {
    flex-grow: 1;
    height: 24px;
    background: var(--bg-subtle);
    border-radius: 4px;
    position: relative;
}

.h-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 4px;
    transition: width 1s ease-out;
}

.h-bar-value {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.5);
}

/* Scatterplot Grid & Ticks */
.scatterplot-grid-x,
.scatterplot-grid-y {
    position: absolute;
    background: var(--border-light);
    opacity: 0.2;
    z-index: 1;
}

.scatterplot-grid-x {
    width: 1px;
    height: 100%;
    top: 0;
}

.scatterplot-grid-y {
    width: 100%;
    height: 1px;
    left: 0;
}

.axis-tick {
    position: absolute;
    font-size: 10px;
    color: var(--text-muted);
}

.axis-tick.x {
    top: 100%;
    margin-top: 8px;
    transform: translateX(-50%);
}

.axis-tick.y {
    right: 100%;
    margin-right: 12px;
    transform: translateY(50%);
    text-align: right;
    width: 60px;
}

/* Scatterplot */
.scatterplot-container {
    width: 100%;
    height: 100%;
    /* Fill the wrapper's space */
    position: relative;
    border-left: 2px solid var(--border-dashed);
    border-bottom: 2px solid var(--border-dashed);
}

.scatter-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    opacity: 0.7;
    transition: all 0.2s;
    cursor: pointer;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.scatter-dot:hover {
    opacity: 1;
    transform: translate(-50%, -50%) scale(2);
    z-index: 20;
}

.scatter-label {
    position: absolute;
    font-size: 9px;
    font-weight: 600;
    color: var(--text-secondary);
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 4px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.scatter-tooltip {
    position: absolute;
    background: #1a1d21;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: none;
}

.axis-label {
    position: absolute;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.axis-label.x {
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
}

.axis-label.y {
    top: 50%;
    left: -70px;
    transform: rotate(-90deg) translateY(-50%);
    white-space: nowrap;
}

/* ========================================
   AD CAROUSEL STYLES
   ======================================== */

/* Ad Blocker Notice */
.ad-blocker-notice {
    background: linear-gradient(135deg, #fff9e6 0%, #fff4d6 100%);
    border: 1px solid #f0d98f;
    border-radius: 12px;
    padding: 14px 18px;
    margin: var(--spacing-xl) 0 var(--spacing-lg);
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #7a6a3a;
    box-shadow: 0 2px 8px rgba(240, 217, 143, 0.15);
    transition: all var(--transition-smooth);
}

.ad-blocker-notice.visible {
    display: flex;
}

.ad-blocker-notice-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.ad-blocker-notice-text {
    flex: 1;
    line-height: 1.5;
}

.ad-blocker-notice-text strong {
    color: #5a4a2a;
    font-weight: 600;
}

@media (max-width: 768px) {
    .ad-blocker-notice {
        font-size: 13px;
        padding: 12px 14px;
    }
}

.ad-carousel-outer {
    margin: var(--spacing-3xl) 0;
    position: relative;
}

.ad-carousel-container {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 0 var(--spacing-2xl);
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) var(--bg-subtle);
    -webkit-overflow-scrolling: touch;
    align-items: flex-end;
    /* Bottom align the cards */
}

.ad-carousel-container::-webkit-scrollbar {
    height: 6px;
}

.ad-carousel-container::-webkit-scrollbar-track {
    background: var(--bg-subtle);
    border-radius: 10px;
}

.ad-carousel-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.ad-card {
    flex: 0 0 280px;
    scroll-snap-align: start;
    background: var(--bg-card);
    border: 1px dashed var(--border-light);
    overflow: hidden;
    transition: all var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.ad-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.ad-card-image-wrap {
    width: 100%;
    /* Removed aspect-ratio to allow natural height */
    background: #f0f0f0;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.ad-card-image-wrap img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    /* Ensure full image is visible */
}

.ad-card-content {
    padding: var(--spacing-lg);
}

.ad-card-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.ad-card-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

.ad-card-stats span {
    display: block;
}

.ad-card-stats strong {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .ad-card {
        flex: 0 0 240px;
    }

    .carousel-nav {
        display: none !important;
    }
}

/* Navigation Arrows */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-smooth);
    font-size: 24px;
    color: var(--text-primary);
    user-select: none;
}

.carousel-nav:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.carousel-nav.prev {
    left: -22px;
}

.carousel-nav.next {
    right: -22px;
}