/* ── SPA MODAL SYSTEM ── */
body.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.85);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 0.35s ease,
        visibility 0.35s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg);
    width: 100%;
    max-width: 980px;
    height: 85vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    will-change: transform;
    transform: translateY(25px) scale(0.98) translateZ(0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1) translateZ(0);
}

.modal-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem 1rem 2.5rem;
    border-bottom: 1px solid var(--faint);
    flex-shrink: 0;
    gap: 1rem;
}

.modal-label {
    font-family: "DM Mono", monospace;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.modal-ext {
    font-family: "DM Mono", monospace;
    font-size: 11px;
    color: var(--blue);
    text-decoration: none;
    letter-spacing: 0.05em;
    transition: opacity 0.15s;
    margin-right: 15px;
}

.modal-ext:hover {
    opacity: 0.7;
}

.modal-close {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--faint);
    border-radius: 50%;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition:
        border-color 0.15s,
        background 0.15s;
}

.modal-close:hover {
    border-color: var(--text);
    background: var(--text);
}

.modal-close:hover svg {
    stroke: #fff;
}

.modal-close svg {
    width: 13px;
    height: 13px;
    stroke: var(--muted);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    will-change: transform;
    transform: translateZ(0);
}

.modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.modal-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family:
        "DM Mono", "DM Mono Fallback", ui-monospace, SFMono-Regular, Menlo,
        Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.modal-placeholder {
    padding: 8rem 3.5rem;
    text-align: center;
    font-family:
        "EB Garamond", "EB Garamond Fallback", Georgia, "Times New Roman",
        Times, serif;
    font-size: 2rem;
    color: var(--muted);
    font-weight: 500;
}

/* ── ARTICLE PAGE VIEW STYLES (replaces modal) ── */
.article-page-view {
    background: #f4f1e6;
    min-height: calc(100vh - 60px);
    animation: articleReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes articleReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#article-view-content,
#research-article-view-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 3.5rem 8rem;
}

@media (max-width: 768px) {
    #article-view-content,
    #research-article-view-content {
        padding: 1.5rem 1.5rem 4rem;
    }
}

/* ── MODAL INNER CONTENT STYLES ── */
.article {
    max-width: 860px;
    margin: 0 auto;
    padding: 4rem 3.5rem 8rem;
    font-family: "Lora", serif;
    font-size: 18px;
    line-height: 1.8;
    color: var(--text);
}

.article-header {
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--faint);
}

.article-type {
    font-family:
        "DM Mono", "DM Mono Fallback", ui-monospace, SFMono-Regular, Menlo,
        Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--blue);
    margin-bottom: 1.25rem;
    display: block;
}

.article-title {
    font-family:
        "EB Garamond", "EB Garamond Fallback", Georgia, "Times New Roman",
        Times, serif;
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: -0.02em;
}

.article section {
    margin-bottom: 4rem;
}

.article h2 {
    font-family:
        "EB Garamond", "EB Garamond Fallback", Georgia, "Times New Roman",
        Times, serif;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    color: var(--blue);
    margin-bottom: 1.5rem;
}

.article h3 {
    font-family:
        "EB Garamond", "EB Garamond Fallback", Georgia, "Times New Roman",
        Times, serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.article p {
    font-size: 18px;
    color: var(--muted);
    margin-bottom: 1.5rem;
    line-height: 1.85;
}

.article p:last-child {
    margin-bottom: 0;
}

.article p strong {
    color: var(--text);
    font-weight: 600;
}

.article .emphasis {
    font-weight: 600;
    color: var(--text);
    font-style: normal;
}

.article .highlight,
.article code {
    font-family: "JetBrains Mono", monospace;
    background: rgba(0, 0, 0, 0.04);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--text);
}

.article hr.divider {
    height: 1px;
    background: var(--faint);
    border: none;
    margin: 4rem 0;
}

.article ul,
.article ol {
    margin: 1rem 0 1.5rem 1.5rem;
}

.article li {
    font-family: "Lora", serif;
    font-size: 18px;
    color: var(--muted);
    margin-bottom: 8px;
    line-height: 1.75;
}

.article ul li::marker {
    color: var(--blue);
}

.article blockquote {
    margin: 2.5rem 0;
    padding: 0;
    border: none;
    font-family:
        "EB Garamond", "EB Garamond Fallback", Georgia, "Times New Roman",
        Times, serif;
    font-size: 1.8rem;
    font-weight: 500;
    font-style: italic;
    color: var(--blue);
    line-height: 1.45;
    letter-spacing: -0.01em;
}

.article .video-container {
    width: 100%;
    margin: 2rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--faint);
}

.article .video-container video,
.article .video-container iframe {
    width: 100%;
    display: block;
    background: #000;
    aspect-ratio: 16 / 9;
}

/* CODE BLOCK STYLES */
.code-block {
    background: var(--code-bg);
    border-radius: 10px;
    overflow: hidden;
    margin: 2rem 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.code-header {
    background: var(--code-header);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-title {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
}

.btn-copy {
    font-family: "DM Mono", monospace;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    background: var(--blue);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-copy:hover {
    opacity: 0.85;
}

.code-content {
    padding: 1.5rem;
    overflow-x: auto;
}

.code-content pre {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.82rem;
    line-height: 1.75;
    color: var(--code-text);
    margin: 0;
    white-space: pre;
}

.kw {
    color: #c792ea;
}

.fn {
    color: #82aaff;
}

.str {
    color: #c3e88d;
}

.cm {
    color: #546e7a;
    font-style: italic;
}

.nb {
    color: #ffcb6b;
}

.article .cta-link,
.article .notebook-link {
    font-family: "DM Mono", monospace;
    font-size: 14px;
    letter-spacing: 0.06em;
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.15s;
    display: inline-block;
}

.article .cta-link:hover,
.article .notebook-link:hover {
    opacity: 0.7;
}

.article .result-stack {
    margin: 2rem 0;
}

.article .result-item {
    margin-bottom: 1.25rem;
}

.article .result-item p {
    font-size: 17px;
    margin-bottom: 0;
    line-height: 1.75;
}

.article .result-item strong {
    color: var(--text);
    font-weight: 600;
}

/* ARTICLE TABLES - CLEAN DESIGN
           NOTE: These styles apply to desktop tables. On mobile, all tables except Placebo
           are hidden via hide-on-mobile. The Placebo table has its own mobile card design
           using .placebo-results-mobile class. DO NOT change table visibility on mobile. */
.article table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 1.5rem 0;
    font-size: 15px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.article thead {
    background-color: #f5f5f5;
}

.article th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text);
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    border-bottom: 1px solid #e0e0e0;
}

.article td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--muted);
    vertical-align: middle;
}

.article tbody tr:last-child td {
    border-bottom: none;
}

.article tbody tr:hover {
    background-color: #fafafa;
}

.placebo-results-wrap {
    margin: 1.75rem 0 2.25rem;
}

.placebo-results-scroll {
    overflow-x: auto;
}

/* Placebo table matches article table styling */
.article .placebo-results-scroll table.placebo-results-table {
    margin: 2.5rem 0;
    font-size: 16px;
}

.placebo-results-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
}

.placebo-results-table thead {
    background-color: #f5f5f5;
}

.placebo-results-table thead th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text);
    font-weight: 600;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    border-bottom: 1px solid #e0e0e0;
}

.placebo-results-table thead th.num,
.placebo-results-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.placebo-results-table tbody th,
.placebo-results-table tbody td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--faint);
    color: var(--muted);
    vertical-align: top;
}

.placebo-results-table tbody th {
    font-weight: 400;
    color: var(--text);
    text-align: left;
}

.placebo-results-table tbody tr:last-child th,
.placebo-results-table tbody tr:last-child td {
    border-bottom: none;
}

.placebo-results-table tr.placebo-results-highlight th,
.placebo-results-table tr.placebo-results-highlight td {
    background: var(--blue-bg);
    color: var(--text);
    border-bottom-color: #d4ddf3;
}

.placebo-results-table tr.placebo-results-highlight th {
    color: var(--blue);
}

.placebo-results-footnote {
    margin: 1.5rem 0 0;
    padding: 0 2px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.placebo-results-mobile {
    display: none;
    list-style: none;
    margin: 1.5rem 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--faint);
}

.article .placebo-results-mobile > li.placebo-card {
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    margin: 0;
    list-style: none;
}

.placebo-card {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0.75rem 0.25rem;
    box-shadow: none;
    border-bottom: 1px solid var(--faint);
}

.placebo-card-highlight {
    background: var(--blue-bg);
    border-bottom-color: #d4ddf3;
}

.placebo-card-city {
    font-family: "IBM Plex Sans", sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin: 0 0 0.4rem;
}

.placebo-card-highlight .placebo-card-city {
    color: var(--blue);
}

.placebo-card-metrics {
    margin: 0;
}

.placebo-card-pair {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--faint);
    font-size: 13px;
}

.placebo-card-pair:first-of-type {
    border-top: none;
    padding-top: 0;
}

.placebo-card-highlight .placebo-card-pair {
    border-top-color: #d4ddf3;
}

.placebo-card-highlight .placebo-card-pair:first-of-type {
    border-top: none;
}

.placebo-card-lbl {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    flex: 1;
    min-width: 0;
}

.placebo-card-val {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

/* REGRESSION TABLE SPECIFIC */
.regression-table {
    margin-top: 1rem !important;
}

.regression-table th {
    font-family: "IBM Plex Sans", sans-serif !important;
    font-size: 15.5px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    border-bottom: 1px solid var(--text) !important;
    padding-bottom: 16px !important;
    vertical-align: top !important;
    text-align: left !important;
}

.regression-table td {
    vertical-align: middle !important;
    color: var(--text) !important;
    padding: 18px 12px !important;
}

.regression-table td:first-child {
    font-weight: 600;
    width: 40px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 4px;
    font-family: "Inter", sans-serif;
    font-size: 14.5px;
    min-width: 75px;
}

.gray-pill {
    background-color: #dadada;
}

.blue-pill {
    background-color: #cce4ff;
}

.th-sub {
    display: block;
    font-weight: 400;
    color: var(--muted);
    font-size: 14px;
    margin-top: 4px;
}

/* ========================================================================
           AI DEVELOPER NOTE: CHART SPACING & LAYOUT STANDARDS
           When implementing new D3 interactive charts within article sections,
           always adhere to the following spacing and structural classes:

           1. SPACING:
              - .chart-divider: Always precede the chart title block with this.
                Mobile margin is 3rem top/bottom. Desktop margin-bottom is 4rem.
              - .chart-title-block: margin-bottom must be 1.5rem to create separation
                between the title and the chart SVG.

           2. ASPECT RATIOS:
              - Always use a `.chart-ratio` wrapper. Height is controlled via padding-bottom.
              - Create a custom ratio class if needed (e.g., `.ratio-chow { padding-bottom: 60%; }`)
                to ensure the chart scales perfectly without being distorted.
           ======================================================================== */
.chart-divider {
    border: none;
    border-top: 1px solid var(--faint);
    margin: 3rem 0;
}

.chart-title-block {
    margin: 0 0 1.5rem;
}

.chart-title-block .ct-title {
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.3;
}

.chart-title-block .ct-sub {
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 1.05rem;
    color: var(--muted);
}

.mobile-br {
    display: none;
}

.mobile-sub {
    display: none;
}

.desktop-sub {
    display: block;
}

.chart-block {
    margin: 0 0 2rem;
}

.chart-scene {
    position: relative;
    width: 100%;
}

.chart-ratio {
    position: relative;
    width: 100%;
    padding-bottom: 65.625%;
    height: 0;
}

.ratio-chow {
    padding-bottom: 60%;
}

.ratio-chow-synth {
    padding-bottom: 68.75%;
}

.ratio-delivery {
    padding-bottom: 60%;
}

.ratio-chow-placebo {
    padding-bottom: 60%;
}

.ratio-campaign-dist {
    padding-bottom: 72%;
}

.ratio-campaign-trend {
    padding-bottom: 68%;
}

.chart-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}

#chart-chow-wrap,
#chart-chow-wrap svg,
#chart-chow-synth-wrap,
#chart-chow-synth-wrap svg,
#chart-chow-placebo-wrap,
#chart-chow-placebo-wrap svg,
#chart-campaign-dist-wrap,
#chart-campaign-dist-wrap svg,
#chart-campaign-trend-wrap,
#chart-campaign-trend-wrap svg {
    overflow: visible !important;
}

.chart-wrap svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.chart-tooltip {
    position: fixed;
    background: #1a1a1a;
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: opacity 0.1s;
    top: 0;
    left: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.chart-tooltip::-webkit-scrollbar {
    width: 6px;
}

.chart-tooltip::-webkit-scrollbar-thumb {
    background: #666;
    border-radius: 3px;
}

.chart-tooltip b {
    display: block;
    margin-bottom: 2px;
}

